Inheritance: IXmlDictionary
		public override bool TryResolveType(Type type, Type declaredType, DataContractResolver knownTypeResolver,
											out System.Xml.XmlDictionaryString typeName,
											out System.Xml.XmlDictionaryString typeNamespace)
		{

			if (type == null)
				throw new ArgumentNullException("type");
			if (declaredType == null)
				throw new ArgumentNullException("declaredType");
			if (knownTypeResolver == null)
				throw new ArgumentNullException("knownTypeResolver");

			if (knownTypeResolver.TryResolveType(type, declaredType, knownTypeResolver, out typeName, out typeNamespace))
				return true;

			if (type.IsPrimitive && declaredType == typeof(object))
			{
				return knownTypeResolver.TryResolveType(type, type, knownTypeResolver, out typeName, out typeNamespace);
			}

			XmlDictionary dict = new XmlDictionary();

			typeNamespace = dict.Add(xmlNamespace);
			typeName = dict.Add(type.AssemblyQualifiedName);

			return true;
		}
Esempio n. 2
0
 /// <summary>
 /// Override this method to map a data contract type to an xsi:type name and namespace during serialization.
 /// </summary>
 /// <param name="type">The type to map.</param>
 /// <param name="declaredType">The type declared in the data contract.</param>
 /// <param name="knownTypeResolver">The known type resolver.</param>
 /// <param name="typeName">The xsi:type name.</param>
 /// <param name="typeNamespace">The xsi:type namespace.</param>
 /// <returns>
 /// true if mapping succeeded; otherwise, false.
 /// </returns>
 public override bool TryResolveType(Type type, Type declaredType, DataContractResolver knownTypeResolver, out System.Xml.XmlDictionaryString typeName, out System.Xml.XmlDictionaryString typeNamespace)
 {
     if (type == typeof(Tag))
     {
         XmlDictionary dictionary = new XmlDictionary();
         typeName = dictionary.Add("Tag");
         typeNamespace = dictionary.Add(uri);
         return true;
     }
         else if (type == typeof(Entry))
     {
         XmlDictionary dictionary = new XmlDictionary();
         typeName = dictionary.Add("Entry");
         typeNamespace = dictionary.Add(uri);
         return true;
     }
     else if (type == typeof(LinkEntry))
     {
         XmlDictionary dictionary = new XmlDictionary();
         typeName = dictionary.Add("LinkEntry");
         typeNamespace = dictionary.Add(uri);
         return true;
     }
     else if (type == typeof(LinkItem))
     {
         XmlDictionary dictionary = new XmlDictionary();
         typeName = dictionary.Add("LinkItem");
         typeNamespace = dictionary.Add(uri);
         return true;
     }
     else
         return knownTypeResolver.TryResolveType(type, declaredType, knownTypeResolver, out typeName, out typeNamespace);
 }
        // Serialization
        public override bool TryResolveType(Type type, Type declaredType, DataContractResolver knownTypeResolver, out System.Xml.XmlDictionaryString typeName, out System.Xml.XmlDictionaryString typeNamespace)
        {
            Type[] genericTypes = type.GetGenericArguments();

            string ns = string.Empty;
            Type genericType = null;

            foreach (Type genType in genericTypes)
            {
                if (typesByType.ContainsKey(genType) == true)
                {
                    typesByType.TryGetValue(genType, out ns);
                    genericType = genType;
                    break;
                }
            }

            if (string.IsNullOrEmpty(ns) == false)
            {
                XmlDictionary dictionary = new XmlDictionary();
                typeName = dictionary.Add(genericType.Name);
                typeNamespace = dictionary.Add(ns);

                return true;
            }
            else
            {
                return knownTypeResolver.TryResolveType(type, declaredType, null, out typeName, out typeNamespace);
            }
        }
 public Wsrm11Dictionary(XmlDictionary dictionary)
 {
     this.AckRequestedAction = dictionary.Add("http://docs.oasis-open.org/ws-rx/wsrm/200702/AckRequested");
     this.CloseSequence = dictionary.Add("CloseSequence");
     this.CloseSequenceAction = dictionary.Add("http://docs.oasis-open.org/ws-rx/wsrm/200702/CloseSequence");
     this.CloseSequenceResponse = dictionary.Add("CloseSequenceResponse");
     this.CloseSequenceResponseAction = dictionary.Add("http://docs.oasis-open.org/ws-rx/wsrm/200702/CloseSequenceResponse");
     this.CreateSequenceAction = dictionary.Add("http://docs.oasis-open.org/ws-rx/wsrm/200702/CreateSequence");
     this.CreateSequenceResponseAction = dictionary.Add("http://docs.oasis-open.org/ws-rx/wsrm/200702/CreateSequenceResponse");
     this.DiscardFollowingFirstGap = dictionary.Add("DiscardFollowingFirstGap");
     this.Endpoint = dictionary.Add("Endpoint");
     this.FaultAction = dictionary.Add("http://docs.oasis-open.org/ws-rx/wsrm/200702/fault");
     this.Final = dictionary.Add("Final");
     this.IncompleteSequenceBehavior = dictionary.Add("IncompleteSequenceBehavior");
     this.LastMsgNumber = dictionary.Add("LastMsgNumber");
     this.MaxMessageNumber = dictionary.Add("MaxMessageNumber");
     this.Namespace = dictionary.Add("http://docs.oasis-open.org/ws-rx/wsrm/200702");
     this.NoDiscard = dictionary.Add("NoDiscard");
     this.None = dictionary.Add("None");
     this.SequenceAcknowledgementAction = dictionary.Add("http://docs.oasis-open.org/ws-rx/wsrm/200702/SequenceAcknowledgement");
     this.SequenceClosed = dictionary.Add("SequenceClosed");
     this.TerminateSequenceAction = dictionary.Add("http://docs.oasis-open.org/ws-rx/wsrm/200702/TerminateSequence");
     this.TerminateSequenceResponse = dictionary.Add("TerminateSequenceResponse");
     this.TerminateSequenceResponseAction = dictionary.Add("http://docs.oasis-open.org/ws-rx/wsrm/200702/TerminateSequenceResponse");
     this.UsesSequenceSSL = dictionary.Add("UsesSequenceSSL");
     this.UsesSequenceSTR = dictionary.Add("UsesSequenceSTR");
     this.WsrmRequired = dictionary.Add("WsrmRequired");
 }
 public SecureConversationDec2005Dictionary(XmlDictionary dictionary)
 {
     base.SecurityContextToken = dictionary.Add("SecurityContextToken");
     base.AlgorithmAttribute = dictionary.Add("Algorithm");
     base.Generation = dictionary.Add("Generation");
     base.Label = dictionary.Add("Label");
     base.Offset = dictionary.Add("Offset");
     base.Properties = dictionary.Add("Properties");
     base.Identifier = dictionary.Add("Identifier");
     base.Cookie = dictionary.Add("Cookie");
     base.RenewNeededFaultCode = dictionary.Add("RenewNeeded");
     base.BadContextTokenFaultCode = dictionary.Add("BadContextToken");
     base.Prefix = dictionary.Add("sc");
     base.DerivedKeyTokenType = dictionary.Add("http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512/dk");
     base.SecurityContextTokenType = dictionary.Add("http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512/sct");
     base.SecurityContextTokenReferenceValueType = dictionary.Add("http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512/sct");
     base.RequestSecurityContextIssuance = dictionary.Add("http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/SCT");
     base.RequestSecurityContextIssuanceResponse = dictionary.Add("http://docs.oasis-open.org/ws-sx/ws-trust/200512/RSTR/SCT");
     this.RequestSecurityContextRenew = dictionary.Add("http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/SCT/Renew");
     this.RequestSecurityContextRenewResponse = dictionary.Add("http://docs.oasis-open.org/ws-sx/ws-trust/200512/RSTR/SCT/Renew");
     this.RequestSecurityContextClose = dictionary.Add("http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/SCT/Cancel");
     this.RequestSecurityContextCloseResponse = dictionary.Add("http://docs.oasis-open.org/ws-sx/ws-trust/200512/RSTR/SCT/Cancel");
     base.Namespace = dictionary.Add("http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512");
     base.DerivedKeyToken = dictionary.Add("DerivedKeyToken");
     base.Nonce = dictionary.Add("Nonce");
     base.Length = dictionary.Add("Length");
     this.Instance = dictionary.Add("Instance");
 }
        public override bool TryResolveType(Type dataContractType, Type declaredType, DataContractResolver knownTypeResolver, out XmlDictionaryString typeName, out XmlDictionaryString typeNamespace)
        {
            var res = knownTypeResolver.TryResolveType(dataContractType, declaredType, null, out typeName, out typeNamespace);
            if (res)
                return res;
            System.Reflection.Assembly asm = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(p => p == dataContractType.Assembly);
            if (asm != null)
            {
                XmlDictionary dictionary = new XmlDictionary();
                typeName = dictionary.Add(dataContractType.Name);
                typeNamespace = dictionary.Add("http://tempuri.com/" + asm.FullName);
                return true;
            }
            foreach (IPlugin plugin in PluginHelper.plugins.Values)
            {
                if (plugin.GetType().Assembly == dataContractType.Assembly){
                    XmlDictionary dictionary = new XmlDictionary();
                    typeName = dictionary.Add(dataContractType.Name);
                    typeNamespace = dictionary.Add("http://tempuri.com/"+ plugin.Name);
                    return true;
                }
            }

            return false;
        }
