Ejemplo n.º 1
0
 /// <summary>
 /// Obtient tous les data qui contien l'attribut 'attributname'
 /// </summary>
 /// <param name="attributname"></param>
 /// <param name="replacenameparattribut"></param>
 /// <returns></returns>
 public ParamValues GetDatasWithAttribut(string attributname, bool replacenameparattribut = false)
 {
     try
     {
         ParamValues retour = new ParamValues();
         WaitMutex();
         foreach (ParamValuesNode datb in this.dataStore.Values)
         {
             if (datb[attributname] != "")
             {
                 ParamValuesNode ee = datb.Clone();
                 if (replacenameparattribut)
                 {
                     ee.Name = datb[attributname];
                 }
                 retour.Add(ee);
             }
         }
         return(retour);
     }
     catch (Exception e)
     {
         throw new Exception("Impossible d'obtenir des datas avec l'attribut " + attributname + " " + e.Message);
     }
     finally
     {
         ReleaseMutex();
     }
 }
Ejemplo n.º 2
0
        // -------------------------------------------------------------------------------------------
        #region Traitement des données



        /// <summary>
        /// Creer une liste de données
        /// </summary>
        /// <param name="dodoc">autre datadoc, Ne link pas les données, il recopie intégralement l'objet</param>
        public ParamValues Clone()
        {
            ParamValues retour = new ParamValues(this._DataValueName);

            try
            {
                WaitMutex();
                foreach (ParamValuesNode itemd in this.dataStore.Values)
                {
                    retour.Add(itemd.Clone());
                }
            }
            finally
            {
                ReleaseMutex();
            }
            return(retour);
        }
Ejemplo n.º 3
0
 private void FromJsonSub(ParamValues datavalue, System.Text.Json.JsonProperty elem, string lastpath)
 {
     if (elem.Value.ValueKind == System.Text.Json.JsonValueKind.Array)
     {
         // Array invalids
     }
     else if (elem.Value.ValueKind == System.Text.Json.JsonValueKind.Object)
     {
         string newlastpath = lastpath + elem.Name + "/";
         foreach (var jsubitem in elem.Value.EnumerateObject().ToList())
         {
             FromJsonSub(datavalue, jsubitem, newlastpath);
         }
     }
     else
     {
         string          fullname    = lastpath + elem.Name;
         ParamValuesNode dataelement = new ParamValuesNode();
         dataelement.Name  = fullname;
         dataelement.Value = Nglib.DATA.KEYVALUES.KeyValuesSerializerJson.ReadValue(elem.Value);
         datavalue.Add(dataelement);
     }
 }
Ejemplo n.º 4
0
        private void getdataXMLChild(ParamValues datavalue, XmlNode xdot, string pathac, XmlAttributeCollection sattributs)
        {
            string                 lastpath      = pathac;
            ParamValuesNode        bufliste      = new ParamValuesNode();
            XmlAttributeCollection sauvattributs = null;

            foreach (XmlNode xChild in xdot.ChildNodes)
            {
                //System.Console.WriteLine(xChild.Name);
                if (xChild.NodeType == XmlNodeType.Element)
                {
                    lastpath = pathac + xChild.Name.ToLower() + "/";
                    if (xChild.Attributes.Count > 0)
                    {
                        sauvattributs = xChild.Attributes;
                    }
                    else
                    {
                        sauvattributs = null;
                    }
                }

                if (xChild.NodeType == XmlNodeType.Text || (xChild.NodeType == XmlNodeType.Element && !xChild.HasChildNodes && xChild.Value == null))
                {
                    bufliste = GenerateNewNodeFromXML(datavalue, lastpath, xChild); // Ajout d'une nouvelle clef/valeur
                    if (bufliste != null)
                    {
                        datavalue.Add(bufliste);
                    }
                }
                else if (xChild.HasChildNodes)
                {
                    getdataXMLChild(datavalue, xChild, lastpath, sauvattributs);
                }
            }
        }