public virtual IEnumerable <T> GetObject() { if (string.IsNullOrEmpty(paths)) { return(Enumerable.Empty <T>()); } var ps = paths.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); List <DirectoryInfo> dirs = new List <DirectoryInfo>(); foreach (var p in ps) { dirs.AddRange(fileProvider.GetPaths(p, false)); } List <T> objs = new List <T>(); dirs.GetFiles(fileName, false) .ForEach(f => { string json = File.ReadAllText(f.FullName); if (!string.IsNullOrEmpty(json)) { IEnumerable <T> os = jsonSerializer.Deserialize <IEnumerable <T> >(json); foreach (var obj in os) { InitializeObject(obj); AddToList(objs, obj); } } }); return(objs); }
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); }); }