Esempio n. 7
0
		static SecureConversationVersion ()
		{
			var dic = new XmlDictionary ();
			WSSecureConversation13 = new SecureConversationVersionImpl () { Prefix = dic.Add ("wsse"), Namespace = dic.Add ("http://schemas.xmlsoap.org/ws/2002/12/secext") };
			WSSecureConversationFeb2005 = new SecureConversationVersionImpl () { Prefix = dic.Add ("wsse"), Namespace = dic.Add ("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd") };
			Default = WSSecureConversation13;
		}
Esempio n. 8
0
		static TrustVersion ()
		{
			var dic = new XmlDictionary ();
			WSTrust13 = new TrustVersionImpl () { Prefix = dic.Add ("wst"), Namespace = dic.Add ("http://docs.oasis-open.org/ws-sx/ws-trust/200512") };
			WSTrustFeb2005 = new TrustVersionImpl () { Prefix = dic.Add ("wsse"), Namespace = dic.Add ("http://schemas.xmlsoap.org/ws/2002/12/secext") };
			Default = WSTrust13;
		}
Esempio n. 9
0
 public InvalidDataContractCriticalHelper(Type type)
     : base(type)
 {
     StableName = DataContract.GetStableName(type);
     _xmlDictionary = new XmlDictionary(2);
     this.Name = this.TopLevelElementName = _xmlDictionary.Add(StableName.Name);
     this.Namespace = this.TopLevelElementNamespace = _xmlDictionary.Add(StableName.Namespace);
 }
