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

C# Linq.XProcessingInstruction类代码示例

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

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



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

示例1: CreateProcessingInstructionSimple

                /// <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);
                }
开发者ID:johnhhm,项目名称:corefx,代码行数:33,代码来源:SDMPI.cs


示例2: ProcessingInstructionEquals

                /// <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);
                }
开发者ID:johnhhm,项目名称:corefx,代码行数:30,代码来源:SDMPI.cs


示例3: XProcessingInstruction

 public XProcessingInstruction(XProcessingInstruction other)
 {
     if (other == null)
         throw new ArgumentNullException ("other");
     this.name = other.name;
     this.data = other.data;
 }
开发者ID:nicocrm,项目名称:DotNetSDataClient,代码行数:7,代码来源:XProcessingInstruction.cs


示例4: XProcessingInstruction

 public XProcessingInstruction(XProcessingInstruction other)
 {
     if (other == null)
     {
         throw new ArgumentNullException("other");
     }
     this.target = other.target;
     this.data = other.data;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:XProcessingInstruction.cs


示例5: ValidPIVariation

 //[Variation(Priority = 0, Desc = "XProcessingInstruction - Valid Name")]
 public void ValidPIVariation()
 {
     _runWithEvents = (bool)Params[0];
     XProcessingInstruction toChange = new XProcessingInstruction("target", "data");
     if (_runWithEvents) _eHelper = new EventsHelper(toChange);
     toChange.Target = "newTarget";
     if (_runWithEvents) _eHelper.Verify(XObjectChange.Name);
     TestLog.Compare(toChange.Target.Equals("newTarget"), "Name did not change");
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:10,代码来源:XElement_Value.cs


示例6: CreateProcessingInstructionSimple

        public void CreateProcessingInstructionSimple()
        {
            Assert.Throws<ArgumentNullException>(() => new XProcessingInstruction(null, "abcd"));
            Assert.Throws<ArgumentNullException>(() => new XProcessingInstruction("abcd", null));

            XProcessingInstruction c = new XProcessingInstruction("foo", "bar");
            Assert.Equal("foo", c.Target);
            Assert.Equal("bar", c.Data);
            Assert.Null(c.Parent);
        }
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:10,代码来源:SDMPI.cs


示例7: CreateDocumentVerbose

        // <?xml version="1.0"?>
        // <?order alpha ascending?>
        // <art xmlns='urn:art-org:art'>
        //   <period name='Renaissance' xmlns:a='urn:art-org:artists'>
        //     <a:artist>Leonardo da Vinci</a:artist>
        //     <a:artist>Michelangelo</a:artist>
        //     <a:artist><![CDATA[Donatello]]></a:artist>
        //   </period>
        //   <!-- insert period here -->
        // </art>
        public static XDocument CreateDocumentVerbose()
        {
            XNamespace nsArt = "urn:art-org:art";
            XNamespace nsArtists = "urn:art-org:artists";

            // create the document
            XDocument document = new XDocument();

            // create the xml declaration and
            // set on the document
            document.Declaration = new XDeclaration("1.0", null, null);

            // create the art element and
            // add to the document
            XElement art = new XElement(nsArt + "art");
            document.Add(art);

            // create the order processing instruction and
            // add before the art element
            XProcessingInstruction pi = new XProcessingInstruction("order", "alpha ascending");
            art.AddBeforeSelf(pi);

            // create the period element and
            // add to the art element
            XElement period = new XElement(nsArt + "period");
            art.Add(period);

            // add the name attribute to the period element
            period.SetAttributeValue("name", "Renaissance");

            // create the namespace declaration xmlns:a and
            // add to the period element
            XAttribute nsdecl = new XAttribute(XNamespace.Xmlns + "a", nsArtists);
            period.Add(nsdecl);

            // create the artists elements and
            // the underlying text nodes
            period.SetElementValue(nsArtists + "artist", "Michelangelo");

            XElement artist = new XElement(nsArtists + "artist", "Leonardo ", "da ", "Vinci");
            period.AddFirst(artist);

            artist = new XElement(nsArtists + "artist");
            period.Add(artist);
            XText cdata = new XText("Donatello");
            artist.Add(cdata);

            // create the comment and
            // add to the art element
            XComment comment = new XComment("insert period here");
            art.Add(comment);

            return document;
        }
开发者ID:jamesmaxwell,项目名称:DesignPatternDemo,代码行数:64,代码来源:Program.cs


示例8: Process

 public override IEnumerable< XNode > Process(XNode node)
 {
     XElement element = _AssumeElement( node );
     Validation.RequireAttributes( element, AttrName.Name );
     // PI name and value can have symbolic expansions or expressions
     string pi_name =
         _ProcessText( ( string ) element.Attribute( AttrName.Name ) ).GetTextValue();
     string pi_val = _ProcessText( element.Value ).GetTextValue();
     var pi = new XProcessingInstruction( pi_name, pi_val );
     return new[] {pi};
 }
开发者ID:BiYiTuan,项目名称:CruiseControl.NET,代码行数:11,代码来源:ProcessingInstructionProcessor.cs


示例9: CreateDocumentWithContent

        public void CreateDocumentWithContent()
        {
            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);

            Assert.Equal(new XNode[] { comment, instruction, element }, doc.Nodes());
        }
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:11,代码来源:SDMDocument.cs


示例10: set_ProcessingInstruction

 public static XDocument set_ProcessingInstruction(this XDocument xDocument, string target, string data)
 {
     var processingInstruntion = xDocument.processingInstruction(target);
     if (processingInstruntion.notNull())
         processingInstruntion.Data = data;
     else
     {
         var newProcessingInstruction = new XProcessingInstruction(target, data);//"xsl-stylesheet", "type=\"text/xsl\" href=\"LogStyle.xsl\"");
         xDocument.AddFirst(newProcessingInstruction);
     }
     return xDocument;
 }
开发者ID:SergeTruth,项目名称:OxyChart,代码行数:12,代码来源:XProcessingInstruction_ExtensionMethods.cs


示例11: CreateDocumentCopy

                /// <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);
                }
