當前位置: 首頁>>代碼示例>>C#>>正文


C# Json.XmlObjectSerializerReadContextComplexJson類代碼示例

本文整理匯總了C#中System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson的典型用法代碼示例。如果您正苦於以下問題:C# XmlObjectSerializerReadContextComplexJson類的具體用法?C# XmlObjectSerializerReadContextComplexJson怎麽用?C# XmlObjectSerializerReadContextComplexJson使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


XmlObjectSerializerReadContextComplexJson類屬於System.Runtime.Serialization.Json命名空間,在下文中一共展示了XmlObjectSerializerReadContextComplexJson類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ReadJsonValueCore

 public override object ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
 {
     jsonReader.Read();
     object obj2 = this.JsonFormatReaderDelegate(jsonReader, context, XmlDictionaryString.Empty, this.MemberNames);
     jsonReader.ReadEndElement();
     return obj2;
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:7,代碼來源:JsonClassDataContract.cs

示例2: ConvertDictionaryToClassDataContract

        public static object ConvertDictionaryToClassDataContract(DataContractJsonSerializer serializer, ClassDataContract dataContract, Dictionary<string, object> deserialzedValue, XmlObjectSerializerReadContextComplexJson context)
        {
            if (deserialzedValue == null)
            {
                return null;
            }

            if (dataContract.UnderlyingType == Globals.TypeOfDateTimeOffsetAdapter)
            {
                var tuple = deserialzedValue["DateTime"] as Tuple<DateTime, string>;
                DateTimeOffset dto = new DateTimeOffset(tuple != null ? tuple.Item1 : (DateTime)deserialzedValue["DateTime"]);
                return dto.ToOffset(new TimeSpan(0, (int)deserialzedValue["OffsetMinutes"], 0));
            }

            object serverTypeStringValue;
            if (deserialzedValue.TryGetValue(JsonGlobals.ServerTypeString, out serverTypeStringValue))
            {
                dataContract = ResolveDataContractFromTypeInformation(serverTypeStringValue.ToString(), dataContract, context);
            }

            object o = CreateInstance(dataContract);

            CheckDuplicateNames(dataContract);
            DataContractJsonSerializer.InvokeOnDeserializing(o, dataContract, context);
            ReadClassDataContractMembers(serializer, dataContract, deserialzedValue, o, context);
            DataContractJsonSerializer.InvokeOnDeserialized(o, dataContract, context);
            if (dataContract.IsKeyValuePairAdapter)
            {
                return dataContract.GetKeyValuePairMethodInfo.Invoke(o, Array.Empty<Type>());
            }
            return o;
        }
開發者ID:er0dr1guez,項目名稱:corefx,代碼行數:32,代碼來源:ObjectToDataContractConverterHelper.cs

示例3: ReadJsonValue

 public object ReadJsonValue(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
 {
     PushKnownDataContracts(context);
     object deserializedObject = ReadJsonValueCore(jsonReader, context);
     PopKnownDataContracts(context);
     return deserializedObject;
 }
開發者ID:johnhhm,項目名稱:corefx,代碼行數:7,代碼來源:JsonDataContract.cs

示例4: ReadJsonValue

 public object ReadJsonValue(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
 {
     this.PushKnownDataContracts(context);
     object obj2 = this.ReadJsonValueCore(jsonReader, context);
     this.PopKnownDataContracts(context);
     return obj2;
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:7,代碼來源:JsonDataContract.cs

示例5: ReadJsonValueCore

 public override object ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
 {
     if (context == null)
     {
         return TryReadNullAtTopLevel(jsonReader) ? null : jsonReader.ReadElementContentAsQName();
     }
     else
     {
         return HandleReadValue(jsonReader.ReadElementContentAsQName(), context);
     }
 }
開發者ID:krytht,項目名稱:DotNetReferenceSource,代碼行數:11,代碼來源:JsonQNameDataContract.cs

示例6: ReadJsonValueCore

 public override object ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
 {
     if (context != null)
     {
         return JsonDataContract.HandleReadValue(jsonReader.ReadElementContentAsBase64(), context);
     }
     if (!JsonDataContract.TryReadNullAtTopLevel(jsonReader))
     {
         return jsonReader.ReadElementContentAsBase64();
     }
     return null;
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:12,代碼來源:JsonByteArrayDataContract.cs

示例7: ReadClassDataContractMembers

        private static void ReadClassDataContractMembers(DataContractJsonSerializer serializer, ClassDataContract dataContract, Dictionary<string, object> deserialzedValue, object newInstance, XmlObjectSerializerReadContextComplexJson context)
        {
            if (dataContract.BaseContract != null)
            {
                ReadClassDataContractMembers(serializer, dataContract.BaseContract, deserialzedValue, newInstance, context);
            }
            for (int i = 0; i < dataContract.Members.Count; i++)
            {
                DataMember member = dataContract.Members[i];
                object currentMemberValue;
                if (deserialzedValue.TryGetValue(XmlConvert.DecodeName(dataContract.Members[i].Name), out currentMemberValue) ||
                    dataContract.IsKeyValuePairAdapter && deserialzedValue.TryGetValue(XmlConvert.DecodeName(dataContract.Members[i].Name.ToLowerInvariant()), out currentMemberValue))
                {
                    if (member.MemberType.GetTypeInfo().IsPrimitive || currentMemberValue == null)
                    {
                        SetMemberValue(newInstance, serializer.ConvertObjectToDataContract(member.MemberTypeContract, currentMemberValue, context), dataContract.Members[i].MemberInfo, dataContract.UnderlyingType);
                    }
                    else
                    {
                        context.PushKnownTypes(dataContract);
                        object subMemberValue = serializer.ConvertObjectToDataContract(member.MemberTypeContract, currentMemberValue, context);
                        Type declaredType = (member.MemberType.GetTypeInfo().IsGenericType && member.MemberType.GetGenericTypeDefinition() == Globals.TypeOfNullable)
                            ? Nullable.GetUnderlyingType(member.MemberType)
                            : member.MemberType;

                        if (!(declaredType == Globals.TypeOfObject && subMemberValue.GetType() == Globals.TypeOfObjectArray) && declaredType != subMemberValue.GetType())
                        {
                            DataContract memberValueContract = DataContract.GetDataContract(subMemberValue.GetType());
                            context.CheckIfTypeNeedsVerifcation(member.MemberTypeContract, memberValueContract);
                        }

                        if (member.IsGetOnlyCollection)
                        {
                            PopulateReadOnlyCollection(newInstance, member, (IEnumerable)subMemberValue);
                        }
                        else
                        {
                            SetMemberValue(newInstance, subMemberValue, dataContract.Members[i].MemberInfo, dataContract.UnderlyingType);
                        }
                        context.PopKnownTypes(dataContract);
                    }
                }
                else if (member.IsRequired)
                {
                    XmlObjectSerializerWriteContext.ThrowRequiredMemberMustBeEmitted(dataContract.MemberNames[i].Value, dataContract.UnderlyingType);
                }
            }
        }
開發者ID:er0dr1guez,項目名稱:corefx,代碼行數:48,代碼來源:ObjectToDataContractConverterHelper.cs

示例8: ReadJsonValueCore

        public override object ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
        {
            object obj2;
            string attribute = jsonReader.GetAttribute("type");
            string key = attribute;
            if (key != null)
            {
                int num;
                if (<PrivateImplementationDetails>{D290E7C2-4296-4D66-A436-0C17851A078B}.$$method0x60012be-1.TryGetValue(key, out num))
                {
                    switch (num)
                    {
                        case 0:
                            jsonReader.Skip();
                            obj2 = null;
                            goto Label_011B;

                        case 1:
                            obj2 = jsonReader.ReadElementContentAsBoolean();
                            goto Label_011B;

                        case 2:
                            goto Label_00BB;

                        case 3:
                            obj2 = ParseJsonNumber(jsonReader.ReadElementContentAsString());
                            goto Label_011B;

                        case 4:
                            jsonReader.Skip();
                            obj2 = new object();
                            goto Label_011B;

                        case 5:
                            return DataContractJsonSerializer.ReadJsonValue(DataContract.GetDataContract(Globals.TypeOfObjectArray), jsonReader, context);
                    }
                }
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(System.Runtime.Serialization.SR.GetString("JsonUnexpectedAttributeValue", new object[] { attribute })));
            }
        Label_00BB:
            obj2 = jsonReader.ReadElementContentAsString();
        Label_011B:
            if (context != null)
            {
                context.AddNewObject(obj2);
            }
            return obj2;
        }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:48,代碼來源:JsonObjectDataContract.cs

示例9: ReadJsonValueCore

 public override object ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
 {
     jsonReader.Read();
     object obj2 = null;
     if (context.IsGetOnlyCollection)
     {
         context.IsGetOnlyCollection = false;
         this.JsonFormatGetOnlyReaderDelegate(jsonReader, context, XmlDictionaryString.Empty, JsonGlobals.itemDictionaryString, this.TraditionalCollectionDataContract);
     }
     else
     {
         obj2 = this.JsonFormatReaderDelegate(jsonReader, context, XmlDictionaryString.Empty, JsonGlobals.itemDictionaryString, this.TraditionalCollectionDataContract);
     }
     jsonReader.ReadEndElement();
     return obj2;
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:16,代碼來源:JsonCollectionDataContract.cs

示例10: ReadJsonValueCore

        public override object ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
        {
            object enumValue;
            if (IsULong)
            {
                enumValue = Enum.ToObject(TraditionalDataContract.UnderlyingType, jsonReader.ReadElementContentAsUnsignedLong());
            }
            else
            {
                enumValue = Enum.ToObject(TraditionalDataContract.UnderlyingType, jsonReader.ReadElementContentAsLong());
            }

            if (context != null)
            {
                context.AddNewObject(enumValue);
            }
            return enumValue;
        }
開發者ID:JokerMisfits,項目名稱:linux-packaging-mono,代碼行數:18,代碼來源:JsonEnumDataContract.cs

示例11: ReadJsonValueCore

 public override object ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
 {
     object obj2;
     string s = jsonReader.ReadElementContentAsString();
     DataContractSerializer serializer = new DataContractSerializer(base.TraditionalDataContract.UnderlyingType, this.GetKnownTypesFromContext(context, (context == null) ? null : context.SerializerKnownTypeList), 1, false, false, null);
     MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(s));
     XmlDictionaryReaderQuotas readerQuotas = ((JsonReaderDelegator) jsonReader).ReaderQuotas;
     if (readerQuotas == null)
     {
         obj2 = serializer.ReadObject(stream);
     }
     else
     {
         obj2 = serializer.ReadObject(XmlDictionaryReader.CreateTextReader(stream, readerQuotas));
     }
     if (context != null)
     {
         context.AddNewObject(obj2);
     }
     return obj2;
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:21,代碼來源:JsonXmlDataContract.cs

示例12: ReadJsonValueCore

        public override object ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
        {
            object obj;
            string contentMode = jsonReader.GetAttribute(JsonGlobals.typeString);

            switch (contentMode)
            {
                case JsonGlobals.nullString:
                    jsonReader.Skip();
                    obj = null;
                    break;
                case JsonGlobals.booleanString:
                    obj = jsonReader.ReadElementContentAsBoolean();
                    break;
                case JsonGlobals.stringString:
                case null:
                    obj = jsonReader.ReadElementContentAsString();
                    break;
                case JsonGlobals.numberString:
                    obj = ParseJsonNumber(jsonReader.ReadElementContentAsString());
                    break;
                case JsonGlobals.objectString:
                    jsonReader.Skip();
                    obj = new object();
                    break;
                case JsonGlobals.arrayString:
                    // Read as object array
                    return DataContractJsonSerializer.ReadJsonValue(DataContract.GetDataContract(Globals.TypeOfObjectArray), jsonReader, context);
                default:
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                        XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.JsonUnexpectedAttributeValue, contentMode)));
            }

            if (context != null)
            {
                context.AddNewObject(obj);
            }
            return obj;
        }
開發者ID:ItsVeryWindy,項目名稱:mono,代碼行數:39,代碼來源:JsonObjectDataContract.cs

示例13: ReadFromJson

        public object ReadFromJson (XmlReaderDelegator xmlReader, XmlObjectSerializerReadContextComplexJson context, XmlDictionaryString emptyDictionaryString, XmlDictionaryString[] memberNames)
        {
            // InitArgs()
            this.xmlReader = xmlReader;
            this.context = context;
            this.emptyDictionaryString = emptyDictionaryString;
            this.memberNames = memberNames;
            
            //DemandSerializationFormatterPermission(classContract);
            //DemandMemberAccessPermission(memberAccessFlag);
            CreateObject (classContract);
            
            context.AddNewObject (objectLocal);
            InvokeOnDeserializing (classContract);
            
            string objectId = null;
            
            if (classContract.IsISerializable)
                ReadISerializable (classContract);
            else
                ReadClass (classContract);
            if (Globals.TypeOfIDeserializationCallback.IsAssignableFrom (classContract.UnderlyingType))
                ((IDeserializationCallback) objectLocal).OnDeserialization (null);
            InvokeOnDeserialized(classContract);
            if (!InvokeFactoryMethod (classContract)) {

                // Do a conversion back from DateTimeOffsetAdapter to DateTimeOffset after deserialization.
                // DateTimeOffsetAdapter is used here for deserialization purposes to bypass the ISerializable implementation
                // on DateTimeOffset; which does not work in partial trust.

                if (classContract.UnderlyingType == Globals.TypeOfDateTimeOffsetAdapter)
                    objectLocal = DateTimeOffsetAdapter.GetDateTimeOffset ((DateTimeOffsetAdapter) objectLocal);
                // else - do we have to call CodeInterpreter.ConvertValue()? I guess not...
            }
            return objectLocal;
        }
開發者ID:Profit0004,項目名稱:mono,代碼行數:36,代碼來源:JsonFormatReaderGenerator_static.cs

示例14: ReadJsonValueCore

        public override object ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
        {
            string xmlContent = jsonReader.ReadElementContentAsString();

            DataContractSerializer dataContractSerializer = new DataContractSerializer(TraditionalDataContract.UnderlyingType,
                GetKnownTypesFromContext(context, (context == null) ? null : context.SerializerKnownTypeList), 1, false, false); //  maxItemsInObjectGraph //  ignoreExtensionDataObject //  preserveObjectReferences

            MemoryStream memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(xmlContent));
            object xmlValue;
            XmlDictionaryReaderQuotas quotas = ((JsonReaderDelegator)jsonReader).ReaderQuotas;
            if (quotas == null)
            {
                xmlValue = dataContractSerializer.ReadObject(memoryStream);
            }
            else
            {
                xmlValue = dataContractSerializer.ReadObject(XmlDictionaryReader.CreateTextReader(memoryStream, quotas));
            }
            if (context != null)
            {
                context.AddNewObject(xmlValue);
            }
            return xmlValue;
        }
開發者ID:Rayislandstyle,項目名稱:corefx,代碼行數:24,代碼來源:JsonXmlDataContract.cs

示例15: ResolveDataContractFromTypeInformation

 private static ClassDataContract ResolveDataContractFromTypeInformation(string typeName, DataContract contract, XmlObjectSerializerReadContextComplexJson context)
 {
     DataContract dataContract = context.ResolveDataContractFromType(typeName, Globals.DataContractXsdBaseNamespace, contract);
     if (dataContract == null)
     {
         XmlQualifiedName qname = XmlObjectSerializerReadContextComplexJson.ParseQualifiedName(typeName);
         throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.Format(SR.DcTypeNotFoundOnDeserialize, qname.Namespace, qname.Name)));
     }
     return (ClassDataContract)dataContract;
 }
開發者ID:er0dr1guez,項目名稱:corefx,代碼行數:10,代碼來源:ObjectToDataContractConverterHelper.cs


注:本文中的System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。