Пример #1
0
        public CremaDataSet Filter(CremaDataSet srcDataSet, CremaDataSet destDataSet, TagInfo tags)
        {
            CremaDataTable parentDestDataTable = null;

            if (this.Parent != null)
            {
                parentDestDataTable = new CremaDataTable(this.ParentName, this.Parent.CategoryPath);
                destDataSet.Tables.Add(parentDestDataTable);
            }

            var destDataTable = new CremaDataTable(this.TableName, this.CategoryPath);

            destDataSet.Tables.Add(destDataTable);
            destDataTable.Parent = parentDestDataTable;

            foreach (var column in this.Columns)
            {
                if ((column.DerivedTags & tags) != TagInfo.Unused)
                {
                    var newColumn = new CremaDataColumn(column.ColumnName, column.DataType);
                    destDataTable.Columns.Add(newColumn);
                }
            }

            var columns = destDataTable.Columns.ToArray();

            foreach (var row in this.Rows)
            {
                if ((row.DerivedTags & tags) == TagInfo.Unused)
                {
                    continue;
                }

                destDataTable.AddRow(row.Filter(columns, tags));
            }

            return(destDataSet);
        }
Пример #2
0
        protected override void OnValidateSetColumnName(string value)
        {
            base.OnValidateSetColumnName(value);

            var dataTable = this.Table;

            if (dataTable == null && string.IsNullOrEmpty(value) == false && CremaDataSet.VerifyName(value) == false)
            {
                throw new ArgumentException(Resources.Exception_InvalidName);
            }
            if (dataTable != null && value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }
            if (dataTable != null && CremaDataSet.VerifyName(value) == false)
            {
                throw new ArgumentException(Resources.Exception_InvalidName);
            }
            if (dataTable != null && dataTable.ChildItems.Where(item => item.LocalName == value).Any() == true)
            {
                throw new ArgumentException($"{value} 은(는) 자식 테이블의 이름으로 사용되고 있으므로 사용할 수 없습니다.");
            }
        }
Пример #3
0
 internal static string GetTypeName(CremaDataSet dataSet, string typeNamespace)
 {
     return(InternalDataSet.GetTypeName((InternalDataSet)dataSet, typeNamespace));
 }
Пример #4
0
 internal static string GetTableCategoryPath(CremaDataSet dataSet, string tableNamespace)
 {
     return(InternalDataSet.GetTableCategoryPath((InternalDataSet)dataSet, tableNamespace));
 }
Пример #5
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)));
            }
        }
Пример #6
0
 public CremaDataTable CopyTo(CremaDataSet dataSet)
 {
     return(this.CopyToCore(dataSet, true));
 }
Пример #7
0
 public CremaDataTable CloneTo(CremaDataSet dataSet)
 {
     return(this.CopyToCore(dataSet, false));
 }
Пример #8
0
        public static CremaTemplate Create(CremaDataSet dataSet, string tableName, string categoryPath)
        {
            var dataTable = dataSet.Tables.Add(tableName, categoryPath);

            return(new CremaTemplate(dataTable));
        }
Пример #9
0
 public InternalDataSet(CremaDataSet target, string dataSetName)
     : base(dataSetName)
 {
     base.Target    = target;
     this.Namespace = CremaSchema.BaseNamespace;
 }