/// <summary>Generates the output XSD/WSDL schemas from the input BPL classes.</summary> /// <returns>The generated <see cref="Output"/>.</returns> public ReadOnlyDictionary<string, XDocument> Generate() { _schemas = new List<XNamespace>(); _imports = new DictionarySet<XNamespace, XNamespace>(); _services = new DictionarySet<BplService, BplOperation>(); _classes = new HashSet<BplClass>(); _containers = new Dictionary<BplClass, ContainerFlags>(); _primitives = new HashSet<BplPrimitive>(); _coreSchema = BplLanguage.Schemas["sys"]; if (_coreSchema == null || !_coreSchema.NamespaceName.StartsWith("urn:Mpcr.Core?")) { throw new InvalidOperationException("BPL core schema was not found"); } _modelSchema = BplLanguage.Schemas["bpl"]; if (_modelSchema == null || !_modelSchema.NamespaceName.StartsWith("urn:Mpcr.Model?")) { throw new InvalidOperationException("BPL model schema was not found"); } _addPrimitive(BplPrimitive.Get<BplIdentity>()); _addPrimitive(BplPrimitive.Get<BplArray<BplIdentity>>()); // scan metadata of all input classes foreach (var bplClass in Input) { _addClass(bplClass); var operation = bplClass.Operation; if (operation != null) { _services.Add(operation.Service, operation); if (operation.Output != null) { _addClass(operation.Output); } if (operation.Failures != null) { foreach (var failure in operation.Failures) { _addClass(failure); } } } } _output = new Dictionary<string, XDocument>(); // generate primary XSD schemas var primarySchemas = CreateSchemaSet(_schemas); foreach (var ns in primarySchemas) { var xsd = _generateXSD(ns); if (xsd != null) { _output.Add(FormatFileName(ns, ".xsd"), xsd); } } // generate secondary XSD schemas (i.e., indirectly-used by primary schemas) var secondarySchemas = CreateSchemaSet(_imports.Values); foreach (var ns in secondarySchemas.Except(primarySchemas)) { var xsd = _generateXSD(ns); if (xsd != null) { _output.Add(FormatFileName(ns, ".xsd"), xsd); } } // generate WSDL schemas if (IsWSDL) { foreach (var service in _services.Keys.Where(s => !s.IsAbstract)) { var wsdl = _generateWSDL(service); _output.Add(FormatFileName(service.Urn, ".wsdl"), wsdl); } } Output = new ReadOnlyDictionary<string, XDocument>(_output); return Output; }
private bool InitData(string filename) { try { Config parser = new Config(filename,true); searchSet = parser.GetSearchd(); sourceList = parser.GetSourceList(); indexList = parser.GetIndexList(); dictSet = parser.GetDictionarySet(); indexerSet = parser.GetIndexer(); fileSet = parser.FileIndexSet; return true; } catch (Exception ex) { #if DEBUG Console.WriteLine(string.Format("Exception for open file {0},{1}", filename, ex.ToString())); #endif ShowError(string.Format("Exception for open file {0},{1}", filename, ex.ToString())); return false; } }
public void TestDictionaries() { Run(DictionarySet.Create(1), x => new DTO.DictionarySet(x)); }