Exemple #1
0
        private void ReadMany(Dictionary <string, string> items)
        {
            var typeSchemas = items.Keys.Where(item => item.StartsWith(this.TypeNamespace)).ToArray();

            Parallel.ForEach(typeSchemas, item =>
            {
                this.ReadTypeString(items[item]);
            });

            var tableSchemas = items.Keys.Where(item => item.StartsWith(this.TableNamespace) && item.EndsWith(CremaSchema.SchemaExtension)).ToArray();

            Parallel.ForEach(tableSchemas, item =>
            {
                var schema = items[item];

                if (schema.StartsWith(this.TableNamespace) == true)
                {
                    var ns           = item.Remove(item.Length - CremaSchema.SchemaExtension.Length);
                    var tableName    = CremaDataSet.GetTableName(this, ns);
                    var categoryPath = CremaDataSet.GetTableCategoryPath(this, ns);
                    schema           = items[schema + CremaSchema.SchemaExtension];
                    this.ReadXmlSchemaString(schema, new ItemName(categoryPath, tableName));
                }
                else
                {
                    this.ReadXmlSchemaString(schema);
                }
            });

            var tableXmls = items.Keys.Where(item => item.StartsWith(this.TableNamespace) && item.EndsWith(CremaSchema.XmlExtension))
                            .OrderBy(item => item.Length)
                            .ToList();

            var threadcount = 8;
            var query       = from item in tableXmls
                              let key = tableXmls.IndexOf(item) % threadcount
                                        group item by key into g
                                        select g;

            var parallellist = new List <string>(tableXmls.Count);

            foreach (var item in query)
            {
                parallellist.AddRange(item);
            }

            this.BeginLoad();
            Parallel.ForEach(parallellist, new ParallelOptions {
                MaxDegreeOfParallelism = threadcount
            }, item =>
            {
                var ns           = item.Remove(item.Length - CremaSchema.XmlExtension.Length);
                var tableName    = CremaDataSet.GetTableName(this, ns);
                var categoryPath = CremaDataSet.GetTableCategoryPath(this, ns);
                var xml          = items[item];
                this.ReadXmlString(xml, new ItemName(categoryPath, tableName));
            });
            this.EndLoad();
            //this.AcceptChanges();
        }
Exemple #2
0
        internal string GetXmlPath(string targetNamespace)
        {
            var baseNamespace = this.DataSet != null ? this.DataSet.Namespace : CremaSchema.BaseNamespace;

            if (targetNamespace == this.Namespace || targetNamespace == baseNamespace)
            {
                return(this.Name);
            }

            if (this.TemplateNamespace != string.Empty)
            {
                if (this.Parent == null)
                {
                    return(CremaDataSet.GetTableName(this.DataSet, this.TemplateNamespace));
                }
                return(CremaDataSet.GetTableName(this.DataSet, this.TemplateNamespace));
            }

            return(this.Name);
        }