Пример #1
0
        private void DetectElement(string source)
        {
            source = source.Substring(1, source.Length - 2);
            var tag   = source.Split(' ').First().ToLower();
            var attrs = ResolveAttributes(source, tag);

            if (RuleActions.ContainsKey(tag))
            {
                var action = RuleActions[tag];
                action.Invoke(tag, attrs);
            }
            else if (tag.FirstOrDefault() == '/')
            {
                var element = OpennedElements.Pop();
            }
            else if (source.LastOrDefault() == '/')
            {
                var elementType     = DomElements[tag];
                var elementInstance = Activator.CreateInstance(elementType) as HTMLElement;

                if (elementInstance != null)
                {
                    elementInstance.IsNeedClose = false;
                }

                ResolveElement(elementInstance, elementType, tag, attrs);
            }
            else if (DomElements.ContainsKey(tag))
            {
                var elementType     = DomElements[tag];
                var elementInstance = Activator.CreateInstance(elementType) as HTMLElement;

                ResolveElement(elementInstance, elementType, tag, attrs);
            }
        }