示例#1
0
        public static ParsedType Parse(string type)
        {
            var less_than = type.IndexOf('<');

            // No generics
            if (less_than < 0)
            {
                return new ParsedType {
                           Type = type
                }
            }
            ;

            var greater_than = type.LastIndexOf('>');
            var type_args    = type.Substring(less_than + 1, greater_than - less_than - 1);
            var type_string  = type.Substring(0, less_than) + "<{0}>" + (greater_than + 1 < type.Length ? type.Substring(greater_than + 1) : string.Empty);

            var parsed_args = ParseTypeList(type_args);

            var t = new ParsedType {
                Type = type_string
            };

            foreach (var p in parsed_args)
            {
                t.GenericArguments.Add(Parse(p));
            }

            return(t);
        }
示例#2
0
        public string GetOutputName(string type)
        {
            // Handle a few special cases
            if (type == "System.Void")
            {
                return("void");
            }
            if (type.StartsWith("params "))
            {
                return("params " + GetOutputName(type.Substring("params ".Length)));
            }
            if (type.StartsWith("global::"))
            {
                Report.LogCodedError(Report.ErrorUnexpectedGlobal);
            }
            if (!UseGlobal)
            {
                return(type);
            }

            // Add "global::" in front of types
            return(ParsedType.Parse(type).ToString(UseGlobal));
        }