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


C# Metadata.ContainsKey方法代码示例

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


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

示例1: 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

示例2: CloneWithCanMerge

        public void CloneWithCanMerge()
        {
            // Arrange
            var key1 = A<string>();
            var key2 = A<string>();
            var value1 = A<string>();
            var value2 = A<string>();

            // Act
            var metadata1 = new Metadata { [key1] = value1 };
            var metadata2 = metadata1.CloneWith(new KeyValuePair<string, string>(key2, value2));

            // Assert
            metadata1.ContainsKey(key2).Should().BeFalse();

            metadata2.ContainsKey(key1).Should().BeTrue();
            metadata2.ContainsKey(key2).Should().BeTrue();
            metadata2[key1].Should().Be(value1);
            metadata2[key2].Should().Be(value2);
        }
开发者ID:joaomajesus,项目名称:EventFlow,代码行数:20,代码来源:MetadataTests.cs

示例3: GetActualMetadata

        private async Task<Metadata> GetActualMetadata(ICloudBlob blob)
        {
            var metadata = new Metadata(blob.Metadata);

            if (blob.Properties.LastModified.HasValue || blob.SnapshotTime.HasValue)
            {
                metadata.StoredLastModified = blob.SnapshotTime.HasValue ? blob.SnapshotTime.Value.UtcDateTime : blob.Properties.LastModified.Value.UtcDateTime;
                if(!metadata.LastModified.HasValue)
                {
                    metadata.LastModified = metadata.StoredLastModified;
                }
            }

            metadata.StoredContentLength = blob.Properties.Length;
            metadata.StoredContentType = blob.Properties.ContentType;
            metadata.ETag = blob.Properties.ETag;

            // Remove the snapshot key at this point if we have it
            if(metadata.ContainsKey(InternalSnapshotKey))
            {
                metadata.Remove(InternalSnapshotKey);
            }

            // Remove the store key as well...
            if(metadata.ContainsKey(StoreVersionKey))
            {
                metadata.Remove(StoreVersionKey);
            }

            if (_enableSnapshots)
            {
                if (blob.IsSnapshot)
                {
                    metadata.Snapshot = blob.SnapshotTime.Value.UtcTicks.ToString(CultureInfo.InvariantCulture);
                }
                else if (blob.Metadata.ContainsKey(InternalSnapshotKey))
                {
                    // Try and use our save snapshot instead of making more calls...
                    metadata.Snapshot = blob.Metadata[InternalSnapshotKey];
                }
                else
                {
                    // Try and find last snapshot
                    // Unfortunately we need to make a request since this information isn't on the actual blob that we are working with...
                    var snapBlob = await ListBlobs(blob.Container, blob.Name, BlobListingDetails.Snapshots | BlobListingDetails.Metadata)
                        .Where(b => b.IsSnapshot && b.Uri == blob.Uri && b.SnapshotTime.HasValue)
                        .Scan((a, b) => a.SnapshotTime.Value > b.SnapshotTime.Value ? a : b)
                        .LastOrDefault()
                        .ConfigureAwait(false);

                    metadata.Snapshot = snapBlob == null ? null : snapBlob.SnapshotTime.Value.UtcTicks.ToString(CultureInfo.InvariantCulture);
                }
            }

            return metadata;
        }
开发者ID:KalixHealth,项目名称:Kalix.Leo,代码行数:56,代码来源:AzureStore.cs

示例4: ContainsKeyReturnsTrueForValidValue

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

            // When
            bool contains = metadata.ContainsKey("A");

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

示例5: ContainsReturnsFalseForInvalidValue

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

            // When
            bool contains = metadata.ContainsKey("B");

            // Then
            Assert.IsFalse(contains);
        }
开发者ID:JasonKoopmans,项目名称:Wyam,代码行数:14,代码来源:MetadataFixture.cs


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