本文整理匯總了C#中MonoDevelop.Core.Serialization.SerializationContext.IsDefaultValueSerializationForced方法的典型用法代碼示例。如果您正苦於以下問題:C# SerializationContext.IsDefaultValueSerializationForced方法的具體用法?C# SerializationContext.IsDefaultValueSerializationForced怎麽用?C# SerializationContext.IsDefaultValueSerializationForced使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MonoDevelop.Core.Serialization.SerializationContext
的用法示例。
在下文中一共展示了SerializationContext.IsDefaultValueSerializationForced方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Serialize
internal DataCollection Serialize (SerializationContext serCtx, object obj)
{
DataCollection itemCol = new DataCollection ();
foreach (ItemProperty prop in Properties) {
if (prop.ReadOnly || !prop.CanSerialize (serCtx, obj))
continue;
DataCollection col = itemCol;
object val = prop.GetValue (obj);
if (val == null) {
if (serCtx.IncludeDeletedValues) {
if (prop.IsNested)
col = GetNestedCollection (col, prop.NameList, 0, true);
col.Add (new DataDeletedNode (prop.SingleName));
}
continue;
}
var isDefault = val.Equals (prop.DefaultValue);
if (isDefault && !serCtx.IsDefaultValueSerializationForced (prop))
continue;
if (prop.IsNested)
col = GetNestedCollection (col, prop.NameList, 0, isDefault);
if (prop.ExpandedCollection) {
ICollectionHandler handler = prop.ExpandedCollectionHandler;
object pos = handler.GetInitialPosition (val);
while (handler.MoveNextItem (val, ref pos)) {
object item = handler.GetCurrentItem (val, pos);
if (item == null) continue;
DataNode data = prop.Serialize (serCtx, obj, item);
data.Name = prop.SingleName;
col.Add (data);
}
}
else {
DataNode data = prop.Serialize (serCtx, obj, val);
if (data == null) {
if (serCtx.IncludeDeletedValues)
col.Add (new DataDeletedNode (prop.SingleName));
continue;
}
data.IsDefaultValue = isDefault;
col.Add (data);
}
}
if (obj is IExtendedDataItem) {
// Serialize raw data which could not be deserialized
DataItem uknData = (DataItem) ((IExtendedDataItem)obj).ExtendedProperties ["__raw_data"];
if (uknData != null)
itemCol.Merge (uknData.ItemData);
}
return itemCol;
}