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


C# Serialization.XmlObjectSerializer类代码示例

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


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

示例1: XmlObjectSerializerBodyWriter

		public XmlObjectSerializerBodyWriter (
			object body, XmlObjectSerializer formatter)
			: base (true)
		{
			this.body = body;
			this.formatter = formatter;
		}
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:XmlObjectSerializerBodyWriter.cs

示例2: XmlObjectSerializerHeader

 private XmlObjectSerializerHeader(XmlObjectSerializer serializer, bool mustUnderstand, string actor, bool relay)
 {
     this.syncRoot = new object();
     if (actor == null)
     {
         throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("actor");
     }
     this.mustUnderstand = mustUnderstand;
     this.relay = relay;
     this.serializer = serializer;
     this.actor = actor;
     if (actor == EnvelopeVersion.Soap12.UltimateDestinationActor)
     {
         this.isOneOneSupported = false;
         this.isOneTwoSupported = true;
     }
     else if (actor == EnvelopeVersion.Soap12.NextDestinationActorValue)
     {
         this.isOneOneSupported = false;
         this.isOneTwoSupported = true;
     }
     else if (actor == EnvelopeVersion.Soap11.NextDestinationActorValue)
     {
         this.isOneOneSupported = true;
         this.isOneTwoSupported = false;
     }
     else
     {
         this.isOneOneSupported = true;
         this.isOneTwoSupported = true;
         this.isNoneSupported = true;
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:33,代码来源:XmlObjectSerializerHeader.cs

示例3: Deserialize

        public static object Deserialize(string xmlContent, string serializerType)
        {
            object returnValue = null;
            SerializerTypes serializerTypeValue;
            Type instanceType;
            GetSerializerDetails(serializerType, out serializerTypeValue, out instanceType);

            if (serializerTypeValue == SerializerTypes.XmlSerializer)
            {
                StringReader sww = new StringReader(xmlContent);
                XmlReader reader = XmlReader.Create(sww);
                System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(instanceType);
                returnValue = serializer.Deserialize(reader);
            }
            else if (serializerTypeValue == SerializerTypes.XmlObjectSerializer)
            {
                XmlObjectSerializer serializer = new XmlObjectSerializer();
                returnValue = serializer.Deserialize(xmlContent, true);
            }
            else
            {
                if (instanceType == typeof(string))
                {
                    returnValue = xmlContent;
                }
                else
                {
                    var method = instanceType.GetMethod("Parse", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
                    returnValue = method.Invoke(null, new object[] { xmlContent });
                }
            }
            return returnValue;
        }
开发者ID:priestofpsi,项目名称:theDiary-Common-Framework,代码行数:33,代码来源:SerializationHelper.cs

示例4: MessageSubscribtionInfo

        public MessageSubscribtionInfo(DataContractKey contractKey, ICallHandler handler, XmlObjectSerializer serializer, bool receiveSelfPublish, IEnumerable<BusHeader> filterHeaders)
        {
            _handler = handler;
            _serializer = serializer;

            _filterInfo = new MessageFilterInfo(contractKey, receiveSelfPublish, filterHeaders);
        }
开发者ID:ronybot,项目名称:MessageBus,代码行数:7,代码来源:MessageSubscribtionInfo.cs

示例5: WebFormatterSerializationContext

 private WebFormatterSerializationContext(XmlObjectSerializer xmlSerializer)
 {
     if (xmlSerializer is DataContractJsonSerializer)
         ContentFormat = SerializationFormat.Json;
     else
         ContentFormat = SerializationFormat.Xml;
     XmlSerializer = xmlSerializer;
 }
开发者ID:richet,项目名称:WcfRestContrib,代码行数:8,代码来源:WebFormatterSerializationContext.cs

示例6: CreateHeader

 public static MessageHeader CreateHeader(string name, string ns, object value, XmlObjectSerializer serializer, bool mustUnderstand, string actor, bool relay)
 {
     if (serializer == null)
     {
         throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("serializer"));
     }
     return new XmlObjectSerializerHeader(name, ns, value, serializer, mustUnderstand, actor, relay);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:MessageHeader.cs

示例7: XmlObjectSerializerContext

 internal XmlObjectSerializerContext(XmlObjectSerializer serializer, int maxItemsInObjectGraph, StreamingContext streamingContext, bool ignoreExtensionDataObject, DataContractResolver dataContractResolver)
 {
     this.serializer = serializer;
     this.itemCount = 1;
     this.maxItemsInObjectGraph = maxItemsInObjectGraph;
     this.streamingContext = streamingContext;
     this.ignoreExtensionDataObject = ignoreExtensionDataObject;
     this.dataContractResolver = dataContractResolver;
 }
开发者ID:yangjunhua,项目名称:mono,代码行数:9,代码来源:XmlObjectSerializerContext.cs

示例8: XmlObjectSerializerFault

 public XmlObjectSerializerFault(FaultCode code, FaultReason reason, object detail, XmlObjectSerializer serializer, string actor, string node)
 {
     this.code = code;
     this.reason = reason;
     this.detail = detail;
     this.serializer = serializer;
     this.actor = actor;
     this.node = node;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:XmlObjectSerializerFault.cs

示例9: XmlObjectSerializerContext

 internal XmlObjectSerializerContext(XmlObjectSerializer serializer, int maxItemsInObjectGraph, StreamingContext streamingContext, bool ignoreExtensionDataObject, System.Runtime.Serialization.DataContractResolver dataContractResolver)
 {
     this.scopedKnownTypes = new ScopedKnownTypes();
     this.serializer = serializer;
     this.itemCount = 1;
     this.maxItemsInObjectGraph = maxItemsInObjectGraph;
     this.streamingContext = streamingContext;
     this.ignoreExtensionDataObject = ignoreExtensionDataObject;
     this.dataContractResolver = dataContractResolver;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:10,代码来源:XmlObjectSerializerContext.cs

示例10: JsonSerializer

        public JsonSerializer(Type type, XmlObjectSerializer fallbackSerializer, bool isCompress,
            SerializeContentTypes contentType)
        {
            this.type = type;
            this.isCustomSerialization = true;
            this.fallbackSerializer = fallbackSerializer;

            m_IsCompress = isCompress;
            m_ContentType = contentType;
        }
开发者ID:JackFong,项目名称:GenericWcfServiceHostAndClient,代码行数:10,代码来源:JsonSerializer.cs

示例11: WriteObject

        /// <remarks>
        /// DataContractJsonSerializer : XmlObjectSerializer (abstract)
        /// DataContractSerializer : XmlObjectSerializer (abstract)
        /// </remarks>
        private string WriteObject(Location location, XmlObjectSerializer serializer)
        {
            var memoryStream = new System.IO.MemoryStream();

            serializer.WriteObject(memoryStream, location);

            memoryStream.Position = 0;
            var reader = new System.IO.StreamReader(memoryStream);
            var output = reader.ReadToEnd();
            return output;
        }
开发者ID:dennido5,项目名称:70-483,代码行数:15,代码来源:TestClass.cs

示例12: Serialize

        static byte[] Serialize(object result, XmlObjectSerializer serializer)
        {
            byte[] body;
            using (var stream = new MemoryStream())
            {
                serializer.WriteObject(stream, result);
                body = stream.ToArray();
            }

            //hack to remove the type info from the json
            var bodyString = Encoding.UTF8.GetString(body);

            var toReplace = $", {result.GetType().Assembly.GetName().Name}";

            bodyString = bodyString.Replace(toReplace, ", ServiceControl");

            body = Encoding.UTF8.GetBytes(bodyString);
            return body;
        }
开发者ID:Particular,项目名称:ServiceControl.Plugin.Nsb6.Heartbeat,代码行数:19,代码来源:ServiceControlBackend.cs

示例13: DeserializeClaimSet

        public static ClaimSet DeserializeClaimSet(XmlDictionaryReader reader, SctClaimDictionary dictionary, XmlObjectSerializer serializer, XmlObjectSerializer claimSerializer)
        {
            if (reader.IsStartElement(dictionary.NullValue, dictionary.EmptyString))
            {
                reader.ReadElementString();
                return null;
            }
            else if (reader.IsStartElement(dictionary.X509CertificateClaimSet, dictionary.EmptyString))
            {
                reader.ReadStartElement();
                byte[] rawData = reader.ReadContentAsBase64();
                reader.ReadEndElement();
                return new X509CertificateClaimSet(new X509Certificate2(rawData), false);
            }
            else if (reader.IsStartElement(dictionary.SystemClaimSet, dictionary.EmptyString))
            {
                reader.ReadElementString();
                return ClaimSet.System;
            }
            else if (reader.IsStartElement(dictionary.WindowsClaimSet, dictionary.EmptyString))
            {
                reader.ReadElementString();
                return ClaimSet.Windows;
            }
            else if (reader.IsStartElement(dictionary.AnonymousClaimSet, dictionary.EmptyString))
            {
                reader.ReadElementString();
                return ClaimSet.Anonymous;
            }
            else if (reader.IsStartElement(dictionary.ClaimSet, dictionary.EmptyString))
            {
                ClaimSet issuer = null;
                List<Claim> claims = new List<Claim>();
                reader.ReadStartElement();

                if (reader.IsStartElement(dictionary.PrimaryIssuer, dictionary.EmptyString))
                {
                    reader.ReadStartElement();
                    issuer = DeserializeClaimSet(reader, dictionary, serializer, claimSerializer);
                    reader.ReadEndElement();
                }

                while (reader.IsStartElement())
                {
                    reader.ReadStartElement();
                    claims.Add(DeserializeClaim(reader, dictionary, claimSerializer));
                    reader.ReadEndElement();
                }

                reader.ReadEndElement();
                return issuer != null ? new DefaultClaimSet(issuer, claims) : new DefaultClaimSet(claims);
            }
            else
            {
                return (ClaimSet)serializer.ReadObject(reader);
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:57,代码来源:SctClaimSerializer.cs

示例14: ReadHeaderObject

		object ReadHeaderObject (Type type, XmlObjectSerializer serializer, XmlDictionaryReader reader)
		{
			// FIXME: it's a nasty workaround just to avoid UniqueId output as a string.
			// Seealso MessageHeader.DefaultMessageHeader.OnWriteHeaderContents().
			// Note that msg.Headers.GetHeader<UniqueId> () simply fails (on .NET too) and it is useless. The API is lame by design.
			if (type == typeof (UniqueId))
				return new UniqueId (reader.ReadElementContentAsString ());
			else
				return serializer.ReadObject (reader);
		}
开发者ID:pasko,项目名称:mono,代码行数:10,代码来源:BaseMessagesFormatter.cs

示例15: XmlObjectSerializerReadContextComplex

 internal XmlObjectSerializerReadContextComplex(XmlObjectSerializer serializer, int maxItemsInObjectGraph, StreamingContext streamingContext, bool ignoreExtensionDataObject)
     : base(serializer, maxItemsInObjectGraph, streamingContext, ignoreExtensionDataObject)
 {
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:4,代码来源:XmlObjectSerializerReadContextComplex.cs


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