Esempio n. 10
0
		public void Empty ()
		{
			XmlDictionary d = new XmlDictionary ();
			XmlDictionaryString dns;
			d.Add (String.Empty);
			Assert.IsTrue (d.TryLookup (String.Empty, out dns), "#0");
			Assert.AreEqual (0, dns.Key, "#1");
		}
Esempio n. 11
0
		public void Add ()
		{
			XmlDictionary d = new XmlDictionary ();
			Assert.AreEqual (0, d.Add ("foo").Key, "#1");
			Assert.AreEqual (0, d.Add ("foo").Key, "#2");
			Assert.AreEqual (1, d.Add ("bar").Key, "#3");
			Assert.AreEqual (2, d.Add ("baz").Key, "#4");
		}
 internal static DataContractSerializer CreateSerializer(Type type, IList<Type> knownTypes, string rootName, string rootNs, int maxItems)
 {
     XmlDictionary dictionary = new XmlDictionary(2);
     return new DataContractSerializer(
         type,
         dictionary.Add(rootName),
         dictionary.Add(rootNs),
         knownTypes);
 }
Esempio n. 13
0
		public void TryAddDuplicate ()
		{
			XmlDictionary dic = new XmlDictionary ();
			XmlDictionaryString d1 = dic.Add ("foo");
			XmlBinaryWriterSession s = new XmlBinaryWriterSession ();
			int idx;
			s.TryAdd (d1, out idx);
			s.TryAdd (d1, out idx);
		}
 private static XmlDictionaryString AddToDictionary(XmlDictionary dictionary, string s)
 {
     XmlDictionaryString str;
     if (!dictionary.TryLookup(s, out str))
     {
         str = dictionary.Add(s);
     }
     return str;
 }
 static DXD()
 {
     XmlDictionary dictionary = new XmlDictionary(0x89);
     atomicTransactionExternal11Dictionary = new System.ServiceModel.AtomicTransactionExternal11Dictionary(dictionary);
     coordinationExternal11Dictionary = new System.ServiceModel.CoordinationExternal11Dictionary(dictionary);
     secureConversationDec2005Dictionary = new System.ServiceModel.SecureConversationDec2005Dictionary(dictionary);
     securityAlgorithmDec2005Dictionary = new System.ServiceModel.SecurityAlgorithmDec2005Dictionary(dictionary);
     trustDec2005Dictionary = new System.ServiceModel.TrustDec2005Dictionary(dictionary);
     wsrm11Dictionary = new System.ServiceModel.Wsrm11Dictionary(dictionary);
 }
 public override bool TryResolveType(Type dataContractType, Type declaredType, DataContractResolver knownTypeResolver, out XmlDictionaryString typeName, out XmlDictionaryString typeNamespace)
 {
     if (!knownTypeResolver.TryResolveType(dataContractType, declaredType, null, out typeName, out typeNamespace))
     {
         XmlDictionary dictionary = new XmlDictionary();
         typeName = dictionary.Add(dataContractType.FullName);
         typeNamespace = dictionary.Add(dataContractType.Assembly.FullName);
     }
     return true;
 }
