コード例 #1
0
        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>();
                }
            }
        }
コード例 #2
0
ファイル: ObjectContent.cs プロジェクト: Ace4teaM/Syntaxi
        /// <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>();
                }
            }
        }
コード例 #3
0
ファイル: ParamContent.cs プロジェクト: Ace4teaM/Syntaxi
 // copie
 public ParamContent(ParamContent src) : this()
 {
     // Id
     this.id = src.id;
     // ParamName
     this.paramname = src.paramname;
     // ParamValue
     this.paramvalue = src.paramvalue;
 }
コード例 #4
0
ファイル: ParamContent.cs プロジェクト: Ace4teaM/Syntaxi
        // Identifiants
        public bool CompareIdentifier(IEntityPersistent e)
        {
            ParamContent b = e as ParamContent;

            if (b == null)
            {
                return(false);
            }
            return(this.Id == b.Id);
        }
コード例 #5
0
ファイル: ObjectContent.cs プロジェクト: Ace4teaM/Syntaxi
 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"));
     }
 }
コード例 #6
0
ファイル: ObjectContent.cs プロジェクト: Ace4teaM/Syntaxi
 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"));
     }
 }
コード例 #7
0
ファイル: ParamContent.cs プロジェクト: Ace4teaM/Syntaxi
        // 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);
        }
コード例 #8
0
ファイル: ObjectContent.cs プロジェクト: Ace4teaM/Syntaxi
        // 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);
        }
コード例 #9
0
ファイル: ParamContent.cs プロジェクト: Ace4teaM/Syntaxi
        // 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);
        }
コード例 #10
0
ファイル: ObjectContent.cs プロジェクト: Ace4teaM/Syntaxi
        // 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);
        }
コード例 #11
0
ファイル: ObjectContent.cs プロジェクト: Ace4teaM/Syntaxi
        /// <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;
                }
            }
        }
コード例 #12
0
ファイル: ObjectContent.cs プロジェクト: Ace4teaM/Syntaxi
 public void RemoveParamContent(ParamContent obj)
 {
     obj.ObjectContent = null;
     obj.Factory       = null;
     ParamContent.Remove(obj);
 }
コード例 #13
0
ファイル: ObjectContent.cs プロジェクト: Ace4teaM/Syntaxi
 public void AddParamContent(ParamContent obj)
 {
     obj.ObjectContent = this;
     obj.Factory       = this.Factory;
     ParamContent.Add(obj);
 }
コード例 #14
0
ファイル: ParamContent.cs プロジェクト: Ace4teaM/Syntaxi
 // copie
 public ParamContent(ParamContent src) : this()
 {
     Copy(this, src);
 }