Example #1
0
 public virtual void Load(string PhysicalPath, List <string> CustomAttributes)
 {
     _PhysicalPath = PhysicalPath;
     try
     {
         foreach (string sDirName in System.IO.Directory.GetDirectories(PhysicalPath))
         {
             try
             {
                 PropertyInfo pInfo = this.GetType().GetProperty("Item");
                 ISbnObject   sbn   = (ISbnObject)Activator.CreateInstance(pInfo.PropertyType);
                 sbn.Load(sDirName, CustomAttributes);
                 this.Add((T)sbn);
             }
             catch (Exception ex)
             {
             }
             ///((SbnListObject<T>)this).Add(sbn);//.Add((T)sbn);
         }
         return;
     }
     catch (Exception ex)
     {
         Console.Write(PhysicalPath + " " + ex.Message);
         throw;
     }
     return;
 }
Example #2
0
        public virtual void Load(string PhysicalPath, List <string> CustomAttributes)
        {
            try
            {
                if (!System.IO.Directory.Exists(PhysicalPath))
                {
                    return;
                }

                string sLocation = PhysicalPath;

                _PhysicalPath = sLocation;

                //this._InitialAndLoadMode = true;

                XMLParser xmlpars = new XMLParser();
                xmlpars.load(_PhysicalPath + "\\BaseValues.xml");

                this.InitializeFromXML(xmlpars.documentElement.xml, this.GetType().ToString(), CustomAttributes);

                List <PropertyInfo> pInfos = Methods.GetBrowsableAttributes(this.GetType());

                foreach (PropertyInfo pInfo in pInfos)
                {
                    try {
                        if (CustomAttributes != null && CustomAttributes.Contains(pInfo.Name))
                        {
                        }
                        else
                        {
                            Type dtype = pInfo.PropertyType;

                            if (dtype != typeof(string) && dtype != typeof(System.Byte[]) && dtype != typeof(System.Guid) &&
                                dtype != typeof(System.Int64) && dtype != typeof(System.Int32) &&
                                dtype != typeof(SbnBoolean) &&
                                dtype != typeof(RequestArgs) &&
                                dtype != typeof(SbnOwnershipDomain))
                            {
                                if (dtype.Name == "ISbnObject")
                                {
                                    if (System.IO.Directory.Exists(_PhysicalPath + "\\" + pInfo.Name))
                                    {
                                        IXMLDOMNode dNode = this.XMLParser.GetNode((IXMLDOMNode)this.XMLParser.XMLBaseNode, pInfo.Name);

                                        string sNameSpace  = this.XMLParser.GetAttributeValue((IXMLDOMElement)dNode, 0);
                                        string sObjectType = this.XMLParser.GetAttributeValue((IXMLDOMElement)dNode, 1);
                                        string sLocation1  = this.GetType().Assembly.Location;
                                        sLocation1 = sLocation1.Replace(this.GetType().Assembly.ManifestModule.Name, "");

                                        Assembly asb = Assembly.LoadFile(sLocation1 + sNameSpace);

                                        object obj = asb.CreateInstance(sObjectType);

                                        try {
                                            ((ISbnObject)obj).Load(_PhysicalPath + "\\" + pInfo.Name, CustomAttributes);

                                            pInfo.SetValue(this, obj, null);
                                        }
                                        catch (Exception ex)
                                        {
                                        }
                                    }
                                }
                                else
                                {
                                    if (System.IO.Directory.Exists(_PhysicalPath + "\\" + pInfo.Name))
                                    {
                                        if (dtype.BaseType.Name.Contains("SbnListObject"))
                                        {
                                            //string sLocation1 = this.GetType().Assembly.Location;
                                            //sLocation1 = sLocation1.Replace(this.GetType().Assembly.ManifestModule.Name, "");

                                            //Assembly asb = Assembly.LoadFile(sLocation1 + "\\" + dtype.Assembly.ManifestModule.Name);

                                            //object obj = asb.CreateInstance(dtype.FullName);

                                            try {
                                                ISbnObject iSbn = (ISbnObject)Activator.CreateInstance(dtype);
                                                iSbn.Load(_PhysicalPath + "\\" + pInfo.Name, CustomAttributes);
                                                pInfo.SetValue(this, iSbn, null);
                                            }
                                            catch (Exception ex)
                                            {
                                            }
                                        }
                                        else
                                        {
                                            try {
                                                ISbnObject iSbn = (ISbnObject)Activator.CreateInstance(dtype);
                                                iSbn.Load(_PhysicalPath + "\\" + pInfo.Name, CustomAttributes);

                                                pInfo.SetValue(this, iSbn, null);
                                            }
                                            catch (Exception ex)
                                            {
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                    //Type tObj = typeof(ISbnObject);
                }

                xmlpars = null;

                return;
            }
            catch (Exception ex)
            {
                Console.Write(PhysicalPath);
                throw;
            }
            return;
        }