Adding a default value setter for Infoset

This commit is contained in:
Sebastien Ros
2013-12-07 09:48:33 -08:00
parent d667c3b3aa
commit 1ca9c8b133

View File

@@ -9,6 +9,7 @@ namespace Orchard.ContentManagement {
public static TProperty Retrieve<TPart, TProperty>(this TPart contentPart,
Expression<Func<TPart, TProperty>> targetExpression,
TProperty defaultValue = default(TProperty),
bool versioned = false) where TPart : ContentPart {
var propertyInfo = ReflectionHelper<TPart>.GetPropertyInfo(targetExpression);
@@ -19,7 +20,7 @@ namespace Orchard.ContentManagement {
? null
: (versioned ? infosetPart.VersionInfoset.Element : infosetPart.Infoset.Element)
.Element(contentPart.GetType().Name);
return el == null ? default(TProperty) : el.Attr<TProperty>(name);
return el == null ? defaultValue : el.Attr<TProperty>(name);
}
public static TProperty Retrieve<TProperty>(this ContentPart contentPart, string name,