//NamedValues1 public LeMonde0(NamedValues <ZValue> values) { // year : mandatory, int or numeric string // day : mandatory, int or numeric string // month : mandatory, int or numeric string // type_quo : optional, string null, "_quo" // types_quo_sup : optional, string[], "tv", "argent" // type_sup : optional, string null, "livres" // number : not used, int or numeric string // type : not used, string "_quo", "-livres", "_quo+tv", "_quo+tv+argent" if (!values.ContainsKey("year")) { throw new PBException("error creating LeMonde unknow year"); } if (!values.ContainsKey("month")) { throw new PBException("error creating LeMonde unknow month"); } if (!values.ContainsKey("day")) { throw new PBException("error creating LeMonde unknow day"); } _date = zdate.CreateDate(values); _type = GetType(values); }
//NamedValues1 public LeMonde0(NamedValues<ZValue> values) { // year : mandatory, int or numeric string // day : mandatory, int or numeric string // month : mandatory, int or numeric string // type_quo : optional, string null, "_quo" // types_quo_sup : optional, string[], "tv", "argent" // type_sup : optional, string null, "livres" // number : not used, int or numeric string // type : not used, string "_quo", "-livres", "_quo+tv", "_quo+tv+argent" if (!values.ContainsKey("year")) throw new PBException("error creating LeMonde unknow year"); if (!values.ContainsKey("month")) throw new PBException("error creating LeMonde unknow month"); if (!values.ContainsKey("day")) throw new PBException("error creating LeMonde unknow day"); _date = zdate.CreateDate(values); _type = GetType(values); }
//NamedValues1 public static LeMondeType GetType(NamedValues <ZValue> values) { LeMondeType type = LeMondeType.Unknow; if (values.ContainsKey("type_code")) { type = GetTypeCode((string)values["type_code"]); } else if (values.ContainsKey("type_quo") && values["type_quo"] != null) { 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); } foreach (string s in (string[])o) { type |= GetTypeSup(s); } } } else { 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); } type = GetTypeSup((string)o); } return(type); }
// 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); }
public LeMonde0(Date date, LeMondeType type) { _date = date; _type = type; }
//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); }
// type_dossier : name public override bool TrySetValues(NamedValues<ZValue> values) { if (!base.TrySetValues(values)) return false; LeMondeType type; if (!TryGetType(values, out type)) return false; if (type != LeMondeType.Unknow) _type = type; if (values.ContainsKey("type_dossier")) { ZValue v = values["type_dossier"]; if (v != null && v is ZString) { _dossier = (string)v; } } _typeCode = null; return true; }
// 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; }
//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; }