Exemple #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);
            }
        }
Exemple #2
0
        private void details(StringBuilder sb, ApplicationComponent cmp, string param, string value)
        {
            if (param.IsNotNullOrWhiteSpace())
            {
                sb.AppendLine("<f color=gray>Trying to set parameter <f color=yellow>'{0}'<f color=gray> to value  <f color=cyan>'{1}'".Args(param, value ?? "<null>"));
                if (!ExternalParameterAttribute.SetParameter(cmp.App, cmp, param, value))
                {
                    sb.AppendLine("<f color=red>Parameter <f color=yellow>'{0}'<f color=red> set did NOT SUCCEED".Args(param));
                    return;
                }
                sb.AppendLine("<f color=green>Parameter <f color=yellow>'{0}'<f color=green> set SUCCEEDED".Args(param));
                sb.AppendLine();
            }

            dumpDetails(sb, cmp, 0);
        }
Exemple #3
0
 /// <summary>
 /// Sets external parameter value returning true if parameter was found and set
 /// </summary>
 public bool ExternalSetParameter(string name, object value, params string[] groups)
 {
     if (name.StartsWith(TBL_PARAM_PREFIX) && name.Length > TBL_PARAM_PREFIX.Length)
     {
         var tname = name.Substring(TBL_PARAM_PREFIX.Length);
         var tbl   = m_Tables[tname];
         if (tbl == null)
         {
             return(false);
         }
         tbl.Options.AsExternalParameter = value;
         return(true);
     }
     else
     {
         return(ExternalParameterAttribute.SetParameter(this, name, value, groups));
     }
 }
Exemple #4
0
 /// <summary>
 /// Sets external parameter value returning true if parameter was found and set
 /// </summary>
 public bool ExternalSetParameter(string name, object value, params string[] groups)
 {
     return(ExternalParameterAttribute.SetParameter(this, name, value, groups));
 }
Exemple #5
0
 /// <summary>
 /// Returns named parameters that can be used to control this component
 /// </summary>
 public IEnumerable <KeyValuePair <string, Type> > ExternalParametersForGroups(params string[] groups)
 {
     return(ExternalParameterAttribute.GetParameters(this, groups));
 }
Exemple #6
0
 /// <summary>
 /// Gets external parameter value returning true if parameter was found
 /// </summary>
 public virtual bool ExternalGetParameter(string name, out object value, params string[] groups)
 {
     return(ExternalParameterAttribute.GetParameter(this, name, out value, groups));
 }
Exemple #7
0
 protected virtual IEnumerable <KeyValuePair <string, Type> > DoGetExternalParametersForGroups(params string[] groups)
 {
     return(ExternalParameterAttribute.GetParameters(this, groups));
 }
Exemple #8
0
 protected virtual bool DoExternalSetParameter(string name, object value, params string[] groups)
 {
     return(ExternalParameterAttribute.SetParameter(this, name, value, groups));
 }
Exemple #9
0
 protected virtual IEnumerable <KeyValuePair <string, Type> > DoGetExternalParameters()
 {
     return(ExternalParameterAttribute.GetParameters(this));
 }
Exemple #10
0
 public bool ExternalSetParameter(string name, object value, params string[] groups)
 => ExternalParameterAttribute.SetParameter(App, this, name, value, groups);
Exemple #11
0
 protected virtual bool DoExternalGetParameter(string name, out object value, params string[] groups)
 {
     return(ExternalParameterAttribute.GetParameter(App, this, name, out value, groups));
 }
Exemple #12
0
 /// <summary>
 /// Returns named parameters that can be used to control this component
 /// </summary>
 public IEnumerable <KeyValuePair <string, Type> > ExternalParametersForGroups(params string[] groups)
 {
     return(ExternalParameterAttribute.GetParameters(this, groups).Concat(getTableOptionsAsExternalParameters()));
 }
 /// <summary>
 /// Sets external parameter value returning true if parameter was found and set
 /// </summary>
 public virtual bool ExternalSetParameter(string name, object value, params string[] groups)
 {
   return ExternalParameterAttribute.SetParameter(App, this, name, value, groups);
 }
Exemple #14
0
 /// <summary>
 /// Gets external parameter value returning true if parameter was found
 /// </summary>
 public virtual bool ExternalGetParameter(string name, out object value, params string[] groups)
 => ExternalParameterAttribute.GetParameter(App, this, name, out value, groups);
Exemple #15
0
 /// <summary>
 /// Returns named parameters that can be used to control this component
 /// </summary>
 public virtual IEnumerable <KeyValuePair <string, Type> > ExternalParametersForGroups(params string[] groups)
 => ExternalParameterAttribute.GetParameters(this, groups);
Exemple #16
0
 protected virtual bool DoExternalSetParameter(string name, object value, params string[] groups)
 => ExternalParameterAttribute.SetParameter(App, this, name, value, groups);