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


C# XmlObjectSerializerReadContext类代码示例

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


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

示例1: ReadXmlValue

 public override object ReadXmlValue(XmlReaderDelegator reader, XmlObjectSerializerReadContext context)
 {
     object obj2;
     if (reader.IsEmptyElement)
     {
         reader.Skip();
         obj2 = new object();
     }
     else
     {
         string localName = reader.LocalName;
         string namespaceURI = reader.NamespaceURI;
         reader.Read();
         try
         {
             reader.ReadEndElement();
             obj2 = new object();
         }
         catch (XmlException exception)
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(System.Runtime.Serialization.SR.GetString("XmlForObjectCannotHaveContent", new object[] { localName, namespaceURI }), exception));
         }
     }
     if (context != null)
     {
         return base.HandleReadValue(obj2, context);
     }
     return obj2;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:29,代码来源:ObjectDataContract.cs

示例2: ReflectionInitArgs

 private void ReflectionInitArgs(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context, XmlDictionaryString[] memberNames, XmlDictionaryString[] memberNamespaces)
 {
     _arg0XmlReader = xmlReader;
     _arg1Context = context;
     _arg2MemberNames = memberNames;
     _arg3MemberNamespaces = memberNamespaces;
 }
开发者ID:SGuyGe,项目名称:corefx,代码行数:7,代码来源:ReflectionXmlFormatReader.cs

示例3: ReflectionReadMembers

 private void ReflectionReadMembers(object obj, XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context, XmlDictionaryString[] memberNames, XmlDictionaryString[] memberNamespaces)
 {
     int memberCount = _classContract.MemberNames.Length;
     context.IncrementItemCount(memberCount);
     int memberIndex = -1;
     int firstRequiredMember;
     bool[] requiredMembers = GetRequiredMembers(_classContract, out firstRequiredMember);
     bool hasRequiredMembers = (firstRequiredMember < memberCount);
     int requiredIndex = hasRequiredMembers ? firstRequiredMember : -1;
     int index = -1;
     while (true)
     {
         if (!XmlObjectSerializerReadContext.MoveToNextElement(xmlReader))
         {
             return;
         }
         if (hasRequiredMembers)
         {
             index = context.GetMemberIndexWithRequiredMembers(xmlReader, memberNames, memberNamespaces, memberIndex, requiredIndex, null);
         }
         else
         {
             index = context.GetMemberIndex(xmlReader, memberNames, memberNamespaces, memberIndex, null);
         }
         ReflectionReadMember(obj, index, xmlReader, context, memberNames, memberNamespaces);
         memberIndex = index;
         requiredIndex = index + 1;
     }
 }
开发者ID:SGuyGe,项目名称:corefx,代码行数:29,代码来源:ReflectionXmlFormatReader.cs

