Ejemplo n.º 1
0
        public void AddSchemasToContract(NameValueCollection schemasAndLocations, string workingFolder, string projectRootFolder)
        {
            //TODO:(SB): Will need to have a way to add header and message schemas separately
            string    schemaNamespace          = String.Empty;
            ArrayList importedSchemaNamespaces = new ArrayList();


            // Add the selected schemas to the ServiceInterfaceContract.Imports collection.
            foreach (string key in schemasAndLocations.Keys)
            {
                string    schemaName     = key;
                string    schemaLocation = schemasAndLocations[key];
                ArrayList result;
                // Read the content of the imported files and add them to the local arrays for UI.
                result = SchemaUtility.GetSchemasFromXsd(schemaLocation, out schemaNamespace);

                if (schemaNamespace != null)
                {
                    importedSchemaNamespaces.Add(schemaNamespace.ToLower());
                }
                MessageSchemas.AddRange((List <SchemaElement>)result[1]);
                HeaderSchemas.AddRange((List <SchemaElement>)result[1]);

                SchemaImport si = new SchemaImport(schemaLocation, schemaName, schemaNamespace, workingFolder, projectRootFolder);

                this.Imports.Add(si);
            }

            // Import the embedded types.
            //ImportEmbeddedTypes();

            // Check for the messages count found in the imported files and alert the user if no messages
            // are found.
            if (MessageSchemas.Count < 1)
            {
                throw new Exception("There are no elements in this XSD to use as operation messages.");
            }
        }