Esempio n. 1
0
        //NamedValues1
        protected virtual bool TryGetIndex(NamedValues <ZValue> values, out int index)
        {
            index = 0;
            if (!values.ContainsKey("index"))
            {
                //throw new PBException("error index not found");
                values.SetError("error index not found");
                return(false);
            }
            string s = (string)values["index"];

            if (s == null)
            {
                //return 0;
                return(true);
            }
            int index2;

            if (!int.TryParse(s, out index2))
            {
                //throw new PBException("error invalid index \"{0}\"", s);
                values.SetError("error invalid index \"{0}\"", s);
                return(false);
            }
            //return index;
            index = index2;
            return(true);
        }
Esempio n. 2
0
        //NamedValues1
        protected virtual bool TryGetPrintNumber(NamedValues <ZValue> values, out int number)
        {
            number = 0;
            if (!values.ContainsKey("number"))
            {
                //throw new PBException("error print number not found");
                values.SetError("error print number not found");
                return(false);
            }
            int number2;

            if (!int.TryParse((string)values["number"], out number2))
            {
                //throw new PBException("error invalid print number \"{0}\"", values["number"]);
                values.SetError("error invalid print number \"{0}\"", values["number"]);
                return(false);
            }
            //return printNumber;
            number = number2;
            return(true);
        }
Esempio n. 3
0
 // type_code     : quo, arg, arh, dos, mde, edu, aut, peh, liv, mag, mdv, sch, scq, sph, sty, nyt, tel
 // type_quo      :
 // fix_type_quo  :
 // types_quo_sup : argent, culture, dossier, éco, eco, édu, edu, festival, géo, geo, livres, mag, mode, science, sport, style, nyt, tv, document, élection, election, hebdo, sup
 // type_sup      : argent, culture, dossier, éco, eco, édu, edu, festival, géo, geo, livres, mag, mode, science, sport, style, nyt, tv, document, élection, election, hebdo, sup
 // type_sups     : argent, culture, dossier, éco, eco, édu, edu, festival, géo, geo, livres, mag, mode, science, sport, style, nyt, tv, document, élection, election, hebdo, sup
 // fix_type_eco  :
 // fix_type_tv   :
 public static bool TryGetType(NamedValues <ZValue> values, out LeMondeType type)
 {
     type = LeMondeType.Unknow;
     if (values.ContainsKey("type_code"))
     {
         type = GetTypeCode((string)values["type_code"]);
         if (type == LeMondeType.Unknow)
         {
             values.SetError("error unknow le monde type sup : \"{0}\"", values["type_code"]);
             return(false);
         }
     }
     else if ((values.ContainsKey("type_quo") && values["type_quo"] != null) || values.ContainsKey("fix_type_quo"))
     {
         type = LeMondeType.Quotidien;
         if (values.ContainsKey("types_quo_sup"))
         {
             ZValue v = values["types_quo_sup"];
             if (v != null && !(v is ZStringArray))
             {
                 values.SetError("error creating LeMonde value types_quo_sup should be a string array : {0}", v);
                 return(false);
             }
             foreach (string s in (string[])v)
             {
                 LeMondeType type2 = GetTypeSup(s);
                 if (type2 == LeMondeType.Unknow)
                 {
                     values.SetError("error unknow le monde type sup : \"{0}\"", s);
                     return(false);
                 }
                 type |= type2;
             }
         }
     }
     else if (values.ContainsKey("type_sup"))
     {
         ZValue v = values["type_sup"];
         if (!(v is ZString))
         {
             values.SetError("error creating LeMonde value type_sup should be a string : {0}", v);
             return(false);
         }
         type = GetTypeSup((string)v);
         if (type == LeMondeType.Unknow)
         {
             values.SetError("error unknow le monde type sup : \"{0}\"", v);
             return(false);
         }
     }
     else if (values.ContainsKey("type_sups"))
     {
         ZValue v = values["type_sups"];
         if (v != null)
         {
             if (v is ZString)
             {
                 LeMondeType type2 = GetTypeSup((string)v);
                 if (type2 == LeMondeType.Unknow)
                 {
                     values.SetError("error unknow le monde type sup : \"{0}\"", (string)v);
                     return(false);
                 }
                 type = type2;
             }
             else if (v is ZStringArray)
             {
                 type = LeMondeType.Unknow;
                 foreach (string s in (string[])v)
                 {
                     LeMondeType type2 = GetTypeSup(s);
                     if (type2 == LeMondeType.Unknow)
                     {
                         values.SetError("error unknow le monde type sup : \"{0}\"", s);
                         //return false;
                     }
                     else
                     {
                         type |= type2;
                     }
                 }
             }
             else
             {
                 values.SetError("error creating LeMonde value type_sups should be a string or string array : {0}", v);
                 return(false);
             }
         }
     }
     else if (values.ContainsKey("fix_type_eco"))
     {
         type = LeMondeType.Economie;
     }
     else if (values.ContainsKey("fix_type_tv"))
     {
         type = LeMondeType.TV;
     }
     return(true);
 }
