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

C# XmlWriterDelegator类代码示例

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

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



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


示例16: WriteNull

 protected override void WriteNull(XmlWriterDelegator xmlWriter)
 {
 }
开发者ID:jsalvadorp,项目名称:corefx,代码行数:3,代码来源:XmlObjectSerializerWriteContextComplexJson.cs


示例17: WriteDataContractValue

 protected override void WriteDataContractValue(DataContract dataContract, XmlWriterDelegator xmlWriter, object obj, RuntimeTypeHandle declaredTypeHandle)
 {
     _jsonSerializer.WriteObjectInternal(obj, dataContract, this, WriteTypeInfo(null, dataContract, DataContract.GetDataContract(declaredTypeHandle, obj.GetType())), declaredTypeHandle);
 }
开发者ID:jsalvadorp,项目名称:corefx,代码行数:4,代码来源:XmlObjectSerializerWriteContextComplexJson.cs


示例18: WriteJsonISerializable

 public void WriteJsonISerializable(XmlWriterDelegator xmlWriter, ISerializable obj)
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:1,代码来源:XmlObjectSerializerWriteContextComplexJson.cs


示例19: WriteNull

 protected override void WriteNull(XmlWriterDelegator xmlWriter)
 {
     DataContractJsonSerializerImpl.WriteJsonNull(xmlWriter);
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:4,代码来源:XmlObjectSerializerWriteContextComplexJson.cs


示例20: SerializeWithXsiTypeAtTopLevel

        internal override void SerializeWithXsiTypeAtTopLevel(DataContract dataContract, XmlWriterDelegator xmlWriter, object obj, RuntimeTypeHandle originalDeclaredTypeHandle, Type graphType)
        {
            bool verifyKnownType = false;
            Type declaredType = rootTypeDataContract.UnderlyingType;
            bool isDeclaredTypeInterface = declaredType.GetTypeInfo().IsInterface;

            if (!(isDeclaredTypeInterface && CollectionDataContract.IsCollectionInterface(declaredType))
                && !declaredType.IsArray)//Array covariance is not supported in XSD. If declared type is array do not write xsi:type. Instead write xsi:type for each item
            {
                verifyKnownType = WriteTypeInfo(xmlWriter, dataContract, rootTypeDataContract);
                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,代码行数:19,代码来源:XmlObjectSerializerWriteContextComplexJson.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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