public static string DebugDescribe(this object obj) { if (obj == null) { return("[null]"); } IDebugDescribable idd = obj as IDebugDescribable; if (idd != null) { return(idd.DebugDescribe( )); } return("[" + obj.ToString( ) + "]"); }
public static void DebugDescribe(this System.Text.StringBuilder sb, IDebugDescribable dd) { sb.Append ( (dd==null)?("NULL"):(dd.DebugDescribe())); }
public bool ExtractFromString(ref string str, bool required) { bool success = false; // FIXME find matching! if (str.Length < sep0.Length + sep1.Length) { Debug.Log("Can't extract with seps " + sep0 + " " + sep1 + " as str too short '" + str + "'"); } else { // string regexStr = @"^(" + ENDS_REGEX + @")"; // System.Text.RegularExpressions.Regex regex = // new System.Text.RegularExpressions.Regex( Sep1StartRegex ); // System.Text.RegularExpressions.Match match = regex.Match( str ); if (str.StartsWith(sep0)) { string prevStr = str; //Found first. Now search forward for matching if (DEBUG_Parsing) { Debug.Log("Found " + sep0 + " at start of " + str); } int index = sep0.Length; string contentString = string.Empty; int numNestedNotMatched = 0; while (!success && index < (str.Length - sep1.Length + 1)) { string testString = str.Substring(index, sep1.Length); if (testString.StartsWith(sep0)) { if (DEBUG_Parsing) { Debug.Log("Found " + sep0 + " at " + index + " (" + numNestedNotMatched + ")"); } numNestedNotMatched++; index = index + sep0.Length; } else if (testString.StartsWith(sep1)) { if (numNestedNotMatched > 0) { if (DEBUG_Parsing) { Debug.Log("Found " + sep1 + " at " + index + " (" + numNestedNotMatched + ")"); } numNestedNotMatched--; index = index + sep1.Length; } else { contentString = str.Substring(sep0.Length, index - sep0.Length); string msg = "Found matching " + sep1 + " for initial " + sep0 + " in '" + str + "'" + "\nContent = '" + contentString + "'"; int contentLength = contentString.Length; if (_extractFromString(ref contentString)) { int deleteLength = sep0.Length + contentLength + sep1.Length; if (deleteLength > str.Length) { Debug.LogError("deleteLength " + deleteLength + " strLen=" + str.Length); str = string.Empty; } else if (deleteLength == str.Length) { str = string.Empty; } else { str = str.Substring(deleteLength); } msg = msg + "'\nRemaining = '" + str + "'"; msg = msg + "\n" + GetType( ) + " Extracted from '" + prevStr; IDebugDescribable dd = this as IDebugDescribable; if (dd != null) { msg = msg + "\n" + dd.DebugDescribe( ); } if (DEBUG_Parsing) { Debug.Log(msg); } success = true; } else { Debug.LogWarning("Failed to extract from " + contentString); index = str.Length; } } } else { index = index + 1; } } if (!success) { string warningStr = GetType( ) + " Failed to read " + typeof(T) + " from \n" + str; if (required) { throw new System.Exception(warningStr); } else { if (DEBUG_AbstractStringExtractable || DebugType( )) { Debug.LogWarning(warningStr); } } } } else { Debug.LogWarning("Doesn't start with " + sep0 + " : " + str); } } return(success); }
public static void DebugDescribe(this System.Text.StringBuilder sb, IDebugDescribable dd) { sb.Append((dd == null) ? ("NULL") : (dd.DebugDescribe( ))); }
public static string DebugDescribe(this IDebugDescribable obj) { sb.Length = 0; obj.DebugDescribe(sb); return(sb.ToString( )); }
public static string DebugDescribe(this IDebugDescribable dd) { System.Text.StringBuilder sb = new System.Text.StringBuilder( ); dd.DebugDescribe(sb); return(sb.ToString( )); }