コード例 #1
0
 public void LoadFromXml(XmlElement xml)
 {
     CopyMembers = new DatabaseStructureMembers();
     CopyMembers.LoadFromXml_ForJob(xml.FindElement("Members"));
     TableOptions = new TableCopyOptions();
     TableOptions.LoadFromXml(xml.FindElement("TableOptions"));
     foreach (XmlElement tbl in xml.SelectNodes("DataCopyTables/Table"))
     {
         DataCopyTables.Add(NameWithSchema.LoadFromXml(tbl));
     }
     this.LoadPropertiesCore(xml);
 }
コード例 #2
0
 public void LoadFromXml(XmlElement xml)
 {
     TableName = NameWithSchema.LoadFromXml(xml.FindElement("Table"));
     foreach (XmlElement col in xml.SelectNodes("SourceColumn"))
     {
         SourceColumns.Add(col.InnerText);
     }
     foreach (XmlElement col in xml.SelectNodes("ReferenceColumn"))
     {
         ReferenceColumns.Add(col.InnerText);
     }
 }
コード例 #3
0
        private void LoadInternal(XmlElement xml)
        {
            m_dataType = DbTypeBase.Load(xml);
            XmlTool.LoadSpecificAttributes(SpecificData, "colspec.", xml);
            var defval = xml.FindElement("Default");

            if (defval != null)
            {
                m_defaultValue = SqlExpression.Load(defval);
            }
            Domain = NameWithSchema.LoadFromXml(xml, "domain.");
        }
コード例 #4
0
ファイル: DbStructure.cs プロジェクト: janproch/datadmin
        public DomainStructure(XmlElement xml)
            : base(xml)
        {
            //this.LoadProperties(xml);
            SpecificData = XmlTool.LoadParameters(xml);
            FullName     = NameWithSchema.LoadFromXml(xml);
            DataType     = DbTypeBase.Load(xml);
            var defval = xml.FindElement("Default");

            if (defval != null)
            {
                DefaultValue = SqlExpression.Load(defval);
            }
        }
コード例 #5
0
 public void LoadFromXml_ForJob(XmlElement xml)
 {
     if (xml.GetAttribute("table") == "1")
     {
         TableMembers = TableStructureMembers.AllNoRefs;
     }
     if (xml.SelectSingleNode("Table") != null)
     {
         TableFilter = new List <NameWithSchema>();
     }
     foreach (XmlElement x in xml.SelectNodes("Table"))
     {
         TableFilter.Add(NameWithSchema.LoadFromXml(x));
     }
     foreach (XmlAttribute attr in xml.Attributes)
     {
         if (!attr.Name.StartsWith("detail."))
         {
             continue;
         }
         string type = attr.Name.Substring("detail.".Length);
         SpecificObjectOverride[type] = new SpecificObjectMembers();
         SpecificObjectOverride[type].ObjectDetail = true;
     }
     foreach (XmlElement child in xml)
     {
         if (child.Name == "Table")
         {
             continue;
         }
         var repr = SpecificRepresentationAddonType.Instance.FindByElement(child.Name);
         if (repr == null)
         {
             continue;
         }
         if (SpecificObjectOverride[repr.ObjectType] == null)
         {
             SpecificObjectOverride[repr.ObjectType] = new SpecificObjectMembers();
         }
         if (SpecificObjectOverride[repr.ObjectType].ObjectFilter == null)
         {
             SpecificObjectOverride[repr.ObjectType].ObjectFilter = new List <NameWithSchema>();
         }
         SpecificObjectOverride[repr.ObjectType].ObjectFilter.Add(NameWithSchema.LoadFromXml(child));
     }
     this.LoadPropertiesCore(xml);
 }
コード例 #6
0
        public QueryDesignTableFrame(XmlElement xml, QueryDesignFrame frame)
        {
            InitializeComponent();
            Translating.TranslateControl(this);
            m_frame = frame;
            var tbl = new TableStructure(xml.FindElement("Structure"));

            tbl.Parent = new DatabaseStructure();
            foreach (XmlElement rx in xml.SelectNodes("Reference"))
            {
                var fk = new ForeignKey(rx.FindElement("ForeignKey"));
                fk.SetDummyTable(NameWithSchema.LoadFromXml(rx));
                tbl.AddReference(fk);
            }
            m_table = tbl;
            this.LoadPropertiesCore(xml);
            FillData();
        }
コード例 #7
0
ファイル: DbTable.cs プロジェクト: janproch/datadmin
 private void LoadFromXml(XmlElement xml, bool oldStyle)
 {
     LoadBase(xml);
     FullName = NameWithSchema.LoadFromXml(xml);
     if (oldStyle)
     {
         foreach (XmlElement child in xml)
         {
             var cnt = Constraint.FromXml(child, true);
             if (cnt != null)
             {
                 _Constraints.Add(cnt);
             }
             else if (child.Name == "Column")
             {
                 _Columns.Add(new ColumnStructure(child));
             }
         }
     }
     else
     {
         foreach (XmlElement child in xml.SelectNodes("Column"))
         {
             _Columns.Add(new ColumnStructure(child));
         }
         foreach (XmlElement child in xml.SelectNodes("Constraint"))
         {
             _Constraints.Add(Constraint.FromXml(child, false));
         }
     }
     SpecificData = XmlTool.LoadParameters(xml);
     if (xml.FindElement("Comment") != null)
     {
         Comment = xml.FindElement("Comment").InnerText;
     }
     if (xml.FindElement("FixedData") != null)
     {
         FixedData = new InMemoryTable(this, xml.FindElement("FixedData"));
     }
 }