示例4: ReadXmlValue

 public override object ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
 {
     xmlReader.Read();
     Type underlyingType = base.UnderlyingType;
     object obj2 = underlyingType.IsArray ? Array.CreateInstance(underlyingType.GetElementType(), 0) : this.GetUninitializedObject(underlyingType);
     context.AddNewObject(obj2);
     string objectId = context.GetObjectId();
     SerializationInfo serInfo = context.ReadSerializationInfo(xmlReader, underlyingType);
     object newObj = this.SerializationSurrogateSetObjectData(obj2, serInfo, context.GetStreamingContext());
     if (newObj == null)
     {
         newObj = obj2;
     }
     if (newObj is IDeserializationCallback)
     {
         ((IDeserializationCallback) newObj).OnDeserialization(null);
     }
     if (newObj is IObjectReference)
     {
         newObj = GetRealObject((IObjectReference) newObj, context.GetStreamingContext());
     }
     context.ReplaceDeserializedObject(objectId, obj2, newObj);
     xmlReader.ReadEndElement();
     return newObj;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:25,代码来源:SurrogateDataContract.cs

示例5: GetArrayLengthQuota

 protected int GetArrayLengthQuota(XmlObjectSerializerReadContext context)
 {
     if (this.dictionaryReader.Quotas == null)
     {
         return context.RemainingItemCount;
     }
     return Math.Min(context.RemainingItemCount, this.dictionaryReader.Quotas.MaxArrayLength);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:XmlReaderDelegator.cs

示例6: ReadXmlValue

 public override object ReadXmlValue(XmlReaderDelegator reader, XmlObjectSerializerReadContext context)
 {
     if (context != null)
     {
         return base.HandleReadValue(reader.ReadElementContentAsChar(), context);
     }
     return reader.ReadElementContentAsChar();
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:CharDataContract.cs

示例7: ReadXmlValue

 public override object ReadXmlValue(XmlReaderDelegator reader, XmlObjectSerializerReadContext context)
 {
     if (context != null)
     {
         return base.HandleReadValue(reader.ReadElementContentAsQName(), context);
     }
     if (!base.TryReadNullAtTopLevel(reader))
     {
         return reader.ReadElementContentAsQName();
     }
     return null;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:12,代码来源:QNameDataContract.cs

示例8: ReflectionReadClass

        internal object ReflectionReadClass(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context, XmlDictionaryString[] memberNames, XmlDictionaryString[] memberNamespaces)
        {
            ReflectionInitArgs(xmlReader, context, memberNames, memberNamespaces);
            object obj = ReflectionCreateObject(_classContract);
            context.AddNewObject(obj);
            ReflectionReadMembers(obj, xmlReader, context, memberNames, memberNamespaces);

            if (obj.GetType() == typeof(DateTimeOffsetAdapter))
            {
                obj = DateTimeOffsetAdapter.GetDateTimeOffset((DateTimeOffsetAdapter)obj);
            }
            else if (obj.GetType().GetTypeInfo().IsGenericType && obj.GetType().GetGenericTypeDefinition() == typeof(KeyValuePairAdapter<,>))
            {
                obj = _classContract.GetKeyValuePairMethodInfo.Invoke(obj, Array.Empty<object>());
            }

            return obj;
        }
开发者ID:SGuyGe,项目名称:corefx,代码行数:18,代码来源:ReflectionXmlFormatReader.cs

示例9: ReadFromXml

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

				// 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:JokerMisfits,项目名称:linux-packaging-mono,代码行数:39,代码来源:XmlFormatReaderGenerator_static.cs

示例10: ReflectionReadMembers

        protected override void ReflectionReadMembers(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context, XmlDictionaryString[] memberNames, XmlDictionaryString[] memberNamespaces, ClassDataContract classContract, ref object obj)
        {
            int memberCount = classContract.MemberNames.Length;
            context.IncrementItemCount(memberCount);
            int memberIndex = -1;
            int firstRequiredMember;
            bool[] requiredMembers = GetRequiredMembers(classContract, out firstRequiredMember);
            bool hasRequiredMembers = (firstRequiredMember < memberCount);
            int requiredIndex = hasRequiredMembers ? firstRequiredMember : -1;
            DataMember[] members = new DataMember[memberCount];
            int reflectedMemberCount = ReflectionGetMembers(classContract, members);
            Debug.Assert(reflectedMemberCount == memberCount, "The value returned by ReflectionGetMembers() should equal to memberCount.");

            while (true)
            {
                if (!XmlObjectSerializerReadContext.MoveToNextElement(xmlReader))
                {
                    return;
                }
                if (hasRequiredMembers)
                {
                    memberIndex = context.GetMemberIndexWithRequiredMembers(xmlReader, memberNames, memberNamespaces, memberIndex, requiredIndex, null);
                }
                else
                {
                    memberIndex = context.GetMemberIndex(xmlReader, memberNames, memberNamespaces, memberIndex, null);
                }

                // GetMemberIndex returns memberNames.Length if member not found
                if (memberIndex < members.Length)
                {
                    ReflectionReadMember(xmlReader, context, classContract, ref obj, memberIndex, members);
                    requiredIndex = memberIndex + 1;
                }
            }
        }
开发者ID:dotnet,项目名称:corefx,代码行数:36,代码来源:ReflectionXmlFormatReader.cs

示例11: ReadXmlValue

 public override object ReadXmlValue(XmlReaderDelegator reader, XmlObjectSerializerReadContext context)
 {
     object obj;
     if (reader.IsEmptyElement)
     {
         reader.Skip();
         obj = new object();
     }
     else
     {
         string localName = reader.LocalName;
         string ns = reader.NamespaceURI;
         reader.Read();
         try
         {
             reader.ReadEndElement();
             obj = new object();
         }
         catch (XmlException xes)
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.Format(SR.XmlForObjectCannotHaveContent, localName, ns), xes));
         }
     }
     return (context == null) ? obj : HandleReadValue(obj, context);
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:25,代码来源:PrimitiveDataContract.cs

示例12: ReadXmlValue

 public override object ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
 {
     object obj = ReadEnumValue(xmlReader);
     if (context != null)
         context.AddNewObject(obj);
     return obj;
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:7,代码来源:EnumDataContract.cs

示例13: TryReadDoubleArray

        internal bool TryReadDoubleArray(XmlObjectSerializerReadContext context,
#endif   
            XmlDictionaryString itemName, XmlDictionaryString itemNamespace,
            int arrayLength, out double[] array)
        {
            if (dictionaryReader == null)
            {
                array = null;
                return false;
            }

            if (arrayLength != -1)
            {
                CheckExpectedArrayLength(context, arrayLength);
                array = new double[arrayLength];
                int read = 0, offset = 0;
                while ((read = dictionaryReader.ReadArray(itemName, itemNamespace, array, offset, arrayLength - offset)) > 0)
                {
                    offset += read;
                }
                CheckActualArrayLength(arrayLength, offset, itemName, itemNamespace);
            }
            else
            {
                array = DoubleArrayHelperWithDictionaryString.Instance.ReadArray(
                    dictionaryReader, itemName, itemNamespace, GetArrayLengthQuota(context));
                context.IncrementItemCount(array.Length);
            }
            return true;
        }
开发者ID:jsalvadorp,项目名称:corefx,代码行数:30,代码来源:XmlReaderDelegator.cs

示例14: TryReadInt64Array

 public bool TryReadInt64Array(XmlObjectSerializerReadContext context,
开发者ID:jsalvadorp,项目名称:corefx,代码行数:1,代码来源:XmlReaderDelegator.cs

示例15: ExtensionDataReader

 internal ExtensionDataReader(XmlObjectSerializerReadContext context)
 {
     this.attributeIndex = -1;
     this.context = context;
 }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:5,代码来源:ExtensionDataReader.cs


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