public void ReadBinary(BinaryReader reader) { // Properties Id = reader.ReadString(); ObjectType = reader.ReadString(); Filename = reader.ReadString(); Position = reader.ReadInt32(); // ParamContent { int size = reader.ReadInt32(); if (size > 0) { this.ParamContent = new Collection <ParamContent>(); for (int i = 0; i < size; i++) { ParamContent o = new ParamContent(); o.ReadBinary(reader); this.AddParamContent(o); } } else { this.ParamContent = new Collection <ParamContent>(); } } }
/// <summary> /// Initialise l'instance depuis les données d'un flux binaire /// </summary> /// <param name="reader">Flux binaire</param> /// <param name="aggregationCallback">Permet d'appliquer des modifications aux entités importées par aggrégation</param> /// <remarks>Seuls les éléments existants dans le noeud Xml son importés dans l'objet</remarks> public void ReadBinary(BinaryReader reader, EntityCallback aggregationCallback) { // Properties Id = reader.ReadString(); ObjectType = reader.ReadString(); Filename = reader.ReadString(); Position = reader.ReadInt32(); // ParamContent { int size = reader.ReadInt32(); if (size > 0) { this.ParamContent = new Collection <ParamContent>(); for (int i = 0; i < size; i++) { ParamContent o = new ParamContent(); o.ReadBinary(reader, aggregationCallback); if (aggregationCallback != null) { aggregationCallback(o); } this.AddParamContent(o); } } else { this.ParamContent = new Collection <ParamContent>(); } } }
// copie public ParamContent(ParamContent src) : this() { // Id this.id = src.id; // ParamName this.paramname = src.paramname; // ParamValue this.paramvalue = src.paramvalue; }
// Identifiants public bool CompareIdentifier(IEntityPersistent e) { ParamContent b = e as ParamContent; if (b == null) { return(false); } return(this.Id == b.Id); }
public void RemoveParamContent(ParamContent obj) { obj.Model.Remove(obj); obj.ObjectContent = null; obj.Factory = this.Factory; obj.Model = null; if (this.PropertyChanged != null) { this.PropertyChanged(this, new PropertyChangedEventArgs("ParamContent")); } }
public void AddParamContent(ParamContent obj) { this.Model.Add(obj); obj.ObjectContent = this; obj.Factory = this.Factory; obj.Model = this.Model;//assure l'initialisation (normalement par this.Model.Add) if (this.PropertyChanged != null) { this.PropertyChanged(this, new PropertyChangedEventArgs("ParamContent")); } }
// clone public IEntity Clone() { ParamContent e = new ParamContent(); // Id e.id = this.id; // ParamName e.paramname = this.paramname; // ParamValue e.paramvalue = this.paramvalue; return(e); }
// ObjectContent(0,1) <-> (0,*)ParamContent public IEnumerable <ParamContent> LoadParamContent() { string query = "SELECT [Param_Content_Id] FROM T_PARAM_CONTENT WHERE [Object_Content_Id] = " + Factory.ParseType(this.Id) + ""; Factory.Query(query, reader => { List <ParamContent> updatedEntities = new List <ParamContent>(); while (reader.Read()) { // obtient l'identifiant String Id = ""; if (reader["Param_Content_Id"] == null) { continue; } Id = reader["Param_Content_Id"].ToString(); // obtient l'objet de reference ParamContent _entity = (from p in Factory.GetReferences().OfType <ParamContent>() where p.Id == Id select p).FirstOrDefault(); if (_entity == null) { _entity = new ParamContent(); _entity.Factory = this.Factory; _entity.Id = Id; _entity = Factory.GetReference(_entity) as ParamContent;//mise en cache } // Recharge les données depuis la BDD _entity.Load(); // Ajoute la reference à la collection this.AddParamContent(_entity); // liste les entités trouvées updatedEntities.Add(_entity); } // Supprime les entités qui ne sont plus en base de données ParamContent[] restEntities = this.ParamContent.Where(p => p.EntityState != Lib.EntityState.Deleted).Except(updatedEntities).ToArray(); for (int i = 0; i < restEntities.Length; i++) { restEntities[i].EntityState = Lib.EntityState.Deleted; // indique la suppression en base this.Model.Remove(restEntities[i]); // retire du model } return(0); }); return(ParamContent); }
// copie public IEntity Copy(IEntity _dst, IEntity _src) { ParamContent src = _src as ParamContent; ParamContent dst = _dst as ParamContent; if (src == null || dst == null) { return(null); } // Id dst.id = src.id; // ParamName dst.paramname = src.paramname; // ParamValue dst.paramvalue = src.paramvalue; return(dst); }
// ObjectContent(0,1) <-> (0,*)ParamContent public Collection <ParamContent> LoadParamContent() { string query = "SELECT Param_Content_Id FROM T_PARAM_CONTENT WHERE Object_Content_Id = " + Factory.ParseType(this.Id) + ""; this.ParamContent = new Collection <ParamContent>(); Factory.Query(query, reader => { while (reader.Read()) { // obtient l'identifiant String Id = ""; if (reader["Param_Content_Id"] == null) { continue; } Id = reader["Param_Content_Id"].ToString(); // obtient l'objet de reference ParamContent _entity = (from p in Factory.GetReferences().OfType <ParamContent>() where p.Id == Id select p).FirstOrDefault(); if (_entity == null) { _entity = new ParamContent(); _entity.Factory = this.Factory; _entity.Id = Id; _entity = Factory.GetReference(_entity) as ParamContent;//mise en cache } // Recharge les données depuis la BDD _entity.Load(); // Ajoute la reference à la collection this.AddParamContent(_entity); } return(0); }); return(ParamContent); }
/// <summary> /// Initialise l'instance depuis des données XML /// </summary> /// <param name="element">Élément contenant les information sur l'objet</param> /// <param name="aggregationCallback">Permet d'appliquer des modifications aux entités importées par aggrégation</param> /// <remarks>Seuls les éléments existants dans le noeud Xml son importés dans l'objet</remarks> public void FromXml(XmlElement element, EntityCallback aggregationCallback) { foreach (XmlElement m in element.ChildNodes) { string property_value = m.InnerText.Trim(); // charge les paramètres switch (m.Name) { // // Fields // // Assigne le membre Id case "Id": { this.id = property_value; } break; // Assigne le membre ObjectType case "ObjectType": { this.objecttype = property_value; } break; // Assigne le membre Filename case "Filename": { this.filename = property_value; } break; // Assigne le membre Position case "Position": { int value; if (int.TryParse(property_value, out value) == false) { this.Position = new Int32(); } else { this.Position = value; } } break; // // Aggregations // // Assigne la collection ParamContent case "ParamContent": { foreach (XmlElement c in m.ChildNodes) { if ("ParamContent" == c.Name) { ParamContent value = new ParamContent(); value.FromXml(c, aggregationCallback); if (aggregationCallback != null) { aggregationCallback(value); } this.AddParamContent(value); } } } break; } } }
public void RemoveParamContent(ParamContent obj) { obj.ObjectContent = null; obj.Factory = null; ParamContent.Remove(obj); }
public void AddParamContent(ParamContent obj) { obj.ObjectContent = this; obj.Factory = this.Factory; ParamContent.Add(obj); }
// copie public ParamContent(ParamContent src) : this() { Copy(this, src); }