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


C# XmlWriterDelegator类代码示例

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


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

示例1: WriteJsonValueCore

        public override void WriteJsonValueCore(XmlWriterDelegator jsonWriter, object obj, XmlObjectSerializerWriteContextComplexJson context, RuntimeTypeHandle declaredTypeHandle)
        {
            DataContractSerializer dataContractSerializer = new DataContractSerializer(Type.GetTypeFromHandle(declaredTypeHandle),
                GetKnownTypesFromContext(context, (context == null) ? null : context.SerializerKnownTypeList), 1, false, false); //  maxItemsInObjectGraph //  ignoreExtensionDataObject //  preserveObjectReferences

            MemoryStream memoryStream = new MemoryStream();
            dataContractSerializer.WriteObject(memoryStream, obj);
            memoryStream.Position = 0;
            string serialized = new StreamReader(memoryStream).ReadToEnd();
            jsonWriter.WriteString(serialized);
        }
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:11,代码来源:JsonXmlDataContract.cs

示例2: WriteJsonValueCore

 public override void WriteJsonValueCore(XmlWriterDelegator jsonWriter, object obj, XmlObjectSerializerWriteContextComplexJson context, RuntimeTypeHandle declaredTypeHandle)
 {
     if (IsULong)
     {
         jsonWriter.WriteUnsignedLong(((IConvertible)obj).ToUInt64(null));
     }
     else
     {
         jsonWriter.WriteLong(((IConvertible)obj).ToInt64(null));
     }
 }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:11,代码来源:JsonEnumDataContract.cs

