Пример #1
0
        static void HelperParseParametersAndReturnType(DefaultMethodName s, string myReturnType, string parameters,
                                                       out ParameterData[] pms, out TypeName returnType)
        {
            pms        = null;
            returnType = null;

            if (myReturnType == null && s.Name == "op_Explicit" || s.Name == "op_Implicit")
            {
                var toSyntaxParams = Regex.Split(parameters, @"\s+to\s+");
                if (toSyntaxParams.Length == 2)
                {
                    returnType = TypeCodeReference.ParseTypeName(toSyntaxParams[1], s);
                    pms        = MethodCodeReference.SplitParameters(toSyntaxParams[0], s);
                    return;
                }
            }
            if (myReturnType != null)
            {
                returnType = TypeCodeReference.ParseTypeName(myReturnType, s);
            }

            pms = MethodCodeReference.SplitParameters(parameters, s);
        }
Пример #2
0
        public static ParameterData[] SplitParameters(string parametersText, GenericNameContext context)
        {
            if (parametersText.Length == 0)
            {
                return(Array.Empty <ParameterData>());
            }

            var list = new List <ParameterData>();

            foreach (string t in SplitParametersInternal(parametersText))
            {
                if (string.IsNullOrWhiteSpace(t))
                {
                    list.Add(new ParameterData(string.Empty, null));
                    continue;
                }

                string typeName = t.Trim();
                var    targ     = string.IsNullOrEmpty(typeName) ? null : TypeCodeReference.ParseTypeName(typeName, context);
                list.Add(new ParameterData(null, targ));
            }

            return(list.ToArray());
        }
Пример #3
0
 public static CodeReference Type(string text)
 {
     return(TypeCodeReference.ParseType(text));
 }