本文整理汇总了C#中MonoDevelop.Core.Serialization.SerializationContext类的典型用法代码示例。如果您正苦于以下问题:C# SerializationContext类的具体用法?C# SerializationContext怎么用?C# SerializationContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SerializationContext类属于MonoDevelop.Core.Serialization命名空间,在下文中一共展示了SerializationContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DataSerializer
public DataSerializer (DataContext ctx, string baseFile)
{
dataContext = ctx;
serializationContext = ctx.CreateSerializationContext ();
serializationContext.BaseFile = baseFile;
serializationContext.Serializer = this;
}
示例2: OnSerialize
internal protected override DataNode OnSerialize (SerializationContext serCtx, object mapData, object value)
{
FilePath path = value is string ? new FilePath ((string) value) : (FilePath) value;
if (path.IsNullOrEmpty) return null;
FilePath basePath = Path.GetDirectoryName (serCtx.BaseFile);
string file = path.ToRelative (basePath);
if (Path.DirectorySeparatorChar != serCtx.DirectorySeparatorChar)
file = file.Replace (Path.DirectorySeparatorChar, serCtx.DirectorySeparatorChar);
return new DataValue (Name, file);
}
示例3: OnDeserialize
internal protected override object OnDeserialize (SerializationContext serCtx, object mapData, DataNode data)
{
string file = ((DataValue)data).Value;
if (!string.IsNullOrEmpty (file)) {
if (Path.DirectorySeparatorChar != serCtx.DirectorySeparatorChar)
file = file.Replace (serCtx.DirectorySeparatorChar, Path.DirectorySeparatorChar);
string basePath = Path.GetDirectoryName (serCtx.BaseFile);
file = FileService.RelativeToAbsolutePath (basePath, file);
}
if (ValueType == typeof (string))
return file;
else
return (FilePath) file;
}
示例4: OnSerialize
internal protected override DataNode OnSerialize (SerializationContext serCtx, object mapData, object value)
{
string str = value as string;
switch (str) {
case "None":
str = Nothing;
break;
case "EmbeddedResource":
str = EmbedAsResource;
break;
case "Content":
str = Exclude;
break;
}
return new DataValue (Name, str);
}
示例5: OnDeserialize
internal protected override object OnDeserialize (SerializationContext serCtx, object mapData, DataNode data)
{
string str = ((DataValue)data).Value;
switch (str) {
case "Nothing":
str = BuildAction.None;
break;
case "EmbedAsResource":
str = BuildAction.EmbeddedResource;
break;
case "FileCopy":
case "Exclude":
str = BuildAction.Content;
break;
}
return str;
}
示例6: OnDeserialize
internal protected override object OnDeserialize (SerializationContext serCtx, object mapData, DataNode data)
{
return TimeSpan.FromTicks (long.Parse (((DataValue)data).Value, CultureInfo.InvariantCulture));
}
示例7: OnSerialize
internal protected override DataNode OnSerialize (SerializationContext serCtx, object mapData, object value)
{
return new DataValue (Name, ((TimeSpan)value).Ticks.ToString (CultureInfo.InvariantCulture));
}
示例8: OnSerialize
internal protected override DataNode OnSerialize (SerializationContext serCtx, object mapData, object value)
{
return new DataValue (Name, ((FilePath) value).ToString ());
}
示例9: OnDeserialize
internal protected override object OnDeserialize (SerializationContext serCtx, object mapData, DataNode data)
{
return XmlConvert.ToDateTime (((DataValue)data).Value, XmlDateTimeSerializationMode.Local);
}
示例10: OnSerialize
internal protected override DataNode OnSerialize (SerializationContext serCtx, object mapData, object value)
{
return new DataValue (Name, (bool)value ? "true" : "false");
}
示例11: OnDeserialize
internal protected override void OnDeserialize (SerializationContext serCtx, object mdata, DataNode data, object collectionInstance)
{
MapData mapData = (mdata != null) ? (MapData) mdata : GetDefaultData ();
DataCollection items = ((DataItem) data).ItemData;
IDictionary dict = (IDictionary) collectionInstance;
foreach (DataItem item in items) {
DataNode key = item.ItemData [mapData.KeyName];
if (key == null)
continue;
DataNode val = item.ItemData [mapData.ValueName];
object keyObj = mapData.KeyType.Deserialize (serCtx, null, key);
object valueObj = val != null ? mapData.ValueType.Deserialize (serCtx, null, val) : null;
dict [keyObj] = valueObj;
}
}
示例12: OnSerialize
internal protected override DataNode OnSerialize (SerializationContext serCtx, object mdata, object collection)
{
MapData mapData = (mdata != null) ? (MapData) mdata : GetDefaultData ();
DataItem colItem = new DataItem ();
colItem.Name = Name;
colItem.UniqueNames = false;
IDictionary dict = (IDictionary) collection;
foreach (DictionaryEntry e in dict) {
DataItem item = new DataItem ();
item.Name = mapData.ItemName;
item.UniqueNames = true;
DataNode key = mapData.KeyType.Serialize (serCtx, null, e.Key);
key.Name = mapData.KeyName;
DataNode value = mapData.ValueType.Serialize (serCtx, null, e.Value);
value.Name = mapData.ValueName;
item.ItemData.Add (key);
item.ItemData.Add (value);
colItem.ItemData.Add (item);
}
return colItem;
}
示例13: OnDeserialize
internal protected virtual object OnDeserialize (DataType dataType, SerializationContext serCtx, object mapData, DataNode data)
{
return dataType.OnDeserialize (serCtx, mapData, data);
}
示例14: OnSerialize
internal protected virtual DataNode OnSerialize (DataType dataType, SerializationContext serCtx, object mapData, object value)
{
return dataType.OnSerialize (serCtx, mapData, value);
}
示例15: OnDeserializeProperty
internal protected virtual void OnDeserializeProperty (ItemProperty prop, SerializationContext serCtx, object instance, DataNode data, object valueInstance)
{
prop.OnDeserialize (serCtx, data, valueInstance);
}