Example #1
0
        static bool TryParseHelper(string text, out PropertyName result)
        {
            result = default(PropertyName);
            text   = text.Trim();

            string name, declaring;
            string parameters;

            name = SplitMemberName(text, out declaring, out parameters);
            if (parameters.Length > 0 && parameters.Last() != ')' && parameters[0] != '(')
            {
                return(false);
            }

            if (parameters.Length > 0)
            {
                parameters = parameters.Substring(1, parameters.Length - 2).Trim();
            }

            if (declaring.Length == 0)
            {
                var pms = MethodCodeReference.SplitParameters(parameters, null);
                result = new PropertyName(null, name, null, pms);
                return(true);
            }
            else
            {
                TypeName type;
                if (TypeName.TryParse(declaring, out type))
                {
                    var pms = MethodCodeReference.SplitParameters(parameters, GenericNameContext.Create(type));

                    result = new PropertyName(type, name, null, pms);
                    return(true);
                }
            }

            return(false);
        }
Example #2
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);
        }
Example #3
0
 protected internal override string FormatGenericInstanceMethod(string format, GenericInstanceMethodName name, IFormatProvider formatProvider)
 {
     return(MethodCodeReference.FormatMethod(name));
 }
Example #4
0
 public static CodeReference Method(string text)
 {
     return(MethodCodeReference.ParseMethod(text));
 }