public HmdEnum(String context, String inlineDefinition) { inlineDefinition = inlineDefinition.ToLower(); this.name = context; this.values = HmdStringExtensions.SplitByWhitespace(inlineDefinition, 0); if (this.values == null || this.values.Length <= 0) { throw new FormatException("Invalid inline enum definition"); } }
public HmdEnum(String definition) { int saveOffset, offset = 0; // skip whitespace while (true) { if (offset >= definition.Length) { throw new FormatException("Reached end of enum definition too soon"); } if (!Char.IsWhiteSpace(definition[offset])) { break; } offset++; } saveOffset = offset; while (true) { offset++; if (offset >= definition.Length) { throw new FormatException("Reached end of enum definition too soon"); } if (Char.IsWhiteSpace(definition[offset])) { break; } } this.name = definition.Substring(saveOffset, offset - saveOffset); offset++; this.values = HmdStringExtensions.SplitByWhitespace(definition, offset); if (this.values == null || this.values.Length <= 0) { throw new FormatException("Reached end of enum definition too soon"); } }