Exemple #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);
        }
Exemple #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());
        }
Exemple #3
0
 internal static TypeName ParseTypeName(string typeName, GenericNameContext context)
 {
     return(new TypeCodeReferenceParser(typeName, context).Parse());
 }
Exemple #4
0
 internal static TypeName ParseTypeName(string typeName, MethodName context)
 {
     return(ParseTypeName(typeName, GenericNameContext.Create(context)));
 }
Exemple #5
0
 public static ParameterData[] SplitParameters(string parametersText, MethodName context)
 {
     return(SplitParameters(parametersText, GenericNameContext.Create(context)));
 }
 public TypeCodeReferenceParser(string typeName, GenericNameContext context)
 {
     this.s       = new Scanner(typeName);
     this.context = context;
 }