Esempio n. 17
0
 public NetDataContractSerializer(string rootName, string rootNamespace,
     StreamingContext context,
     int maxItemsInObjectGraph,
     bool ignoreExtensionDataObject,
     FormatterAssemblyStyle assemblyFormat,
     ISurrogateSelector surrogateSelector)
 {
     XmlDictionary dictionary = new XmlDictionary(2);
     Initialize(dictionary.Add(rootName), dictionary.Add(DataContract.GetNamespace(rootNamespace)), context, maxItemsInObjectGraph, ignoreExtensionDataObject, assemblyFormat, surrogateSelector);
 }
 public CoordinationExternal11Dictionary(XmlDictionary dictionary)
 {
     this.Namespace = dictionary.Add("http://docs.oasis-open.org/ws-tx/wscoor/2006/06");
     this.CreateCoordinationContextAction = dictionary.Add("http://docs.oasis-open.org/ws-tx/wscoor/2006/06/CreateCoordinationContext");
     this.CreateCoordinationContextResponseAction = dictionary.Add("http://docs.oasis-open.org/ws-tx/wscoor/2006/06/CreateCoordinationContextResponse");
     this.RegisterAction = dictionary.Add("http://docs.oasis-open.org/ws-tx/wscoor/2006/06/Register");
     this.RegisterResponseAction = dictionary.Add("http://docs.oasis-open.org/ws-tx/wscoor/2006/06/RegisterResponse");
     this.FaultAction = dictionary.Add("http://docs.oasis-open.org/ws-tx/wscoor/2006/06/fault");
     this.CannotCreateContext = dictionary.Add("CannotCreateContext");
     this.CannotRegisterParticipant = dictionary.Add("CannotRegisterParticipant");
 }
