// [....], this could be simplified if we used generics.
            internal static void ConvertExtensions(WsdlNS.ServiceDescriptionFormatExtensionCollection extensions, EnvelopeVersion version, ConvertExtension conversionMethod)
            {
                bool foundOne = false;

                for (int i = extensions.Count - 1; i >= 0; i--)
                {
                    object o = extensions[i];
                    if (conversionMethod(ref o, version))
                    {
                        if (o == null)
                        {
                            extensions.Remove(extensions[i]);
                        }
                        else
                        {
                            extensions[i] = o;
                        }
                        foundOne = true;
                    }
                }

                if (!foundOne)
                {
                    object o = null;
                    conversionMethod(ref o, version);
                    if (o != null)
                    {
                        extensions.Add(o);
                    }
                }
            }
		public void Find ()
		{
			ServiceDescriptionFormatExtensionCollection c =
				new ServiceDescriptionFormatExtensionCollection (new ServiceDescription ());
			c.Add (new MySoapBinding ());
			Assert.IsNotNull (c.Find (typeof (SoapBinding)));
		}
		public void Add ()
		{
			ServiceDescriptionFormatExtensionCollection c =
				new ServiceDescriptionFormatExtensionCollection (new ServiceDescription ());

			c.Add (0);
		}
		public void Add2 ()
		{
			ServiceDescriptionFormatExtensionCollection c =
				new ServiceDescriptionFormatExtensionCollection (new ServiceDescription ());

			c.Add (new XmlDocument ().CreateElement ("foo"));
		}
Example #5
0
        internal static void ReadExtension(XmlDocument doc, XmlReader reader, object ob)
        {
            ServiceDescriptionFormatExtensionCollection extensions = ExtensionManager.GetExtensionPoint(ob);

            if (extensions != null)
            {
                ExtensionInfo info = ExtensionManager.GetFormatExtensionInfo(reader.LocalName, reader.NamespaceURI);
                if (info != null)
                {
                    object extension = info.Serializer.Deserialize(reader);
                    extensions.Add((ServiceDescriptionFormatExtension)extension);
                    return;
                }
            }

            //No XmlFormatExtensionPoint attribute found

#if NET_2_0
            //Add to DocumentableItem.Extensions property
            DocumentableItem item = ob as DocumentableItem;
            if (item == null)
            {
                reader.Skip();
                return;
            }

            item.Extensions.Add(doc.ReadNode(reader));
#else
            reader.Skip();
#endif
        }