示例3: WriteTypeInfo

 protected override void WriteTypeInfo(XmlWriterDelegator writer, string dataContractName, string dataContractNamespace)
 {
     if (_emitXsiType != EmitTypeInformation.Never)
     {
         if (string.IsNullOrEmpty(dataContractNamespace))
         {
             WriteTypeInfo(writer, dataContractName);
         }
         else
         {
             WriteTypeInfo(writer, string.Concat(dataContractName, JsonGlobals.NameValueSeparatorString, TruncateDefaultDataContractNamespace(dataContractNamespace)));
         }
     }
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:14,代码来源:XmlObjectSerializerWriteContextComplexJson.cs

示例4: WriteCollectionToJson

		public void WriteCollectionToJson (XmlWriterDelegator xmlWriter, object obj, XmlObjectSerializerWriteContextComplexJson context, CollectionDataContract dataContract)
		{
			this.writer = xmlWriter;
			this.obj = obj;
			this.context = context;
			this.dataContract = dataContract;

			InitArgs (collectionContract.UnderlyingType);			

			// DemandMemberAccessPermission(memberAccessFlag);
			if (collectionContract.IsReadOnlyContract)
			{
				DataContract.ThrowInvalidDataContractException (collectionContract.SerializationExceptionMessage, null);
			}

			WriteCollection (collectionContract);
		}
开发者ID:psni,项目名称:mono,代码行数:17,代码来源:JsonFormatWriterGenerator_static.cs

示例5: WriteToJson

		public void WriteToJson (XmlWriterDelegator xmlWriter, object obj, XmlObjectSerializerWriteContextComplexJson context, ClassDataContract dataContract, XmlDictionaryString [] memberNames)
		{
			this.writer = xmlWriter;
			this.obj = obj;
			this.context = context;
			this.dataContract = dataContract;
			this.memberNames = memberNames;

			InitArgs (classContract.UnderlyingType);

			// DemandSerializationFormatterPermission (classContract) - irrelevant
			// DemandMemberAccessPermission (memberAccessFlag) - irrelevant

			if (classContract.IsReadOnlyContract)
			{
				DataContract.ThrowInvalidDataContractException (classContract.SerializationExceptionMessage, null);
			}

			WriteClass (classContract);
		}
开发者ID:psni,项目名称:mono,代码行数:20,代码来源:JsonFormatWriterGenerator_static.cs

示例6: ReflectionWriteEndElement

 public void ReflectionWriteEndElement(XmlWriterDelegator xmlWriter)
 {
     xmlWriter.WriteEndElement();
 }        
开发者ID:Corillian,项目名称:corefx,代码行数:4,代码来源:ReflectionJsonFormatWriter.cs

示例7: WriteClrTypeInfo

 internal override bool WriteClrTypeInfo(XmlWriterDelegator xmlWriter, DataContract dataContract)
 {
     return false;
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:4,代码来源:XmlObjectSerializerWriteContextComplexJson.cs

示例8: SerializeWithXsiType

        protected override void SerializeWithXsiType(XmlWriterDelegator xmlWriter, object obj, RuntimeTypeHandle objectTypeHandle, Type objectType, int declaredTypeID, RuntimeTypeHandle declaredTypeHandle, Type declaredType)
        {
            DataContract dataContract;
            bool verifyKnownType = false;
            bool isDeclaredTypeInterface = declaredType.GetTypeInfo().IsInterface;

            if (isDeclaredTypeInterface && CollectionDataContract.IsCollectionInterface(declaredType))
            {
                dataContract = GetDataContract(declaredTypeHandle, declaredType);
            }
            else if (declaredType.IsArray) // If declared type is array do not write __serverType. Instead write__serverType for each item
            {
                dataContract = GetDataContract(declaredTypeHandle, declaredType);
            }
            else
            {
                dataContract = GetDataContract(objectTypeHandle, objectType);
                DataContract declaredTypeContract = (declaredTypeID >= 0)
                    ? GetDataContract(declaredTypeID, declaredTypeHandle)
                    : GetDataContract(declaredTypeHandle, declaredType);
                verifyKnownType = WriteTypeInfo(xmlWriter, dataContract, declaredTypeContract);
                HandleCollectionAssignedToObject(declaredType, ref dataContract, ref obj, ref verifyKnownType);
            }

            if (isDeclaredTypeInterface)
            {
                VerifyObjectCompatibilityWithInterface(dataContract, obj, declaredType);
            }
            SerializeAndVerifyType(dataContract, xmlWriter, obj, verifyKnownType, declaredType.TypeHandle, declaredType);
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:30,代码来源:XmlObjectSerializerWriteContextComplexJson.cs

示例9: WriteJsonNameWithMapping

 internal static void WriteJsonNameWithMapping(XmlWriterDelegator xmlWriter, XmlDictionaryString[] memberNames, int index)
 {
     xmlWriter.WriteStartElement("a", JsonGlobals.itemString, JsonGlobals.itemString);
     xmlWriter.WriteAttributeString(null, JsonGlobals.itemString, null, memberNames[index].Value);
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:5,代码来源:XmlObjectSerializerWriteContextComplexJson.cs

示例10: WriteDataContractValue

 protected override void WriteDataContractValue(DataContract dataContract, XmlWriterDelegator xmlWriter, object obj, RuntimeTypeHandle declaredTypeHandle)
 {
     JsonDataContract jsonDataContract = JsonDataContract.GetJsonDataContract(dataContract);
     if (_emitXsiType == EmitTypeInformation.Always && !_perCallXsiTypeAlreadyEmitted && RequiresJsonTypeInfo(dataContract))
     {
         WriteTypeInfo(xmlWriter, jsonDataContract.TypeName);
     }
     _perCallXsiTypeAlreadyEmitted = false;
     DataContractJsonSerializerImpl.WriteJsonValue(jsonDataContract, xmlWriter, obj, this, declaredTypeHandle);
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:10,代码来源:XmlObjectSerializerWriteContextComplexJson.cs

示例11: OnHandleReference

 internal override bool OnHandleReference(XmlWriterDelegator xmlWriter, object obj, bool canContainCyclicReference)
 {
     if (obj.GetType().GetTypeInfo().IsValueType)
     {
         return false;
     }
     if (_byValObjectsInScope.Contains(obj))
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.Format(SR.CannotSerializeObjectWithCycles, DataContract.GetClrTypeFullName(obj.GetType()))));
     }
     _byValObjectsInScope.Push(obj);
     return false;
 }
开发者ID:johnhhm,项目名称:corefx,代码行数:13,代码来源:XmlObjectSerializerWriteContextComplexJson.cs

示例12: OnEndHandleReference

 internal override void OnEndHandleReference(XmlWriterDelegator xmlWriter, object obj, bool canContainCyclicReference)
 {
     if (!obj.GetType().GetTypeInfo().IsValueType)
         _byValObjectsInScope.Pop(obj);
 }
开发者ID:johnhhm,项目名称:corefx,代码行数:5,代码来源:XmlObjectSerializerWriteContextComplexJson.cs

示例13: WriteNull

        protected override void WriteNull(XmlWriterDelegator xmlWriter)
        {
#if NET_NATIVE || MERGE_DCJS
            DataContractJsonSerializerImpl.WriteJsonNull(xmlWriter);
#endif
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:6,代码来源:XmlObjectSerializerWriteContextComplexJson.cs

示例14: WriteDataContractValue

        protected override void WriteDataContractValue(DataContract dataContract, XmlWriterDelegator xmlWriter, object obj, RuntimeTypeHandle declaredTypeHandle)
        {
#if NET_NATIVE || MERGE_DCJS
            JsonDataContract jsonDataContract = JsonDataContract.GetJsonDataContract(dataContract);
            if (_emitXsiType == EmitTypeInformation.Always && !_perCallXsiTypeAlreadyEmitted && RequiresJsonTypeInfo(dataContract))
            {
                WriteTypeInfo(xmlWriter, jsonDataContract.TypeName);
            }
            _perCallXsiTypeAlreadyEmitted = false;
            DataContractJsonSerializerImpl.WriteJsonValue(jsonDataContract, xmlWriter, obj, this, declaredTypeHandle);
#else
            _jsonSerializer.WriteObjectInternal(obj, dataContract, this, WriteTypeInfo(null, dataContract, DataContract.GetDataContract(declaredTypeHandle, obj.GetType())), declaredTypeHandle);
#endif
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:14,代码来源:XmlObjectSerializerWriteContextComplexJson.cs

示例15: WriteTypeInfo

        protected override bool WriteTypeInfo(XmlWriterDelegator writer, DataContract contract, DataContract declaredContract)
        {
            if (!((object.ReferenceEquals(contract.Name, declaredContract.Name) &&
                   object.ReferenceEquals(contract.Namespace, declaredContract.Namespace)) ||
                 (contract.Name.Value == declaredContract.Name.Value &&
                 contract.Namespace.Value == declaredContract.Namespace.Value)) &&
                 (contract.UnderlyingType != Globals.TypeOfObjectArray))
            {
                // We always deserialize collections assigned to System.Object as object[]
                // Because of its common and JSON-specific nature, 
                //    we don't want to validate known type information for object[]

                // Return true regardless of whether we actually wrote __type information
                // E.g. We don't write __type information for enums, but we still want verifyKnownType
                //      to be true for them.
                return true;
            }
            return false;
        }
开发者ID:jsalvadorp,项目名称:corefx,代码行数:19,代码来源:XmlObjectSerializerWriteContextComplexJson.cs


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