Esempio n. 19
0
 /// <summary>
 /// Initializes a new instance of the Message class.
 /// </summary>
 /// <param name="to">The JID of the intended recipient.</param>
 /// <param name="body">The content of the message.</param>
 /// <param name="subject">The subject of the message.</param>
 /// <param name="thread">The conversation thread this message belongs to.</param>
 /// <param name="type">The type of the message. Can be one of the values from
 /// the MessagType enumeration.</param>
 /// <param name="language">The language of the XML character data of
 /// the stanza.</param>
 /// <exception cref="ArgumentNullException">The to parameter is null.</exception>
 /// <exception cref="ArgumentException">The body parameter is the empty string.</exception>
 public Message(Jid to, string body = null, string subject = null, string thread = null,
     MessageType type = MessageType.Normal, CultureInfo language = null)
     : base(to, null, null, null, language)
 {
     to.ThrowIfNull("to");
     AlternateSubjects = new XmlDictionary(element, "subject", "xml:lang");
     AlternateBodies = new XmlDictionary(element, "body", "xml:lang");
     Type = type;
     Body = body;
     Subject = subject;
     Thread = thread;
 }
		public override bool TryResolveType(
			Type type,
			Type declaredType,
			DataContractResolver knownTypeResolver,
			out XmlDictionaryString typeName,
			out XmlDictionaryString typeNamespace)
		{
			var dict = new XmlDictionary();
			typeName = dict.Add(Uri.EscapeDataString(type.FullName).Replace("%", ".."));
			typeNamespace = dict.Add(type.Namespace);
			return true;
		}
Esempio n. 21
0
		public XmlSimpleDictionaryReader (XmlReader reader,
			XmlDictionary dictionary, OnXmlDictionaryReaderClose onClose)
		{
			this.reader = reader;
			this.onClose = onClose;
			as_line_info = reader as IXmlLineInfo;
			as_dict_reader = reader as XmlDictionaryReader;

			if (dictionary == null)
				dictionary = new XmlDictionary ();
			dict = dictionary;
		}
Esempio n. 22
0
		protected override byte [] EncodeSecurityState (byte [] src)
		{
foreach (byte b in src) Console.Write ("{0:X02} ", b); Console.WriteLine ();
			// this show how it is LAMESPEC.
			//Array.Reverse (src);
XmlDictionary dic = new XmlDictionary ();
for (int i = 0; i < 60; i++)
	dic.Add ("n" + i);
XmlDictionaryReaderQuotas quotas =
	new XmlDictionaryReaderQuotas ();
XmlDictionaryReader cr = XmlDictionaryReader.CreateBinaryReader (src, 0, src.Length, dic, quotas);
cr.Read ();
XmlWriter w = XmlWriter.Create (Console.Out);
while (!cr.EOF)
	switch (cr.NodeType) {
	case XmlNodeType.Element:
		int dummy;
		w.WriteStartElement (cr.Prefix, cr.LocalName, cr.NamespaceURI);
		for (int i = 0; i < cr.AttributeCount; i++) {
			cr.MoveToAttribute (i);
			w.WriteStartAttribute (cr.Prefix, cr.LocalName, cr.NamespaceURI);
			bool b64 = cr.LocalName == "n41";
			while (cr.ReadAttributeValue ()) {
				if (b64)
					foreach (byte b in Convert.FromBase64String (cr.Value)) w.WriteString (String.Format ("{0:X02}-", b));
				else
					w.WriteString (cr.Value);
			}
			w.WriteEndAttribute ();
		}
		//w.WriteAttributes (cr, false);
		cr.MoveToElement ();
		if (cr.IsEmptyElement)
			w.WriteEndElement ();
		cr.Read ();
		break;
	case XmlNodeType.EndElement:
		w.WriteEndElement ();
		cr.Read ();
		break;
	default:
		if (cr.TryGetBase64ContentLength (out dummy)) {
			foreach (byte b in cr.ReadContentAsBase64 ()) w.WriteString (String.Format ("{0:X02} ", b));
		}
		else
			w.WriteNode (cr, false);
		break;
	}
w.Close ();

			return src;
		}
