private void LoadBxlSources(IBSharpContext context) { var bxlparser = new BxlParser(); foreach (var file in DirectoryFileFilter.Create(Project).Collect()) { try { var xml = bxlparser.Parse(null, file); Project.Sources.Add(xml); Project.Log.Debug("add src from " + file); } catch (Exception ex) { context.RegisterError(BSharpErrors.Generic(ex)); Project.Log.Fatal("cannot load src from " + file + " : " + ex.Message); } } }
private void LoadJsonSources(IBSharpContext context) { var jsonparser = new Json.JsonParser(); foreach (var file in Directory.GetFiles(Project.GetRootDirectory(), "*.bxls.json", SearchOption.AllDirectories)) { try { var xml = jsonparser.ParseXml(File.ReadAllText(file)); ConvertToBSharpSourceXml(file, xml); Project.Sources.Add(xml); Project.Log.Debug("add src from " + file); } catch (Exception ex) { context.RegisterError(BSharpErrors.Generic(ex)); Project.Log.Fatal("cannot load src from " + file + " : " + ex.Message); } } }
private void LoadBxlSources(IBSharpContext context) { var bxlparser = new BxlParser(); if (null != Project.Definition) { Project.Log.Debug(Project.SrcClass.Compiled.ToString()); } var filter = DirectoryFileFilter.Create(Project); PrintDebugFilter(filter); foreach (var file in filter.Collect().ToArray()) { try { var xml = bxlparser.Parse(null, file); Project.Sources.Add(xml); Project.Log.Debug("add src from " + file); } catch (Exception ex) { context.RegisterError(BSharpErrors.Generic(ex)); Project.Log.Fatal("cannot load src from " + file + " : " + ex.Message); } } }
/// <summary> /// Регистратор ошибок /// </summary> /// <param name="result"></param> /// <param name="e"></param> protected virtual void RegisterError(IBSharpContext result, Exception e) { result.RegisterError(BSharpErrors.Generic(e)); }
/// <summary> /// Регистратор ошибок /// </summary> /// <param name="result"></param> /// <param name="e"></param> protected virtual void RegisterError(IBSharpContext result, Exception e){ result.RegisterError(BSharpErrors.Generic(e)); }
private IEnumerable <IBSharpClass> GetAllImports(string root, IScope config) { var dict = ((IDictionary <string, object>)config); var self = ((IDictionary <string, object>)BuildSelfParametesSource()); foreach (var p in self.Where(_ => _.Value != null)) { if (!dict.ContainsKey(p.Key) && !p.Value.ToStr().Contains("${")) { dict[p.Key] = p.Value; } } if (null != DefaultImport) { if (root != DefaultImport.FullName) { foreach (IBSharpClass i in ((BSharpClass)DefaultImport).GetAllImports(root, config)) { yield return(i); } yield return(DefaultImport); } } foreach (IBSharpImport i in SelfImports) { if (null != i.Target && !i.Target.IsOrphaned && !i.Target.Is(BSharpClassAttributes.Ignored) && i.Match(config) ) { if (root != i.Target.FullName) { if (!i.Target.Is(BSharpClassAttributes.Static)) { foreach (BSharpClass ic in ((BSharpClass)i.Target).GetAllImports(root, config)) { yield return(ic); } } yield return(i.Target); } else { if (!Is(BSharpClassAttributes.Cycle)) { _context.RegisterError(BSharpErrors.RecycleImport(this, root, i)); Set(BSharpClassAttributes.Cycle); } } } } foreach (IBSharpImport i in SelfImports.Where(_ => null != _.Target && _.Target.IsOrphaned)) { _context.RegisterError(BSharpErrors.OrphanImport(this, i)); } foreach ( IBSharpImport i in SelfImports.Where(_ => null != _.Target && _.Target.Is(BSharpClassAttributes.Ignored) && _.Match(config))) { _context.RegisterError(BSharpErrors.IgnoredImport(this, i)); } }