开发者ID:johnhhm,项目名称:corefx,代码行数:57,代码来源:SDMDocument.cs


示例12: PI

                // equals => hashcode should be the same

                //  - all "simple" node types
                //  - text vs. CDATA
                //  XDocument:
                //  - Normal mode
                //  - Concatenated text (Whitespace) nodes
                //  - Diffs in XDecl

                //  XElement:
                //  - Normal mode
                //      - same nodes, different order
                //          - comments inside the texts
                //      - same nodes, same order (positive)
                //
                //  - Concatenated text nodes
                //      - string content vs. text node/s
                //          - empty string vs. empty text node
                //      - Multiple text nodes but the same value
                //      - adjacent text & CData
                //  
                //  - IsEmpty
                //  - Attribute order
                //  - Namespace declarations 
                //      - local vs. in-scope
                //      - default redef.

                //[Variation(Priority = 0, Desc = "PI normal", Params = new object[] { "PI", "click", "PI", "click", true })]
                //[Variation(Priority = 0, Desc = "PI target=data", Params = new object[] { "PI", "PI", "PI", "PI", true })]
                //[Variation(Priority = 0, Desc = "PI data = ''", Params = new object[] { "PI", "", "PI", "", true })]
                //[Variation(Priority = 1, Desc = "PI data1!=data2", Params = new object[] { "PI", "click", "PI", "", false })]
                //[Variation(Priority = 2, Desc = "PI target1!=target2!", Params = new object[] { "AAAAP", "click", "AAAAQ", "click", false })]
                //[Variation(Priority = 2, Desc = "PI hashconflict I.", Params = new object[] { "AAAAP", "AAAAQ", "AAAAP", "AAAAQ", true })]
                //[Variation(Priority = 2, Desc = "PI data=target, not the same", Params = new object[] { "PA", "PA", "PI", "PI", false })]
                //[Variation(Priority = 2, Desc = "PI hashconflict II.", Params = new object[] { "AAAAP", "AAAAQ", "AAAAQ", "AAAAP", false })]
                public void PI()
                {
                    bool expected = (bool)Variation.Params[4];
                    XProcessingInstruction p1 = new XProcessingInstruction(Variation.Params[0] as string, Variation.Params[1] as string);
                    XProcessingInstruction p2 = new XProcessingInstruction(Variation.Params[2] as string, Variation.Params[3] as string);

                    VerifyComparison(expected, p1, p2);

                    XDocument doc = new XDocument(p1);
                    XElement e2 = new XElement("p2p", p2);

                    VerifyComparison(expected, p1, p2);
                }
