Example #1
0
        /// <include file='doc\ServiceDescriptionReflector.uex' path='docs/doc[@for="ServiceDescriptionReflector.Reflect"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public void Reflect(Type type, string url)
        {
            serviceType = type;
            serviceUrl  = url;

            serviceAttr = WebServiceReflector.GetAttribute(type);

            methods = WebMethodReflector.GetMethods(type);
            CheckForDuplicateMethods(methods);

            descriptionsWithPost = descriptions;
            schemasWithPost      = schemas;

            if (reflectorsWithPost != null)
            {
                ReflectInternal(reflectorsWithPost);

                descriptions = new ServiceDescriptionCollection();
                schemas      = new XmlSchemas();
            }

            ReflectInternal(reflectors);

            if (serviceAttr.Description != null && serviceAttr.Description.Length > 0)
            {
                ServiceDescription.Documentation = serviceAttr.Description;
            }

            // need to preprocess all exported schemas to make sure that IXmlSerializable schemas are Merged and the resulting set is valid
            ServiceDescription.Types.Schemas.Compile(null, false);

            if (ServiceDescriptions.Count > 1)
            {
                // if defining interfaces, we move all schemas to the external collection
                // since the types therein may be referenced from any of the sdls
                Schemas.Add(ServiceDescription.Types.Schemas);
                ServiceDescription.Types.Schemas.Clear();
            }
            else if (ServiceDescription.Types.Schemas.Count > 0)
            {
                XmlSchema[] descriptionSchemas = new XmlSchema[ServiceDescription.Types.Schemas.Count];
                ServiceDescription.Types.Schemas.CopyTo(descriptionSchemas, 0);
                foreach (XmlSchema schema in descriptionSchemas)
                {
                    // we always move dataset schemas to the external schema's collection.
                    if (XmlSchemas.IsDataSet(schema))
                    {
                        ServiceDescription.Types.Schemas.Remove(schema);
                        Schemas.Add(schema);
                    }
                }
            }
        }
Example #2
0
        /// <include file='doc\ServiceDescriptionReflector.uex' path='docs/doc[@for="ServiceDescriptionReflector.Reflect"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public void Reflect(Type type, string url)
        {
            serviceType = type;
            serviceUrl  = url;

            serviceAttr = WebServiceReflector.GetAttribute(type);

            methods = WebMethodReflector.GetMethods(type);
            CheckForDuplicateMethods(methods);

            descriptionsWithPost = descriptions;
            schemasWithPost      = schemas;

            if (reflectorsWithPost != null)
            {
                ReflectInternal(reflectorsWithPost);

                descriptions = new ServiceDescriptionCollection();
                schemas      = new XmlSchemas();
            }

            ReflectInternal(reflectors);

            XmlSchema[] descriptionSchemas = new XmlSchema[ServiceDescription.Types.Schemas.Count];
            ServiceDescription.Types.Schemas.CopyTo(descriptionSchemas, 0);
            // if defining interfaces, we move all schemas to the external collection
            // since the types therein may be referenced from any of the sdls
            bool externalizeSchemas = ServiceDescriptions.Count > 1;

            foreach (XmlSchema schema in descriptionSchemas)
            {
                // we always move dataset schemas to the external schema's collection.
                if (externalizeSchemas || XmlSchemas.IsDataSet(schema))
                {
                    ServiceDescription.Types.Schemas.Remove(schema);
                    Schemas.Add(schema);
                }
            }
        }