public static CLogTypeContainer[] BuildTypes(CLogConfigurationFile configFile, CLogLineMatch traceLineMatch, string argString, string traceLine, out string cleanedString) { List <CLogTypeContainer> ret = new List <CLogTypeContainer>(); string pieces = string.Empty; int argCount = 0; cleanedString = string.Empty; string prefixString = ""; if (string.IsNullOrEmpty(argString)) { return(new CLogTypeContainer[0]); } // Make surew e start and stop with a quote - this prevents L"" (unicode) as well as other oddities that seem to be 'okay' in WPP but shoudlnt be okay argString = argString.Trim(); for (int i = 0; i < argString.Length; ++i) { pieces += argString[i]; if ('%' == argString[i]) { pieces += argCount++; pieces += " "; CLogTypeContainer newNode = new CLogTypeContainer(); newNode.LeadingString = prefixString; newNode.ArgStartingIndex = i; ++i; CLogEncodingCLogTypeSearch t; try { // 'i' will point to the final character on a match (such that i+1 is the next fresh character) t = configFile.FindTypeAndAdvance(argString, traceLineMatch, ref i); } catch (CLogTypeNotFoundException e) { throw e; } newNode.TypeNode = t; newNode.ArgLength = i - newNode.ArgStartingIndex + 1; prefixString = ""; ret.Add(newNode); } else { prefixString += argString[i]; } } cleanedString = pieces; return(ret.ToArray()); }
public static CLogTypeContainer[] BuildTypes(CLogConfigurationFile configFile, CLogLineMatch traceLineMatch, string argString, string traceLine, out DecomposedString decompString) { List <CLogTypeContainer> ret = new List <CLogTypeContainer>(); string pieces = string.Empty; int argCount = 0; decompString = new DecomposedString(); string prefixString = ""; DecomposedString.EncodingArg currentArg = decompString.CreateNewArg(); if (string.IsNullOrEmpty(argString)) { return(new CLogTypeContainer[0]); } // Make sure we start and stop with a quote - this prevents L"" (unicode) as well as other oddities that seem to be 'okay' in WPP but shoudlnt be okay argString = argString.Trim(); for (int i = 0; i < argString.Length; ++i) { pieces += argString[i]; currentArg.Prefix += argString[i]; if ('%' == argString[i]) { pieces += (argCount++) + 1;; CLogTypeContainer newNode = new CLogTypeContainer(); newNode.LeadingString = prefixString; newNode.ArgStartingIndex = i; currentArg = decompString.CreateNewArg(); ++i; // Check to see if a custom name is specified for this type string preferredName = ""; if ('{' == argString[i]) { // Skip the opening brace i++; if (i == argString.Length) { throw new CLogEnterReadOnlyModeException("InvalidNameFormatInTypeSpcifier", CLogHandledException.ExceptionType.TooFewArguments, traceLineMatch); } while (',' != argString[i]) { // If we find a closing brace or a space before finding the comma, it's a parsing error if ('}' == argString[i] || char.IsWhiteSpace(argString[i])) { throw new CLogEnterReadOnlyModeException("InvalidNameFormatInTypeSpcifier", CLogHandledException.ExceptionType.WhiteSpaceNotAllowed, traceLineMatch); } preferredName += argString[i]; i++; if (i == argString.Length) { throw new CLogEnterReadOnlyModeException("InvalidNameFormatInTypeSpcifier", CLogHandledException.ExceptionType.TooFewArguments, traceLineMatch); } } // Skip the comma i++; // Don't allow white spaces after comma if (char.IsWhiteSpace(argString[i])) { throw new CLogEnterReadOnlyModeException("InvalidNameFormatInTypeSpcifier", CLogHandledException.ExceptionType.WhiteSpaceNotAllowed, traceLineMatch); } if (i == argString.Length) { throw new CLogEnterReadOnlyModeException("InvalidNameFormatInTypeSpcifier", CLogHandledException.ExceptionType.TooFewArguments, traceLineMatch); } } CLogEncodingCLogTypeSearch t; try { // 'i' will point to the final character on a match (such that i+1 is the next fresh character) t = configFile.FindTypeAndAdvance(argString, traceLineMatch, ref i); } catch (CLogTypeNotFoundException) { throw; } // If we found a preferred name, the next character after the type should be a closing brace if (preferredName.Length != 0) { i++; if (i == argString.Length || '}' != argString[i]) { throw new CLogEnterReadOnlyModeException("InvalidNameFormatInTypeSpcifier", CLogHandledException.ExceptionType.TooFewArguments, traceLineMatch); } newNode.PreferredName = preferredName; } // Compute lengths newNode.TypeNode = t; newNode.ArgLength = i - newNode.ArgStartingIndex + 1; currentArg.Type = t; prefixString = ""; ret.Add(newNode); } else { prefixString += argString[i]; } } if (!pieces.Equals(decompString.AsManifestedETWEncoding)) { throw new Exception("ETW strings dont match"); } return(ret.ToArray()); }