public void SetProjectExtension(XmlElement value) { AssertCanModify(); var sr = new StringReader(value.OuterXml); var xr = new XmlTextReader(sr); xr.MoveToContent(); var cr = new MSBuildXmlReader { XmlReader = xr }; var section = value.LocalName; MSBuildXmlElement elem = new MSBuildXmlElement(); elem.Read(cr); int i = ChildNodes.FindIndex(n => (n is MSBuildXmlElement) && ((MSBuildXmlElement)n).Name == section); if (i == -1) { ChildNodes = ChildNodes.Add(elem); } else { ChildNodes = ChildNodes.RemoveAt(i); ChildNodes = ChildNodes.Insert(i, elem); } elem.ParentNode = this; elem.ResetIndent(false); NotifyChanged(); }
internal override void ReadChildElement(MSBuildXmlReader reader) { MSBuildObject ob = null; switch (reader.LocalName) { case "ItemGroup": ob = new MSBuildItemGroup(); break; case "PropertyGroup": ob = new MSBuildPropertyGroup(); break; case "ImportGroup": ob = new MSBuildImportGroup(); break; case "Import": ob = new MSBuildImport(); break; case "Target": ob = new MSBuildTarget(); break; case "Choose": ob = new MSBuildChoose(); break; case "ProjectExtensions": ob = new MSBuildProjectExtensions(); break; default: ob = new MSBuildXmlElement(); break; } if (ob != null) { ob.ParentNode = this; ob.Read(reader); ChildNodes = ChildNodes.Add(ob); } else { base.ReadChildElement(reader); } }
internal virtual void ReadChildElement(MSBuildXmlReader reader) { if (reader.ForEvaluation && !ContentRequiredForEvaluation) { reader.Skip(); } else { var n = new MSBuildXmlElement(); n.Read(reader); n.ParentNode = this; ChildNodes = ChildNodes.Add(n); } }
internal override void ReadChildElement(MSBuildXmlReader reader) { MSBuildObject ob = null; switch (reader.LocalName) { case "ItemGroup": ob = new MSBuildItemGroup(); break; case "PropertyGroup": ob = new MSBuildPropertyGroup(); break; case "ImportGroup": ob = new MSBuildImportGroup(); break; case "Choose": ob = new MSBuildChoose(); break; default: ob = new MSBuildXmlElement(); break; } ob.ParentNode = this; ob.Read(reader); ChildNodes = ChildNodes.Add(ob); }
void WriteValue(XmlWriter writer, WriteContext context, string value) { if (value == null) { value = string.Empty; } // This code is from Microsoft.Build.Internal.Utilities if (value.IndexOf('<') != -1) { // If the value looks like it probably contains XML markup ... try { var sr = new StringReader("<a>" + value + "</a>"); var elem = new MSBuildXmlElement(); using (var xr = new XmlTextReader(sr)) { xr.MoveToContent(); var cr = new MSBuildXmlReader { XmlReader = xr }; elem.Read(cr); } elem.ParentNode = this; elem.SetNamespace(Namespace); elem.StartWhitespace = StartWhitespace; elem.EndWhitespace = EndWhitespace; elem.ResetChildrenIndent(); elem.WriteContent(writer, context); return; } catch (XmlException) { // But that may fail, in the event that "value" is not really well-formed // XML. Eat the exception and fall through below ... } } // The value does not contain valid XML markup. Write it as text, so it gets // escaped properly. writer.WriteValue(value); }
public void SetProjectExtension (XmlElement value) { AssertCanModify (); var sr = new StringReader (value.OuterXml); var xr = new XmlTextReader (sr); xr.MoveToContent (); var cr = new MSBuildXmlReader { XmlReader = xr }; var section = value.LocalName; MSBuildXmlElement elem = new MSBuildXmlElement (); elem.Read (cr); int i = ChildNodes.FindIndex (n => (n is MSBuildXmlElement) && ((MSBuildXmlElement)n).Name == section); if (i == -1) ChildNodes = ChildNodes.Add (elem); else { ChildNodes = ChildNodes.RemoveAt (i); ChildNodes = ChildNodes.Insert (i, elem); } elem.ParentNode = this; elem.ResetIndent (false); NotifyChanged (); }
internal virtual void ReadChildElement (MSBuildXmlReader reader) { if (reader.ForEvaluation) reader.Skip (); else { var n = new MSBuildXmlElement (); n.Read (reader); n.ParentNode = this; ChildNodes = ChildNodes.Add (n); } }
void WriteValue (XmlWriter writer, WriteContext context, string value) { if (value == null) value = string.Empty; // This code is from Microsoft.Build.Internal.Utilities if (value.IndexOf('<') != -1) { // If the value looks like it probably contains XML markup ... try { var sr = new StringReader ("<a>"+ value + "</a>"); var elem = new MSBuildXmlElement (); using (var xr = new XmlTextReader (sr)) { xr.MoveToContent (); var cr = new MSBuildXmlReader { XmlReader = xr }; elem.Read (cr); } elem.ParentNode = this; elem.SetNamespace (MSBuildProject.Schema); elem.StartWhitespace = StartWhitespace; elem.EndWhitespace = EndWhitespace; elem.ResetChildrenIndent (); elem.WriteContent (writer, context); return; } catch (XmlException) { // But that may fail, in the event that "value" is not really well-formed // XML. Eat the exception and fall through below ... } } // The value does not contain valid XML markup. Write it as text, so it gets // escaped properly. writer.WriteValue (value); }
internal override void ReadChildElement (MSBuildXmlReader reader) { MSBuildObject ob = null; switch (reader.LocalName) { case "ItemGroup": ob = new MSBuildItemGroup (); break; case "PropertyGroup": ob = new MSBuildPropertyGroup (); break; case "ImportGroup": ob = new MSBuildImportGroup (); break; case "Import": ob = new MSBuildImport (); break; case "Target": ob = new MSBuildTarget (); break; case "Choose": ob = new MSBuildChoose (); break; case "ProjectExtensions": ob = new MSBuildProjectExtensions (); break; default: ob = new MSBuildXmlElement (); break; } if (ob != null) { ob.ParentNode = this; ob.Read (reader); ChildNodes = ChildNodes.Add (ob); } else base.ReadChildElement (reader); }