示例#1
0
        /// <summary>
        /// Chargement d'un flux(Json/Ou XML) dans le datavalue
        /// </summary>
        /// <param name="itemdv"></param>
        /// <param name="flux"></param>
        public static void FromFlux(this ParamValues datavalue, string flux, bool?isXml = null)
        {
            //clean
            if (string.IsNullOrWhiteSpace(flux))
            {
                return;
            }
            flux = flux.Trim();

            if (!isXml.HasValue)
            {
                isXml = flux.TrimStart().StartsWith("<");
            }


            IParamValuesSerializer serial = ParamValuesTools.SerializerFactory(isXml.Value);

            serial.DeSerialize(flux, datavalue);

            //parse
            //if (flux.StartsWith("{")) this.FromFluxJson(flux);
            //if (flux.StartsWith("<")) fromFluxXML(datavalue,flux);
        }
示例#2
0
        /// <summary>
        /// Exporter un flux du datavalue
        /// </summary>
        /// <param name="datavalue"></param>
        /// <param name="Xml">true=xml, false=json</param>
        /// <returns></returns>
        public static string ToFlux(this ParamValues datavalue, bool isXml = true)
        {
            IParamValuesSerializer serial = ParamValuesTools.SerializerFactory(isXml);

            return(serial.Serialize(datavalue));
        }