コード例 #8
0
        public override void DisplayProps(Action <string, string> display)
        {
            base.DisplayProps(display);
            var tx = SerializedState.SelectSingleNode("//Table") as XmlElement;

            if (tx != null)
            {
                display("s_table", NameWithSchema.LoadFromXml(tx).ToString());
            }
            var dbx = SerializedState.SelectSingleNode("Database") as XmlElement;

            if (dbx != null && dbx.HasAttribute("dbname"))
            {
                display("s_database", dbx.GetAttribute("dbname"));
            }
            var dsx = SerializedState.SelectSingleNode("DataSource") as XmlElement;

            if (dsx != null)
            {
                display("s_server", dsx.InnerText);
            }
        }
コード例 #9
0
ファイル: DbStructure.cs プロジェクト: janproch/datadmin
        public SpecificObjectStructure(XmlElement xml, string objtype)
            : base(xml)
        {
            this.LoadPropertiesCore(xml);
            ObjectType   = objtype;
            SpecificData = XmlTool.LoadParameters(xml);
            ObjectName   = NameWithSchema.LoadFromXml(xml);
            RelatedTable = NameWithSchema.LoadFromXml(xml, "relschema", "reltable");
            var deps = xml.FindElement("DependsOn");

            if (deps != null)
            {
                DependsOn = new List <DependencyItem>();
                foreach (XmlElement child in deps)
                {
                    var repr = SpecificRepresentationAddonType.Instance.FindByElement(child.Name);
                    DependsOn.Add(new DependencyItem {
                        Name = NameWithSchema.LoadFromXml(child), ObjectType = repr.ObjectType
                    });
                }
            }
        }
コード例 #10
0
 public override void LoadFromXml(XmlElement xml)
 {
     base.LoadFromXml(xml);
     m_table = NameWithSchema.LoadFromXml(xml.FindElement("Table"));
 }
コード例 #11
0
        public static void LoadPropertiesCore(this object o, XmlElement xml)
        {
            if (xml == null)
            {
                return;
            }
            foreach (PropertyInfo prop in o.GetType().GetProperties())
            {
                bool       propHandled = false;
                MethodInfo mtd         = prop.GetSetMethod();
                if (mtd == null)
                {
                    continue;              // not SET method available
                }
                string sval = null;
                foreach (XmlAttribAttribute attr in prop.GetCustomAttributes(typeof(XmlAttribAttribute), true))
                {
                    if (xml.HasAttribute(attr.Name ?? prop.Name))
                    {
                        sval = xml.GetAttribute(attr.Name ?? prop.Name);
                    }
                }
                foreach (XmlElemAttribute attr in prop.GetCustomAttributes(typeof(XmlElemAttribute), true))
                {
                    if (prop.PropertyType == typeof(NameWithSchema))
                    {
                        propHandled = true;
                        var elem = xml.SelectSingleNode(attr.Name ?? prop.Name) as XmlElement;
                        if (elem != null)
                        {
                            prop.CallSet(o, NameWithSchema.LoadFromXml(elem));
                        }
                    }
                    else
                    {
                        if (xml.SelectSingleNode(attr.Name ?? prop.Name) != null)
                        {
                            sval = xml.SelectSingleNode(attr.Name ?? prop.Name).InnerText;
                        }
                    }
                }
                foreach (XmlSubElemAttribute attr in prop.GetCustomAttributes(typeof(XmlSubElemAttribute), true))
                {
                    object subval = prop.CallGet(o);
                    var    elem   = xml.FindElement(attr.Name ?? prop.Name);
                    if (elem != null)
                    {
                        var addon = AddonRegister.Instance.FindAddonType(prop.PropertyType);
                        if (addon != null)
                        {
                            subval = addon.LoadAddon(elem);
                            prop.CallSet(o, subval);
                        }
                        else
                        {
                            if (subval == null)
                            {
                                try
                                {
                                    subval = prop.PropertyType.CreateNewInstance();
                                    prop.CallSet(o, subval);
                                }
                                catch
                                {
                                    subval = null;
                                }
                            }
                            if (subval != null)
                            {
                                LoadProperties(subval, elem);
                            }
                        }
                    }
                }
                foreach (XmlCollectionAttribute attr in prop.GetCustomAttributes(typeof(XmlCollectionAttribute), true))
                {
                    string name = attr.GetElemName(prop);
                    var    lst  = xml.SelectNodes(name);
                    if (lst.Count > 0)
                    {
                        object colval = prop.CallGet(o);
                        if (colval == null)
                        {
                            try
                            {
                                colval = prop.PropertyType.CreateNewInstance();
                                prop.CallSet(o, colval);
                            }
                            catch
                            {
                                colval = null;
                            }
                        }
                        if (colval != null)
                        {
                            var addon = AddonRegister.Instance.FindAddonType(attr.ElemType);

                            foreach (XmlElement elem in lst)
                            {
                                if (attr.ElemType == typeof(string))
                                {
                                    ((IList)colval).Add(elem.InnerText);
                                }
                                else
                                {
                                    object item;
                                    if (addon != null)
                                    {
                                        item = addon.LoadAddon(elem);
                                    }
                                    else
                                    {
                                        item = attr.ElemType.CreateNewInstance();
                                        item.LoadProperties(elem);
                                    }
                                    ((IList)colval).Add(item);
                                }
                            }
                        }
                    }
                }
                if (propHandled)
                {
                    continue;
                }
                object val = PropertyFromString(prop, sval);
                if (val != null)
                {
                    mtd.Invoke(o, new object[] { val });
                }
            }
        }