当前位置: 首页>>代码示例>>C#>>正文


C# File.AddNote方法代码示例

本文整理汇总了C#中File.AddNote方法的典型用法代码示例。如果您正苦于以下问题:C# File.AddNote方法的具体用法?C# File.AddNote怎么用?C# File.AddNote使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在File的用法示例。


在下文中一共展示了File.AddNote方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: XliffElement_SelectElement

        public void XliffElement_SelectElement()
        {
            File file;
            Group group;
            Unit unit;
            Segment segment;
            Ignorable ignorable;
            TestXliffElement element;

            element = new TestXliffElement();
            element.Document = new XliffDocument();

            Console.WriteLine("Test with no items.");
            Assert.IsNull(element.CallSelectElement("#/file"));

            Console.WriteLine("Test with file items.");
            file = new File("file");
            element.Document.Files.Add(file);
            Assert.AreEqual(file, element.CallSelectElement("#/f=file"));

            Console.WriteLine("Test with relative path to file item.");
            Assert.AreEqual(file, element.Document.Select("#f=file"));

            Console.WriteLine("Test with many items.");
            group = new Group("group");
            file.Containers.Add(new Group());
            file.Containers.Add(group);

            unit = new Unit("unit");
            group.Containers.Add(unit);
            group.Containers.Add(new Group());
            group.Containers.Add(new Unit());
            Assert.AreEqual(unit, element.CallSelectElement("#/f=file/g=group/u=unit"));

            Console.WriteLine("Test with segment.");
            segment = new Segment("segment");
            unit.Resources.Add(segment);
            Assert.AreEqual(segment, element.CallSelectElement("#/f=file/g=group/u=unit/segment"));

            Console.WriteLine("Test with relative path to segment.");
            Assert.AreEqual(segment, group.Select("#u=unit/segment"));

            Console.WriteLine("Test with invalid relative path to segment.");
            try
            {
                group.Select("u=unit/segment");
                Assert.Fail("Expected ArgumentException to be thrown.");
            }
            catch (ArgumentException)
            {
            }

            Console.WriteLine("Test with ignorable.");
            ignorable = new Ignorable("ignorable");
            unit.Resources.Add(ignorable);
            Assert.AreEqual(ignorable, element.CallSelectElement("#/f=file/g=group/u=unit/ignorable"));

            Console.WriteLine("Test with data.");
            unit.OriginalData = new OriginalData();
            unit.OriginalData.AddData("data", "text");
            Assert.AreEqual(unit.OriginalData.DataElements[0],
                            element.CallSelectElement("#/f=file/g=group/u=unit/d=data"));

            Console.WriteLine("Test with note.");
            file.AddNote("note").Id = "note";
            Assert.AreEqual(file.Notes[0], element.CallSelectElement("#/f=file/n=note"));

            //
            // This test should still work even though it's an invalid document.
            //

            Console.WriteLine("Test with duplicate names.");
            element.Document.Files.Add(new File("file"));
            Assert.AreEqual(file, element.CallSelectElement("#/f=file"), "Found wrong item.");

            Console.WriteLine("Test with bogus names.");
            Assert.IsNull(element.CallSelectElement("#/f=foo"), "Item should not have been found.");

            Console.WriteLine("Test with bogus path.");
            Assert.IsNull(element.CallSelectElement("#/blah"), "Item should not have been found.");

            Console.WriteLine("Test with empty string.");
            // This returns null because SelectElement is called directly which doesn't search for the leading '#'.
            Assert.IsNull(element.CallSelectElement(String.Empty));

            Console.WriteLine("Test with empty path.");
            Assert.IsNull(element.CallSelectElement("/"), "Item should not have been found.");

            Console.WriteLine("Test with inline element.");
            segment.Source = new Source();
            segment.Source.Text.Add(new MarkedSpan("ms1"));
            Assert.AreEqual(segment.Source.Text[0],
                            element.CallSelectElement("#/f=file/g=group/u=unit/ms1"),
                            "Item should have been found.");

            Console.WriteLine("Test with inline element.");
            segment.Target = new Target();
            segment.Target.Text.Add(new MarkedSpan("ms2"));
            Assert.AreEqual(segment.Target.Text[0],
                            element.CallSelectElement("#/f=file/g=group/u=unit/t=ms2"),
//.........这里部分代码省略.........
开发者ID:jogleasonjr,项目名称:XLIFF2-Object-Model,代码行数:101,代码来源:XliffElementTests.cs


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