Example #1
0
        public static string GetNiceTypeName(System.Type type)
        {
            var options = new NamingOptions();

            options.NameOverrideFunc = ReflectionUtil.GetCSharpTypeAlias;
            return(ReflectionUtil.GetNiceTypeName(type, options));
        }
Example #2
0
        public static string GetNiceTypeName(System.Type type, NamingOptions options)
        {
            if (options != null && options.NameOverrideFunc != null)
            {
                string s = options.NameOverrideFunc(type);
                if (s != null)
                {
                    return(s);
                }
            }

            if (ReflectionUtil.IsNullableType(type))
            {
                var actualtype = type.GetGenericArguments()[0];
                return(ReflectionUtil.GetNiceTypeName(actualtype, options) + "?");
            }

            if (type.IsArray)
            {
                var at = type.GetElementType();
                return(String.Format("{0}[]", ReflectionUtil.GetNiceTypeName(at, options)));
            }

            if (type.IsGenericType)
            {
                var sb     = new System.Text.StringBuilder();
                var tokens = type.Name.Split('`');

                sb.Append(tokens[0]);
                var gas      = type.GetGenericArguments();
                var ga_names = gas.Select(i => ReflectionUtil.GetNiceTypeName(i, options));

                sb.Append("<");
                sb.AppendJoin(", ", ga_names);
                sb.Append(">");
                return(sb.ToString());
            }

            return(type.Name);
        }
 public TypeInfo(Type type)
 {
     this.Type         = type;
     this.TypeCategory = ReflectionUtil.GetTypeCategory(type);
     this.Label        = ReflectionUtil.GetTypeCategoryDisplayString(type) + " " + ReflectionUtil.GetNiceTypeName(type);
 }
        public IVisio.Document DrawScriptingDocumentation()
        {
            this._client.Application.AssertApplicationAvailable();

            var formdoc = new Models.Forms.FormDocument();

            formdoc.Subject = "VisioAutomation.Scripting Documenation";
            formdoc.Title   = "VisioAutomation.Scripting Documenation";
            formdoc.Creator = "";
            formdoc.Company = "";

            //docbuilder.BodyParaSpacingAfter = 6.0;
            var lines = new List <string>();

            var cmdst_props = Client.GetProperties().OrderBy(i => i.Name).ToList();
            var sb          = new System.Text.StringBuilder();
            var helpstr     = new System.Text.StringBuilder();

            foreach (var cmdset_prop in cmdst_props)
            {
                var cmdset_type = cmdset_prop.PropertyType;

                // Calculate the text
                var commands = CommandSet.GetCommands(cmdset_type);
                lines.Clear();
                foreach (var command in commands)
                {
                    sb.Length = 0;
                    var method_params = command.MethodInfo.GetParameters();
                    TextCommandsUtil.Join(sb, ", ", method_params.Select(param =>
                                                                         String.Format("{0} {1}", ReflectionUtil.GetNiceTypeName(param.ParameterType), param.Name)));

                    if (command.MethodInfo.ReturnType != typeof(void))
                    {
                        string line =
                            String.Format("{0}({1}) -> {2}", command.MethodInfo.Name, sb,
                                          ReflectionUtil.GetNiceTypeName(command.MethodInfo.ReturnType));
                        lines.Add(line);
                    }
                    else
                    {
                        string line = String.Format("{0}({1})", command.MethodInfo.Name, sb);
                        lines.Add(line);
                    }
                }

                lines.Sort();

                helpstr.Length = 0;
                TextCommandsUtil.Join(helpstr, "\r\n", lines);

                var formpage = new Models.Forms.FormPage();
                formpage.Title  = cmdset_prop.Name + " commands";
                formpage.Body   = helpstr.ToString();
                formpage.Name   = cmdset_prop.Name + " commands";
                formpage.Size   = new Drawing.Size(8.5, 11);
                formpage.Margin = new Drawing.Margin(0.5, 0.5, 0.5, 0.5);
                formdoc.Pages.Add(formpage);
            }


            //hide_ui_stuff(docbuilder.VisioDocument);

            var app = this._client.Application.Get();
            var doc = formdoc.Render(app);

            return(doc);
        }