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

C# ODataEntry类代码示例

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

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



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

示例1: InjectMetadataBuilderShouldNotSetBuilderOnEntry

 public void InjectMetadataBuilderShouldNotSetBuilderOnEntry()
 {
     var entry = new ODataEntry();
     var builder = new TestEntityMetadataBuilder(entry);
     testSubject.InjectMetadataBuilder(entry, builder);
     entry.MetadataBuilder.Should().BeOfType<NoOpEntityMetadataBuilder>();
 }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:7,代码来源:JsonMinimalMetadataLevelTests.cs


示例2: ReadLinkShouldNotBeOmittedWhenNotIdenticalToEditLink

 public void ReadLinkShouldNotBeOmittedWhenNotIdenticalToEditLink()
 {
     DateTimeOffset updatedTime = DateTimeOffset.UtcNow;
     var entry = new ODataEntry
     {
         Id = new Uri("http://test.org/EntitySet('1')"),
         EditLink = new Uri("http://test.org/EntitySet('1')/edit"),
         ReadLink = new Uri("http://test.org/EntitySet('1')/read")
     };
     entry.SetAnnotation(new AtomEntryMetadata() { Updated = updatedTime });
     string actual = this.WriteAtomEntry(entry);
     string expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
         "<entry xmlns=\"http://www.w3.org/2005/Atom\" xmlns:d=\"http://docs.oasis-open.org/odata/ns/data\" xmlns:m=\"http://docs.oasis-open.org/odata/ns/metadata\" xmlns:georss=\"http://www.georss.org/georss\" xmlns:gml=\"http://www.opengis.net/gml\" m:context=\"http://temp.org/$metadata#EntitySet/$entity\">" +
             "<id>http://test.org/EntitySet('1')</id>" +
             "<link rel=\"edit\" href=\"http://test.org/EntitySet('1')/edit\" />" +
             "<link rel=\"self\" href=\"http://test.org/EntitySet('1')/read\" />" +
             "<title />" +
             "<updated>" + ODataAtomConvert.ToAtomString(updatedTime) + "</updated>" +
             "<author>" +
                 "<name />" +
             "</author>" +
             "<content type=\"application/xml\" />" +
         "</entry>";
     Assert.Equal(expected, actual);
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:25,代码来源:ODataAtomWriterIntegrationTests.cs


示例3: WriteCompletedAsyncResponse

        public void WriteCompletedAsyncResponse()
        {
            var asyncWriter = this.TestInit();

            var innerMessage = asyncWriter.CreateResponseMessage();
            innerMessage.StatusCode = 200;
            innerMessage.SetHeader("Content-Type", "application/json");

            var settings = new ODataMessageWriterSettings();
            settings.SetServiceDocumentUri(new Uri(ServiceDocumentUri));
            settings.DisableMessageStreamDisposal = true;

            using (var innerMessageWriter = new ODataMessageWriter(innerMessage, settings, this.userModel))
            {
                var entryWriter = innerMessageWriter.CreateODataEntryWriter(singleton, testType);
                var entry = new ODataEntry() {TypeName = "NS.Test", Properties = new[] {new ODataProperty() {Name = "Id", Value = 1}}};
                entryWriter.WriteStart(entry);
                entryWriter.WriteEnd();
            }

            asyncWriter.Flush();

            var payload = this.TestFinish();
            Assert.Equal("HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nOData-Version: 4.0\r\n\r\n{\"@odata.context\":\"http://host/service/$metadata#MySingleton\",\"Id\":1}", payload);
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:25,代码来源:ODataAsynchronousWriterTests.cs


示例4: ODataEntryMetadataContextTest

 public ODataEntryMetadataContextTest()
 {
     this.entry = new ODataEntry {TypeName = ActualEntityType.FullName()};
     this.typeContext = new TestFeedAndEntryTypeContext();
     this.entryMetadataContextWithoutModel = ODataEntryMetadataContext.Create(this.entry, this.typeContext, new ODataFeedAndEntrySerializationInfo(), /*actualEntityType*/null, new TestMetadataContext(), SelectedPropertiesNode.EntireSubtree);
     this.entryMetadataContextWithModel = ODataEntryMetadataContext.Create(this.entry, this.typeContext, /*serializationInfo*/null, ActualEntityType, new TestMetadataContext(), SelectedPropertiesNode.EntireSubtree);
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:7,代码来源:ODataEntryMetadataContextTest.cs


示例5: EntryMetadataUrlRoundTrip

        public void EntryMetadataUrlRoundTrip()
        {
            var stream = new MemoryStream();
            var writerRequestMemoryMessage = new InMemoryMessage();
            writerRequestMemoryMessage.Stream = stream;
            writerRequestMemoryMessage.SetHeader("Content-Type", "application/json");

            var writerSettings = new ODataMessageWriterSettings() {Version = ODataVersion.V4, DisableMessageStreamDisposal = true};
            writerSettings.ODataUri = new ODataUri() {ServiceRoot = new Uri("http://christro.svc/")};

            var messageWriter = new ODataMessageWriter((IODataResponseMessage)writerRequestMemoryMessage, writerSettings, this.model);
            var organizationSetWriter = messageWriter.CreateODataEntryWriter(this.organizationsSet);
            var odataEntry = new ODataEntry(){ TypeName = ModelNamespace + ".Corporation" };
            odataEntry.Property("Id", 1);
            odataEntry.Property("Name", "");
            odataEntry.Property("TickerSymbol", "MSFT");

            organizationSetWriter.WriteStart(odataEntry);
            organizationSetWriter.WriteEnd();

            var readerPayloadInput = Encoding.UTF8.GetString(stream.GetBuffer());
            Console.WriteLine(readerPayloadInput);

            var readerResponseMemoryMessage = new InMemoryMessage();
            readerResponseMemoryMessage.Stream = new MemoryStream(stream.GetBuffer());
            readerResponseMemoryMessage.SetHeader("Content-Type", "application/json");

            var messageReader = new ODataMessageReader((IODataResponseMessage)readerResponseMemoryMessage, new ODataMessageReaderSettings() {MaxProtocolVersion = ODataVersion.V4, DisableMessageStreamDisposal = true}, this.model);
            var organizationReader = messageReader.CreateODataEntryReader(this.organizationsSet, this.organizationsSet.EntityType());
            organizationReader.Read().Should().Be(true);
            organizationReader.Item.As<ODataEntry>();
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:32,代码来源:MetadataUriRoundTripTests.cs


示例6: InjectMetadataBuilderShouldSetBuilderOnEntry

 public void InjectMetadataBuilderShouldSetBuilderOnEntry()
 {
     var entry = new ODataEntry();
     var builder = new TestEntityMetadataBuilder(entry);
     testSubject.InjectMetadataBuilder(entry, builder);
     entry.MetadataBuilder.Should().BeSameAs(builder);
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:7,代码来源:JsonNoMetadataLevelTests.cs


示例7: CreateEntryWithKeyAsSegmentConvention

        private static ODataEntry CreateEntryWithKeyAsSegmentConvention(bool addAnnotation, bool? useKeyAsSegment)
        {
            var model = new EdmModel();
            var container = new EdmEntityContainer("Fake", "Container");
            model.AddElement(container);
            if (addAnnotation)
            {
                model.AddVocabularyAnnotation(new EdmAnnotation(container, UrlConventionsConstants.ConventionTerm, UrlConventionsConstants.KeyAsSegmentAnnotationValue));                
            }
            
            EdmEntityType entityType = new EdmEntityType("Fake", "FakeType");
            entityType.AddKeys(entityType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32));
            model.AddElement(entityType);

            var entitySet = new EdmEntitySet(container, "FakeSet", entityType);
            container.AddElement(entitySet);

            var metadataContext = new ODataMetadataContext(
                true,
                ODataReaderBehavior.DefaultBehavior.OperationsBoundToEntityTypeMustBeContainerQualified,
                new EdmTypeReaderResolver(model, ODataReaderBehavior.DefaultBehavior),
                model,
                new Uri("http://temp.org/$metadata"),
                null /*requestUri*/);

            var thing = new ODataEntry {Properties = new[] {new ODataProperty {Name = "Id", Value = 1}}};
            thing.SetAnnotation(new ODataTypeAnnotation(entitySet, entityType));
            thing.MetadataBuilder = metadataContext.GetEntityMetadataBuilderForReader(new TestJsonLightReaderEntryState { Entry = thing, SelectedProperties = new SelectedPropertiesNode("*")}, useKeyAsSegment);
            return thing;
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:30,代码来源:KeyAsSegmentTemplateIntegrationTests.cs


示例8: ODataNavigationLinkTests

        public ODataNavigationLinkTests()
        {
            this.navigationLink = new ODataNavigationLink();

            var entry = new ODataEntry
            {
                TypeName = "ns.DerivedType",
                Properties = new[]
                {
                    new ODataProperty{Name = "Id", Value = 1, SerializationInfo = new ODataPropertySerializationInfo{PropertyKind = ODataPropertyKind.Key}},
                    new ODataProperty{Name = "Name", Value = "Bob", SerializationInfo = new ODataPropertySerializationInfo{PropertyKind = ODataPropertyKind.ETag}}
                }
            };

            var serializationInfo = new ODataFeedAndEntrySerializationInfo { NavigationSourceName = "Set", NavigationSourceEntityTypeName = "ns.BaseType", ExpectedTypeName = "ns.BaseType" };
            var typeContext = ODataFeedAndEntryTypeContext.Create(serializationInfo, null, null, null, EdmCoreModel.Instance, true);
            var metadataContext = new TestMetadataContext();
            var entryMetadataContext = ODataEntryMetadataContext.Create(entry, typeContext, serializationInfo, null, metadataContext, SelectedPropertiesNode.EntireSubtree);
            var metadataBuilder = new ODataConventionalEntityMetadataBuilder(entryMetadataContext, metadataContext, new ODataConventionalUriBuilder(ServiceUri, UrlConvention.CreateWithExplicitValue(false)));
            this.navigationLinkWithFullBuilder = new ODataNavigationLink { Name = "NavProp" };
            this.navigationLinkWithFullBuilder.MetadataBuilder = metadataBuilder;

            this.navigationLinkWithNoOpBuilder = new ODataNavigationLink { Name = "NavProp" };
            this.navigationLinkWithNoOpBuilder.MetadataBuilder = new NoOpEntityMetadataBuilder(entry);

            this.navigationLinkWithNullBuilder = new ODataNavigationLink { Name = "NavProp" };
            this.navigationLinkWithNullBuilder.MetadataBuilder = ODataEntityMetadataBuilder.Null;
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:28,代码来源:ODataNavigationLinkTests.cs


示例9: ShouldBeAbleToSetTheEntrySerializationInfo

 public void ShouldBeAbleToSetTheEntrySerializationInfo()
 {
     ODataEntry entry = new ODataEntry();
     ODataFeedAndEntrySerializationInfo serializationInfo = new ODataFeedAndEntrySerializationInfo { NavigationSourceName = "Set", NavigationSourceEntityTypeName = "ns.base", ExpectedTypeName = "ns.expected" };
     entry.SetSerializationInfo(serializationInfo);
     entry.SerializationInfo.Should().BeSameAs(serializationInfo);
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:7,代码来源:ODataObjectModelExtensionTests.cs


示例10: GetOperationsInEntry

        /// <summary>
        /// Returns a hash set of operation imports (actions and functions) in the given entry.
        /// </summary>
        /// <param name="entry">The entry in question.</param>
        /// <param name="model">The edm model to resolve operation imports.</param>
        /// <param name="metadataDocumentUri">The metadata document uri.</param>
        /// <returns>The hash set of operation imports (actions and functions) in the given entry.</returns>
        private static HashSet<IEdmOperation> GetOperationsInEntry(ODataEntry entry, IEdmModel model, Uri metadataDocumentUri)
        {
            Debug.Assert(entry != null, "entry != null");
            Debug.Assert(model != null, "model != null");
            Debug.Assert(metadataDocumentUri != null && metadataDocumentUri.IsAbsoluteUri, "metadataDocumentUri != null && metadataDocumentUri.IsAbsoluteUri");

            HashSet<IEdmOperation> edmOperationImportsInEntry = new HashSet<IEdmOperation>(EqualityComparer<IEdmOperation>.Default);
            IEnumerable<ODataOperation> operations = ODataUtilsInternal.ConcatEnumerables((IEnumerable<ODataOperation>)entry.NonComputedActions, (IEnumerable<ODataOperation>)entry.NonComputedFunctions);
            if (operations != null)
            {
                foreach (ODataOperation operation in operations)
                {
                    Debug.Assert(operation.Metadata != null, "operation.Metadata != null");
                    string operationMetadataString = UriUtils.UriToString(operation.Metadata);
                    Debug.Assert(
                        ODataJsonLightUtils.IsMetadataReferenceProperty(operationMetadataString),
                        "ODataJsonLightUtils.IsMetadataReferenceProperty(operationMetadataString)");
                    Debug.Assert(
                        operationMetadataString[0] == ODataConstants.ContextUriFragmentIndicator || metadataDocumentUri.IsBaseOf(operation.Metadata),
                        "operationMetadataString[0] == JsonLightConstants.ContextUriFragmentIndicator || metadataDocumentUri.IsBaseOf(operation.Metadata)");

                    string fullyQualifiedOperationName = ODataJsonLightUtils.GetUriFragmentFromMetadataReferencePropertyName(metadataDocumentUri, operationMetadataString);
                    IEnumerable<IEdmOperation> edmOperations = model.ResolveOperations(fullyQualifiedOperationName);
                    if (edmOperations != null)
                    {
                        foreach (IEdmOperation edmOperation in edmOperations)
                        {
                            edmOperationImportsInEntry.Add(edmOperation);
                        }
                    }
                }
            }

            return edmOperationImportsInEntry;
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:42,代码来源:ODataMissingOperationGenerator.cs


示例11: InjectMetadataBuilderShouldNotSetBuilderOnEntryMediaResource

 public void InjectMetadataBuilderShouldNotSetBuilderOnEntryMediaResource()
 {
     var entry = new ODataEntry();
     var builder = new TestEntityMetadataBuilder(entry);
     entry.MediaResource = new ODataStreamReferenceValue();
     testSubject.InjectMetadataBuilder(entry, builder);
     entry.MediaResource.GetMetadataBuilder().Should().BeNull();
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:8,代码来源:JsonNoMetadataLevelTests.cs


示例12: ShouldBeAbleToWriteTransientEntry

 public void ShouldBeAbleToWriteTransientEntry()
 {
     IEdmEntityType entityType = GetEntityType();
     IEdmEntitySet entitySet = GetEntitySet(entityType);
     ODataEntry transientEntry = new ODataEntry() { IsTransient = true };
     var actual = WriteJsonLightEntry(true, null, false, transientEntry, entitySet, entityType);
     actual.Should().Contain("\"@odata.id\":null");
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:8,代码来源:ODataJsonLightWriterIntegrationTests.cs


示例13: ODataEdmStructuredValue

        /// <summary>
        /// Creates a new Edm structured value from an OData entry.
        /// </summary>
        /// <param name="entry">The <see cref="ODataEntry"/> to create the structured value for.</param>
        internal ODataEdmStructuredValue(ODataEntry entry)
            : base(entry.GetEdmType())
        {
            Debug.Assert(entry != null, "entry != null");

            this.properties = entry.NonComputedProperties;
            this.structuredType = this.Type == null ? null : this.Type.AsStructured();
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:12,代码来源:ODataEdmStructuredValue.cs


示例14: ODataEntryMetadataContext

        /// <summary>
        /// Constructs an instance of <see cref="ODataEntryMetadataContext"/>.
        /// </summary>
        /// <param name="entry">The entry instance.</param>
        /// <param name="typeContext">The context object to answer basic questions regarding the type of the entry.</param>
        protected ODataEntryMetadataContext(ODataEntry entry, IODataFeedAndEntryTypeContext typeContext)
        {
            Debug.Assert(entry != null, "entry != null");
            Debug.Assert(typeContext != null, "typeContext != null");

            this.entry = entry;
            this.typeContext = typeContext;
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:13,代码来源:ODataEntryMetadataContext.cs


示例15: GetIdShouldBeNullWhenEntryIsTransient

 public void GetIdShouldBeNullWhenEntryIsTransient()
 {
     Uri id = new Uri("http://example.com");
     ODataEntry odataEntry = new ODataEntry()
     {
         IsTransient = true,
         Id = id
     };
     new NoOpEntityMetadataBuilder(odataEntry).GetId().Should().BeNull();
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:10,代码来源:NoOpEntityMetadataBuilderTests.cs


示例16: EntryPropertiesValueCache

        /// <summary>
        /// Creates a new cache.
        /// </summary>
        /// <param name="entry">The entry for which to create the properties cache.</param>
        internal EntryPropertiesValueCache(ODataEntry entry)
        {
            Debug.Assert(entry != null, "entry != null");

            // Cache the entry properties right here as there's no point in delaying since we will enumerate those anyway.
            if (entry.Properties != null)
            {
                this.entryPropertiesCache = new List<ODataProperty>(entry.Properties);
            }
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:14,代码来源:EntryPropertiesValueCache.cs


示例17: ValidateNoMetadataShouldThrow

        public void ValidateNoMetadataShouldThrow()
        {
            var model = CreateTestModel();
            var coreWriter = CreateODataWriterCore(ODataFormat.Json, true, model, null, null, false);

            var entry = new ODataEntry();
            Action test = () => coreWriter.ValidateEntityType2(entry);

            test.ShouldThrow<ODataException>().WithMessage(Strings.WriterValidationUtils_MissingTypeNameWithMetadata);
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:10,代码来源:ODataWriterCoreTests.cs


示例18: ValidateEntityTypeShouldAlwaysReturnSpecifiedTypeName

        public void ValidateEntityTypeShouldAlwaysReturnSpecifiedTypeName()
        {
            var model = CreateTestModel();
            var set = model.EntityContainer.FindEntitySet("Objects");
            var objectType = (IEdmEntityType)model.FindDeclaredType("DefaultNamespace.Object");
            var coreWriter = CreateODataWriterCore(ODataFormat.Json, true, model, set, objectType, false);

            var entry = new ODataEntry() { TypeName = "DefaultNamespace.Person" };
            var entityType = coreWriter.ValidateEntityType2(entry);
            entityType.Should().BeSameAs(model.FindDeclaredType("DefaultNamespace.Person"));
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:11,代码来源:ODataWriterCoreTests.cs


示例19: ValidateEntityTypeShouldReturnEntityTypeOfSet

        public void ValidateEntityTypeShouldReturnEntityTypeOfSet()
        {
            var model = CreateTestModel();
            var peopleSet = model.EntityContainer.FindEntitySet("People");
            var personType = (IEdmEntityType)model.FindDeclaredType("DefaultNamespace.Person");

            var coreWriter = CreateODataWriterCore(ODataFormat.Json, true, model, peopleSet, null, false);

            var entry = new ODataEntry();
            var entityType = coreWriter.ValidateEntityType2(entry);
            entityType.Should().BeSameAs(personType);
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:12,代码来源:ODataWriterCoreTests.cs


示例20: CreateEntityMetadataBuilder

 /// <summary>
 /// Creates the metadata builder for the given entry. If such a builder is set, asking for payload
 /// metadata properties (like EditLink) of the entry may return a value computed by convention, 
 /// depending on the metadata level and whether the user manually set an edit link or not.
 /// </summary>
 /// <param name="entry">The entry to create the metadata builder for.</param>
 /// <param name="typeContext">The context object to answer basic questions regarding the type of the entry or feed.</param>
 /// <param name="serializationInfo">The serialization info for the entry.</param>
 /// <param name="actualEntityType">The entity type of the entry.</param>
 /// <param name="selectedProperties">The selected properties of this scope.</param>
 /// <param name="isResponse">true if the entity metadata builder to create should be for a response payload; false for a request.</param>
 /// <param name="keyAsSegment">true if keys should go in seperate segments in auto-generated URIs, false if they should go in parentheses.
 /// A null value means the user hasn't specified a preference and we should look for an annotation in the entity container, if available.</param>
 /// <param name="odataUri">The OData Uri.</param>
 /// <returns>The created metadata builder.</returns>
 internal override ODataEntityMetadataBuilder CreateEntityMetadataBuilder(
     ODataEntry entry, 
     IODataFeedAndEntryTypeContext typeContext, 
     ODataFeedAndEntrySerializationInfo serializationInfo, 
     IEdmEntityType actualEntityType, 
     SelectedPropertiesNode selectedProperties, 
     bool isResponse, 
     bool? keyAsSegment,
     ODataUri odataUri)
 {
     return ODataEntityMetadataBuilder.Null;
 }
开发者ID:rossjempson,项目名称:odata.net,代码行数:27,代码来源:JsonNoMetadataLevel.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# ODataFeed类代码示例发布时间:2022-05-24
下一篇:
C# ODataConventionModelBuilder类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap