本文整理汇总了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;
}