internal Property(ITreeConfigNode parent, string guid, string name, DataType dataType) : this(parent) { this.Guid = guid; this._Name = name; this._DataType = dataType; }
private static object CreateSettingsForProject(ITreeConfigNode node, IAppProject tt, Dictionary <string, object> dic_apgs, bool isShortVersion) { TypeBuilder tbAppGen = SettingsTypeBuilder.GetTypeBuilder(); // type builder for app generators foreach (var ttt in tt.ListAppProjectGenerators) { if (!string.IsNullOrWhiteSpace(ttt.PluginGuid)) { if (!string.IsNullOrWhiteSpace(ttt.PluginGeneratorGuid)) { var nds = (IGetNodeSetting)node; var nsettings = nds.GetSettings(ttt.Guid); dic_apgs[ttt.Name] = nsettings; SettingsTypeBuilder.CreateProperty(tbAppGen, ttt.Name, nsettings.GetType(), ttt.NameUi, ttt.Description); } } } SettingsTypeBuilder.CreateToString(tbAppGen, "Project"); Type apgsType = tbAppGen.CreateType(); var objAppGen = Activator.CreateInstance(apgsType); foreach (var dt in dic_apgs) { apgsType.InvokeMember(dt.Key, BindingFlags.SetProperty, null, objAppGen, new object[] { dt.Value }); } return(objAppGen); }
//private static object CreateSettingsForProject(ITreeConfigNode node, AppProject tt, Dictionary<string, object> dic_apgs, bool isShortVersion) //{ // TypeBuilder tbAppGen = SettingsTypeBuilder.GetTypeBuilder(); // type builder for app generators // foreach (var ttt in tt.ListAppProjectGenerators) // { // if (!string.IsNullOrWhiteSpace(ttt.PluginGuid)) // { // if (!string.IsNullOrWhiteSpace(ttt.PluginGeneratorGuid)) // { // Dictionary<string, object> dic_gs = new Dictionary<string, object>(); // object objGen = null; // objGen = CreateSettingsForAppProjectGenerator(node, ttt, dic_gs, isShortVersion); // if (dic_gs.Count > 0) // { // dic_apgs[ttt.Name] = objGen; // SettingsTypeBuilder.CreateProperty(tbAppGen, ttt.Name, typeof(Object), ttt.NameUi, ttt.Description); // } // } // } // } // SettingsTypeBuilder.CreateToString(tbAppGen, "Project"); // Type apgsType = tbAppGen.CreateType(); // var objAppGen = Activator.CreateInstance(apgsType); // foreach (var dt in dic_apgs) // { // apgsType.InvokeMember(dt.Key, BindingFlags.SetProperty, null, objAppGen, new object[] { dt.Value }); // } // return objAppGen; //} private static object CreateSettingsForAppProjectGenerator(ITreeConfigNode node, AppProjectGenerator ttt, Dictionary <string, object> dic_gs, bool isShortVersion) { var nds = (IGetNodeSetting)node; TypeBuilder tbGen = SettingsTypeBuilder.GetTypeBuilder(); // type builder for generators foreach (var tttt in ttt.ListGenerators) { if (tttt.Generator == null) { continue; } if (isShortVersion && (tttt.Guid != ttt.PluginGeneratorGuid)) { continue; } IvPluginGenerator gen = tttt.Generator; var nsettings = nds.GetSettings(ttt.Guid); if (nsettings == null) { continue; } SettingsTypeBuilder.CreateProperty(tbGen, gen.Name, nsettings.GetType(), gen.NameUi, gen.Description); dic_gs[gen.Name] = nsettings; } SettingsTypeBuilder.CreateToString(tbGen, "Generator"); Type settingsType = tbGen.CreateType(); var objGen = Activator.CreateInstance(settingsType); foreach (var dt in dic_gs) { settingsType.InvokeMember(dt.Key, BindingFlags.SetProperty, null, objGen, new object[] { dt.Value }); } return(objGen); }
private void UpdateAddCounts(ITreeConfigNode p, ValidationMessage m) { switch (m.Severity) { case FluentValidation.Severity.Error: p.CountErrors++; while (p.Parent != null) { p = p.Parent; p.CountErrors++; } break; case FluentValidation.Severity.Warning: p.CountWarnings++; while (p.Parent != null) { p = p.Parent; p.CountWarnings++; } break; case FluentValidation.Severity.Info: p.CountInfos++; while (p.Parent != null) { p = p.Parent; p.CountInfos++; } break; default: throw new ArgumentException(); } }
protected void SetSelected(ITreeConfigNode node) { if (this.Parent != null) { this.GetConfig().SelectedNode = node; } }
protected void GetUniqueName(string defName, ITreeConfigNode configObject, IEnumerable <ITreeConfigNode> lst) { if (!string.IsNullOrWhiteSpace(configObject.Name)) { return; } int i = 0; foreach (var tt in lst) { if (tt == configObject) { continue; } if (tt.Name.StartsWith(defName)) { string s = tt.Name.Remove(0, defName.Length); int ii; if (int.TryParse(s, out ii)) { if (ii > i) { i = ii; } } } } i++; configObject.Name = defName + i; }
public void VisitTabs(string appGenGuig, EnumVisitType typeOp, ITreeConfigNode p, Action <IReadOnlyList <TableInfo> > action) { if (p is IPropertiesTab) { this.VisitTabs(appGenGuig, p as IPropertiesTab, action, typeOp); } else if (p is ICatalog) { this.VisitTabs(appGenGuig, p as ICatalog, action, typeOp); } else if (p is ICatalogFolder) { this.VisitTabs(appGenGuig, p as ICatalogFolder, action, typeOp); } else if (p is IDocument) { this.VisitTabs(appGenGuig, p as IDocument, action, typeOp); } else if (p is IGroupListConstants) { } else { throw new ArgumentException(); } }
public void ValidateSubTreeFromNode(ITreeConfigNode node, ILogger logger = null) { if (node == null) { return; } if (this.cancellationSourceForValidatingFullConfig != null) { this.cancellationSourceForValidatingFullConfig.Cancel(); // if (logger != null && logger.IsEnabled) if (logger != null) { logger.LogInformation("=== Cancellation request ==="); } } this.cancellationSourceForValidatingFullConfig = new CancellationTokenSource(); var token = this.cancellationSourceForValidatingFullConfig.Token; var visitor = new ValidationConfigVisitor(token, logger); visitor.UpdateSubstructCounts(node); (node as IConfigAcceptVisitor).AcceptConfigNodeVisitor(visitor); if (!token.IsCancellationRequested) { // update for UI from another Thread (if from async version) (it is not only update, many others including CountErrors, CountWarnings ... node.ValidationCollection.Clear(); node.ValidationCollection = visitor.Result; } else { logger.LogInformation("=== Cancelled ==="); } }
public AppSolution(ITreeConfigNode parent, string name, List <AppProject> listProjects) : this(parent) { Contract.Requires(listProjects != null); this.Name = name; foreach (var t in listProjects) { this.ListAppProjects.Add(t); } }
public CatalogFolder(ITreeConfigNode parent, string name, List <Property> listProperties) : this(parent) { Contract.Requires(listProperties != null); this.Name = name; foreach (var t in listProperties) { this.GroupProperties.ListProperties.Add(t); } }
public Plugin(ITreeConfigNode parent, IvPlugin plugin) : this(parent) { Contract.Requires(plugin != null); this.Guid = plugin.Guid.ToString(); this._Name = plugin.Name; this.Description = plugin.Description; this.VPlugin = plugin; this.IsEditable = false; }
public ConfigObjectBase(ITreeConfigNode parent, TValidator validator) : base(validator) { if (_logger == null) { _logger = Logger.CreateLogger <T>(); } this.Parent = parent; this.ListInModels = new List <IModelRow>(); }
public AppProject(ITreeConfigNode parent, string name, string projectPath) : this(parent) { Contract.Requires(parent != null); this.Name = name; #pragma warning disable CA1062 // Validate arguments of public methods (parent as AppSolution).ListAppProjects.Add(this); #pragma warning restore CA1062 // Validate arguments of public methods this.RelativeAppProjectPath = projectPath; }
public async Task ValidateSubTreeFromNodeAsync(ITreeConfigNode node) { // https://msdn.microsoft.com/en-us/magazine/jj991977.aspx // https://docs.microsoft.com/en-us/dotnet/standard/asynchronous-programming-patterns/task-based-asynchronous-pattern-tap // https://devblogs.microsoft.com/pfxteam/asynclazyt/ // https://github.com/StephenCleary/AsyncEx // https://msdn.microsoft.com/en-us/magazine/dn818493.aspx await Task.Run(() => { this.ValidateSubTreeFromNode(node); }).ConfigureAwait(false); // not keeping context because doing nothing after await }
public object Run(ITreeConfigNode node, bool isShortVersion) { TypeBuilder tbSol = SettingsTypeBuilder.GetTypeBuilder(); // type builder for solutions ConstructorBuilder constructor = tbSol.DefineDefaultConstructor(MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName); Config cfg = (Config)node.GetConfig(); var dic_sols = new Dictionary <string, object>(); foreach (var t in cfg.GroupAppSolutions.ListAppSolutions) { TypeBuilder tbPrj = SettingsTypeBuilder.GetTypeBuilder(); // type builder for projects var dic_prjs = new Dictionary <string, object>(); foreach (var tt in t.ListAppProjects) { Dictionary <string, object> dic_apgs = new Dictionary <string, object>(); var objAppGen = CreateSettingsForProject(node, tt, dic_apgs, isShortVersion); if (dic_apgs.Count > 0) { dic_prjs[tt.Name] = objAppGen; SettingsTypeBuilder.CreateProperty(tbPrj, tt.Name, objAppGen.GetType(), tt.NameUi, tt.Description); } } SettingsTypeBuilder.CreateToString(tbPrj, "Solution"); Type prjsType = tbPrj.CreateType(); SettingsTypeBuilder.CreateProperty(tbSol, t.Name, prjsType, t.NameUi, t.Description); object objPrj = Activator.CreateInstance(prjsType); foreach (var dt in dic_prjs) { prjsType.InvokeMember(dt.Key, BindingFlags.SetProperty, null, objPrj, new object[] { dt.Value }); } //if (dic_prjs.Count > 0) dic_sols[t.Name] = objPrj; } SettingsTypeBuilder.CreateToString(tbSol, "Solutions"); Type solsType = tbSol.CreateType(); object objSol = Activator.CreateInstance(solsType); foreach (var dt in dic_sols) { if (dic_sols.Count == 1) // remove solution level node in settings { return(dt.Value); } solsType.InvokeMember(dt.Key, BindingFlags.SetProperty, null, objSol, new object[] { dt.Value }); } if (dic_sols.Count == 0) { return(null); } return(objSol); }
public void UpdateSubstructCounts(ITreeConfigNode p) { Contract.Requires(p != null); var pp = p; while (pp.Parent != null) { pp = pp.Parent; pp.CountErrors -= p.CountErrors; pp.CountWarnings -= p.CountWarnings; pp.CountInfos -= p.CountInfos; } }
public ConfigObjectCommonBase(ITreeConfigNode parent, TValidator validator) : base(validator) { if (_logger == null) { _logger = Logger.CreateLogger <T>(); } this.IsNotifying = false; this.Parent = parent; this.ListInModels = new List <IModelRow>(); this.PropertyChanged += ConfigObjectCommonBase_PropertyChanged; this.IsNotifying = true; }
private void GetConfig(ITreeConfigNode parent) { ITreeConfigNode p = parent; while (p.Parent != null) { p = p.Parent; } if (!(p is Config)) { throw new Exception(); } this.cfg = (Config)p; }
private void ValidateSubAndCollectErrors(ITreeConfigNode p, IValidatableWithSeverity sub) { if (p is ICanGoLeft || p is ICanGoRight) // is visible in the tree { this.node = p; } sub.Validate(); foreach (var t in sub.ValidationCollection) { t.Model = this.node; this.AddMessage(p, t); } }
public IConfig GetConfig() { ITreeConfigNode p = this.Parent; if (p == null) { return(null); } while (p.Parent != null) { p = p.Parent; } return((IConfig)p); }
private static void GetObjectTypeDesc(StringBuilder sb, ITreeConfigNode prev) { if (prev is Catalog) { sb.Append("catalog '"); } else if (prev is Document) { sb.Append("document '"); } else if (prev is PropertiesTab) { sb.Append("properties tab '"); } else { throw new Exception(); } }
private void AddMessage(ITreeConfigNode p, ValidationMessage t) { this.UpdateAddCounts(p, t); t.RaiseSeverityLevel(this._level); ulong weight = 0; ITreeConfigNode nnode = p; while (nnode.Parent != null) { weight++; nnode = nnode.Parent; } if (weight > VmBindable.MaxSortingWeight) { throw new Exception(); } this.Result.Add(t, VmBindable.MaxSortingWeight - weight); }
public override ITreeConfigNode NodeAddNewSubNode(ITreeConfigNode node_impl = null) { Form node = null; if (node_impl == null) { node = new Form(this); } else { node = (Form)node_impl; } this.Add(node); if (node_impl == null) { this.GetUniqueName(Form.DefaultName, node, this.ListForms); } this.SetSelected(node); return(node); }
public override ITreeConfigNode NodeAddNewSubNode(ITreeConfigNode node_impl = null) { PropertiesTab node = null; if (node_impl == null) { node = new PropertiesTab(this); } else { node = (PropertiesTab)node_impl; } this.Add(node); if (node_impl == null) { this.GetUniqueName(PropertiesTab.DefaultName, node, this.ListPropertiesTabs); } this.SetSelected(node); return(node); }
public GeneratorDbSchemaNodeSettings(ITreeConfigNode node) : base(GeneratorDbSchemaNodeSettingsValidator.Validator) { //var lst = new List<string>(); //if (!(node is IConstant)) //{ // lst.Add(this.GetPropertyName(() => this.IsConstantParam1)); //} //if (!(node.Parent is ICatalog) && !(node is IForm)) //{ // lst.Add(this.GetPropertyName(() => this.IsCatalogFormParam1)); //} //this.HidePropertiesForXceedPropertyGrid(lst.ToArray()); this.DicNodeExcludedProperties = new Dictionary <string, string>(); if (!(node is IConstant)) { DicNodeExcludedProperties[this.GetPropertyName(() => this.IsConstantParam1)] = null;; } if (!(node.Parent is ICatalog) && !(node is IForm)) { DicNodeExcludedProperties[this.GetPropertyName(() => this.IsCatalogFormParam1)] = null; } }
public override ITreeConfigNode NodeAddNewSubNode(ITreeConfigNode node_impl = null) { BaseConfigLink node = null; if (node_impl == null) { node = new BaseConfigLink(this); } else { node = (BaseConfigLink)node_impl; } this.Add(node); if (node_impl == null) { this.GetUniqueName(BaseConfigLink.DefaultName, node, this.ListBaseConfigLinks); } this.SetSelected(node); return(node); }
public override ITreeConfigNode NodeAddNewSubNode(ITreeConfigNode node_impl = null) { Journal node = null; if (node_impl == null) { node = new Journal(this); } else { node = (Journal)node_impl; } this.Add(node); if (node_impl == null) { this.GetUniqueName(Journal.DefaultName, node, this.ListJournals); } this.SetSelected(node); return(node); }
public override ITreeConfigNode NodeAddNewSubNode(ITreeConfigNode node_impl = null) { Report node = null; if (node_impl == null) { node = new Report(this); } else { node = (Report)node_impl; } this.Add(node); if (node_impl == null) { this.GetUniqueName(Report.DefaultName, node, this.ListReports); } this.SetSelected(node); return(node); }
public override ITreeConfigNode NodeAddNewSubNode(ITreeConfigNode node_impl = null) { Catalog node = null; if (node_impl == null) { node = new Catalog(this); } else { node = (Catalog)node_impl; } this.Add(node); if (node_impl == null) { this.GetUniqueName(Catalog.DefaultName, node, this.ListCatalogs); } this.SetSelected(node); return(node); }
public override ITreeConfigNode NodeAddNewSubNode(ITreeConfigNode node_impl = null) { Enumeration node = null; if (node_impl == null) { node = new Enumeration(this); } else { node = (Enumeration)node_impl; } this.Add(node); if (node_impl == null) { this.GetUniqueName(Enumeration.DefaultName, node, this.ListEnumerations); } this.SetSelected(node); return(node); }