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


C# Metadata.Clone方法代码示例

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


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

示例1: CanCloneWithNewValues

        public void CanCloneWithNewValues()
        {
            // Given
            Engine engine = new Engine();
            Metadata metadata = new Metadata(engine);

            // When
            metadata = metadata.Clone(new [] { new KeyValuePair<string, object>("A", "a") });

            // Then
            Assert.AreEqual("a", metadata["A"]);
        }
开发者ID:Rohansi,项目名称:Wyam,代码行数:12,代码来源:MetadataFixture.cs

示例2: ClonedMetadataDoesNotContainNewValues

        public void ClonedMetadataDoesNotContainNewValues()
        {
            // Given
            Engine engine = new Engine();
            engine.Metadata["A"] = "a";
            Metadata metadata = new Metadata(engine);

            // When
            Metadata clone = metadata.Clone(new Dictionary<string, object> { { "B", "b" } });

            // Then
            Assert.IsFalse(metadata.ContainsKey("B"));
        }
开发者ID:Rohansi,项目名称:Wyam,代码行数:13,代码来源:MetadataFixture.cs

示例3: CloneContainsPreviousValues

        public void CloneContainsPreviousValues()
        {
            // Given
            Engine engine = new Engine();
            engine.Metadata["A"] = "a";
            Metadata metadata = new Metadata(engine);

            // When
            Metadata clone = metadata.Clone(new Dictionary<string, object> { { "B", "b" } });

            // Then
            Assert.AreEqual("a", clone["A"]);
        }
开发者ID:Rohansi,项目名称:Wyam,代码行数:13,代码来源:MetadataFixture.cs

示例4: ConvertStringArrayToIntArray

        public void ConvertStringArrayToIntArray()
        {
            // Given
            Engine engine = new Engine();
            Metadata metadata = new Metadata(engine);

            // When
            metadata = metadata.Clone(new[] { new KeyValuePair<string, object>("A", new string[] { "1", "2", "3" }) });
            IMetadata<int[]> metadataAs = metadata.MetadataAs<int[]>();

            // Then
            CollectionAssert.AreEqual(new string[] { "1", "2", "3" }, (IEnumerable)metadata["A"]);
            CollectionAssert.AreEqual(new int[] { 1, 2, 3 }, (IEnumerable)metadataAs["A"]);
        }
开发者ID:Rohansi,项目名称:Wyam,代码行数:14,代码来源:MetadataAsFixture.cs

示例5: ConvertIntToString

        public void ConvertIntToString()
        {
            // Given
            Engine engine = new Engine();
            Metadata metadata = new Metadata(engine);

            // When
            metadata = metadata.Clone(new[] { new KeyValuePair<string, object>("A", 1) });
            IMetadata<string> metadataAs = metadata.MetadataAs<string>();

            // Then
            Assert.AreEqual(1, metadata["A"]);
            Assert.AreEqual("1", metadataAs["A"]);
        }
开发者ID:Rohansi,项目名称:Wyam,代码行数:14,代码来源:MetadataAsFixture.cs

示例6: CloneContainsNewValues

        public void CloneContainsNewValues()
        {
            // Given
            Engine engine = new Engine();
            engine.Trace.AddListener(new TestTraceListener());
            engine.Metadata["A"] = "a";
            Metadata metadata = new Metadata(engine);

            // When
            Metadata clone = metadata.Clone(new Dictionary<string, object> { { "B", "b" } });

            // Then
            Assert.AreEqual("b", clone["B"]);
        }
开发者ID:JasonKoopmans,项目名称:Wyam,代码行数:14,代码来源:MetadataFixture.cs

示例7: ConvertIntArrayToStringEnumerable

        public void ConvertIntArrayToStringEnumerable()
        {
            // Given
            Engine engine = new Engine();
            engine.Trace.AddListener(new TestTraceListener());
            Metadata metadata = new Metadata(engine);

            // When
            metadata = metadata.Clone(new[] { new KeyValuePair<string, object>("A", new int[] { 1, 2, 3 }) });
            IMetadata<IEnumerable<string>> metadataAs = metadata.MetadataAs<IEnumerable<string>>();

            // Then
            CollectionAssert.AreEqual(new int[] { 1, 2, 3 }, (IEnumerable)metadata["A"]);
            CollectionAssert.AreEqual(new string[] { "1", "2", "3" }, metadataAs["A"]);
        }
开发者ID:JasonKoopmans,项目名称:Wyam,代码行数:15,代码来源:MetadataAsFixture.cs

示例8: ConvertStringToIntArray

        public void ConvertStringToIntArray()
        {
            // Given
            Engine engine = new Engine();
            engine.Trace.AddListener(new TestTraceListener());
            Metadata metadata = new Metadata(engine);

            // When
            metadata = metadata.Clone(new[] { new KeyValuePair<string, object>("A", "1") });
            IMetadata<int[]> metadataAs = metadata.MetadataAs<int[]>();

            // Then
            Assert.AreEqual("1", metadata["A"]);
            CollectionAssert.AreEqual(new int[] { 1 }, (IEnumerable)metadataAs["A"]);
        }
开发者ID:JasonKoopmans,项目名称:Wyam,代码行数:15,代码来源:MetadataAsFixture.cs

示例9: CloneReplacesValue

        public void CloneReplacesValue()
        {
            // Given
            Engine engine = new Engine();
            engine.Metadata["A"] = "a";
            Metadata metadata = new Metadata(engine);

            // When
            Metadata clone = metadata.Clone(new Dictionary<string, object> { { "A", "b" } });

            // Then
            Assert.AreEqual("a", metadata["A"]);
            Assert.AreEqual("b", clone["A"]);
        }
开发者ID:Rohansi,项目名称:Wyam,代码行数:14,代码来源:MetadataFixture.cs


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