コード例 #1
0
ファイル: HmdEnum.cs プロジェクト: As-You-Like/DotNetStuff
        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");
            }
        }
コード例 #2
0
ファイル: HmdEnum.cs プロジェクト: As-You-Like/DotNetStuff
        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");
            }
        }