• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Serialization.XmlDataSerializer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MonoDevelop.Core.Serialization.XmlDataSerializer的典型用法代码示例。如果您正苦于以下问题:C# XmlDataSerializer类的具体用法?C# XmlDataSerializer怎么用?C# XmlDataSerializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



XmlDataSerializer类属于MonoDevelop.Core.Serialization命名空间,在下文中一共展示了XmlDataSerializer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: SerializationDoubleRoundtrip

		public void SerializationDoubleRoundtrip ()
		{
			var bag = new PropertyBag ();
			var t = new SerializableObject {
				SomeValue = "test1"
			};
			bag.SetValue ("foo", t);

			var w = new StringWriter ();
			var ser = new XmlDataSerializer (new DataContext ());
			ser.Serialize (w, bag);
			var data = w.ToString ();

			SerializableObject.CreationCount = 0;

			bag = ser.Deserialize<PropertyBag> (new StringReader (data));

			// SerializableObject is not instantiated if not queried
			Assert.AreEqual (0, SerializableObject.CreationCount);

			w = new StringWriter ();
			ser.Serialize (w, bag);
			data = w.ToString ();

			bag = ser.Deserialize<PropertyBag> (new StringReader (data));

			// SerializableObject is not instantiated if not queried
			Assert.AreEqual (0, SerializableObject.CreationCount);

			t = bag.GetValue<SerializableObject> ("foo");
			Assert.NotNull (t);
			Assert.AreEqual ("test1", t.SomeValue);
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:33,代码来源:PropertyBagTests.cs


示例2: SaveContents

		public void SaveContents (string fileName)
		{
			using (StreamWriter writer = new StreamWriter (fileName)) {
				XmlDataSerializer serializer = new XmlDataSerializer (MonoDevelop.Projects.Services.ProjectService.DataContext);
				serializer.Serialize (writer, this);
			}
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:7,代码来源:ToolboxConfiguration.cs


示例3: CreateFramework

		public TargetFramework CreateFramework ()
		{
			Stream s;
			if (SystemAssemblyService.UseExpandedFrameworksFile) {
				if (resource != null)
					s = Addin.GetResource (resource);
				else if (file != null)
					s = File.OpenRead (Addin.GetFilePath (file));
				else
					throw new InvalidOperationException ("Framework xml source not specified");
			}
			else {
				string file = System.IO.Path.Combine (SystemAssemblyService.ReferenceFrameworksPath, resource);
				Console.WriteLine ("Loading framework file: " + file);
				s = File.OpenRead (file);
			}
			
			using (s) {
				XmlTextReader reader = new XmlTextReader (s);
				XmlDataSerializer ser = new XmlDataSerializer (new DataContext ());
				TargetFramework fx = (TargetFramework) ser.Deserialize (reader, typeof(TargetFramework));
				fx.FrameworkNode = this;
				return fx;
			}
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:25,代码来源:TargetFrameworkNode.cs


示例4: DeserializeString

        public static object DeserializeString(string XMLString, Type serType)
        {
            context.IncludeType (serType);

            XmlDataSerializer ser = new XmlDataSerializer (context);

            TextReader serReader = new StringReader (XMLString);
            return ser.Deserialize (serReader, serType);
        }
开发者ID:skyronic,项目名称:TFAddin,代码行数:9,代码来源:Util.cs


示例5: SaveConfig

 public static void SaveConfig ()
 {
     if (configuration != null) {
         XmlDataSerializer s = new XmlDataSerializer (dataContext);
         using (var wr = new XmlTextWriter (File.CreateText (ConfigFile))) {
             wr.Formatting = Formatting.Indented;
             s.Serialize (wr, configuration, typeof(AddinConfig)); 
         }
     }
 }
开发者ID:taiste,项目名称:ViewInAndroidStudio,代码行数:10,代码来源:AddInPreferences.cs


示例6: LoadFromFile

		public static ToolboxConfiguration LoadFromFile (string fileName)
		{
			object o;
			
			using (StreamReader reader = new StreamReader (fileName))
			{
				XmlDataSerializer serializer = new XmlDataSerializer (MonoDevelop.Projects.Services.ProjectService.DataContext);
				o = serializer.Deserialize (reader, typeof (ToolboxConfiguration));	
			}
			return (ToolboxConfiguration) o;			
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:11,代码来源:ToolboxConfiguration.cs


示例7: Write

		public XmlElement Write ()
		{
			XmlDataSerializer ser = new XmlDataSerializer (new DataContext ());
			ser.Namespace = MSBuildProject.Schema;
			var sw = new StringWriter ();
			ser.Serialize (new XmlTextWriter (sw), this);
			XmlDocument doc = new XmlDocument ();
			doc.LoadXml (sw.ToString ());
			var elem = doc.DocumentElement;
			doc.RemoveChild (elem);
			return elem;
		}
开发者ID:sushihangover,项目名称:monodevelop,代码行数:12,代码来源:MakefileData.cs


示例8: SaveConfig

		static void SaveConfig ()
		{
			try {
				XmlDataSerializer ser = new XmlDataSerializer (new DataContext ());
				StreamWriter sw = new StreamWriter (configFile);
				using (sw) {
					ser.Serialize (new XmlTextWriter (sw), config, typeof(AddinAuthoringServiceConfig));
				}
			}
			catch (Exception ex) {
				LoggingService.LogError ("Could not save add-in authoring service configuration", ex);
			}
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:13,代码来源:AddinAuthoringService.cs


示例9: GetLinuxDeployData

		public static LinuxDeployData GetLinuxDeployData (Project entry)
		{
			LinuxDeployData data = (LinuxDeployData) entry.ExtendedProperties ["Deployment.LinuxDeployData"];
			if (data != null)
				return data;
			
			var elem = entry.MSBuildProject.GetMonoDevelopProjectExtension ("Deployment.LinuxDeployData");
			if (elem != null) {
				XmlDataSerializer ser = new XmlDataSerializer (new DataContext ());
				data = (LinuxDeployData) ser.Deserialize (new XmlNodeReader (elem), typeof(LinuxDeployData));
			} else {
				data = CreateDefault (entry);
			}
			data.entry = entry;
			entry.ExtendedProperties ["Deployment.LinuxDeployData"] = data;
			return data;
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:17,代码来源:LinuxDeployData.cs


示例10: CreateFramework

		public TargetFramework CreateFramework ()
		{
			Stream s;
			if (resource != null)
				s = Addin.GetResource (resource);
			else if (file != null)
				s = File.OpenRead (Addin.GetFilePath (file));
			else
				throw new InvalidOperationException ("Framework xml source not specified");
			
			using (s) {
				XmlTextReader reader = new XmlTextReader (s);
				XmlDataSerializer ser = new XmlDataSerializer (new DataContext ());
				TargetFramework fx = (TargetFramework) ser.Deserialize (reader, typeof(TargetFramework));
				fx.FrameworkNode = this;
				return fx;
			}
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:18,代码来源:TargetFrameworkNode.cs


示例11: LoadViews

		void LoadViews ()
		{
			try {
				XmlDataSerializer ser = new XmlDataSerializer (new DataContext ());
				FilePath file = ConfigFile;
				if (System.IO.File.Exists (file)) {
					views = (List<ChartView>) ser.Deserialize (file, typeof (List<ChartView>));
					UpdateViews ();
					return;
				}
			} catch (Exception ex) {
				LoggingService.LogError ("Error while loading monitor-views.xml", ex);
			}
			views = new List<ChartView> ();
			ChartView v = new ChartView ();
			v.Name = "Default";
			views.Add (v);
			UpdateViews ();
		}
开发者ID:zenek-y,项目名称:monodevelop,代码行数:19,代码来源:InstrumentationViewerDialog.cs


示例12: ReadWorkspaceItemFile

		WorkspaceItem ReadWorkspaceItemFile (FilePath fileName, ProgressMonitor monitor)
		{
			XmlTextReader reader = new XmlTextReader (new StreamReader (fileName));
			try {
				monitor.BeginTask (string.Format (GettextCatalog.GetString ("Loading workspace item: {0}"), fileName), 1);
				reader.MoveToContent ();
				XmlDataSerializer ser = new XmlDataSerializer (MD1ProjectService.DataContext);
				ser.SerializationContext.BaseFile = fileName;
				ser.SerializationContext.ProgressMonitor = monitor;
				WorkspaceItem entry = (WorkspaceItem)ser.Deserialize (reader, typeof(WorkspaceItem));
				entry.FileName = fileName;
				return entry;
			} catch (Exception ex) {
				monitor.ReportError (string.Format (GettextCatalog.GetString ("Could not load solution item: {0}"), fileName), ex);
				throw;
			} finally {
				monitor.EndTask ();
				reader.Close ();
			}
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:20,代码来源:WorkspaceSerializationExtension.cs


示例13: SerializeObjectToString

        public static string SerializeObjectToString(object o)
        {
            LogUtil log = new LogUtil ("Util.Serialization");
            // log.DEBUG("Serializing - " + o.ToString());
            //StringBuilder resultString;
            context.IncludeType (o.GetType ());

            XmlDataSerializer ser = new XmlDataSerializer (context);
            //XmlTextWriter xtw = new XmlTextWriter(Console.Out);
            TextWriter serWriter = new StringWriter ();
            XmlTextWriter xtw = new XmlTextWriter (serWriter);

            ser.Serialize (xtw, o);
            string serializedString = serWriter.ToString ();
            //serializedString = serReader.ReadToEnd();

            //log.DEBUG("The serialized string is - " + serializedString);

            return serializedString;
        }
开发者ID:skyronic,项目名称:TFAddin,代码行数:20,代码来源:Util.cs


示例14: AddinAuthoringService

		static AddinAuthoringService ()
		{
			if (IdeApp.IsInitialized) {
				IdeApp.ProjectOperations.EndBuild += OnEndBuild;
			}
			
			configFile = Path.Combine (PropertyService.ConfigPath, "AddinAuthoring.config");
			if (File.Exists (configFile)) {
				try {
					XmlDataSerializer ser = new XmlDataSerializer (new DataContext ());
					StreamReader sr = new StreamReader (configFile);
					using (sr) {
						config = (AddinAuthoringServiceConfig) ser.Deserialize (new XmlTextReader (sr), typeof(AddinAuthoringServiceConfig));
					}
				}
				catch (Exception ex) {
					LoggingService.LogError ("Could not load add-in authoring service configuration", ex);
				}
			}
			if (config == null)
				config = new AddinAuthoringServiceConfig ();
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:22,代码来源:AddinAuthoringService.cs


示例15: GetConfig

 private static AddinConfig GetConfig ()
 {
     if (configuration != null) {
         return configuration;
     }
     if (File.Exists (ConfigFile)) {
         try {
             XmlDataSerializer s = new XmlDataSerializer (dataContext);
             using (var reader = File.OpenText (ConfigFile)) {
                 configuration = (AddinConfig)s.Deserialize (reader, typeof(AddinConfig));
             }
         } catch {
             ((FilePath)ConfigFile).Delete ();
         }
     }
     if (configuration == null) {
         configuration = new AddinConfig ();
     }
     return configuration;
 }
开发者ID:taiste,项目名称:ViewInAndroidStudio,代码行数:20,代码来源:AddInPreferences.cs


示例16: SaveViews

		public void SaveViews ()
		{
			try {
				XmlDataSerializer ser = new XmlDataSerializer (new DataContext ());
				ser.Serialize (ConfigFile, views);
			} catch (Exception ex) {
				LoggingService.LogError ("Error while saving monitor-views.xml", ex);
			}
		}
开发者ID:zenek-y,项目名称:monodevelop,代码行数:9,代码来源:InstrumentationViewerDialog.cs


示例17: SaveConfiguration

		public static void SaveConfiguration ()
		{
			if (configuration != null) {
				XmlDataSerializer ser = new XmlDataSerializer (dataContext);
				XmlTextWriter tw = new XmlTextWriter (new StreamWriter (ConfigFile));
				tw.Formatting = Formatting.Indented;
				try {
					ser.Serialize (tw, configuration, typeof (VersionControlConfiguration));
				} finally {
					tw.Close ();
				}
			}
		}
开发者ID:vac0,项目名称:monodevelop,代码行数:13,代码来源:VersionControlService.cs


示例18: GetConfiguration

		static VersionControlConfiguration GetConfiguration ()
		{
			if (configuration == null) {
				if (File.Exists (ConfigFile)) {
					XmlDataSerializer ser = new XmlDataSerializer (dataContext);
					XmlTextReader reader = new XmlTextReader (new StreamReader (ConfigFile));
					try {
						configuration = (VersionControlConfiguration) ser.Deserialize (reader, typeof (VersionControlConfiguration));
					} finally {
						reader.Close ();
					}
				}
				if (configuration == null)
					configuration = new VersionControlConfiguration ();
			}
			return configuration;
		}
开发者ID:vac0,项目名称:monodevelop,代码行数:17,代码来源:VersionControlService.cs


示例19: ReadFile

		public object ReadFile (FilePath fileName, Type expectedType, IProgressMonitor monitor)
		{
			object readObject = null;
			
			ProjectExtensionUtil.BeginLoadOperation ();
			try {
				string ext = Path.GetExtension (fileName).ToLower ();
				
				if (ext == ".mdp") {
					object project = ReadProjectFile (fileName, monitor);
					if (project is DotNetProject)
						((DotNetProject)project).SetItemHandler (new MD1DotNetProjectHandler ((DotNetProject) project));
					readObject = project;
				}
				else if (ext == ".mds") {
					readObject = ReadCombineFile (fileName, monitor);
				}
				else if (ext == ".mdw") {
					readObject = ReadWorkspaceItemFile (fileName, monitor);
				}
				else {
					XmlTextReader reader = new XmlTextReader (new StreamReader (fileName));
					try {
						monitor.BeginTask (string.Format (GettextCatalog.GetString ("Loading solution item: {0}"), fileName), 1);
						reader.MoveToContent ();
						XmlDataSerializer ser = new XmlDataSerializer (MD1ProjectService.DataContext);
						ser.SerializationContext.BaseFile = fileName;
						ser.SerializationContext.ProgressMonitor = monitor;
						SolutionEntityItem entry = (SolutionEntityItem) ser.Deserialize (reader, typeof(SolutionEntityItem));
						entry.FileName = fileName;
						MD1ProjectService.InitializeHandler (entry);
						readObject = entry;
					}
					catch (Exception ex) {
						monitor.ReportError (string.Format (GettextCatalog.GetString ("Could not load solution item: {0}"), fileName), ex);
						throw;
					}
					finally {
						monitor.EndTask ();
						reader.Close ();
					}
				}
			} finally {
				ProjectExtensionUtil.EndLoadOperation ();
			}
			
			IWorkspaceFileObject fo = readObject as IWorkspaceFileObject;
			if (fo != null)
				fo.ConvertToFormat (MD1ProjectService.FileFormat, false);
			return readObject;
		}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:51,代码来源:MD1FileFormat.cs


示例20: WriteSolutionEntityItem

		void WriteSolutionEntityItem (FilePath actualFile, FilePath outFile, object node, IProgressMonitor monitor)
		{
			StreamWriter sw = new StreamWriter (outFile);
			try {
				monitor.BeginTask (string.Format (GettextCatalog.GetString("Saving solution item: {0}"), actualFile), 1);
				XmlDataSerializer ser = new XmlDataSerializer (MD1ProjectService.DataContext);
				ser.SerializationContext.BaseFile = actualFile;
				ser.SerializationContext.ProgressMonitor = monitor;
				ser.Serialize (sw, node, typeof(SolutionEntityItem));
			} catch (Exception ex) {
				monitor.ReportError (string.Format (GettextCatalog.GetString ("Could not save solution item: {0}"), actualFile), ex);
			} finally {
				monitor.EndTask ();
				sw.Close ();
			}
		}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:16,代码来源:MD1FileFormat.cs



注:本文中的MonoDevelop.Core.Serialization.XmlDataSerializer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Debugger.PinnedWatch类代码示例发布时间:2022-05-26
下一篇:
C# Serialization.SerializationContext类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap