public void BuildMethodArgs(string id) { // Could be any of the following // CompNode.CompNode.Property, // () // (Property, // ((type)literal, // ((type) DisposeAllArgs(); if (string.IsNullOrEmpty(id) || id[0] == ')') { return; } int nArg = 0; _argStatements = new List <IDPropertyList>(); while (!string.IsNullOrEmpty(id)) { _argStatements.Add(new IDPropertyList(this, null, nArg)); IDPropertyList curList = _argStatements[nArg++]; if (id[0] == '(') { id = SplitLiteral(curList, id); } else { id = SplitMethodOrProperty(curList, id); } } }
public string SplitLiteral(IDPropertyList propList, string id) { // Should be in the form of // "(type)1.00, // "(type), // Extract the type Type tgtType = null; int tyEnd = id.IndexOf(')'); if (tyEnd > 0) { string sType = id.Substring(1, tyEnd - 1); id = id.Substring(tyEnd + 1); try { tgtType = Type.GetType("System." + sType); } catch { } if (tgtType == null) { try { tgtType = U.TryGetType(sType); } catch { } } if (tgtType == null) { U.LogPopup("expected to find a type declaration for '{0}'", id); tgtType = typeof(string); } } else { U.LogPopup("expected to find a closing ')' in type declaration for '{0}'", id); } // Look for end of value string value = string.Empty; int endOfVal = id.IndexOf(','); if (endOfVal >= 0) { value = id.Substring(0, endOfVal); id = id.Substring(endOfVal); } else { value = id.TrimEnd(')'); id = string.Empty; } propList.SetLiteralValue(value, tgtType); return(id.TrimStart(',')); }