开发者ID:johnhhm,项目名称:corefx,代码行数:48,代码来源:DeepEquals.cs


示例13: XPIEmptyStringShouldNotBeAllowed

 //[Variation(Desc = "pi.Target = '' should not be allowed")]
 public void XPIEmptyStringShouldNotBeAllowed()
 {
     XProcessingInstruction pi = new XProcessingInstruction("PI", "data");
     try
     {
         pi.Target = "";
     }
     catch (ArgumentException)
     {
         return;
     }
     throw new TestException(TestResult.Failed, "");
 }
开发者ID:johnhhm,项目名称:corefx,代码行数:14,代码来源:RegressionTests.cs


示例14: NodeTypes

                //[Variation(Desc = "NodeTypes")]
                public void NodeTypes()
                {
                    XDocument document = new XDocument();
                    XElement element = new XElement("x");
                    XText text = new XText("text-value");
                    XComment comment = new XComment("comment");
                    XProcessingInstruction processingInstruction = new XProcessingInstruction("target", "data");

                    Validate.IsEqual(document.NodeType, XmlNodeType.Document);
                    Validate.IsEqual(element.NodeType, XmlNodeType.Element);
                    Validate.IsEqual(text.NodeType, XmlNodeType.Text);
                    Validate.IsEqual(comment.NodeType, XmlNodeType.Comment);
                    Validate.IsEqual(processingInstruction.NodeType, XmlNodeType.ProcessingInstruction);
                }
开发者ID:johnhhm,项目名称:corefx,代码行数:15,代码来源:SDMMisc.cs


示例15: NodeTypes

        public void NodeTypes()
        {
            XDocument document = new XDocument();
            XElement element = new XElement("x");
            XText text = new XText("text-value");
            XComment comment = new XComment("comment");
            XProcessingInstruction processingInstruction = new XProcessingInstruction("target", "data");

            Assert.Equal(XmlNodeType.Document, document.NodeType);
            Assert.Equal(XmlNodeType.Element, element.NodeType);
            Assert.Equal(XmlNodeType.Text, text.NodeType);
            Assert.Equal(XmlNodeType.Comment, comment.NodeType);
            Assert.Equal(XmlNodeType.ProcessingInstruction, processingInstruction.NodeType);
        }
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:14,代码来源:SDMMisc.cs


示例16: CreateDocumentCopy

        public void CreateDocumentCopy()
        {
            Assert.Throws<ArgumentNullException>(() => new XDocument((XDocument)null));

            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
            Assert.Equal(doc.Declaration.ToString(), doc2.Declaration.ToString());

            // Next node: comment
            Assert.True(e.MoveNext());
            Assert.IsType<XComment>(e.Current);
            Assert.NotSame(comment, e.Current);

            XComment comment2 = (XComment)e.Current;
            Assert.Equal(comment.Value, comment2.Value);

            // Next node: processing instruction
            Assert.True(e.MoveNext());
            Assert.IsType<XProcessingInstruction>(e.Current);
            Assert.NotSame(instruction, e.Current);

            XProcessingInstruction instruction2 = (XProcessingInstruction)e.Current;
            Assert.Equal(instruction.Target, instruction2.Target);
            Assert.Equal(instruction.Data, instruction2.Data);

            // Next node: element.
            Assert.True(e.MoveNext());
            Assert.IsType<XElement>(e.Current);
            Assert.NotSame(element, e.Current);

            XElement element2 = (XElement)e.Current;
            Assert.Equal(element.Name.ToString(), element2.Name.ToString());
            Assert.Empty(element2.Nodes());

            // Should be end.
            Assert.False(e.MoveNext());
        }
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:47,代码来源:SDMDocument.cs


