private void listOne(StringBuilder sb, IEnumerable <IApplicationComponent> all, IApplicationComponent cmp, int level) { if (level > 7) { return; //cyclical ref } var sp = level <= 0?string.Empty : string.Empty.PadLeft(level * 3); var pfx0 = sp + "<f color=darkgray>├▌"; var pfx = sp + "<f color=darkgray>├─"; var pfxL = sp + "<f color=darkgray>└─"; sb.AppendLine(pfx0 + "<f color={0}>SID: <f color=yellow>{1:D4} <f color=gray>{2} <f color=magenta>{3} <f color=green>{4} " .Args( level == 0 ? "white" : level > 1 ? "darkcyan" : "cyan", cmp.ComponentSID, Cmdlets.App.DetailedComponentDateTime(cmp.ComponentStartTime), cmp.ComponentCommonName, (cmp is INamed ? ((INamed)cmp).Name : ""))); if (cmp.ComponentDirector != null && !(cmp.ComponentDirector is ApplicationComponent)) { sb.AppendLine(pfx + "<f color=gray>Director: <f color=blue>" + cmp.ComponentDirector.GetType().FullName); } sb.AppendLine(pfxL + "<f color=gray>{0} <f color=darkgray>{1}".Args(cmp.GetType().FullName, System.IO.Path.GetFileName(cmp.GetType().Assembly.Location))); var children = all.Where(c => object.ReferenceEquals(c.ComponentDirector, cmp)); foreach (var child in children) { listOne(sb, all, child, level + 1); } if (level == 0) { sb.AppendLine(); } }
/// <summary> /// Creates and associates an <see cref="IApplicationComponentView"/> view for the <see cref="IApplicationComponent"/> for the current GUI toolkit. /// </summary> /// <remarks> /// The view is created based on the view extension point that is associated with the specified /// application component class using the <see cref="AssociateViewAttribute"/> attribute. /// </remarks> /// <param name="component">The <see cref="IApplicationComponent"/> for which a view is to be created and associated.</param> /// <returns>A new instance of the view for the specified application component.</returns> /// <exception cref="ArgumentException">Thrown if the application component type of <paramref name="component"/> does not have an associated view extension point (doesn't define <see cref="AssociateViewAttribute"/>).</exception> /// <exception cref="NotSupportedException">Thrown if a view extension for the specified model matching the specified GUI toolkit does not exist.</exception> /// <exception cref="InvalidOperationException">Thrown if the main application view has not been created yet.</exception> public static IApplicationComponentView CreateView(this IApplicationComponent component) { Platform.CheckForNullReference(component, "component"); var applicationComponentView = (IApplicationComponentView)CreateAssociatedView(component.GetType()); applicationComponentView.SetComponent(component); return(applicationComponentView); }
private JsonDataMap getComponentMap(IApplicationComponent cmp, string group = null) { var cmpMap = new JsonDataMap(); var parameterized = cmp as IExternallyParameterized; var instrumentable = cmp as IInstrumentable; cmpMap["instrumentable"] = instrumentable != null; cmpMap["instrumentationEnabled"] = instrumentable != null ? instrumentable.InstrumentationEnabled : false; cmpMap["SID"] = cmp.ComponentSID; cmpMap["startTime"] = Sky.Apps.Terminal.Cmdlets.Appl.DetailedComponentDateTime(cmp.ComponentStartTime); cmpMap["tp"] = cmp.GetType().FullName; if (cmp.ComponentCommonName.IsNotNullOrWhiteSpace()) { cmpMap["commonName"] = cmp.ComponentCommonName; } if (cmp is INamed) { cmpMap["name"] = ((INamed)cmp).Name; } if (cmp.ComponentDirector != null) { cmpMap["director"] = cmp.ComponentDirector.GetType().FullName; } if (parameterized == null) { return(cmpMap); } var pars = group.IsNotNullOrWhiteSpace() ? parameterized.ExternalParametersForGroups(group) : parameterized.ExternalParameters; if (pars == null) { return(cmpMap); } pars = pars.Where(p => p.Key != "InstrumentationEnabled").OrderBy(p => p.Key); if (pars.Count() == 0) { return(cmpMap); } var parameters = new List <JsonDataMap>(); foreach (var par in pars) { object val; if (!parameterized.ExternalGetParameter(par.Key, out val)) { continue; } var parameterMap = new JsonDataMap(); string[] plist = null; var tp = par.Value; if (tp == typeof(bool)) { plist = new string[] { "true", "false" } } ; else if (tp.IsEnum) { plist = Enum.GetNames(tp); } parameterMap["key"] = par.Key; parameterMap["plist"] = plist; var valStr = val.AsString(); if (valStr.IsNotNullOrWhiteSpace() && valStr.StartsWith(CoreConsts.EXT_PARAM_CONTENT_LACONIC)) { valStr = valStr.Substring(Azos.CoreConsts.EXT_PARAM_CONTENT_LACONIC.Length); parameterMap["val"] = valStr.AsLaconicConfig().ToJSONDataMap(); // parameterMap["val"] = @" { // 'detailed-instrumentation': true, // tables: // { // master: { name: 'tfactory', 'fields-qty': 14}, // slave: { name: 'tdoor', 'fields-qty': 20, important: true} // }, // tables1: // { // master: { name: 'tfactory', 'fields-qty': 14}, // slave: { name: 'tdoor', 'fields-qty': 20, important: true} // }, // tables2: // { // master: { name: 'tfactory', 'fields-qty': 14}, // slave: { name: 'tdoor', 'fields-qty': 20, important: true} // } // }".JSONToDataObject(); parameterMap["ct"] = "obj"; // content type is object (string in JSON format) } else { parameterMap["val"] = val; parameterMap["ct"] = "reg"; // content type is regular } parameters.Add(parameterMap); } cmpMap["params"] = parameters; return(cmpMap); }
/// <summary> /// Constructor. /// </summary> /// <param name="path">The path to this page in the navigation tree.</param> /// <param name="component">The application component to be displayed by this page</param> public NavigatorPage(string path, IApplicationComponent component) : this(new Path(path, new ResourceResolver(new [] { component.GetType().Assembly })), component) { }
/// <summary> /// Constructor. /// </summary> /// <param name="path">The path to this page in the navigation tree.</param> /// <param name="component">The application component to be displayed by this page</param> public NavigatorPage(string path, IApplicationComponent component) :this(new Path(path, new ResourceResolver(new [] { component.GetType().Assembly })), component) { }