Esempio n. 23
0
 private void useCustomStaticDictionaryToolStripMenuItem_Click(object sender, EventArgs e)
 {
     string[] allLines = this.ReadAllLinesFromDialog();
     if (allLines != null)
     {
         XmlDictionary temp = new XmlDictionary();
         this.staticDictionary = temp;
         foreach (string line in allLines)
         {
             temp.Add(line);
         }
     }
 }
Esempio n. 24
0
        public override bool TryResolveType(Type dataContractType, Type declaredType, DataContractResolver knownTypeResolver, out XmlDictionaryString typeName, out XmlDictionaryString typeNamespace)
        {
            if (Identity.ContainsKey(dataContractType))
            {
                var dictionary = new XmlDictionary();
                typeName = dictionary.Add(Identity[dataContractType]);
                typeNamespace = dictionary.Add(dataContractType.FullName);
                return true;
            }

            // Defer to the known type resolver
            return knownTypeResolver.TryResolveType(dataContractType, declaredType, null, out typeName, out typeNamespace);
        }
Esempio n. 25
0
		public void TryAddIndex ()
		{
			XmlDictionary dic = new XmlDictionary ();
			XmlDictionaryString d1 = dic.Add ("foo");
			XmlDictionaryString d2 = dic.Add ("bar");
			XmlDictionaryString d3 = dic.Add ("baz");
			XmlBinaryWriterSession s = new XmlBinaryWriterSession ();
			int idx;
			s.TryAdd (d1, out idx);
			Assert.AreEqual (0, idx, "#1");
			s.TryAdd (d3, out idx);
			Assert.AreEqual (1, idx, "#2"); // not 2
		}
Esempio n. 26
0
		public override bool TryResolveType (Type type, Type declaredType, DataContractResolver knownTypeResolver, out XmlDictionaryString typeName, out XmlDictionaryString typeNamespace)
		{
			var map = serializer.InternalKnownTypes.FindUserMap (type);
			if (map == null) {
				typeName = null;
				typeNamespace = null;
				return false;
			} else {
				dictionary = dictionary ?? new XmlDictionary ();
				typeName = dictionary.Add (map.XmlName.Name);
				typeNamespace = dictionary.Add (map.XmlName.Namespace);
				return true;
			}
		}
        public XmlSimpleDictionaryReader(XmlReader reader,
                                         XmlDictionary dictionary, OnXmlDictionaryReaderClose onClose)
        {
            this.reader    = reader;
            this.onClose   = onClose;
            as_line_info   = reader as IXmlLineInfo;
            as_dict_reader = reader as XmlDictionaryReader;

            if (dictionary == null)
            {
                dictionary = new XmlDictionary();
            }
            dict = dictionary;
        }
Esempio n. 28
0
 public override bool TryResolveType(Type type, Type declaredType, DataContractResolver knownTypeResolver, out XmlDictionaryString typeName, out XmlDictionaryString typeNamespace)
 {
     if (type.Assembly.GetName().Name == DynamicTypeBuilder.AssemblyName)
     {
         XmlDictionary dic = new XmlDictionary();
         typeName = dic.Add(type.Name);
         typeNamespace = dic.Add(ResolverNamespace);
         return true;
     }
     else
     {
         return knownTypeResolver.TryResolveType(type, declaredType, null, out typeName, out typeNamespace);
     }
 }
Esempio n. 29
0
		void DumpXmlBinary (byte [] src)
		{
XmlDictionary dic = new XmlDictionary ();
for (int i = 0; i < 12; i++)
	dic.Add ("n" + i);
XmlDictionaryReaderQuotas quotas =
	new XmlDictionaryReaderQuotas ();
XmlDictionaryReader cr = XmlDictionaryReader.CreateBinaryReader (src, 0, src.Length, dic, quotas);
cr.Read ();
XmlWriter w = XmlWriter.Create (Console.Out);
while (!cr.EOF)
	w.WriteNode (cr, false);
w.Close ();
Console.WriteLine ();
		}
