public SbnListPropertyDescriptorCollection(ISbnObject coll, object obj, int idx) : base("#" + idx.ToString(), null) { this.collection = coll; this.index = idx; this._Obj = (SbnObject )obj; }
//#region INotifyPropertyChanged Members //public event PropertyChangedEventHandler PropertyChanged; //public void NotifyPropertyChanged(String info) //{ // if (PropertyChanged != null) // { // PropertyChanged(this, new PropertyChangedEventArgs(info)); // } //} //#endregion public virtual void Initialize(ref SbnObject sbnObject) { sbnObject.ID = this.ID; if (this.AliasCode != null) { sbnObject.AliasCode = (string)this.AliasCode.Clone(); } if (this.Title != null) { sbnObject.Title = (string)this.Title.Clone(); } if (this.Description != null) { sbnObject.Description = (string)this.Description.Clone(); } sbnObject.IsActive = this.IsActive; if (this.RegistrationDate != null) { sbnObject.RegistrationDate = (string)this.RegistrationDate.Clone(); } if (this.LastEditionDate != null) { sbnObject.LastEditionDate = (string)this.LastEditionDate.Clone(); } }
public SbnObject(SbnObject InitialObject) { this.ID = InitialObject.ID; this.IsActive = InitialObject.IsActive; if (InitialObject.LastEditionDate != null) { this.LastEditionDate = (string)InitialObject.LastEditionDate.Clone(); } if (InitialObject.RegistrationDate != null) { this.RegistrationDate = (string)InitialObject.RegistrationDate.Clone(); } if (InitialObject.Title != null) { this.Title = (string)InitialObject.Title.Clone(); } if (InitialObject.Description != null) { this.Description = (string)InitialObject.Description.Clone(); } }
public virtual string GetXML(string sNodeName) { try { if (sNodeName == null) { sNodeName = GetType().Name; } this.XMLParser = new XMLParser(sNodeName); this.XMLParser.AddAttribute("AssemblyName", this.GetType().Assembly.ManifestModule.Name, (IXMLDOMElement)this.XMLParser.documentElement); this.XMLParser.AddAttribute("ObjectType", this.GetType().Name, (IXMLDOMElement)this.XMLParser.documentElement); List <PropertyInfo> pInfos = Methods.GetBrowsableAttributes(this.GetType()); foreach (PropertyInfo pInfo in pInfos) { //Type tObj = typeof(ISbnObject); object val = pInfo.GetValue(this, null); if (!object.ReferenceEquals(val, null)) { IXMLDOMNode node = null; Type type = val.GetType(); if (type == typeof(string)) { node = this.XMLParser.AddChildFromString(pInfo.Name, (string)val, this.XMLParser.documentElement); } else if (type == typeof(System.Byte[])) { if (!_bSaveMode) { node = this.XMLParser.AddChildFromString(pInfo.Name, "", this.XMLParser.documentElement); node.set_dataType("bin.base64"); string attach = Convert.ToBase64String((byte[])val); node.nodeTypedValue = attach; } else { node = this.XMLParser.AddChildFromString(pInfo.Name, _PhysicalPath + "\\" + pInfo.Name + ".dat", this.XMLParser.documentElement); if (!System.IO.Directory.Exists(_PhysicalPath)) { System.IO.Directory.CreateDirectory(_PhysicalPath); } System.IO.StreamWriter sw = new System.IO.StreamWriter(_PhysicalPath + "\\" + pInfo.Name + ".dat"); sw.BaseStream.Write((byte[])val, 0, (int)((byte[])val).Length); sw.Close(); } } else if (type == typeof(System.Guid)) { node = this.XMLParser.AddChildFromString(pInfo.Name, ((Guid)val).ToString(), this.XMLParser.documentElement); } else if (type == typeof(System.Int64) || type == typeof(System.Int32)) { node = this.XMLParser.AddChildFromString(pInfo.Name, val.ToString(), this.XMLParser.documentElement); } else if (type.BaseType == typeof(SbnBinary)) { if (!_bSaveMode) { try { ((SbnObject)val).GetXML(pInfo.Name); if (((SbnObject)val).XMLParser != null && ((SbnObject)val).XMLParser.documentElement != null) { node = this.XMLParser.AddChildFromNode(((SbnObject)val).XMLParser.documentElement, this.XMLParser.documentElement); } } catch (Exception ex) { string sError = ex.Message; node = this.XMLParser.AddChildFromString(pInfo.Name, sError, this.XMLParser.documentElement); } } } else if (type.BaseType == typeof(SbnObject)) { if (!_bSaveMode) { try { ((SbnObject)val).GetXML(pInfo.Name); if (((SbnObject)val).XMLParser != null && ((SbnObject)val).XMLParser.documentElement != null) { node = this.XMLParser.AddChildFromNode(((SbnObject)val).XMLParser.documentElement, this.XMLParser.documentElement); } } catch (Exception ex) { string sError = ex.Message; node = this.XMLParser.AddChildFromString(pInfo.Name, sError, this.XMLParser.documentElement); } } } else if (type.BaseType.Name.Contains("SbnListObject")) { if (!_bSaveMode) { try { node = this.XMLParser.AddChildFromString(pInfo.Name, "", this.XMLParser.documentElement); Type valType = val.GetType(); object countItems = valType.InvokeMember("Count", BindingFlags.GetProperty, null, val, null); for (int i = 0; i < (int)countItems; i++) { object[] objChildItem = new object[1]; objChildItem[0] = i; object objItem = valType.InvokeMember("GetItem", BindingFlags.InvokeMethod, null, val, objChildItem); SbnObject OutObj = (SbnObject)objItem; OutObj.GetXML(null); this.XMLParser.AddChildFromNode(OutObj.XMLParser.documentElement, node); } /* commented by ghmhm 930512 * if (((SbnObject)val).XMLParser != null && ((SbnObject)val).XMLParser.documentElement != null) * node = this.XMLParser.AddChildFromNode(((SbnObject)val).XMLParser.documentElement, this.XMLParser.documentElement); */ } catch (Exception ex) { string sError = ex.Message; node = this.XMLParser.AddChildFromString(pInfo.Name, sError, this.XMLParser.documentElement); } } } else if (type.BaseType == typeof(Enum)) { node = this.XMLParser.AddChildFromString(pInfo.Name, val.ToString(), this.XMLParser.documentElement); } if (node != null) { this.XMLParser.AddAttribute("SystemDataType", type.ToString(), (IXMLDOMElement)node); } else { if (pInfo.PropertyType.Name == "ISbnObject") { node = this.XMLParser.AddChildFromString(pInfo.Name, "", this.XMLParser.documentElement); this.XMLParser.AddAttribute("AssemblyName", type.Assembly.ManifestModule.Name, (IXMLDOMElement)node); this.XMLParser.AddAttribute("SystemDataType", type.ToString(), (IXMLDOMElement)node); } } } } //this.XMLParser.AddChildFromString("UID", this._Uid.ToString(), this.XMLParser.documentElement); //this.XMLParser.AddChildFromString("ID", this._ID.ToString(), this.XMLParser.documentElement); //if (this._Description != null) this.XMLParser.AddChildFromString("Description", this._Description.ToString(), this.XMLParser.documentElement); //this.XMLParser.AddChildFromString("RowIDInList", this._RowIDInList.ToString(), this.XMLParser.documentElement); return(this.XMLParser.xml); } catch { throw; } return(null); }