GetEnum() public static method

public static GetEnum ( string type ) : FrameType
type string
return FrameType
示例#1
0
        private void DeterminateNextTag(StrWithCursor fileName, StrWithCursor pattern, out Dictionary <FrameType, string> frames)
        {
            //TODO ::  Why do we need to use a copy constructor?
            fileName = new StrWithCursor(fileName);
            pattern  = new StrWithCursor(pattern);

            var tag   = new StringBuilder();                                 //Detreminated tag
            var value = new StringBuilder();                                 //Determinated value

            while (fileName != '*' && pattern != '*' && fileName == pattern) //Go to first different symbol
            {
                fileName++;
                pattern++;
            }

            if (pattern == '<')
            {
                DeterminateTag(pattern, tag);
            }
            else
            {
                frames = null;
                return; //If this is not tag - error => return null
            }

            while (fileName != '*' || pattern == '*')
            {
                if (pattern == fileName) //Maybe it first symbol after tag
                {
                    if (fileName == '*') //if end of string than this valid string
                    {
                        frames = new Dictionary <FrameType, string> {
                            { Frame.GetEnum(tag.ToString()), value.ToString() }
                        };                                                                                              //Create and eturn them
                        return;
                    }

                    DeterminateNextTag(fileName, pattern, out frames);               //If not end of string, determinate next
                    if (frames != null)                                              //If recusive method returned non-null dictionary its actualy end of tag
                    {
                        frames.Add(Frame.GetEnum(tag.ToString()), value.ToString()); //We should return them
                        return;
                    } //If returned null, then this not end of string. Continue reading
                }
                value.Append(fileName.Value);
                fileName++;
            }

            frames = null;
        }
示例#2
0
        public List <FrameType> GetTags()
        {
            var pattern    = new StrWithCursor(Pattern);
            var parsedTags = new SortedSet <FrameType>();
            var tag        = new StringBuilder();

            while (pattern != '*')
            {
                if (pattern == '<')
                {
                    DeterminateTag(pattern, tag);
                    parsedTags.Add(Frame.GetEnum(tag.ToString()));
                    tag.Clear();
                }
                else
                {
                    pattern++;
                }
            }

            return(parsedTags.Count != 0 ? parsedTags.ToList() : null);
        }