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

C# ODataVersion类代码示例

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

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



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

示例1: GetRandomPayload

        /// <summary>
        /// Generates an arbitrary top load payload based on the maximum version supplied.
        /// </summary>
        /// <param name="random">Random generator for generating arbitrary payloads</param>
        /// <param name="model">The model to add any new types to</param>
        /// <param name="version">Maximum version for generated payloads.</param>
        /// <returns>A top level payload.</returns>
        public static ODataPayloadElement GetRandomPayload(IRandomNumberGenerator random, EdmModel model, ODataVersion version = ODataVersion.V4)
        {
            ExceptionUtilities.CheckArgumentNotNull(random, "random");
            ExceptionUtilities.CheckArgumentNotNull(model, "model");

            Func<ODataPayloadElement>[] payloadCalls = new Func<ODataPayloadElement>[]
            {
                () => { return GetComplexInstanceCollection(random, model, version); }, 
                () => { return GetComplexProperty(random, model, version); }, 
                () => { return GetDeferredLink(); }, 
                () => { return GetLinkCollection(); }, 
                () => { return GetEntityInstance(random, model, version); }, 
                () => { return GetEntitySetInstance(random, model); }, 
                () => { return GetODataErrorPayload(random); }, 
                () => { return GetPrimitiveCollection(random); }, 
                () => { return GetPrimitiveProperty(random, model); }, 
                () => { return GetPrimitiveValue(random, model); },
            };

            payloadCalls.Concat(new Func<ODataPayloadElement>[]
            {
                () => { return GetComplexMultiValueProperty(random, model, version); }, 
                () => { return GetPrimitiveMultiValueProperty(random); },
            });

            var payloadCall = random.ChooseFrom(payloadCalls);
            return payloadCall();
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:35,代码来源:RandomPayloadBuilder.cs


示例2: WriteJson

 internal void WriteJson(object instance, JsonWriter jsonWriter, string typeName, ODataVersion odataVersion)
 {
     IPrimitiveTypeConverter converter;
     Type type = instance.GetType();
     this.TryGetConverter(type, out converter);
     converter.WriteJson(instance, jsonWriter, typeName, odataVersion);
 }
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:PrimitiveConverter.cs


示例3: ConvertToUriLiteral

 public static string ConvertToUriLiteral(object value, ODataVersion version, IEdmModel model)
 {
     if (value == null)
     {
         value = new ODataUriNullValue();
     }
     if (model == null)
     {
         model = EdmCoreModel.Instance;
     }
     ODataUriNullValue nullValue = value as ODataUriNullValue;
     if (nullValue != null)
     {
         return ODataUriConversionUtils.ConvertToUriNullValue(nullValue, model);
     }
     ODataCollectionValue collectionValue = value as ODataCollectionValue;
     if (collectionValue != null)
     {
         return ODataUriConversionUtils.ConvertToUriCollectionLiteral(collectionValue, model, version);
     }
     ODataComplexValue complexValue = value as ODataComplexValue;
     if (complexValue != null)
     {
         return ODataUriConversionUtils.ConvertToUriComplexLiteral(complexValue, model, version);
     }
     return ODataUriConversionUtils.ConvertToUriPrimitiveLiteral(value, version);
 }
开发者ID:nickchal,项目名称:pash,代码行数:27,代码来源:ODataUriUtils.cs


示例4: TestConfiguration

 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="format">The format used for the test.</param>
 /// <param name="version">The OData protocol version to be used for the payload.</param>
 /// <param name="request">True if the test is reading a request. Otherwise false if it's reading a response.</param>
 public TestConfiguration(ODataFormat format, ODataVersion version, bool request, TestODataBehaviorKind behaviorKind)
 {
     this.Format = format;
     this.Version = version;
     this.IsRequest = request;
     this.RunBehaviorKind = behaviorKind;
 }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:13,代码来源:TestConfiguration.cs


示例5: ConvertToODataEntry

        /// <summary>
        /// Converts an item from the data store into an ODataEntry.
        /// </summary>
        /// <param name="element">The item to convert.</param>
        /// <param name="entitySet">The entity set that the item belongs to.</param>
        /// <param name="targetVersion">The OData version this segment is targeting.</param>
        /// <returns>The converted ODataEntry.</returns>
        public static ODataEntry ConvertToODataEntry(object element, IEdmEntitySet entitySet, ODataVersion targetVersion)
        {
            IEdmEntityType entityType = entitySet.EntityType();

            Uri entryUri = BuildEntryUri(element, entitySet, targetVersion);

            var entry = new ODataEntry
            {
                // writes out the edit link including the service base uri  , e.g.: http://<serviceBase>/Customers('ALFKI')
                EditLink = entryUri,

                // writes out the self link including the service base uri  , e.g.: http://<serviceBase>/Customers('ALFKI')
                ReadLink = entryUri,

                // we use the EditLink as the Id for this entity to maintain convention,
                Id = entryUri,

                // writes out the <category term='Customer'/> element 
                TypeName = element.GetType().Namespace + "." + entityType.Name,

                Properties = entityType.StructuralProperties().Select(p => ConvertToODataProperty(element, p.Name)),
            };

            return entry;
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:32,代码来源:ODataObjectModelConverter.cs


示例6: ResolveAndValidateNonPrimitiveTargetType

 internal static IEdmTypeReference ResolveAndValidateNonPrimitiveTargetType(EdmTypeKind expectedTypeKind, IEdmTypeReference expectedTypeReference, EdmTypeKind payloadTypeKind, IEdmType payloadType, string payloadTypeName, IEdmModel model, ODataMessageReaderSettings messageReaderSettings, ODataVersion version, out SerializationTypeNameAnnotation serializationTypeNameAnnotation)
 {
     bool flag = (messageReaderSettings.ReaderBehavior.TypeResolver != null) && (payloadType != null);
     if (!flag)
     {
         ValidateTypeSupported(expectedTypeReference, version);
         if (model.IsUserModel() && ((expectedTypeReference == null) || !messageReaderSettings.DisableStrictMetadataValidation))
         {
             VerifyPayloadTypeDefined(payloadTypeName, payloadType);
         }
     }
     else
     {
         ValidateTypeSupported((payloadType == null) ? null : payloadType.ToTypeReference(true), version);
     }
     if ((payloadTypeKind != EdmTypeKind.None) && (!messageReaderSettings.DisableStrictMetadataValidation || (expectedTypeReference == null)))
     {
         ValidationUtils.ValidateTypeKind(payloadTypeKind, expectedTypeKind, payloadTypeName);
     }
     serializationTypeNameAnnotation = null;
     if (!model.IsUserModel())
     {
         return null;
     }
     if ((expectedTypeReference == null) || flag)
     {
         return ResolveAndValidateTargetTypeWithNoExpectedType(expectedTypeKind, payloadType, payloadTypeName, out serializationTypeNameAnnotation);
     }
     if (messageReaderSettings.DisableStrictMetadataValidation)
     {
         return ResolveAndValidateTargetTypeStrictValidationDisabled(expectedTypeKind, expectedTypeReference, payloadType, payloadTypeName, out serializationTypeNameAnnotation);
     }
     return ResolveAndValidateTargetTypeStrictValidationEnabled(expectedTypeKind, expectedTypeReference, payloadType, payloadTypeName, out serializationTypeNameAnnotation);
 }
开发者ID:nickchal,项目名称:pash,代码行数:34,代码来源:ReaderValidationUtils.cs


示例7: CheckNextLink

 internal static void CheckNextLink(ODataVersion version)
 {
     if (version < ODataVersion.V2)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_NextLinkNotSupported(ODataUtils.ODataVersionToString(version)));
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:ODataVersionChecker.cs


示例8: CheckCustomTypeScheme

 internal static void CheckCustomTypeScheme(ODataVersion version)
 {
     if (version > ODataVersion.V2)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_PropertyNotSupportedForODataVersionGreaterThanX("TypeScheme", ODataUtils.ODataVersionToString(ODataVersion.V2)));
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:ODataVersionChecker.cs


示例9: CheckCollectionValue

 internal static void CheckCollectionValue(ODataVersion version)
 {
     if (version < ODataVersion.V3)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_CollectionNotSupported(ODataUtils.ODataVersionToString(version)));
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:ODataVersionChecker.cs


示例10: CheckCollectionValueProperties

 internal static void CheckCollectionValueProperties(ODataVersion version, string propertyName)
 {
     if (version < ODataVersion.V3)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_CollectionPropertiesNotSupported(propertyName, ODataUtils.ODataVersionToString(version)));
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:ODataVersionChecker.cs


示例11: ExtraRequestChangesetOperations

        /// <summary>
        /// Generates extra operations to go into a request changeset
        /// </summary>
        /// <param name="random">For generating the payloads to go in the extra operations</param>
        /// <param name="requestManager">For building the operations</param>
        /// <param name="model">To add any new types to.</param>
        /// <param name="baseUri">Base uri for the extra operations.</param>
        /// <param name="version">Maximum version for </param>
        /// <returns>An array of extra request operations.</returns>
        public static IHttpRequest[] ExtraRequestChangesetOperations(
            IRandomNumberGenerator random,
            IODataRequestManager requestManager,
            EdmModel model,
            ODataUri baseUri,
            ODataVersion version = ODataVersion.V4)
        {
            ExceptionUtilities.CheckArgumentNotNull(random, "random");
            ExceptionUtilities.CheckArgumentNotNull(requestManager, "requestManager");
            ExceptionUtilities.CheckArgumentNotNull(baseUri, "baseUri");
            var headers = new Dictionary<string, string> { { "RequestHeader", "RequestHeaderValue" } };
            string mergeContentType = HttpUtilities.BuildContentType(MimeTypes.ApplicationXml, Encoding.UTF8.WebName, null);

            List<IHttpRequest> requests = new List<IHttpRequest>();
            ODataRequest request = null;
            for (int i = 0; i < 4; i++)
            {
                request = requestManager.BuildRequest(baseUri, HttpVerb.Post, headers);
                request.Body = requestManager.BuildBody(mergeContentType, baseUri, RandomPayloadBuilder.GetRandomPayload(random, model, version));
                requests.Add(request);
                request = requestManager.BuildRequest(baseUri, HttpVerb.Put, headers);
                request.Body = requestManager.BuildBody(mergeContentType, baseUri, RandomPayloadBuilder.GetRandomPayload(random, model, version));
                requests.Add(request);
                request = requestManager.BuildRequest(baseUri, HttpVerb.Patch, headers);
                request.Body = requestManager.BuildBody(mergeContentType, baseUri, RandomPayloadBuilder.GetRandomPayload(random, model, version));
                requests.Add(request);
                request = requestManager.BuildRequest(baseUri, HttpVerb.Delete, headers);
                requests.Add(request);
            }

            return requests.ToArray();
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:41,代码来源:BatchUtils.cs


示例12: WriteJsonObjectValue

        /// <summary>
        /// Writes the json object value to the <paramref name="jsonWriter"/>.
        /// </summary>
        /// <param name="jsonWriter">The <see cref="JsonWriter"/> to write to.</param>
        /// <param name="jsonObjectValue">Writes the given json object value to the underlying json writer.</param>
        /// <param name="typeName">Type name of the json object to write. If type name is null, no type name is written.</param>
        /// <param name="odataVersion">The OData protocol version to be used for writing payloads.</param>
        internal static void WriteJsonObjectValue(this JsonWriter jsonWriter, IDictionary<string, object> jsonObjectValue, string typeName, ODataVersion odataVersion)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(jsonWriter != null, "jsonWriter != null");
            Debug.Assert(jsonObjectValue != null, "jsonObjectValue != null");

            jsonWriter.StartObjectScope();

            if (typeName != null)
            {
                Debug.Assert(!jsonObjectValue.ContainsKey(JsonConstants.ODataMetadataName), "__metadata should not be present in jsonObjectValue");
                jsonWriter.WriteName(JsonConstants.ODataMetadataName);
                jsonWriter.StartObjectScope();
                jsonWriter.WriteName(JsonConstants.ODataMetadataTypeName);
                jsonWriter.WriteValue(typeName);
                jsonWriter.EndObjectScope();
            }

            foreach (KeyValuePair<string, object> property in jsonObjectValue)
            {
                jsonWriter.WriteName(property.Key);
                jsonWriter.WriteJsonValue(property.Value, odataVersion);
            }

            jsonWriter.EndObjectScope();
        }
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:33,代码来源:JsonWriterExtensions.cs


示例13: RaiseMinPayloadVersion

 /// <summary>
 /// Sets the configuration limit to require minimum payload version.
 /// </summary>
 /// <param name="version">The minimum payload version required.</param>
 public void RaiseMinPayloadVersion(ODataVersion version)
 {
     if (this.minPayloadVersion < version)
     {
         this.minPayloadVersion = version;
     }
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:11,代码来源:ODataPayloadElementConfigurationValidator.cs


示例14: ConvertFromUriLiteral

 public static object ConvertFromUriLiteral(string value, ODataVersion version, IEdmModel model, IEdmTypeReference typeReference)
 {
     Exception exception;
     ExpressionToken token;
     ExceptionUtils.CheckArgumentNotNull<string>(value, "value");
     if ((typeReference != null) && (model == null))
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ODataUriUtils_ConvertFromUriLiteralTypeRefWithoutModel);
     }
     if (model == null)
     {
         model = EdmCoreModel.Instance;
     }
     ExpressionLexer lexer = new ExpressionLexer(value, false);
     if (!lexer.TryPeekNextToken(out token, out exception))
     {
         return ODataUriConversionUtils.ConvertFromComplexOrCollectionValue(value, version, model, typeReference);
     }
     object primitiveValue = lexer.ReadLiteralToken();
     if (typeReference != null)
     {
         primitiveValue = ODataUriConversionUtils.VerifyAndCoerceUriPrimitiveLiteral(primitiveValue, model, typeReference, version);
     }
     if (primitiveValue is ISpatial)
     {
         ODataVersionChecker.CheckSpatialValue(version);
     }
     return primitiveValue;
 }
开发者ID:nickchal,项目名称:pash,代码行数:29,代码来源:ODataUriUtils.cs


示例15: WriteEntry

        /// <summary>
        /// Writes an OData entry.
        /// </summary>
        /// <param name="writer">The ODataWriter that will write the entry.</param>
        /// <param name="element">The item from the data store to write.</param>
        /// <param name="navigationSource">The navigation source in the model that the entry belongs to.</param>
        /// <param name="model">The data store model.</param>
        /// <param name="targetVersion">The OData version this segment is targeting.</param>
        /// <param name="selectExpandClause">The SelectExpandClause.</param>
        public static void WriteEntry(ODataWriter writer, object element, IEdmNavigationSource entitySource, ODataVersion targetVersion, SelectExpandClause selectExpandClause, Dictionary<string, string> incomingHeaders = null)
        {
            var entry = ODataObjectModelConverter.ConvertToODataEntry(element, entitySource, targetVersion);

            entry.ETag = Utility.GetETagValue(element);

            if (selectExpandClause != null && selectExpandClause.SelectedItems.OfType<PathSelectItem>().Any())
            {
                ExpandSelectItemHandler selectItemHandler = new ExpandSelectItemHandler(entry);
                foreach (var item in selectExpandClause.SelectedItems.OfType<PathSelectItem>())
                {
                    item.HandleWith(selectItemHandler);
                }

                entry = selectItemHandler.ProjectedEntry;
            }

            CustomizeEntry(incomingHeaders, entry);

            writer.WriteStart(entry);

            // gets all of the expandedItems, including ExpandedRefernceSelectItem and ExpandedNavigationItem
            var expandedItems = selectExpandClause == null ? null : selectExpandClause.SelectedItems.OfType<ExpandedReferenceSelectItem>();
            WriteNavigationLinks(writer, element, entry.ReadLink, entitySource, targetVersion, expandedItems);
            writer.WriteEnd();
        }
开发者ID:vebin,项目名称:odata.net,代码行数:35,代码来源:ResponseWriter.cs


示例16: CheckParameterPayload

 internal static void CheckParameterPayload(ODataVersion version)
 {
     if (version < ODataVersion.V3)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_ParameterPayloadNotSupported(ODataUtils.ODataVersionToString(version)));
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:ODataVersionChecker.cs


示例17: CheckAssociationLinks

 internal static void CheckAssociationLinks(ODataVersion version)
 {
     if (version < ODataVersion.V3)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_AssociationLinksNotSupported(ODataUtils.ODataVersionToString(version)));
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:ODataVersionChecker.cs


示例18: ODataMediaTypeFormatter

        /// <summary>
        /// Initializes a new instance of the <see cref="ODataMediaTypeFormatter"/> class.
        /// </summary>
        /// <param name="deserializerProvider">The <see cref="ODataDeserializerProvider"/> to use.</param>
        /// <param name="serializerProvider">The <see cref="ODataSerializerProvider"/> to use.</param>
        /// <param name="payloadKinds">The kind of payloads this formatter supports.</param>
        public ODataMediaTypeFormatter(ODataDeserializerProvider deserializerProvider, ODataSerializerProvider serializerProvider,
            IEnumerable<ODataPayloadKind> payloadKinds)
        {
            if (deserializerProvider == null)
            {
                throw Error.ArgumentNull("deserializerProvider");
            }
            if (serializerProvider == null)
            {
                throw Error.ArgumentNull("serializerProvider");
            }
            if (payloadKinds == null)
            {
                throw Error.ArgumentNull("payloadKinds");
            }

            _deserializerProvider = deserializerProvider;
            _serializerProvider = serializerProvider;
            _payloadKinds = payloadKinds;

            // Maxing out the received message size as we depend on the hosting layer to enforce this limit.
            MessageReaderQuotas = new ODataMessageQuotas { MaxReceivedMessageSize = Int64.MaxValue };
            MessageWriterQuotas = new ODataMessageQuotas { MaxReceivedMessageSize = Int64.MaxValue };

            _version = DefaultODataVersion;
        }
开发者ID:jaceenet,项目名称:aspnetwebstack,代码行数:32,代码来源:ODataMediaTypeFormatter.cs


示例19: ComputeExpectedException

            /// <summary>
            /// Computes the expected exception for this test case.
            /// </summary>
            /// <param name="behaviorKind">The <see cref="TestODataBehaviorKind"/> used by this test variation.</param>
            /// <param name="version">The <see cref="ODataVersion"/> used by this test variation.</param>
            /// <param name="ignoredOnServer">true if the payload value is ignored on the server; otherwise false.</param>
            /// <returns>The expected exception for a test variation using the specified parameter values; null if no exception is expected.</returns>
            public ExpectedException ComputeExpectedException(TestODataBehaviorKind behaviorKind, ODataVersion version, bool ignoredOnServer)
            {
                bool settingsBaseIsNullOrRelative = this.SettingsBaseUri == null || !(new Uri(this.SettingsBaseUri, UriKind.RelativeOrAbsolute).IsAbsoluteUri);
                bool xmlBaseIsNullOrRelative = this.XmlBaseUri == null || !(new Uri(this.XmlBaseUri, UriKind.RelativeOrAbsolute).IsAbsoluteUri);
                bool ignoreXmlBase = false;

                // If both the settings base URI and an xml:base are relative we will fail when we detect the xml:base.
                if (settingsBaseIsNullOrRelative && xmlBaseIsNullOrRelative && !ignoreXmlBase)
                {
                    string relativeBase = this.XmlBaseUri == null ? string.Empty : this.XmlBaseUri;
                    return ODataExpectedExceptions.ODataException("ODataAtomDeserializer_RelativeUriUsedWithoutBaseUriSpecified", relativeBase);
                }

                // Special rules for WCF DS server behavior.
                if (behaviorKind == TestODataBehaviorKind.WcfDataServicesServer)
                {
                    // If the payload is ignored on the server, we expect no exception.
                    if (ignoredOnServer)
                    {
                        return null;
                    }
                }

                return null;
            }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:32,代码来源:XmlBaseReaderTests.cs


示例20: CheckSpatialValue

 internal static void CheckSpatialValue(ODataVersion version)
 {
     if (version < ODataVersion.V3)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_GeographyAndGeometryNotSupported(ODataUtils.ODataVersionToString(version)));
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:ODataVersionChecker.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# ODatabase类代码示例发布时间:2022-05-24
下一篇:
C# ODataValidationSettings类代码示例发布时间: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