public void AddRecentFile(String path)
        {
            string[] oldRecentFiles = this.RecentFiles;
            string[] newRecentFiles = null;
            if (oldRecentFiles.Length > 0)
            {
                string[] union = new String[oldRecentFiles.Length + 1];
                union[0] = path;
                Array.Copy(oldRecentFiles, 0, union, 1, oldRecentFiles.Length);
                newRecentFiles = union.Distinct().Take(RECENT_FILE_LIST_SIZE).ToArray();
            }
            else
            {
                newRecentFiles = new string[1] { path };
            }

            this.RecentFiles = newRecentFiles;

            try
            {
                this.Save();
            }
            catch (IOException e)
            {
                throw new UserFacingException("Could Not Access Setting File", e);
            }
        }
Example #2
0
            public bool Matches(String str)
            { 
                var chars = str.Distinct().Select(x => x.ToString()).ToList();
                Dictionary<string, Boolean> mapping = new Dictionary<string, bool>();
                
                mapping.Add(chars[0], true);
                mapping.Add(chars[1], false);

                var match = str.Select(x => mapping[x.ToString()]).Zip(BooleanPattern, (x, y) => x == y).All(x => x==true);
                if (match)
                    return true;
                mapping.Clear();
                mapping.Add(chars[0], false);
                mapping.Add(chars[1], true);
                match = str.Select(x => mapping[x.ToString()]).Zip(BooleanPattern, (x, y) => x == y).All(x => x == true);
                return match;
            }
Example #3
0
        public void Resources_HasEquivalents()
        {
            IEnumerable<CultureInfo> languages = new[] { new CultureInfo("en-GB"), new CultureInfo("lt-LT") };
            IEnumerable<Type> resourceTypes = Assembly
                .Load("Template.Resources")
                .GetTypes()
                .Where(type => type.Namespace.StartsWith("Template.Resources."));

            foreach (Type type in resourceTypes)
            {
                ResourceManager manager = new ResourceManager(type);
                IEnumerable<String> resourceKeys = new String[0];

                foreach (ResourceSet set in languages.Select(language => manager.GetResourceSet(language, true, true)))
                {
                    resourceKeys = resourceKeys.Union(set.Cast<DictionaryEntry>().Select(resource => resource.Key.ToString()));
                    resourceKeys = resourceKeys.Distinct();
                }

                foreach (CultureInfo language in languages)
                {
                    ResourceSet set = manager.GetResourceSet(language, true, true);
                    foreach (String key in resourceKeys)
                        Assert.True((set.GetObject(key) ?? "").ToString() != "",
                            String.Format("{0}, does not have translation for '{1}' in {2} language.",
                                type.FullName, key, language.EnglishName));
                }
            }
        }
Example #4
0
 public Array getAllPerson(DataTable textFileData)
 {
     ArrayList persons = new ArrayList();
     for (int i = 0; i < textFileData.Rows.Count; ++i)
     {
         persons.Add(textFileData.Rows[i]["Person"]);
     }
     String[] personArray = new String[persons.Count];
     personArray = (String[])persons.ToArray(typeof(String));
     personArray = personArray.Distinct().ToArray();
     return personArray;
 }
Example #5
0
 public Array getAllHouseHolds(DataTable textFileData)
 {
     ArrayList houseHolds = new ArrayList();
     for (int i = 0; i < textFileData.Rows.Count; ++i)
     {
         houseHolds.Add(textFileData.Rows[i]["HouseHold"]);
     }
     String[] houseHoldArray = new String[houseHolds.Count];
     houseHoldArray = (String[])houseHolds.ToArray(typeof(String));
     houseHoldArray = houseHoldArray.Distinct().ToArray();
     return houseHoldArray;
 }
        public void Resources_HasAllTranslations()
        {
            IEnumerable<Language> languages = GlobalizationProviderFactory.CreateProvider().Languages;
            IEnumerable<Type> resourceTypes = Assembly
                .Load("MvcTemplate.Resources")
                .GetTypes()
                .Where(type => type.Namespace.StartsWith("MvcTemplate.Resources."));

            foreach (Type type in resourceTypes)
            {
                ResourceManager manager = new ResourceManager(type);
                IEnumerable<String> resourceKeys = new String[0];

                foreach (Language language in languages)
                {
                    ResourceSet set = manager.GetResourceSet(language.Culture, true, true);
                    resourceKeys = resourceKeys.Union(set.Cast<DictionaryEntry>().Select(resource => resource.Key.ToString()));
                    resourceKeys = resourceKeys.Distinct();
                }

                foreach (Language language in languages)
                {
                    ResourceSet set = manager.GetResourceSet(language.Culture, true, true);
                    foreach (String key in resourceKeys)
                        Assert.True(!String.IsNullOrEmpty(set.GetString(key)),
                            String.Format("{0}, does not have translation for '{1}' in {2} language.",
                                type.FullName, key, language.Culture.EnglishName));
                }
            }
        }
Example #7
0
 public static bool IsRepeat(String[] pNumbers)
 {
     return pNumbers.Length != pNumbers.Distinct().ToArray().Length;
 }
Example #8
0
 //////////////////////////////////////////
 /// UTILITIES METHODS
 //////////////////////////////////////////
 public String[] CleanDuplicate(String[] Input)
 {
     List<String> tmp = new List<string>(Input.Distinct().ToArray());
     if (tmp.Count > 1)
     {
         if (Regex.IsMatch(tmp[0], "^200 OK$") && Regex.IsMatch(tmp[1], "^200 OK(\\s?\\d+)$"))
         {
             tmp.RemoveAt(0);
             return CleanDuplicate(tmp.ToArray());
         }
         else if (Regex.IsMatch(tmp[0], "^200 OK$") && Regex.IsMatch(tmp[1], "^200 OK$"))
         {
             tmp.RemoveAt(0);
             return CleanDuplicate(tmp.ToArray());
         }
         else
         {
             return tmp.ToArray();
         }
     }
     else
     {
         return tmp.ToArray();
     }
 }