/// <summary> /// Initializes a new instance of the <see cref="XmlFileManagerBase"/> class. /// </summary> /// <param name="xmlFileName">Name of the XML file.</param> /// <param name="styleSheetFileName">Name of the style sheet file.</param> protected XmlFileManagerBase(string xmlFileName, string styleSheetFileName) { var outputDir = new DirectoryInfo(OutputDirectory); outputDir.Create(); var fullPath = outputDir.FullName; XProcessingInstruction instruction = null; if (styleSheetFileName != null) { var stylesheet = string.Format("href=\"{0}\" type=\"text/xsl\"", styleSheetFileName); instruction = new XProcessingInstruction("xml-stylesheet", stylesheet); } var doc = new XDocument(instruction, new XElement("StoryQRun")); AppDomain.CurrentDomain.DomainUnload += (sender, args) => { Directory.CreateDirectory(fullPath); doc.Save(Path.Combine(fullPath, xmlFileName)); this.WriteDependantFiles(fullPath); }; this.Categoriser = new XmlCategoriser(doc.Root); }
} // proc ParseConfiguration private void ParseConfigurationPI(ParseContext context, XProcessingInstruction xPI) { if (xPI.Target == "des-begin") // start a block { context.CurrentFrame.IsDeleteNodes = !context.IsDefined(xPI.Data); } else if (xPI.Target == "des-end") { context.CurrentFrame.IsDeleteNodes = false; } else if (!context.CurrentFrame.IsDeleteNodes) { if (xPI.Target.StartsWith("des-var-")) { context.CurrentFrame.SetMemberValue(xPI.Target.Substring(8), xPI.Data.Trim()); } else if (xPI.Target == "des-include") { IncludeConfigTree(context, xPI); } else if (xPI.Target == "des-merge") { MergeConfigTree(context, xPI); } } } // proc ParseConfiguration
/// <summary> /// Validates the behavior of the Equals overload on XProcessingInstruction. /// </summary> /// <returns>true if pass, false if fail</returns> //[Variation(Desc = "ProcessingInstructionEquals")] public void ProcessingInstructionEquals() { XProcessingInstruction c1 = new XProcessingInstruction("targetx", "datax"); XProcessingInstruction c2 = new XProcessingInstruction("targetx", "datay"); XProcessingInstruction c3 = new XProcessingInstruction("targety", "datax"); XProcessingInstruction c4 = new XProcessingInstruction("targety", "datay"); XProcessingInstruction c5 = new XProcessingInstruction("targetx", "datax"); bool b1 = XNode.DeepEquals(c1, (XProcessingInstruction)null); bool b3 = XNode.DeepEquals(c1, c1); bool b4 = XNode.DeepEquals(c1, c2); bool b5 = XNode.DeepEquals(c1, c3); bool b6 = XNode.DeepEquals(c1, c4); bool b7 = XNode.DeepEquals(c1, c5); Validate.IsEqual(b1, false); Validate.IsEqual(b3, true); Validate.IsEqual(b4, false); Validate.IsEqual(b5, false); Validate.IsEqual(b6, false); Validate.IsEqual(b7, true); b1 = XNode.EqualityComparer.GetHashCode(c1) == XNode.EqualityComparer.GetHashCode(c5); Validate.IsEqual(b1, true); }
/// <summary> /// Tests the WriteTo method on XComment. /// </summary> /// <param name="contextValue"></param> /// <returns></returns> //[Variation(Desc = "ProcessingInstructionWriteTo")] public void ProcessingInstructionWriteTo() { XProcessingInstruction c = new XProcessingInstruction("target", "data"); // Null writer not allowed. try { c.WriteTo(null); Validate.ExpectedThrow(typeof(ArgumentNullException)); } catch (Exception ex) { Validate.Catch(ex, typeof(ArgumentNullException)); } // Test. StringBuilder stringBuilder = new StringBuilder(); XmlWriter xmlWriter = XmlWriter.Create(stringBuilder); xmlWriter.WriteStartElement("x"); c.WriteTo(xmlWriter); xmlWriter.WriteEndElement(); xmlWriter.Flush(); Validate.IsEqual( stringBuilder.ToString(), "<?xml version=\"1.0\" encoding=\"utf-16\"?><x><?target data?></x>"); }
static void Exmpl06_09() { XDocument xDocument = new XDocument( new XProcessingInstruction("BookCataloger", "out-of-print"), new XElement("BookParticipants", new XElement("BookParticipant", new XProcessingInstruction("ParticipantDeleter", "delete"), new XElement("FirstName", "Joe"), new XElement("LastName", "Rattz"))) ); Console.WriteLine(xDocument); //2 XDocument xDocument2 = new XDocument( new XElement("BookParticipants", new XElement("BookParticipant", new XElement("FirstName", "Joe"), new XElement("LastName", "Rattz"))) ); XProcessingInstruction xPI1 = new XProcessingInstruction("BookCataloger", "out-of-print"); xDocument2.AddFirst(xPI1); XProcessingInstruction xPI2 = new XProcessingInstruction("ParticipantDeleter", "delete"); XElement outOfPrintParticipant = xDocument.Element("BookParticipants").Elements("BookParticipant").Where(e => ((string)((XElement)e).Element("FirstName")) == "Joe" && ((string)((XElement)e).Element("LastName")) == "Rattz").Single <XElement>(); outOfPrintParticipant.AddFirst(xPI2); Console.WriteLine(xDocument); }
private void ForceDirectoryVariable([NotNull] string variableName, [NotNull] Project project) { if (_defines.Any(d => d.Name.Equals(variableName, StringComparison.Ordinal))) { return; } var data = string.Format(CultureInfo.InvariantCulture, "{0}=$(var.{1}.TargetDir)", variableName, project.Name); var processingInstruction = new XProcessingInstruction(WixNames.Define, data); var lastNode = _defines.LastOrDefault(); if (lastNode != null) { lastNode.Node.AddAfterSelf(processingInstruction); } else { var firstNode = _root.FirstNode; if (firstNode != null) { firstNode.AddBeforeSelf(processingInstruction); } else { _root.Add(processingInstruction); } } _defines.Add(new WixDefine(this, processingInstruction)); }
internal static IXmlNode WrapNode(XObject node) { XDocument xDocument = node as XDocument; XDocument xDocument1 = xDocument; if (xDocument != null) { return(new XDocumentWrapper(xDocument1)); } XElement xElement = node as XElement; XElement xElement1 = xElement; if (xElement != null) { return(new XElementWrapper(xElement1)); } XContainer xContainer = node as XContainer; XContainer xContainer1 = xContainer; if (xContainer != null) { return(new XContainerWrapper(xContainer1)); } XProcessingInstruction xProcessingInstruction = node as XProcessingInstruction; XProcessingInstruction xProcessingInstruction1 = xProcessingInstruction; if (xProcessingInstruction != null) { return(new XProcessingInstructionWrapper(xProcessingInstruction1)); } XText xText = node as XText; XText xText1 = xText; if (xText != null) { return(new XTextWrapper(xText1)); } XComment xComment = node as XComment; XComment xComment1 = xComment; if (xComment != null) { return(new XCommentWrapper(xComment1)); } XAttribute xAttribute = node as XAttribute; XAttribute xAttribute1 = xAttribute; if (xAttribute != null) { return(new XAttributeWrapper(xAttribute1)); } XDocumentType xDocumentType = node as XDocumentType; XDocumentType xDocumentType1 = xDocumentType; if (xDocumentType != null) { return(new Class4(xDocumentType1)); } return(new XObjectWrapper(node)); }
/// <summary> /// Converts an OpenXml package in OPC format to an <see cref="XDocument"/> /// in Flat OPC format. /// </summary> /// <param name="instruction">The processing instruction.</param> /// <returns>The OpenXml package in Flat OPC format.</returns> protected XDocument ToFlatOpcDocument(XProcessingInstruction instruction) { // Save the contents of all parts and relationships that are contained // in the OpenXml package to make sure we convert a consistent state. // This will also invoke ThrowIfObjectDisposed(), so we don't need // to call it here. Save(); // Identify all AlternativeFormatInputParts (AltChunk parts). // This is necessary because AltChunk parts must be treated as binary // parts regardless of the actual content type, which might even be // XML-related such as application/xhtml+xml. var altChunkPartUris = new HashSet <Uri>( Package.GetParts() .Where(part => part.ContentType != RelationshipContentType) .SelectMany(part => part.GetRelationshipsByType(AltChunkRelationshipType)) .Select(pr => PackUriHelper.ResolvePartUri(pr.SourceUri, pr.TargetUri))); // Create an XML document with a standalone declaration, processing // instruction (if not null), and a package root element with a // namespace declaration and one child element for each part. return(new XDocument( new XDeclaration("1.0", "UTF-8", "yes"), instruction, new XElement( Pkg + "package", new XAttribute(XNamespace.Xmlns + "pkg", Pkg.ToString()), Package.GetParts().Select(part => GetContentsAsXml(part, altChunkPartUris))))); }
/// <summary> /// Tests the ProcessingInstruction constructor that takes a value. /// </summary> /// <param name="contextValue"></param> /// <returns></returns> //[Variation(Desc = "CreateProcessingInstructionSimple")] public void CreateProcessingInstructionSimple() { try { new XProcessingInstruction(null, "abcd"); Validate.ExpectedThrow(typeof(ArgumentNullException)); } catch (Exception ex) { Validate.Catch(ex, typeof(ArgumentNullException)); } try { new XProcessingInstruction("abcd", null); Validate.ExpectedThrow(typeof(ArgumentNullException)); } catch (Exception ex) { Validate.Catch(ex, typeof(ArgumentNullException)); } XProcessingInstruction c = new XProcessingInstruction("foo", "bar"); Validate.IsEqual(c.Target, "foo"); Validate.IsEqual(c.Data, "bar"); Validate.IsNull(c.Parent); }
private string GetLocalName() { XElement source = this.source as XElement; if (source != null) { return(source.Name.LocalName); } XAttribute attribute = this.source as XAttribute; if (attribute != null) { if ((this.parent != null) && (attribute.Name.NamespaceName.Length == 0)) { return(string.Empty); } return(attribute.Name.LocalName); } XProcessingInstruction instruction = this.source as XProcessingInstruction; if (instruction != null) { return(instruction.Target); } return(string.Empty); }
private string GetLocalName() { XElement e = _source as XElement; if (e != null) { return(e.Name.LocalName); } XAttribute a = _source as XAttribute; if (a != null) { if (_parent != null && a.Name.NamespaceName.Length == 0) { return(string.Empty); // backcompat } return(a.Name.LocalName); } XProcessingInstruction p = _source as XProcessingInstruction; if (p != null) { return(p.Target); } return(string.Empty); }
private static void RemoveProcessingInstruction(string targetElement, XProcessingInstruction current, string documentNamespace) { if (ProcessingInstructionsPathElementRegex.IsMatch(targetElement)) { // remove whole processing restriction current.Remove(); } else if (AttributePathElementRegex.IsMatch(targetElement)) { // remove attribute from processing instruction var valuesToRemove = AttributeNodeRegex.Matches(current.Data).OfType <Match>().Where(a => { var eAttrName = a.Groups["attrName"]?.Value; return(String.Compare(eAttrName, targetElement.TrimStart('@'), StringComparison.OrdinalIgnoreCase) == 0); }).Select(m => m.Value).ToArray(); if (valuesToRemove.Any()) { foreach (var value in valuesToRemove) { current.Data = current.Data.Replace(value, string.Empty); } } } }
private static OutputFormat GetTransformationOutputFormat(XProcessingInstruction outputFormat, string logFormat, string logValidValueFormat) { var transformationOutputFormat = OutputFormat.Unknown; const string outputformatName = "OutputFormat"; const string invalidXsltTransformation = "Xslt tranformation without output format processing instruction."; if (outputFormat == null) { if (m_log.IsErrorEnabled) { m_log.ErrorFormat(logFormat, outputformatName); } throw new InvalidXsltTransformationException(invalidXsltTransformation); } OutputFormat value; if (Enum.TryParse(outputFormat.Data.Trim(), true, out value)) { transformationOutputFormat = value; } else { if (m_log.IsErrorEnabled) { m_log.ErrorFormat(logValidValueFormat, outputformatName, outputFormat.Data); } throw new InvalidEnumArgumentException(); } return(transformationOutputFormat); }
private BookType GetTransformationBookType(XProcessingInstruction bookType, string logFormat, string logValidValueFormat) { BookType transformationBookType = null; const string bookTypeName = "BookType"; const string invalidXsltTransformation = "Xslt tranformation without book type processing instruction."; if (bookType == null) { if (m_log.IsErrorEnabled) { m_log.ErrorFormat(logFormat, bookTypeName); } throw new InvalidXsltTransformationException(invalidXsltTransformation); } BookTypeEnum value; if (Enum.TryParse(bookType.Data.Trim(), true, out value)) { transformationBookType = m_categoryRepository.FindBookTypeByType(value); } else { if (m_log.IsErrorEnabled) { m_log.ErrorFormat(logValidValueFormat, bookTypeName, bookType.Data); } throw new InvalidEnumArgumentException(); } return(transformationBookType); }
} // proc ParseConfiguration private void IncludeConfigTree(ParseContext context, XProcessingInstruction xPI) { if (xPI.Parent == null) { throw context.CreateConfigException(xPI, "It is not allowed to include to a root element."); } var xInc = context.LoadFile(xPI, xPI.Data).Root; if (xInc.Name == DEConfigurationConstants.xnInclude) { XNode xLast = xPI; // Copy the baseuri annotation var copy = new List <XElement>(); foreach (var xSrc in xInc.Elements()) { Procs.XCopyAnnotations(xSrc, xSrc); copy.Add(xSrc); } // Remove all elements from the source, that not get internal copied. xInc.RemoveAll(); xPI.AddAfterSelf(copy); } else { Procs.XCopyAnnotations(xInc, xInc); xInc.Remove(); xPI.AddAfterSelf(xInc); } } // proc IncludeConfigTree
public void XProcessingInstructionChangeValue() { XProcessingInstruction toChange = new XProcessingInstruction("target", "Original Value"); String newValue = "New Value"; XElement xElem = new XElement("root", toChange); XElement xElemOriginal = new XElement(xElem); using (UndoManager undo = new UndoManager(xElem)) { undo.Group(); using (EventsHelper eHelper = new EventsHelper(xElem)) { using (EventsHelper piHelper = new EventsHelper(toChange)) { toChange.Data = newValue; Assert.True(toChange.Data.Equals(newValue), "Value did not change"); xElem.Verify(); piHelper.Verify(XObjectChange.Value, toChange); } eHelper.Verify(XObjectChange.Value, toChange); } undo.Undo(); Assert.True(XNode.DeepEquals(xElem, xElemOriginal), "Undo did not work!"); } }
private bool CompareProcessingInstructions(XmlCompareContext context, XProcessingInstruction expectedInstruction, XProcessingInstruction actualInstruction) { if (!this.IgnoreProcessingInstructions) { if (expectedInstruction.Target != actualInstruction.Target) { var comparison = new XmlComparison( XmlComparisonType.ProcessingInstructionTarget, new XmlComparisonDetails(expectedInstruction, expectedInstruction.Target), new XmlComparisonDetails(actualInstruction, actualInstruction.Target)); if (!this.HandleDifference(context, comparison)) { return(false); } } if (expectedInstruction.Data != actualInstruction.Data) { var comparison = new XmlComparison( XmlComparisonType.ProcessingInstructionData, new XmlComparisonDetails(expectedInstruction, expectedInstruction.Data), new XmlComparisonDetails(actualInstruction, actualInstruction.Data)); if (!this.HandleDifference(context, comparison)) { return(false); } } } return(true); }
protected virtual XObject VisitProcessingInstruction(XProcessingInstruction node) { return(node.Update( node.Target, node.Data )); }
void WriteNewElement(XElement e) { Write("new XElement("); WriteName(e.Name); if (!e.IsEmpty || e.HasAttributes) { if (IsSingleLineText(e)) { Write(", "); WriteStringLiteral(e.Value); } else { indent += 4; foreach (XAttribute a in e.Attributes()) { Write(","); WriteNewLine(); Write("new XAttribute("); WriteName(a.Name); Write(", "); int i = a.IsNamespaceDeclaration ? namespaces.IndexOf(a.Value) : -1; if (i >= 0) { Write(prefixes[i]); } else { WriteStringLiteral(a.Value); } Write(")"); } foreach (XNode node in e.Nodes()) { Write(","); WriteNewLine(); if (node is XText) { WriteStringLiteral(((XText)node).Value); } else if (node is XElement) { WriteNewElement((XElement)node); } else if (node is XComment) { WriteNewObject("XComment", null, ((XComment)node).Value); } else if (node is XProcessingInstruction) { XProcessingInstruction pi = (XProcessingInstruction)node; WriteNewObject("XProcessingInstruction", pi.Target, pi.Data); } } WriteNewLine(); indent -= 4; } } Write(")"); }
public ContainerIssuer(XProcessingInstruction asset) { //Discarded unreachable code: IL_0002, IL_0006 //IL_0003: Incompatible stack heights: 0 vs 1 //IL_0007: Incompatible stack heights: 0 vs 1 SingletonReader.PushGlobal(); base._002Ector(asset); }
public static XProcessingInstruction CreateChildProcessingInstruction(this XElement source, string documentNamespace, string elementName, string attrName = null, string attrValue = null) { var item = new XProcessingInstruction(elementName, (!string.IsNullOrWhiteSpace(attrName) && !string.IsNullOrWhiteSpace(attrValue)) ? $"{attrName}=\"{attrValue}\"" : string.Empty); source.Add(item); return(item); }
public WixDefine([NotNull] WixSourceFile sourceFile, [NotNull] XProcessingInstruction node) { Contract.Requires(sourceFile != null); Contract.Requires(node != null); _sourceFile = sourceFile; _node = node; }
public static XElement WriteProcessingInstruction(this XElement elem, string target, string data) { XProcessingInstruction xpi = new XProcessingInstruction(target, data); elem.Add(xpi); return(elem); }
public static XObject Update(this XProcessingInstruction node, string target, string data) { CheckNullReference(node); CheckArgumentNull(target, "target"); CheckArgumentNull(data, "data"); return(new XProcessingInstruction(target, data)); }
/// <summary> /// Tests the AddAfterSelf/AddBeforeSelf/Remove method on Node, /// when there's no parent. /// </summary> /// <param name="context"></param> /// <returns></returns> //[Variation(Desc = "NodeNoParentAddRemove")] public void NodeNoParentAddRemove() { // Not allowed if parent is null. int i = 0; while (true) { XNode node = null; switch (i++) { case 0: node = new XElement("x"); break; case 1: node = new XComment("c"); break; case 2: node = new XText("abc"); break; case 3: node = new XProcessingInstruction("target", "data"); break; default: i = -1; break; } if (i < 0) { break; } try { node.AddBeforeSelf("foo"); Validate.ExpectedThrow(typeof(InvalidOperationException)); } catch (Exception ex) { Validate.Catch(ex, typeof(InvalidOperationException)); } try { node.AddAfterSelf("foo"); Validate.ExpectedThrow(typeof(InvalidOperationException)); } catch (Exception ex) { Validate.Catch(ex, typeof(InvalidOperationException)); } try { node.Remove(); Validate.ExpectedThrow(typeof(InvalidOperationException)); } catch (Exception ex) { Validate.Catch(ex, typeof(InvalidOperationException)); } } }
/// <summary> /// Adds any include elements as the first element under the WiX /// element. /// </summary> /// <param name="wixElement"> /// The WiX element to add to. /// </param> private static void AddIncludeFiles(XElement wixElement) { foreach (var includeFile in argValues.IncludeFiles) { var include = new XProcessingInstruction("include", includeFile); wixElement.AddFirst(include); } }
/// <summary> /// Initializes a new XML processing instruction by copying its target and data /// from another XML processing instruction. /// </summary> /// <param name="other">XML processing instruction to copy from.</param> public XProcessingInstruction(XProcessingInstruction other) { if (other == null) { throw new ArgumentNullException("other"); } this.target = other.target; this.data = other.data; }
static void Main() { XDocument doc = XDocument.Load("test.xml"); var proc = new XProcessingInstruction ("xml-stylesheet", "type=\"text/xsl\" href=\"Sample.xsl\""); doc.Root.AddBeforeSelf(proc); doc.Save("test2.xml"); }
//[Variation(Priority = 1, Desc = "XDocument - the same node instance, connected - sanity", Param = true)] //[Variation(Priority = 1, Desc = "XDocument - the same node instance - sanity", Param = false)] public void XDocumentTheSameReferenceSanity() { object[] paras = null; var connected = (bool)Variation.Param; XDocument doc1 = null; if (connected) { doc1 = new XDocument(new XElement("root", new XElement("A"), new XProcessingInstruction("PI", "data"))); paras = new object[] { doc1.Root.LastNode, doc1.Root.LastNode, doc1.Root.Element("A") }; } else { var e = new XElement("A"); var pi = new XProcessingInstruction("PI", "data"); paras = new object[] { pi, pi, e }; } var doc = new XDocument(paras); XNode firstPI = doc.FirstNode; XNode secondPI = firstPI.NextNode; XNode rootElem = secondPI.NextNode; TestLog.Compare(firstPI != null, "firstPI != null"); TestLog.Compare(firstPI.NodeType, XmlNodeType.ProcessingInstruction, "firstPI nodetype"); TestLog.Compare(firstPI is XProcessingInstruction, "firstPI is XPI"); TestLog.Compare(secondPI != null, "secondPI != null"); TestLog.Compare(secondPI.NodeType, XmlNodeType.ProcessingInstruction, "secondPI nodetype"); TestLog.Compare(secondPI is XProcessingInstruction, "secondPI is XPI"); TestLog.Compare(rootElem != null, "rootElem != null"); TestLog.Compare(rootElem.NodeType, XmlNodeType.Element, "rootElem nodetype"); TestLog.Compare(rootElem is XElement, "rootElem is XElement"); TestLog.Compare(rootElem.NextNode == null, "rootElem NextNode"); TestLog.Compare(firstPI != secondPI, "firstPI != secondPI"); TestLog.Compare(XNode.DeepEquals(firstPI, secondPI), "XNode.DeepEquals(firstPI,secondPI)"); foreach (object o in paras) { var e = o as XNode; if (connected) { TestLog.Compare(e.Parent, doc1.Root, "Orig Parent"); TestLog.Compare(e.Document, doc1, "Orig Document"); } else { TestLog.Compare(e.Parent == null, "Orig Parent not connected"); TestLog.Compare(e.Document, doc, "Orig Document not connected"); } } }
/// <summary> /// Validate behavior of the XDocument copy/clone constructor. /// </summary> /// <returns>true if pass, false if fail</returns> //[Variation(Desc = "CreateDocumentCopy")] public void CreateDocumentCopy() { try { new XDocument((XDocument)null); Validate.ExpectedThrow(typeof(ArgumentNullException)); } catch (Exception ex) { Validate.Catch(ex, typeof(ArgumentNullException)); } XDeclaration declaration = new XDeclaration("1.0", "utf-8", "yes"); XComment comment = new XComment("This is a document"); XProcessingInstruction instruction = new XProcessingInstruction("doc-target", "doc-data"); XElement element = new XElement("RootElement"); XDocument doc = new XDocument(declaration, comment, instruction, element); XDocument doc2 = new XDocument(doc); IEnumerator e = doc2.Nodes().GetEnumerator(); // First node: declaration Validate.IsEqual(doc.Declaration.ToString(), doc2.Declaration.ToString()); // Next node: comment Validate.IsEqual(e.MoveNext(), true); Validate.Type(e.Current, typeof(XComment)); Validate.IsNotReferenceEqual(e.Current, comment); XComment comment2 = (XComment)e.Current; Validate.IsEqual(comment2.Value, comment.Value); // Next node: processing instruction Validate.IsEqual(e.MoveNext(), true); Validate.Type(e.Current, typeof(XProcessingInstruction)); Validate.IsNotReferenceEqual(e.Current, instruction); XProcessingInstruction instruction2 = (XProcessingInstruction)e.Current; Validate.String(instruction2.Target, instruction.Target); Validate.String(instruction2.Data, instruction.Data); // Next node: element. Validate.IsEqual(e.MoveNext(), true); Validate.Type(e.Current, typeof(XElement)); Validate.IsNotReferenceEqual(e.Current, element); XElement element2 = (XElement)e.Current; Validate.ElementName(element2, element.Name.ToString()); Validate.Count(element2.Nodes(), 0); // Should be end. Validate.IsEqual(e.MoveNext(), false); }
public void ProcessingInstruction(string target1, string data1, string target2, string data2, bool checkHashCode) { var p1 = new XProcessingInstruction(target1, data1); var p2 = new XProcessingInstruction(target2, data2); VerifyComparison(checkHashCode, p1, p2); XDocument doc = new XDocument(p1); XElement e2 = new XElement("p2p", p2); VerifyComparison(checkHashCode, p1, p2); }
public void XPIEmptyStringShouldNotBeAllowed() { var pi = new XProcessingInstruction("PI", "data"); Assert.Throws<ArgumentNullException>(() => pi.Target = string.Empty); }
/// <summary> /// Initializes a new XML processing instruction by copying its target and data /// from another XML processing instruction. /// </summary> /// <param name="other">XML processing instruction to copy from.</param> public XProcessingInstruction(XProcessingInstruction other) { if (other == null) throw new ArgumentNullException(nameof(other)); this.target = other.target; this.data = other.data; }