Beispiel #1
0
        private void ReadOperationsMetadata(ODataEntry entry, bool isActions)
        {
            string str = isActions ? "actions" : "functions";

            if (base.JsonReader.NodeType != JsonNodeType.StartObject)
            {
                throw new ODataException(Microsoft.Data.OData.Strings.ODataJsonEntryAndFeedDeserializer_PropertyInEntryMustHaveObjectValue(str, base.JsonReader.NodeType));
            }
            base.JsonReader.ReadStartObject();
            HashSet <string> set = new HashSet <string>(StringComparer.Ordinal);

            while (base.JsonReader.NodeType == JsonNodeType.Property)
            {
                ODataOperation operation;
                string         item = base.JsonReader.ReadPropertyName();
                if (set.Contains(item))
                {
                    throw new ODataException(Microsoft.Data.OData.Strings.ODataJsonEntryAndFeedDeserializer_RepeatMetadataValue(str, item));
                }
                set.Add(item);
                if (base.JsonReader.NodeType != JsonNodeType.StartArray)
                {
                    throw new ODataException(Microsoft.Data.OData.Strings.ODataJsonEntryAndFeedDeserializer_MetadataMustHaveArrayValue(str, base.JsonReader.NodeType));
                }
                base.JsonReader.ReadStartArray();
                if (base.JsonReader.NodeType == JsonNodeType.StartObject)
                {
                    goto Label_0227;
                }
                throw new ODataException(Microsoft.Data.OData.Strings.ODataJsonEntryAndFeedDeserializer_OperationMetadataArrayExpectedAnObject(str, base.JsonReader.NodeType));
Label_00E1:
                base.JsonReader.ReadStartObject();
                if (isActions)
                {
                    operation = new ODataAction();
                    ReaderUtils.AddActionToEntry(entry, (ODataAction)operation);
                }
                else
                {
                    operation = new ODataFunction();
                    ReaderUtils.AddFunctionToEntry(entry, (ODataFunction)operation);
                }
                operation.Metadata = base.ResolveUri(item);
                while (base.JsonReader.NodeType == JsonNodeType.Property)
                {
                    string str3 = base.JsonReader.ReadPropertyName();
                    string str6 = str3;
                    if (str6 == null)
                    {
                        goto Label_01E5;
                    }
                    if (!(str6 == "title"))
                    {
                        if (str6 == "target")
                        {
                            goto Label_019D;
                        }
                        goto Label_01E5;
                    }
                    if (operation.Title != null)
                    {
                        throw new ODataException(Microsoft.Data.OData.Strings.ODataJsonEntryAndFeedDeserializer_MultipleOptionalPropertiesInOperation(str3, item, str));
                    }
                    string propertyValue = base.JsonReader.ReadStringValue("title");
                    ODataJsonReaderUtils.ValidateOperationJsonProperty(propertyValue, str3, item, str);
                    operation.Title = propertyValue;
                    continue;
Label_019D:
                    if (operation.Target != null)
                    {
                        throw new ODataException(Microsoft.Data.OData.Strings.ODataJsonEntryAndFeedDeserializer_MultipleTargetPropertiesInOperation(item, str));
                    }
                    string str5 = base.JsonReader.ReadStringValue("target");
                    ODataJsonReaderUtils.ValidateOperationJsonProperty(str5, str3, item, str);
                    operation.Target = base.ProcessUriFromPayload(str5);
                    continue;
Label_01E5:
                    base.JsonReader.SkipValue();
                }
                if (operation.Target == null)
                {
                    throw new ODataException(Microsoft.Data.OData.Strings.ODataJsonEntryAndFeedDeserializer_OperationMissingTargetProperty(item, str));
                }
                base.JsonReader.ReadEndObject();
Label_0227:
                if (base.JsonReader.NodeType == JsonNodeType.StartObject)
                {
                    goto Label_00E1;
                }
                base.JsonReader.ReadEndArray();
            }
            base.JsonReader.ReadEndObject();
        }