示例17: 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");

            Assert.False(XNode.DeepEquals(c1, (XProcessingInstruction)null));
            Assert.True(XNode.DeepEquals(c1, c1));
            Assert.False(XNode.DeepEquals(c1, c2));
            Assert.False(XNode.DeepEquals(c1, c3));
            Assert.False(XNode.DeepEquals(c1, c4));
            Assert.True(XNode.DeepEquals(c1, c5));

            Assert.Equal(XNode.EqualityComparer.GetHashCode(c1), XNode.EqualityComparer.GetHashCode(c5));
        }
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:17,代码来源:SDMPI.cs


示例18: XProcessingInstructionPIVariation

 public void XProcessingInstructionPIVariation()
 {
     XProcessingInstruction toChange = new XProcessingInstruction("target", "data");
     XProcessingInstruction original = new XProcessingInstruction(toChange);
     using (UndoManager undo = new UndoManager(toChange))
     {
         undo.Group();
         using (EventsHelper eHelper = new EventsHelper(toChange))
         {
             toChange.Target = "newTarget";
             Assert.True(toChange.Target.Equals("newTarget"), "Name did not change");
             eHelper.Verify(XObjectChange.Name, toChange);
         }
         undo.Undo();
         Assert.True(XNode.DeepEquals(toChange, original), "Undo did not work");
     }
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:17,代码来源:EventsName.cs


示例19: ProcessingInstructionValues

        public void ProcessingInstructionValues()
        {
            XProcessingInstruction c = new XProcessingInstruction("xxx", "yyy");
            Assert.Equal("xxx", c.Target);
            Assert.Equal("yyy", c.Data);

            // Null values not allowed.
            Assert.Throws<ArgumentNullException>(() => c.Target = null);
            Assert.Throws<ArgumentNullException>(() => c.Data = null);

            // Try setting values.
            c.Target = "abcd";
            Assert.Equal("abcd", c.Target);

            c.Data = "efgh";
            Assert.Equal("efgh", c.Data);
            Assert.Equal("abcd", c.Target);
        }
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:18,代码来源:SDMPI.cs


示例20: InvalidPIVariation

                //[Variation(Priority = 0, Desc = "XProcessingInstruction - Invalid Name")]
                public void InvalidPIVariation()
                {
                    _runWithEvents = (bool)Params[0];
                    XProcessingInstruction toChange = new XProcessingInstruction("target", "data");
                    if (_runWithEvents) _eHelper = new EventsHelper(toChange);

                    try
                    {
                        toChange.Target = null;
                    }
                    catch (Exception)
                    {
                        if (_runWithEvents) _eHelper.Verify(0);
                        return;
                    }

                    try
                    {
                        toChange.Target = " ";
                    }
                    catch (Exception)
                    {
                        if (_runWithEvents) _eHelper.Verify(0);

                        return;
                    }

                    try
                    {
                        toChange.Target = "";
                    }
                    catch (Exception)
                    {
                        if (_runWithEvents) _eHelper.Verify(0);
                        return;
                    }

                    throw new TestException(TestResult.Failed, "");
                }
开发者ID:noahfalk,项目名称:corefx,代码行数:40,代码来源:XElement_Value.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Linq.XStreamingElement类代码示例发布时间:2022-05-26
下一篇:
C# Linq.XNode类代码示例发布时间: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