public static MethodInstance GetMethodInstance(string name)
        {
            List <Type> methodtTypes = Utils.GetObjectsWithBaseType(typeof(MethodBase), true);

            string[] aliasses = new string[0];
            foreach (Type t in methodtTypes)
            {
                FormatMethodAttribute att = FormatMethodAttribute.GetAttribute(t);
                if (att != null)
                {
                    if (att.Name.Equals(name, StringComparison.Ordinal))
                    {
                        MethodInstance instance = new MethodInstance()
                        {
                            Formatter = (MethodBase)Activator.CreateInstance(t), Name = att.Name
                        };
                        foreach (FormatMethodParameterAttribute at in att.Parameters)
                        {
                            instance.Properties.Add(at);
                        }

                        return(instance);
                    }
                    else
                    {
                        aliasses = Utils.Split(att.Aliasses, ",");
                        foreach (string alias in aliasses)
                        {
                            if (alias.Trim().Equals(name, StringComparison.Ordinal))
                            {
                                MethodInstance instance = new MethodInstance()
                                {
                                    Formatter = (MethodBase)Activator.CreateInstance(t), Name = att.Name
                                };
                                foreach (FormatMethodParameterAttribute at in att.Parameters)
                                {
                                    instance.Properties.Add(at);
                                }

                                return(instance);
                            }
                        }
                    }
                }
            }
            return(null);
        }
Beispiel #2
0
        public void ListFormatters(StringBuilder sb)
        {
            List <Type> methodtTypes             = Utils.GetObjectsWithBaseType(typeof(MethodBase), true);
            List <FormatMethodAttribute> attribs = new List <FormatMethodAttribute>();

            foreach (Type t in methodtTypes)
            {
                FormatMethodAttribute att = FormatMethodAttribute.GetAttribute(t);
                if (!string.IsNullOrEmpty(att.Name))
                {
                    attribs.Add(att);
                }
            }
            attribs = (from t in attribs
                       orderby t.Name ascending
                       select t).ToList();

            foreach (FormatMethodAttribute att in attribs)
            {
                sb.Append(BuildItemHelp(att));
            }
        }
        public override void Initialize()
        {
            _ListBoxInsight.Items.Clear();

            List <Type> methodtTypes             = Utils.GetObjectsWithBaseType(typeof(GK.Template.Methods.MethodBase), true);
            List <FormatMethodAttribute> attribs = new List <FormatMethodAttribute>();

            foreach (Type t in methodtTypes)
            {
                FormatMethodAttribute att = FormatMethodAttribute.GetAttribute(t);
                if (!string.IsNullOrEmpty(att.Name))
                {
                    attribs.Add(att);
                }
            }
            attribs = (from t in attribs
                       orderby t.Name ascending
                       select t).ToList();

            foreach (FormatMethodAttribute att in attribs)
            {
                _ListBoxInsight.Items.Add(att);
            }
        }