Esempio n. 4
0
 //NamedValues1
 protected virtual bool TryGetIndex(NamedValues<ZValue> values, out int index)
 {
     index = 0;
     if (!values.ContainsKey("index"))
     {
         //throw new PBException("error index not found");
         values.SetError("error index not found");
         return false;
     }
     string s = (string)values["index"];
     if (s == null)
         //return 0;
         return true;
     int index2;
     if (!int.TryParse(s, out index2))
     {
         //throw new PBException("error invalid index \"{0}\"", s);
         values.SetError("error invalid index \"{0}\"", s);
         return false;
     }
     //return index;
     index = index2;
     return true;
 }
Esempio n. 5
0
 //NamedValues1
 protected virtual bool TryGetPrintNumber(NamedValues<ZValue> values, out int number)
 {
     number = 0;
     if (!values.ContainsKey("number"))
     {
         //throw new PBException("error print number not found");
         values.SetError("error print number not found");
         return false;
     }
     int number2;
     if (!int.TryParse((string)values["number"], out number2))
     {
         //throw new PBException("error invalid print number \"{0}\"", values["number"]);
         values.SetError("error invalid print number \"{0}\"", values["number"]);
         return false;
     }
     //return printNumber;
     number = number2;
     return true;
 }
Esempio n. 6
0
 //NamedValues1
 public static bool TryGetType(NamedValues <ZValue> values, out LeMondeType type)
 {
     type = LeMondeType.Unknow;
     if (values.ContainsKey("type_code"))
     {
         type = GetTypeCode((string)values["type_code"]);
         if (type == LeMondeType.Unknow)
         {
             values.SetError("error unknow le monde type sup : \"{0}\"", (string)values["type_code"]);
             return(false);
         }
     }
     else if ((values.ContainsKey("type_quo") && values["type_quo"] != null) || values.ContainsKey("fix_type_quo"))
     //else if (values.ContainsKey("type_quo"))
     {
         type = LeMondeType.Quotidien;
         if (values.ContainsKey("types_quo_sup"))
         {
             object o = values["types_quo_sup"];
             if (o != null && !(o is string[]))
             {
                 //throw new PBException("error creating LeMonde value types_quo_sup should be a string array : {0}", o);
                 values.SetError("error creating LeMonde value types_quo_sup should be a string array : {0}", o);
                 return(false);
             }
             foreach (string s in (string[])o)
             {
                 //type |= GetTypeSup(s);
                 LeMondeType type2 = GetTypeSup(s);
                 if (type2 == LeMondeType.Unknow)
                 {
                     values.SetError("error unknow le monde type sup : \"{0}\"", s);
                     return(false);
                 }
                 type |= type2;
             }
         }
     }
     else if (values.ContainsKey("type_sup"))
     {
         //if (!values.ContainsKey("type_sup"))
         //    throw new PBException("error creating LeMonde unknow type_sup");
         object o = values["type_sup"];
         if (!(o is string))
         {
             //throw new PBException("error creating LeMonde value type_sup should be a string : {0}", o);
             values.SetError("error creating LeMonde value type_sup should be a string : {0}", o);
             return(false);
         }
         type = GetTypeSup((string)o);
         if (type == LeMondeType.Unknow)
         {
             values.SetError("error unknow le monde type sup : \"{0}\"", o);
             return(false);
         }
     }
     else if (values.ContainsKey("fix_type_eco"))
     {
         type = LeMondeType.Economie;
     }
     else if (values.ContainsKey("fix_type_tv"))
     {
         type = LeMondeType.TV;
     }
     else
     {
         //throw new PBException("error creating LeMonde unknow type");
         values.SetError("error creating LeMonde unknow type");
         return(false);
     }
     //return type;
     return(true);
 }