Esempio n. 30
0
 //      These methods are necessary for standard .Net serialisation
 //      For JSon we use different means, have a look in JsonBinSerializer for its custom Json.NET handler.
 public override bool TryResolveType(Type dataContractType, Type declaredType, DataContractResolver knownTypeResolver, out XmlDictionaryString typeName, out XmlDictionaryString typeNamespace)
 {
     if (TypeIdentity.Instance.ContainsKey(dataContractType))
     {
         XmlDictionary dictionary = new XmlDictionary();
         typeName = dictionary.Add(TypeIdentity.Instance[dataContractType].Alias);
         typeNamespace = dictionary.Add(dataContractType.FullName);
         return true; // indicating that this resolver knows how to handle
     }
     else
     {
         // Defer to the known type resolver
         return knownTypeResolver.TryResolveType(dataContractType, declaredType, null, out typeName, out typeNamespace);
     }
 }
        public PrimitiveOperationFormatter(OperationDescription description, bool isRpc)
        {
            if (description == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("description");

            OperationFormatter.Validate(description, isRpc, false/*isEncoded*/);

            this.operation = description;
#pragma warning suppress 56506 // Microsoft, OperationDescription.Messages never be null
            this.requestMessage = description.Messages[0];
            if (description.Messages.Count == 2)
                this.responseMessage = description.Messages[1];

            int stringCount = 3 + requestMessage.Body.Parts.Count;
            if (responseMessage != null)
                stringCount += 2 + responseMessage.Body.Parts.Count;

            XmlDictionary dictionary = new XmlDictionary(stringCount * 2);

            xsiNilLocalName = dictionary.Add("nil");
            xsiNilNamespace = dictionary.Add(System.Xml.Schema.XmlSchema.InstanceNamespace);

            OperationFormatter.GetActions(description, dictionary, out this.action, out this.replyAction);

            if (requestMessage.Body.WrapperName != null)
            {
                requestWrapperName = AddToDictionary(dictionary, requestMessage.Body.WrapperName);
                requestWrapperNamespace = AddToDictionary(dictionary, requestMessage.Body.WrapperNamespace);
            }

            requestParts = AddToDictionary(dictionary, requestMessage.Body.Parts, isRpc);

            if (responseMessage != null)
            {
                if (responseMessage.Body.WrapperName != null)
                {
                    responseWrapperName = AddToDictionary(dictionary, responseMessage.Body.WrapperName);
                    responseWrapperNamespace = AddToDictionary(dictionary, responseMessage.Body.WrapperNamespace);
                }

                responseParts = AddToDictionary(dictionary, responseMessage.Body.Parts, isRpc);

                if (responseMessage.Body.ReturnValue != null && responseMessage.Body.ReturnValue.Type != typeof(void))
                {
                    returnPart = AddToDictionary(dictionary, responseMessage.Body.ReturnValue, isRpc);
                }
            }
        }
Esempio n. 32
0
        // XmlWriterSettings support

        #endregion

        #region Constructors

        public XmlBinaryDictionaryWriter(Stream stream,
                                         IXmlDictionary dictionary,
                                         XmlBinaryWriterSession session, bool ownsStream)
        {
            if (dictionary == null)
            {
                dictionary = new XmlDictionary();
            }
            if (session == null)
            {
                session = new XmlBinaryWriterSession();
            }

            original      = new MyBinaryWriter(stream);
            this.writer   = original;
            buffer_writer = new MyBinaryWriter(buffer);
            this.dict_ext = dictionary;
            this.session  = session;
            owns_stream   = ownsStream;

            AddNamespace("xml", "http://www.w3.org/XML/1998/namespace");
            AddNamespace("xml", "http://www.w3.org/2000/xmlns/");
            ns_index = 2;
        }
 public XmlSimpleDictionaryReader(XmlReader reader,
                                  XmlDictionary dictionary)
     : this(reader, dictionary, null)
 {
 }