Example #1
0
        /// <summary>
        /// Standardize all fields
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <param name="datas"></param>
        /// <returns></returns>
        public static List <string> Standardize <T>(T t, List <string> datas)
        {
            List <string> listDatas = new List <string>();
            IDictionary <string, string> standard = new Dictionary <string, string>();

            listDatas.AddRange(datas);
            listDatas.Remove(string.Empty);

            string type = string.Empty;

            try
            {
                standard = Standardization.GetStandard(DictionnaryStandards[t.GetType()]);
            }
            catch (StandardException e)
            {
                throw new StandardException(e.Message);
            }

            List <string> lstTemp = new List <string>();

            foreach (string l in listDatas)
            {
                string key = l.Remove(l.IndexOf(' '));

                string tmp = string.Empty;

                if (standard.TryGetValue(key, out string itemStandard))
                {
                    tmp = Regex.Replace(l, key, itemStandard, RegexOptions.IgnoreCase);
                    lstTemp.Add(tmp);
                    continue;
                }

                //if (!string.IsNullOrWhiteSpace(feature))
                //{
                //    tmp += feature;
                //}

                lstTemp.Add(l);
            }

            return(lstTemp);
        }
Example #2
0
        //private bool CheckSkill(ref Dictionary<string, int> dicCharacValue, ref Dictionary<string, string> dicSkillFeature)
        //{
        //    string lineCharacterize;

        //    if (!ExtractSkills(out lineCharacterize))
        //    {
        //        return false;
        //    }

        //    List<string> characterize = Standardization.Standardize(new Skill(), Regex.Replace(lineCharacterize, @"\s+", " ").Split('|').ToList());

        //    List<string> skillsValue = SetSkillsFeature(characterize, ref dicSkillFeature);

        //    if (!CheckValue(skillsValue, ref dicCharacValue))
        //    {
        //        throw new CharacterException(string.Concat(_missed));
        //    }
        //    return true;
        //}

        //private bool ExtractSkills(out string datas)
        //{
        //    datas = string.Empty;
        //    bool isMatch = false;
        //    string feature = string.Empty;

        //    Regex match = new Regex(_dictionnaryStandards[typeof(Skill)], RegexOptions.IgnoreCase);

        //    List<char> Readfeatures = new List<char>() { '[', ']' };

        //    foreach (string c in _characterize)
        //    {
        //        if (match.IsMatch(c))
        //        {
        //            isMatch = true;
        //            continue;
        //        }

        //        if (isMatch)
        //        {
        //            if (_fields.Exists(f => f == c))
        //            {
        //                break;
        //            }

        //            if (Readfeatures.Any(c.Contains))
        //            {
        //                feature = c.Replace("[", string.Empty).Replace("]", string.Empty);
        //                continue;
        //            }
        //            // datas for skills is e.g. PERCEPTION 6§INT|SOCIAL 5§EMP| ...
        //            if (!string.IsNullOrWhiteSpace(c))
        //            {
        //                datas += c.Trim() + "§" + feature + "|";
        //            }
        //        }
        //    }

        //    if (string.IsNullOrEmpty(datas))
        //    {
        //        _missed.Add(string.Concat("Aucune Competences n'a été renseigné",
        //                         Environment.NewLine,
        //                         "Veuillez regarder un exemple",
        //                         Environment.NewLine));
        //        return false;
        //    }
        //    return true;


        //    // Concerne les brevets ou la cyber (Ceci est optionnel) donc si ce champ est vide non retour d'erreur
        //    //int index = _characterize.FindIndex(c => c == _dictionnaryStandards[typeof(Patent)]);

        //    //if (index > 0)
        //    //{
        //    //    for (int i = index + 1; i < _characterize.Count; i++)
        //    //    {
        //    //        datas += _characterize[i] + "|";
        //    //    }
        //    //}

        //    //return true;
        //}

        private bool CheckCharacterize <T>(T t)
        {
            //dico = new Dictionary<string, int>();
            string lineCharacterize = ExtractDatas(t);

            if (string.IsNullOrEmpty(lineCharacterize))
            {
                return(false);
            }

            List <string> characterize = Standardization.Standardize(t, Regex.Replace(lineCharacterize, @"\s+", " ").Split('|').ToList());

            // TODO : Mettre dans BdD les corporations
            // Dans le cas Features toutes les valeurs sont requises
            if (t.GetType() == typeof(Feature))
            {
                return(CheckFeatures(characterize));
            }

            return(CheckValue(characterize));
        }