private IEnumerable <NormalType> _GetSubTypes() { if (string.IsNullOrWhiteSpace(_GenericTypeString)) { yield break; } string genericString = _GenericTypeString; string nestStr = ""; int nestLevel = 0; for (int i = 0; i < genericString.Length; i++) { char ch = genericString[i]; if (ch == '<') { nestLevel++; nestStr += "<"; //if we're in a sub-nest, keep the < ie, the second < in "List<List<int>>" but not the first < } else if (ch == '>') { nestLevel--; nestStr += ">"; } else if (ch == ',' && nestLevel == 0) { yield return(NormalType.CreateNormalType(nestStr)); //generate our generic type link nestStr = ""; } else if (ch == ' ') { //do nothing, ignore spaces } else { nestStr += ch.ToString(); } } if (!string.IsNullOrEmpty(nestStr)) { yield return(NormalType.CreateNormalType(nestStr)); } }
/// <summary> /// Gets the method parameter type names from the member name. /// </summary> /// <returns>The method parameter type name list.</returns> /// <example> /// It will prepend the type kind character (<c>T:</c>) to the type string. /// <para>For <c>(System.String,System.Int32)</c>, returns <c>["T:System.String","T:System.Int32"]</c>.</para> /// It also handle generic type. /// <para>For <c>(System.Collections.Generic.IEnumerable{System.String})</c>, returns <c>["T:System.Collections.Generic.IEnumerable{System.String}"]</c>.</para> /// </example> public IEnumerable <NormalType> GetParamTypes() { if (_ParamTypes.Any()) //using the "new" stuff, get the parameter types from the param tags { return(_ParamTypes.Select(x => NormalType.CreateNormalType(x))); } else if (!_Name.Contains('(')) //if there's no parameters (non method/constructor) { return(Enumerable.Empty <NormalType>()); } else { string paramString = _Name.Split('(').Last().Trim(')'); int delta = 0; string ret = ""; var list = new List <string>(); foreach (var ch in paramString) { if (ch == '{') { delta++; } else if (ch == '}') { delta--; } else if (ch != ',' || delta != 0) { ret += ch.ToString(); } else if (delta == 0 && ch == ',') { list.Add(ret); ret = ""; } } return(list.Select(x => NormalType.CreateNormalType(x))); } }