Ejemplo n.º 1
0
        protected internal override object OnDeserialize(SerializationContext serCtx, object mapData, DataNode data)
        {
            XmlConfigurationWriter sw  = new XmlConfigurationWriter();
            XmlDocument            doc = new XmlDocument();

            return(sw.Write(doc, data));
        }
Ejemplo n.º 2
0
		public void Serialize (XmlWriter writer, object obj, Type type)
		{
			DataNode data = serializer.Serialize (obj, type);
			XmlConfigurationWriter cw = new XmlConfigurationWriter ();
			cw.StoreAllInElements = StoreAllInElements;
			cw.Write (writer, data);
		}
Ejemplo n.º 3
0
		void UpdateEntry ()
		{
			var ser = new DataSerializer (new DataContext ());
			var data = ser.Serialize (this);

			XmlDocument doc = new XmlDocument ();
			var writer = new XmlConfigurationWriter { Namespace = MSBuildProject.Schema };
			var elem = writer.Write (doc, data);

			entry.MSBuildProject.SetMonoDevelopProjectExtension ("Deployment.LinuxDeployData", elem);
		}
Ejemplo n.º 4
0
		internal void SaveToXml (XmlWriter xw)
		{
			XmlConfigurationWriter cw = new XmlConfigurationWriter ();
			cw.StoreAllInElements = true;
			cw.StoreInElementExceptions = new String[] { "scope", "inheritsSet", "inheritsScope" };
			xw.WriteStartElement ("PolicySet");
			if (!string.IsNullOrEmpty (Name))
				xw.WriteAttributeString ("name", Name);
			if (!string.IsNullOrEmpty (Id))
				xw.WriteAttributeString ("id", Id);
			if (policies != null) {
				foreach (KeyValuePair<PolicyKey,object> policyPair in policies)
					cw.Write (xw, PolicyService.DiffSerialize (policyPair.Key.PolicyType, policyPair.Value, policyPair.Key.Scope));
			}
			xw.WriteEndElement ();
		}
		internal void SaveToFile (StreamWriter writer)
		{
			XmlWriterSettings xws = new XmlWriterSettings ();
			xws.Indent = true;
			XmlConfigurationWriter cw = new XmlConfigurationWriter ();
			cw.StoreAllInElements = true;
			cw.StoreInElementExceptions = new String[] { "scope", "inheritsSet", "inheritsScope" };
			using (XmlWriter xw = XmlTextWriter.Create(writer, xws)) {
				xw.WriteStartElement ("PolicySet");
				if (policies != null) {
					foreach (KeyValuePair<PolicyKey,object> policyPair in policies)
						cw.Write (xw, PolicyService.DiffSerialize (policyPair.Key.PolicyType, policyPair.Value, policyPair.Key.Scope));
				}
				xw.WriteEndElement ();
			}
		}
		public static void WriteObjectProperties (this IPropertySet pset, object ob, Type typeToScan, bool includeBaseMembers = false)
		{
			DataSerializer ser = new DataSerializer (Services.ProjectService.DataContext);
			var props = Services.ProjectService.DataContext.GetProperties (ser.SerializationContext, ob);
			XmlConfigurationWriter cwriter = null;
			XmlDocument xdoc = null;

			var mso = pset as IMSBuildProjectObject;
			if (mso != null && mso.ParentProject != null)
				ser.SerializationContext.BaseFile = mso.ParentProject.FileName;
			ser.SerializationContext.DirectorySeparatorChar = '\\';
		
			foreach (var prop in props) {
				if (prop.IsExternal)
					continue;
				bool merge = Attribute.IsDefined (prop.Member, typeof(MergeToProjectAttribute));
				if (prop.PropertyType == typeof(FilePath)) {
					var val = (FilePath)prop.GetValue (ob);
					FilePath def = (string)prop.DefaultValue;
					pset.SetValue (prop.Name, val, def, mergeToMainGroup: merge);
				} else if (prop.DataType is PathDataType && prop.PropertyType == typeof(string)) {
					FilePath val = (string)prop.GetValue (ob);
					FilePath def = (string)prop.DefaultValue;
					pset.SetValue (prop.Name, val, def, mergeToMainGroup: merge);
				} else if (prop.PropertyType == typeof(string)) {
					pset.SetValue (prop.Name, (string)prop.GetValue (ob), (string)prop.DefaultValue, merge);
				} else if (prop.DataType.IsSimpleType) {
					pset.SetValue (prop.Name, prop.GetValue (ob), prop.DefaultValue, merge);
				} else if (prop.PropertyType.IsGenericType && prop.PropertyType.GetGenericTypeDefinition () == typeof(Nullable<>)) {
					pset.SetValue (prop.Name, prop.GetValue (ob), prop.DefaultValue, merge);
				} else {
					var val = prop.GetValue (ob);
					if (val != null) {
						if (cwriter == null) {
							cwriter = new XmlConfigurationWriter { Namespace = MSBuildProject.Schema, StoreAllInElements = true };
							xdoc = new XmlDocument ();
						}
						var data = prop.Serialize (ser.SerializationContext, ob, val);
						if (data != null) {
							var elem = cwriter.Write (xdoc, data);
							pset.SetValue (prop.Name, prop.WrapObject ? elem.OuterXml : elem.InnerXml);
						} else
							pset.RemoveProperty (prop.Name);
					} else
						pset.RemoveProperty (prop.Name);
				}
			}
		}
		internal static void WriteExternalProjectProperties (this MSBuildProject project, object ob, Type typeToScan, bool includeBaseMembers = false)
		{
			DataSerializer ser = new DataSerializer (Services.ProjectService.DataContext);
			var props = Services.ProjectService.DataContext.GetProperties (ser.SerializationContext, ob);

			XmlConfigurationWriter writer = null;
			foreach (var prop in props) {
				if (!prop.IsExternal)
					continue;
				var val = prop.GetValue (ob);
				if (val != null) {
					var data = prop.Serialize (ser.SerializationContext, ob, val);
					if (data != null) {
						data.Name = prop.Name;
						if (writer == null)
							writer = new XmlConfigurationWriter { Namespace = MSBuildProject.Schema };

						XmlDocument doc = new XmlDocument ();
						var elem = writer.Write (doc, data);
						// TODO NPM
						project.SetMonoDevelopProjectExtension (prop.Name, elem);
						continue;
					}
				}
				project.RemoveMonoDevelopProjectExtension (prop.Name);
			}
		}
		protected internal override object OnDeserialize (SerializationContext serCtx, object mapData, DataNode data)
		{
			XmlConfigurationWriter sw = new XmlConfigurationWriter ();
			XmlDocument doc = new XmlDocument ();
			return sw.Write (doc, data);
		}