Example #1
0
 internal static string GetTableCategoryPath(CremaDataSet dataSet, string tableNamespace)
 {
     return(InternalDataSet.GetTableCategoryPath((InternalDataSet)dataSet, tableNamespace));
 }
Example #2
0
 internal static string GetTableCategoryPath(string baseNamespace, string tableNamespace)
 {
     return(InternalDataSet.GetTableCategoryPath(baseNamespace, tableNamespace));
 }
Example #3
0
        private CremaDataTable CopyToCore(CremaDataSet dataSet, bool copyData)
        {
            this.ValidateCopyTo(dataSet);

            var columns = EnumerableUtility.Friends(this, this.Childs).SelectMany(item => item.columns);

            foreach (var item in columns)
            {
                var dataType = item.CremaType;
                if (dataType == null)
                {
                    continue;
                }

                if (dataSet.Types.Contains(dataType.TypeName, dataType.CategoryPath) == false)
                {
                    dataType.CopyTo(dataSet);
                }
            }

            var schemaWriter = GetSchemaWriter();
            var action       = new Func <string>(() =>
            {
                using (var sw = new Utf8StringWriter())
                {
                    schemaWriter.Write(sw);
                    return(sw.ToString());
                }
            });

            var schema = action();
            var xml    = copyData == true?this.GetXml() : null;

            var itemName = new ItemName(this.CategoryPath, this.Name);

            dataSet.ReadXmlSchemaString(schema, itemName);
            if (xml != null)
            {
                dataSet.ReadXmlString(xml, itemName);
            }

            var targetTable = dataSet.Tables[this.Name, this.CategoryPath];

            if (this.TemplateNamespace != string.Empty)
            {
                targetTable.AttachTemplatedParent(this.TemplateNamespace);
            }

            return(targetTable);

            CremaSchemaWriter GetSchemaWriter()
            {
                if (this.TemplatedParent != null)
                {
                    return(new CremaSchemaWriter(this.TemplatedParent));
                }
                if (this.TemplateNamespace == string.Empty)
                {
                    return(new CremaSchemaWriter(this));
                }
                var t1 = InternalDataSet.GetTableName((InternalDataSet)this.DataSet, this.TemplateNamespace);
                var c1 = InternalDataSet.GetTableCategoryPath((InternalDataSet)this.DataSet, this.TemplateNamespace);

                return(new CremaSchemaWriter(this, new ItemName(c1, t1)));
            }
        }