Пример #1
0
 CompletionContext ParseElement(CompletionContext parentContext)
 {
     do
     {
         if (reader.NodeType == XmlNodeType.Element)
         {
             bool     isEmpty = reader.IsEmptyElement;
             ItemData data    = parentContext.GetElementData(reader.LocalName);
             if (data != null)
             {
                 CompletionContext childCtx = (CompletionContext)Activator.CreateInstance(data.ChildContextType);
                 childCtx.Init(parentContext, reader);
                 reader.Read();
                 if (PositionFound())
                 {
                     return(FillContext(childCtx));
                 }
                 if (!isEmpty)
                 {
                     CompletionContext ctx = ParseElement(childCtx);
                     if (ctx != null)
                     {
                         return(ctx);
                     }
                 }
             }
             else
             {
                 reader.Skip();
                 if (PositionFound())
                 {
                     return(null);
                 }
             }
         }
         else if (PositionFound())
         {
             if (OpeningElement)
             {
                 return(ModuleExtensionContext(module));
             }
             else
             {
                 return(null);
             }
         }
     }while (reader.Read());
 }
Пример #2
0
        CompletionContext GetCompletionContext(int numParent)
        {
            XElement element = GetParentElement(numParent);

            if (element == null)
            {
                return(topCtx);
            }

            CompletionContext parentContext;

            parentContext = GetCompletionContext(numParent + 1);

            if (parentContext == null)
            {
                return(null);
            }

            if (!element.IsNamed)
            {
                return(parentContext);
            }
            ItemData data = parentContext.GetElementData(element.Name.Name);

            if (data == null)
            {
                return(null);
            }
            if (data.ChildContextType == null)
            {
                return(null);
            }
            if (adesc == null)
            {
                return(null);
            }

            CompletionContext ctx = (CompletionContext)Activator.CreateInstance(data.ChildContextType);

            ctx.Init(registry, adesc, parentContext, element);
            return(ctx);
        }