當前位置: 首頁>>代碼示例>>C#>>正文


C# Serialization.SerializationContext類代碼示例

本文整理匯總了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;
		}
開發者ID:Kalnor,項目名稱:monodevelop,代碼行數:7,代碼來源:DataSerializer.cs

示例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);
		}
開發者ID:FreeBSD-DotNet,項目名稱:monodevelop,代碼行數:10,代碼來源:ProjectPathItemPropertyAttribute.cs

示例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;
		}
開發者ID:FreeBSD-DotNet,項目名稱:monodevelop,代碼行數:14,代碼來源:ProjectPathItemPropertyAttribute.cs

示例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);
		}
開發者ID:transformersprimeabcxyz,項目名稱:monodevelop-1,代碼行數:16,代碼來源:BuildActionDataType.cs

示例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;
		}
開發者ID:transformersprimeabcxyz,項目名稱:monodevelop-1,代碼行數:17,代碼來源:BuildActionDataType.cs

示例6: OnDeserialize

		internal protected override object OnDeserialize (SerializationContext serCtx, object mapData, DataNode data)
		{
			return TimeSpan.FromTicks (long.Parse (((DataValue)data).Value, CultureInfo.InvariantCulture));
		}
開發者ID:FreeBSD-DotNet,項目名稱:monodevelop,代碼行數:4,代碼來源:PrimitiveDataType.cs

示例7: OnSerialize

		internal protected override DataNode OnSerialize (SerializationContext serCtx, object mapData, object value)
		{
			return new DataValue (Name, ((TimeSpan)value).Ticks.ToString (CultureInfo.InvariantCulture));
		}
開發者ID:FreeBSD-DotNet,項目名稱:monodevelop,代碼行數:4,代碼來源:PrimitiveDataType.cs

示例8: OnSerialize

		internal protected override DataNode OnSerialize (SerializationContext serCtx, object mapData, object value)
		{
			return new DataValue (Name, ((FilePath) value).ToString ());
		}
開發者ID:transformersprimeabcxyz,項目名稱:monodevelop-1,代碼行數:4,代碼來源:PrimitiveDataType.cs

示例9: OnDeserialize

		internal protected override object OnDeserialize (SerializationContext serCtx, object mapData, DataNode data)
		{
			return XmlConvert.ToDateTime (((DataValue)data).Value, XmlDateTimeSerializationMode.Local);
		}
開發者ID:transformersprimeabcxyz,項目名稱:monodevelop-1,代碼行數:4,代碼來源:PrimitiveDataType.cs

示例10: OnSerialize

		internal protected override DataNode OnSerialize (SerializationContext serCtx, object mapData, object value)
		{
			return new DataValue (Name, (bool)value ? "true" : "false");
		}
開發者ID:natosha,項目名稱:monodevelop,代碼行數:4,代碼來源:MSBuildProjectService.cs

示例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;
			}
		}
開發者ID:FreeBSD-DotNet,項目名稱:monodevelop,代碼行數:16,代碼來源:DictionaryDataType.cs

示例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;
		}
開發者ID:FreeBSD-DotNet,項目名稱:monodevelop,代碼行數:24,代碼來源:DictionaryDataType.cs

示例13: OnDeserialize

		internal protected virtual object OnDeserialize (DataType dataType, SerializationContext serCtx, object mapData, DataNode data)
		{
			return dataType.OnDeserialize (serCtx, mapData, data);
		}
開發者ID:Kalnor,項目名稱:monodevelop,代碼行數:4,代碼來源:DataSerializer.cs

示例14: OnSerialize

		internal protected virtual DataNode OnSerialize (DataType dataType, SerializationContext serCtx, object mapData, object value)
		{
			return dataType.OnSerialize (serCtx, mapData, value);
		}
開發者ID:Kalnor,項目名稱:monodevelop,代碼行數:4,代碼來源:DataSerializer.cs

示例15: OnDeserializeProperty

		internal protected virtual void OnDeserializeProperty (ItemProperty prop, SerializationContext serCtx, object instance, DataNode data, object valueInstance)
		{
			prop.OnDeserialize (serCtx, data, valueInstance);
		}
開發者ID:Kalnor,項目名稱:monodevelop,代碼行數:4,代碼來源:DataSerializer.cs


注:本文中的MonoDevelop.Core.Serialization.SerializationContext類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。