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


C# XmlWriterDelegator.WriteString方法代码示例

本文整理汇总了C#中System.Runtime.Serialization.XmlWriterDelegator.WriteString方法的典型用法代码示例。如果您正苦于以下问题:C# XmlWriterDelegator.WriteString方法的具体用法?C# XmlWriterDelegator.WriteString怎么用?C# XmlWriterDelegator.WriteString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Runtime.Serialization.XmlWriterDelegator的用法示例。


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

示例1: WriteJsonValueCore

 public override void WriteJsonValueCore(XmlWriterDelegator jsonWriter, object obj, XmlObjectSerializerWriteContextComplexJson context, RuntimeTypeHandle declaredTypeHandle)
 {
     DataContractSerializer serializer = new DataContractSerializer(Type.GetTypeFromHandle(declaredTypeHandle), this.GetKnownTypesFromContext(context, (context == null) ? null : context.SerializerKnownTypeList), 1, false, false, null);
     MemoryStream stream = new MemoryStream();
     serializer.WriteObject(stream, obj);
     stream.Position = 0L;
     string str = new StreamReader(stream).ReadToEnd();
     jsonWriter.WriteString(str);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:JsonXmlDataContract.cs

示例2: WriteString

        internal override void WriteString(XmlWriterDelegator xmlWriter, string value, XmlDictionaryString name, XmlDictionaryString ns)
#endif
        {
            if (value == null)
                WriteNull(xmlWriter, typeof(string), true/*isMemberTypeSerializable*/, name, ns);
            else
            {
                xmlWriter.WriteStartElementPrimitive(name, ns);
                if (!OnHandleReference(xmlWriter, value, false /*canContainCyclicReference*/))
                    xmlWriter.WriteString(value);
                xmlWriter.WriteEndElementPrimitive();
            }
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:13,代码来源:XmlObjectSerializerWriteContextComplex.cs

示例3: WriteXmlValue

 public override void WriteXmlValue(XmlWriterDelegator writer, object obj, XmlObjectSerializerWriteContext context)
 {
     writer.WriteString((string)obj);
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:4,代码来源:PrimitiveDataContract.cs

示例4: WriteEnumValue

        internal void WriteEnumValue(XmlWriterDelegator writer, object value)
        {
            long longValue = IsULong ? (long)Convert.ToUInt64(value, null) : Convert.ToInt64(value, null);
            for (int i = 0; i < Values.Count; i++)
            {
                if (longValue == Values[i])
                {
                    writer.WriteString(ChildElementNames[i].Value);
                    return;
                }
            }
            if (IsFlags)
            {
                int zeroIndex = -1;
                bool noneWritten = true;
                for (int i = 0; i < Values.Count; i++)
                {
                    long current = Values[i];
                    if (current == 0)
                    {
                        zeroIndex = i;
                        continue;
                    }
                    if (longValue == 0)
                        break;
                    if ((current & longValue) == current)
                    {
                        if (noneWritten)
                            noneWritten = false;
                        else
                            writer.WriteString(DictionaryGlobals.Space.Value);

                        writer.WriteString(ChildElementNames[i].Value);
                        longValue &= ~current;
                    }
                }
                // enforce that enum value was completely parsed
                if (longValue != 0)
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.Format(SR.InvalidEnumValueOnWrite, value, DataContract.GetClrTypeFullName(UnderlyingType))));

                if (noneWritten && zeroIndex >= 0)
                    writer.WriteString(ChildElementNames[zeroIndex].Value);
            }
            else
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.Format(SR.InvalidEnumValueOnWrite, value, DataContract.GetClrTypeFullName(UnderlyingType))));
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:46,代码来源:EnumDataContract.cs

示例5: WriteString

 public override void WriteString(XmlWriterDelegator xmlWriter, string value)
 {
     if (!OnHandleReference(xmlWriter, value, false /*canContainCyclicReference*/))
         xmlWriter.WriteString(value);
 }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:5,代码来源:XmlObjectSerializerWriteContextComplex.cs

示例6: WriteEnumValue

 internal void WriteEnumValue(XmlWriterDelegator writer, object value)
 {
     long num = this.IsULong ? ((long) ((IConvertible) value).ToUInt64(null)) : ((IConvertible) value).ToInt64(null);
     for (int i = 0; i < this.Values.Count; i++)
     {
         if (num == this.Values[i])
         {
             writer.WriteString(this.ChildElementNames[i].Value);
             return;
         }
     }
     if (!this.IsFlags)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(System.Runtime.Serialization.SR.GetString("InvalidEnumValueOnWrite", new object[] { value, DataContract.GetClrTypeFullName(base.UnderlyingType) })));
     }
     int index = -1;
     bool flag = true;
     for (int j = 0; j < this.Values.Count; j++)
     {
         long num5 = this.Values[j];
         if (num5 == 0L)
         {
             index = j;
         }
         else
         {
             if (num == 0L)
             {
                 break;
             }
             if ((num5 & num) == num5)
             {
                 if (flag)
                 {
                     flag = false;
                 }
                 else
                 {
                     writer.WriteString(DictionaryGlobals.Space.Value);
                 }
                 writer.WriteString(this.ChildElementNames[j].Value);
                 num &= ~num5;
             }
         }
     }
     if (num != 0L)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(System.Runtime.Serialization.SR.GetString("InvalidEnumValueOnWrite", new object[] { value, DataContract.GetClrTypeFullName(base.UnderlyingType) })));
     }
     if (flag && (index >= 0))
     {
         writer.WriteString(this.ChildElementNames[index].Value);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:54,代码来源:EnumDataContract.cs


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