Example #1
0
        protected virtual void LoadResources(string[] paths)
        {
            if (paths == null || paths.Length <= 0)
                return;

            List<DirectoryInfo> dirs = new List<DirectoryInfo>();
            foreach (var p in paths)
            {
                dirs.AddRange(fileProvider.GetPaths(p, false));
            }
            dirs.GetFiles("*.js", false)
            .ForEach(o =>
            {
                JsonResource jr = new JsonResource();
                jr.FileName = o.FullName;

                string[] fiNames = o.FileNameWithoutExtension().Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
                if (fiNames.Length == 2)
                {
                    jr.NameSpace = fiNames[0];
                    jr.CultureInfoName = fiNames[1];
                }
                else if (fiNames.Length == 1)
                {
                    jr.NameSpace = fiNames[0];
                    jr.CultureInfoName = string.Empty;
                }

                string json = File.ReadAllText(o.FullName);

                jr.Resources = jsonSerializer.Deserialize<SerializableDictionary>(json);
                if (jr.Resources == null)
                    jr.Resources = new SerializableDictionary();

                jsonResources.Add(jr);
            });
        }
        public static List<string> GetNotExistingFilesInOtherQuery(this List<FileQuery> queries, List<FileQuery> otherQueries)
        {
            if (queries == null)
            {
                throw new ArgumentNullException("queries");
            }

            if (otherQueries == null)
            {
                throw new ArgumentNullException("otherQueries");
            }

            var query1 = new HashSet<string>(queries.GetFiles(), new FileNameComparer());
            var query2 = new HashSet<string>(otherQueries.GetFiles(), new FileNameComparer());

            var removedFiles = new HashSet<string>(query1, new FileNameComparer());
            removedFiles.ExceptWith(query2);

            return removedFiles.ToList();
        }