Example #1
0
        private void dumpDetails(StringBuilder sb, ApplicationComponent cmp, int level)
        {
            if (level > 7)
            {
                return;   //cyclical ref
            }
            var pfx = level <= 0?string.Empty : string.Empty.PadLeft(level) + "->";

            sb.AppendLine(pfx + "<f color=white>SID: <f color=yellow> " + cmp.ComponentSID);
            sb.AppendLine(pfx + "<f color=gray>CommonName: <f color=magenta> " + cmp.ComponentCommonName);
            sb.AppendLine(pfx + "<f color=gray>Start Time (local): <f color=yellow> " + cmp.ComponentStartTime);
            sb.AppendLine(pfx + "<f color=gray>Type: <f color=yellow> " + cmp.GetType().FullName);
            sb.AppendLine(pfx + "<f color=gray>Assembly: <f color=yellow> " + cmp.GetType().Assembly.FullName);
            sb.AppendLine(pfx + "<f color=gray>Service: <f color=yellow> " + (cmp is Azos.Apps.Daemon ? "Yes" : "No"));
            if (cmp is INamed)
            {
                sb.AppendLine(pfx + "<f color=gray>Name: <f color=green> " + ((INamed)cmp).Name);
            }

            sb.AppendLine(pfx + "<f color=gray>Interfaces: <f color=yellow> " + cmp.GetType()
                          .GetInterfaces()
                          .OrderBy(it => it.FullName)
                          .Aggregate("", (r, i) =>
                                     r + (typeof(IExternallyParameterized).IsAssignableFrom(i) ?
                                          "<f color=cyan>{0}<f color=yellow>".Args(i.Name) : i.Name) + ", "));

            sb.AppendLine();
            sb.AppendLine();
            sb.AppendLine(pfx + "Parameters: ");
            sb.AppendLine();

            var pars = ExternalParameterAttribute.GetParametersWithAttrs(cmp.GetType());

            foreach (var p in pars)
            {
                var    nm = p.Item1;
                object val;
                if (!ExternalParameterAttribute.GetParameter(cmp.App, cmp, nm, out val))
                {
                    val = "?";
                }
                var tp  = p.Item2;
                var atr = p.Item3;
                sb.AppendLine(pfx + "<f color=gray>{0,-35}: <f color=white>{1,-10} <f color=darkyellow>({2})  <f color=darkgreen>{3}".Args(
                                  nm,
                                  val == null ? "<null>" : val,
                                  tp.DisplayNameWithExpandedGenericArgs().Replace('<', '(').Replace('>', ')')
                                  , atr.Groups == null?"*":atr.Groups.Aggregate("", (r, a) => r + a + ", ")));
            }


            sb.AppendLine();
            var dir = cmp.ComponentDirector;

            sb.AppendLine(pfx + "<f color=gray>Director: <f color=magenta> " + (dir == null? " -none- " : dir.GetType().FullName));
            if (dir is ApplicationComponent)
            {
                dumpDetails(sb, dir as ApplicationComponent, level + 1);
            }
        }
Example #2
0
File: CMan.cs Project: saleyn/agni
        private void listOne(StringBuilder sb, IEnumerable <ApplicationComponent> all, ApplicationComponent 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,
                              Appl.fdt(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();
            }
        }
 public ValidationEditorComponent(ApplicationComponent component)
     : this(component.GetType())
 {
     _liveComponent = component;
 }
Example #4
0
        private JSONDataMap getComponentMap(ApplicationComponent 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"] = Agni.AppModel.Terminal.Cmdlets.Appl.fdt(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(NFX.CoreConsts.EXT_PARAM_CONTENT_LACONIC))
                {
                    valStr = valStr.Substring(NFX.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);
        }