private void SetupRootNodes()
 {
     var rootNode = new RootNode();
     var dataXml = XmlNode.Parse("<data><note desc=\"1\" body=\"One!\"/><note desc=\"2\" body=\"Two?\"/></data>");
     var template = XDocument.Load(@"..\..\templates\noteviewer.xml");
     var templateXml = XmlNode.Parse(template.ToString());
     rootNode.Register<IParentNodeImplementor>(new AggregateNode(dataXml, templateXml));
     dataNode = rootNode.Nodes("data").First();
     templateNode = rootNode.Nodes().Skip(1).First();
 }
        public object InitializeController(IContainer container)
        {
            _xpath = new XPathDecoder();
            var rootNode = new RootNode();

            var template = XDocument.Load(@"..\..\templates\noteviewer.xml");
            if (template.Root == null) throw new Exception("Invalid xml document");

            var xmlNode = XmlNode.Parse("<data><note desc=\"1\" body=\"One!\"/><note desc=\"2\" body=\"Two?\"/></data>");
            //TODO: This needs to be generated dynamically somehow
            var storageNode = XmlNode.Parse("<dynamicData><rowSelector/><textOutput/></dynamicData>");
            var templateNode = XmlNode.Parse(template.ToString());

            rootNode.Register<IParentNodeImplementor>(new AggregateNode(xmlNode, storageNode, templateNode));

            var dataRoot = rootNode.Nodes("data").First();
            var dynamicData = rootNode.Nodes("dynamicData").First();
            var uiRoot = rootNode.Nodes().Skip(2).First();
            //bug: here it is...  this needs to be implemented.  Will want to switch EndNodeWrapper to derive from NodeBase to fix
            //            ProcessTemplateElem(dataRoot, uiRoot);

            //            var fnGetDesc = _xpath.GetPathFunc<IAccessor<string>>("@descr");
            //            var fnGetText = _xpath.GetPathFunc<IAccessor<string>>("@body");
            Func<IParentNode, IAccessor<string>> fnGetDesc = node => node.Attribute("desc").Get<IAccessor<string>>();
            Func<IParentNode, IAccessor<string>> fnGetText = node => node.Attribute("body").Get<IAccessor<string>>();
            var fnGetNotes = _xpath.GetPathFunc<IEnumerable<IParentNode>>("//note");

            EntityList entityList;
            BuildNoteList(dataRoot, fnGetNotes, fnGetDesc, container, out entityList);
            var textDisplay = BuildTextDisplay(dynamicData, container);
            var _entityListController = BuildEntitySelector(dataRoot, fnGetText, rootNode, dynamicData);
            Initialize((IUIInitialize)textDisplay, entityList);

            //TODO:  3. Enforce the constraint that new objects go through a factory where the INode is known at creation time, and a proxy is returned
            //This will eliminate a lot of the difficulty I've been having figuring out what to do when I new objects

            //TODO:  $$ Overall this is pretty awesome, but it can't respond to changes to the IAccessor<string>, only to the column list of the IEntityRow
            return _entityListController;
        }