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; }
public SbnListPropertyDescriptorCollection(ISbnObject coll, object obj, int idx) : base("#" + idx.ToString(), null) { this.collection = coll; this.index = idx; this._Obj = (SbnObject )obj; }
public virtual void InitializeFromXML(string sXML, string sNodeName, List <string> pattern) { try { this.XMLParser = new XMLParser(sNodeName); this.XMLParser.loadXML(sXML); if (this.XMLParser.documentElement == null) { } this.XMLParser.XMLBaseNode = this.XMLParser.documentElement; if (this.XMLParser.XMLBaseNode == null) { } if (sNodeName == null) { if (((IXMLDOMNode)this.XMLParser.XMLBaseNode).firstChild != null) { sNodeName = ((IXMLDOMNode)this.XMLParser.XMLBaseNode).firstChild.nodeName; } } bool bNext = false; if (((IXMLDOMNode)this.XMLParser.XMLBaseNode).selectSingleNode(sNodeName) != null) { this.XMLParser.NextSiblingNode = ((IXMLDOMNode)this.XMLParser.XMLBaseNode).selectSingleNode(sNodeName); bNext = true; PropertyInfo pInfo = this.GetType().GetProperty("Item"); ISbnObject sbn = (ISbnObject)Activator.CreateInstance(pInfo.PropertyType); // SbnBinary attachment = new SbnBinary(); ((SbnObject)sbn).XMLParser = new XMLParser(sNodeName); ((SbnObject)sbn).XMLParser.XMLBaseNode = ((IXMLDOMNode)this.XMLParser.XMLBaseNode).selectSingleNode(sNodeName); while (bNext) { bNext = false; ((SbnObject)sbn).InitializeFromXML(null, sNodeName, pattern); this.Add((T)sbn); if (this.XMLParser.NextSiblingNode != null) { sbn = (ISbnObject)Activator.CreateInstance(pInfo.PropertyType); ((SbnObject)sbn).XMLParser = new XMLParser(sNodeName); ((SbnObject)sbn).XMLParser.XMLBaseNode = this.XMLParser.NextSiblingNode; this.XMLParser.NextSiblingNode = this.XMLParser.NextSiblingNode; bNext = true; } } } return; } catch { throw; } return; }
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; }