Esempio n. 7
0
 // type_code     : quo, arg, arh, dos, mde, edu, aut, peh, liv, mag, mdv, sch, scq, sph, sty, nyt, tel
 // type_quo      :
 // fix_type_quo  :
 // types_quo_sup : argent, culture, dossier, éco, eco, édu, edu, festival, géo, geo, livres, mag, mode, science, sport, style, nyt, tv, document, élection, election, hebdo, sup
 // type_sup      : argent, culture, dossier, éco, eco, édu, edu, festival, géo, geo, livres, mag, mode, science, sport, style, nyt, tv, document, élection, election, hebdo, sup
 // type_sups     : argent, culture, dossier, éco, eco, édu, edu, festival, géo, geo, livres, mag, mode, science, sport, style, nyt, tv, document, élection, election, hebdo, sup
 // fix_type_eco  :
 // fix_type_tv   :
 public static bool TryGetType(NamedValues<ZValue> values, out LeMondeType type)
 {
     type = LeMondeType.Unknow;
     if (values.ContainsKey("type_code"))
     {
         type = GetTypeCode((string)values["type_code"]);
         if (type == LeMondeType.Unknow)
         {
             values.SetError("error unknow le monde type sup : \"{0}\"", values["type_code"]);
             return false;
         }
     }
     else if ((values.ContainsKey("type_quo") && values["type_quo"] != null) || values.ContainsKey("fix_type_quo"))
     {
         type = LeMondeType.Quotidien;
         if (values.ContainsKey("types_quo_sup"))
         {
             ZValue v = values["types_quo_sup"];
             if (v != null && !(v is ZStringArray))
             {
                 values.SetError("error creating LeMonde value types_quo_sup should be a string array : {0}", v);
                 return false;
             }
             foreach (string s in (string[])v)
             {
                 LeMondeType type2 = GetTypeSup(s);
                 if (type2 == LeMondeType.Unknow)
                 {
                     values.SetError("error unknow le monde type sup : \"{0}\"", s);
                     return false;
                 }
                 type |= type2;
             }
         }
     }
     else if (values.ContainsKey("type_sup"))
     {
         ZValue v = values["type_sup"];
         if (!(v is ZString))
         {
             values.SetError("error creating LeMonde value type_sup should be a string : {0}", v);
             return false;
         }
         type = GetTypeSup((string)v);
         if (type == LeMondeType.Unknow)
         {
             values.SetError("error unknow le monde type sup : \"{0}\"", v);
             return false;
         }
     }
     else if (values.ContainsKey("type_sups"))
     {
         ZValue v = values["type_sups"];
         if (v != null)
         {
             if (v is ZString)
             {
                 LeMondeType type2 = GetTypeSup((string)v);
                 if (type2 == LeMondeType.Unknow)
                 {
                     values.SetError("error unknow le monde type sup : \"{0}\"", (string)v);
                     return false;
                 }
                 type = type2;
             }
             else if (v is ZStringArray)
             {
                 type = LeMondeType.Unknow;
                 foreach (string s in (string[])v)
                 {
                     LeMondeType type2 = GetTypeSup(s);
                     if (type2 == LeMondeType.Unknow)
                     {
                         values.SetError("error unknow le monde type sup : \"{0}\"", s);
                         //return false;
                     }
                     else
                         type |= type2;
                 }
             }
             else
             {
                 values.SetError("error creating LeMonde value type_sups should be a string or string array : {0}", v);
                 return false;
             }
         }
     }
     else if (values.ContainsKey("fix_type_eco"))
         type = LeMondeType.Economie;
     else if (values.ContainsKey("fix_type_tv"))
         type = LeMondeType.TV;
     return true;
 }
Esempio n. 8
0
 //NamedValues1
 public static bool TryGetType(NamedValues<ZValue> values, out LeMondeType type)
 {
     type = LeMondeType.Unknow;
     if (values.ContainsKey("type_code"))
     {
         type = GetTypeCode((string)values["type_code"]);
         if (type == LeMondeType.Unknow)
         {
             values.SetError("error unknow le monde type sup : \"{0}\"", (string)values["type_code"]);
             return false;
         }
     }
     else if ((values.ContainsKey("type_quo") && values["type_quo"] != null) || values.ContainsKey("fix_type_quo"))
     //else if (values.ContainsKey("type_quo"))
     {
         type = LeMondeType.Quotidien;
         if (values.ContainsKey("types_quo_sup"))
         {
             object o = values["types_quo_sup"];
             if (o != null && !(o is string[]))
             {
                 //throw new PBException("error creating LeMonde value types_quo_sup should be a string array : {0}", o);
                 values.SetError("error creating LeMonde value types_quo_sup should be a string array : {0}", o);
                 return false;
             }
             foreach (string s in (string[])o)
             {
                 //type |= GetTypeSup(s);
                 LeMondeType type2 = GetTypeSup(s);
                 if (type2 == LeMondeType.Unknow)
                 {
                     values.SetError("error unknow le monde type sup : \"{0}\"", s);
                     return false;
                 }
                 type |= type2;
             }
         }
     }
     else if (values.ContainsKey("type_sup"))
     {
         //if (!values.ContainsKey("type_sup"))
         //    throw new PBException("error creating LeMonde unknow type_sup");
         object o = values["type_sup"];
         if (!(o is string))
         {
             //throw new PBException("error creating LeMonde value type_sup should be a string : {0}", o);
             values.SetError("error creating LeMonde value type_sup should be a string : {0}", o);
             return false;
         }
         type = GetTypeSup((string)o);
         if (type == LeMondeType.Unknow)
         {
             values.SetError("error unknow le monde type sup : \"{0}\"", o);
             return false;
         }
     }
     else if (values.ContainsKey("fix_type_eco"))
         type = LeMondeType.Economie;
     else if (values.ContainsKey("fix_type_tv"))
         type = LeMondeType.TV;
     else
     {
         //throw new PBException("error creating LeMonde unknow type");
         values.SetError("error creating LeMonde unknow type");
         return false;
     }
     //return type;
     return true;
 }