Beispiel #1
0
        /// <summary>
        ///     Creates the list of data list item view model to bind to.
        /// </summary>
        /// <param name="errorString">The error string.</param>
        /// <returns></returns>
        public void CreateListsOfIDataListItemModelToBindTo(out string errorString)
        {
            errorString = string.Empty;
            if (!string.IsNullOrEmpty(Resource.DataList))
            {
                ErrorResultTO errors = new ErrorResultTO();
                try
                {
                    if (!string.IsNullOrEmpty(Resource.DataList))
                    {
                        ConvertDataListStringToCollections(Resource.DataList);
                    }
                }
                catch (Exception)
                {
                    errors.AddError(ErrorResource.InvalidVariableList);
                }
            }
            else
            {
                RecsetCollection.Clear();
                ScalarCollection.Clear();
                ComplexObjectCollection.Clear();

                _recordsetHandler.AddRecordSet();
            }

            BaseCollection = new OptomizedObservableCollection <DataListHeaderItemModel>();

            DataListHeaderItemModel variableNode = DataListItemModelFactory.CreateDataListHeaderItem("Variable");

            if (ScalarCollection.Count == 0)
            {
                IScalarItemModel dataListItemModel = DataListItemModelFactory.CreateScalarItemModel(string.Empty);
                dataListItemModel.IsComplexObject = false;
                dataListItemModel.AllowNotes      = false;
                ScalarCollection.Add(dataListItemModel);
            }
            BaseCollection.Add(variableNode);

            DataListHeaderItemModel recordsetsNode = DataListItemModelFactory.CreateDataListHeaderItem("Recordset");

            if (RecsetCollection.Count == 0)
            {
                _recordsetHandler.AddRecordSet();
            }
            BaseCollection.Add(recordsetsNode);

            DataListHeaderItemModel complexObjectNode = DataListItemModelFactory.CreateDataListHeaderItem("Object");

            BaseCollection.Add(complexObjectNode);

            AddBlankRow(null);

            BaseCollection[0].Children = ScalarCollection;
            BaseCollection[1].Children = RecsetCollection;
            BaseCollection[2].Children = ComplexObjectCollection;

            WriteToResourceModel();
        }
Beispiel #2
0
        /// <summary>
        ///     Creates the list of data list item view model to bind to.
        /// </summary>
        /// <param name="errorString">The error string.</param>
        /// <returns></returns>
        public void CreateListsOfIDataListItemModelToBindTo(out string errorString)
        {
            errorString = string.Empty;
            IDataListCompiler compiler = DataListFactory.CreateDataListCompiler();

            if (!string.IsNullOrEmpty(Resource.DataList))
            {
                ErrorResultTO errors = new ErrorResultTO();
                try
                {
                    IBinaryDataList binarnyDl = CreateBinaryDataListFromXmlData(Resource.DataList, out errors);
                    if (!errors.HasErrors())
                    {
                        ConvertBinaryDataListToListOfIDataListItemModels(binarnyDl, out errorString);
                    }
                    else
                    {
                        string errorMessage = errors.FetchErrors().Aggregate(string.Empty, (current, error) => current + error);
                        throw new Exception(errorMessage);
                    }
                    if (binarnyDl != null)
                    {
                        compiler.ForceDeleteDataListByID(binarnyDl.UID);
                    }
                }
                catch (Exception)
                {
                    errors.AddError("Invalid variable list. Please insure that your variable list has valid entries");
                }
            }
            else
            {
                RecsetCollection.Clear();
                AddRecordSet();
                ScalarCollection.Clear();
            }

            BaseCollection = new OptomizedObservableCollection <DataListHeaderItemModel>();

            DataListHeaderItemModel varNode = DataListItemModelFactory.CreateDataListHeaderItem("Variable");

            if (ScalarCollection.Count == 0)
            {
                var dataListItemModel = DataListItemModelFactory.CreateDataListModel(string.Empty);
                ScalarCollection.Add(dataListItemModel);
            }
            varNode.Children = ScalarCollection;
            BaseCollection.Add(varNode);

            //AddRecordsetNamesIfMissing();

            DataListHeaderItemModel recordsetsNode = DataListItemModelFactory.CreateDataListHeaderItem("Recordset");

            if (RecsetCollection.Count == 0)
            {
                AddRecordSet();
            }
            recordsetsNode.Children = RecsetCollection;
            BaseCollection.Add(recordsetsNode);
        }
        internal IList<IDataListItemModel> CreateDataListItemViewModel(string name, int numberOfChildren, IDataListViewModel dataListVM) {
            IList<IDataListItemModel> dataListItemViewModels = new OptomizedObservableCollection<IDataListItemModel>();
            if(numberOfChildren == 1) {
                dataListItemViewModels.Add(CreateDataListItemViewModel(name, dataListVM));
            }
            else {
                for(int i = 0; i < numberOfChildren; i++) {
                    IDataListItemModel dLVM = CreateDataListItemViewModel((string.Format("{0}{1}", name, (i + 1))), dataListVM);
                    dataListItemViewModels.Add(dLVM);
                }
            }

            return dataListItemViewModels;
        }
Beispiel #4
0
        /// <summary>
        ///     Creates the full data list.
        /// </summary>
        /// <returns></returns>
        private OptomizedObservableCollection <IDataListItemModel> CreateFullDataList()
        {
            var fullDataList = new OptomizedObservableCollection <IDataListItemModel>();

            foreach (var item in ScalarCollection)
            {
                fullDataList.Add(item);
            }
            foreach (var item in RecsetCollection)
            {
                fullDataList.Add(item);
            }

            return(fullDataList);
        }
Beispiel #5
0
        /// <summary>
        /// Creates the list of data list item view model to bind to.
        /// </summary>
        /// <param name="_resource">The resource model.</param>
        /// <param name="errorString">The error string.</param>
        /// <returns></returns>
        private void CreateListsOfIDataListItemModelToBindTo(out string errorString)
        {
            ErrorResultTO errors = new ErrorResultTO();

            errorString = string.Empty;
            if (!string.IsNullOrEmpty(_resource.DataList))
            {
                IBinaryDataList binarnyDL = CreateBinaryDataListFromXmlData(_resource.DataList, out errors);
                if (!errors.HasErrors())
                {
                    ConvertBinaryDataListToListOfIDataListItemModels(binarnyDL, out errorString);
                }
                else
                {
                    string errorMessage = string.Empty;
                    foreach (string error in errors.FetchErrors())
                    {
                        errorMessage += error;
                    }
                    throw new Exception(errorMessage);
                }
                _compiler.ForceDeleteDataListByID(binarnyDL.UID);
            }
            else
            {
                RecsetCollection = new OptomizedObservableCollection <IDataListItemModel>();
                AddRecordSet();
                ScalarCollection = new OptomizedObservableCollection <IDataListItemModel>();
                ScalarCollection.Add(DataListItemModelFactory.CreateDataListModel(string.Empty));
            }
            BaseCollection = new OptomizedObservableCollection <DataListHeaderItemModel>();
            DataListHeaderItemModel VarNode = DataListItemModelFactory.CreateDataListHeaderItem("Variables");

            if (ScalarCollection.Count == 0)
            {
                ScalarCollection.Add(DataListItemModelFactory.CreateDataListModel(string.Empty));
            }
            VarNode.Children = ScalarCollection;
            BaseCollection.Add(VarNode);
            DataListHeaderItemModel RecordsetsNode = DataListItemModelFactory.CreateDataListHeaderItem("Recordsets");

            if (RecsetCollection.Count == 0)
            {
                AddRecordSet();
            }
            RecordsetsNode.Children = RecsetCollection;
            BaseCollection.Add(RecordsetsNode);
        }
Beispiel #6
0
        /// <summary>
        /// Converts a binary data list to list a data list item view models.
        /// </summary>
        /// <param name="dataListToConvert">The data list to convert.</param>
        /// <param name="errorString">The error string.</param>
        /// <returns></returns>
        private void ConvertBinaryDataListToListOfIDataListItemModels(IBinaryDataList dataListToConvert, out string errorString)
        {
            errorString      = string.Empty;
            RecsetCollection = new OptomizedObservableCollection <IDataListItemModel>();
            ScalarCollection = new OptomizedObservableCollection <IDataListItemModel>();

            IList <IBinaryDataListEntry> listOfEntries = dataListToConvert.FetchAllEntries();

            foreach (IBinaryDataListEntry entry in listOfEntries)
            {
                if (entry.IsRecordset)
                {
                    IDataListItemModel recset = DataListItemModelFactory.CreateDataListModel(entry.Namespace, entry.Description, entry.ColumnIODirection);
                    recset.IsEditable = entry.IsEditable;
                    Validator.Add(recset);
                    foreach (Dev2Column col in entry.Columns)
                    {
                        IDataListItemModel child = DataListItemModelFactory.CreateDataListModel(col.ColumnName, col.ColumnDescription, col.ColumnIODirection);
                        child.Parent     = recset;
                        child.IsEditable = col.IsEditable;
                        recset.Children.Add(child);
                        recset.Validator.Add(child);
                    }

                    RecsetCollection.Add(recset);
                }
                else
                {
                    IDataListItemModel scalar = DataListItemModelFactory.CreateDataListModel(entry.Namespace, entry.Description, entry.ColumnIODirection);
                    scalar.IsEditable = entry.IsEditable;
                    ScalarCollection.Add(scalar);
                    Validator.Add(scalar);
                }
            }
        }
        private void SetChildOutputValues(bool value)
        {
            UpdatingChildren = true;
            var updatedChildren = new OptomizedObservableCollection <IDataListItemModel>();

            if (Children != null)
            {
                foreach (var dataListItemModel in Children)
                {
                    var child = (DataListItemModel)dataListItemModel;
                    child.UpdatingChildren = true;
                    child.Output           = value;
                    child.UpdatingChildren = false;
                    updatedChildren.Add(child);
                }
            }
            UpdatingChildren = false;
            if (Children != null)
            {
                Children.Clear();
                foreach (var dataListItemModel in updatedChildren)
                {
                    Children.Add(dataListItemModel);
                }
            }
        }
        public void UpdateOnActionSelection_GivenHasInputsWithDataTypes_ShouldWriteToActiveDatalistAndPopulatesInputValues()
        {
            //---------------Set up test pack-------------------
            var eventAggregator = new Mock <IEventAggregator>();

            var mockResourceModel = Dev2MockFactory.SetupResourceModelMock();

            mockResourceModel.Setup(resModel => resModel.WorkflowXaml).Returns(WorkflowXAMLForTest());

            var dataListViewModel  = CreateDataListViewModel(mockResourceModel, eventAggregator.Object);
            var dataListItems      = new OptomizedObservableCollection <IScalarItemModel>();
            var dataListItem       = new ScalarItemModel("scalar1", enDev2ColumnArgumentDirection.Input, string.Empty);
            var secondDataListItem = new ScalarItemModel("scalar2", enDev2ColumnArgumentDirection.Input, string.Empty);

            dataListItems.Add(dataListItem);
            dataListItems.Add(secondDataListItem);

            DataListSingleton.SetDataList(dataListViewModel);



            var id  = Guid.NewGuid();
            var act = new DsfDotNetDllActivity()
            {
                SourceId = id
            };
            var modelItem    = ModelItemUtils.CreateModelItem(act);
            var actionRegion = new Mock <IActionToolRegion <IPluginAction> >();

            actionRegion.Setup(region => region.SelectedAction).Returns(ValueFunctionWithTypes);

            //---------------Assert Precondition----------------

            var countBefore = DataListSingleton.ActiveDataList.ScalarCollection.Count;

            Assert.AreEqual(4, countBefore);
            //---------------Execute Test ----------------------
            var inputRegion = new DotNetInputRegion(modelItem, actionRegion.Object);

            var methodInfo = typeof(DotNetInputRegion).GetMethod("UpdateOnActionSelection", BindingFlags.NonPublic | BindingFlags.Instance);

            Assert.IsNotNull(methodInfo);
            methodInfo.Invoke(inputRegion, new object[] { });
            //---------------Test Result -----------------------
            Assert.AreEqual("[[name]]", inputRegion.Inputs.ToList()[0].Value);
            Assert.AreEqual("[[surname]]", inputRegion.Inputs.ToList()[1].Value);
        }
        public OptomizedObservableCollection <IDataListItemModel> CreateFullDataList()
        {
            var fullDataList = new OptomizedObservableCollection <IDataListItemModel>();

            foreach (var item in _dataListViewModel.ScalarCollection)
            {
                fullDataList.Add(item);
            }
            foreach (var item in _dataListViewModel.RecsetCollection)
            {
                fullDataList.Add(item);
            }
            foreach (var item in _dataListViewModel.ComplexObjectCollection)
            {
                fullDataList.Add(item);
            }
            return(fullDataList);
        }
Beispiel #10
0
        internal IList <IDataListItemModel> CreateDataListItemViewModel(string name, int numberOfChildren, IDataListViewModel dataListVM)
        {
            IList <IDataListItemModel> dataListItemViewModels = new OptomizedObservableCollection <IDataListItemModel>();

            if (numberOfChildren == 1)
            {
                dataListItemViewModels.Add(CreateDataListItemViewModel(name, dataListVM));
            }
            else
            {
                for (int i = 0; i < numberOfChildren; i++)
                {
                    IDataListItemModel dLVM = CreateDataListItemViewModel((string.Format("{0}{1}", name, (i + 1))), dataListVM);
                    dataListItemViewModels.Add(dLVM);
                }
            }

            return(dataListItemViewModels);
        }
        private OptomizedObservableCollection <IDataListItemModel> CreateChildren(IDataListItemModel parent, int numberOfChildrenToCreate)
        {
            OptomizedObservableCollection <IDataListItemModel> children = new OptomizedObservableCollection <IDataListItemModel>();

            for (int i = 1; i <= numberOfChildrenToCreate; i++)
            {
                children.Add(new DataListItemModel("child" + i.ToString(), enDev2ColumnArgumentDirection.None, "", parent));
            }

            return(children);
        }
Beispiel #12
0
        private OptomizedObservableCollection <IDataListItemModel> ReturnDefaultDataListViewModel(IDataListViewModel dLVM, bool isRecordSet, string dataListItemName = null)
        {
            OptomizedObservableCollection <IDataListItemModel> CollectionObservableCollection = new OptomizedObservableCollection <IDataListItemModel>();
            Mock <IDataListItemModel> dataListItemViewModel = CreateDataListItemViewModel(dataListItemName, dLVM);

            if (isRecordSet)
            {
                dataListItemViewModel.Setup(c => c.IsRecordset).Returns(true);
                dataListItemViewModel.Setup(c => c.DisplayName).Returns("UnitTestRepresentationValue");
                dataListItemViewModel.Setup(c => c.Children).Returns(CollectionObservableCollection);
            }
            else
            {
                dataListItemViewModel.SetupGet(d => d.DisplayName).Returns(dataListItemName);
            }
            CollectionObservableCollection.Add(dataListItemViewModel.Object);

            return(CollectionObservableCollection);
        }
        private void SetChildOutputValues(bool value)
        {
            UpdatingChildren = true;
            var updatedChildren = new OptomizedObservableCollection<IDataListItemModel>();
            if(Children != null)
            {
                foreach(var dataListItemModel in Children)
                {
                    var child = (DataListItemModel)dataListItemModel;
                    child.UpdatingChildren = true;
                    child.Output = value;
                    child.UpdatingChildren = false;
                    updatedChildren.Add(child);
                }
            }
            UpdatingChildren = false;
            if(Children != null)
            {
                Children.Clear();
                foreach(var dataListItemModel in updatedChildren)
                {
                    Children.Add(dataListItemModel);
                }

            }
        }
        public void AddMissingDataListItemsWithUnusedDataListItemsExpectedItemsToBeSetToNotUsed()
        {
            var eventAggregator = new Mock<IEventAggregator>().Object;

            Mock<IContextualResourceModel> mockResourceModel = Dev2MockFactory.SetupResourceModelMock();
            mockResourceModel.Setup(resModel => resModel.WorkflowXaml).Returns(GetAddMissingWorkflowXml());

            var dataListViewModel = CreateDataListViewModel(mockResourceModel, eventAggregator);
            var dataListItems = new OptomizedObservableCollection<IDataListItemModel>();
            IDataListItemModel dataListItem = new DataListItemModel("scalar1", enDev2ColumnArgumentDirection.Input, string.Empty);
            IDataListItemModel secondDataListItem = new DataListItemModel("scalar2", enDev2ColumnArgumentDirection.Input, string.Empty);

            dataListItems.Add(dataListItem);
            dataListItems.Add(secondDataListItem);

            DataListSingleton.SetDataList(dataListViewModel);
            Mock<IPopupController> mockPopUp = Dev2MockFactory.CreateIPopup(MessageBoxResult.Yes);

            dataListViewModel.ScalarCollection.Clear();
            dataListViewModel.RecsetCollection.Clear();
            dataListItems.ToList().ForEach(dataListViewModel.ScalarCollection.Add);
            WorkflowDesignerViewModel workflowDesigner = CreateWorkflowDesignerViewModel(eventAggregator, mockResourceModel.Object, null, false);
            workflowDesigner.PopUp = mockPopUp.Object;

            workflowDesigner.AddMissingWithNoPopUpAndFindUnusedDataListItems();
            Assert.AreEqual(2, dataListViewModel.ScalarCollection.Count);
            Assert.AreEqual(0, dataListViewModel.RecsetCollection.Count);
            workflowDesigner.Dispose();
        }
        public void FindUnusedDataListItemsWithUnusedDataListItemsExpectedItemsToBeSetToNotUsed()
        {
            var eventAggregator = new EventAggregator();

            Mock<IContextualResourceModel> mockResourceModel = Dev2MockFactory.SetupResourceModelMock();
            mockResourceModel.Setup(resModel => resModel.WorkflowXaml).Returns(WorkflowXAMLForTest());

            var dataListViewModel = CreateDataListViewModel(mockResourceModel, eventAggregator);
            var dataListItems = new OptomizedObservableCollection<IDataListItemModel>();
            IDataListItemModel dataListItem = new DataListItemModel("scalar1", enDev2ColumnArgumentDirection.Input, string.Empty);
            IDataListItemModel secondDataListItem = new DataListItemModel("scalar2", enDev2ColumnArgumentDirection.Input, string.Empty);

            dataListItems.Add(dataListItem);
            dataListItems.Add(secondDataListItem);
            DataListSingleton.SetDataList(dataListViewModel);
            Mock<IPopupController> mockPopUp = Dev2MockFactory.CreateIPopup(MessageBoxResult.Yes);

            dataListItems.ToList().ForEach(dataListViewModel.ScalarCollection.Add);
            dataListViewModel.RecsetCollection.Clear();
            WorkflowDesignerViewModel workflowDesigner = CreateWorkflowDesignerViewModelWithDesignerAttributesInitialized(mockResourceModel.Object, eventAggregator);
            workflowDesigner.PopUp = mockPopUp.Object;
            //  workflowDesigner.MediatorRepo = _mockMediatorRepo.Object;

            Assert.IsTrue(dataListViewModel.ScalarCollection[0].IsUsed);
            Assert.IsTrue(dataListViewModel.ScalarCollection[1].IsUsed);

            workflowDesigner.AddMissingWithNoPopUpAndFindUnusedDataListItems();
            workflowDesigner.Dispose();
            Assert.IsTrue(!dataListViewModel.ScalarCollection[0].IsUsed);
        }
        public void SetModelToDirtyAndExpectThatItemsWillBeAdded()
        {
            var eventAggregator = new EventAggregator();

            Mock<IContextualResourceModel> mockResourceModel = Dev2MockFactory.SetupResourceModelMock();
            mockResourceModel.Setup(resModel => resModel.WorkflowXaml).Returns(WorkflowXAMLForTest());

            var dataListViewModel = CreateDataListViewModel(mockResourceModel, eventAggregator);
            var dataListItems = new OptomizedObservableCollection<IDataListItemModel>();
            IDataListItemModel dataListItem = new DataListItemModel("scalar1", enDev2ColumnArgumentDirection.Input, string.Empty);
            IDataListItemModel secondDataListItem = new DataListItemModel("scalar2", enDev2ColumnArgumentDirection.Input, string.Empty);

            dataListItems.Add(dataListItem);
            dataListItems.Add(secondDataListItem);

            DataListSingleton.SetDataList(dataListViewModel);

            dataListItems.ToList().ForEach(dataListViewModel.ScalarCollection.Add);
            dataListViewModel.RecsetCollection.Clear();
            WorkflowDesignerViewModel workflowDesigner = CreateWorkflowDesignerViewModel(eventAggregator, mockResourceModel.Object, null, false);
            workflowDesigner.DispatcherUpdateAction = (a => DataListSingleton.ActiveDataList.UpdateDataListItems(workflowDesigner.ResourceModel, a));
            IDataListItemModel dataListItem3 = new DataListItemModel("scalar8", enDev2ColumnArgumentDirection.Input, string.Empty);
            workflowDesigner.ChangeIsPossible = true;

            dataListItems.Add(dataListItem3);
            Thread.Sleep(3000);
            workflowDesigner.Dispose();
            Assert.AreEqual(5, dataListViewModel.ScalarCollection.Count);
        }
        public void RemoveAllUnusedDataListObjectsWithItemsNotUsedExpectedItemsRemoved()
        {
            var eventAggregator = new EventAggregator();

            Mock<IContextualResourceModel> mockResourceModel = Dev2MockFactory.SetupResourceModelMock();
            mockResourceModel.Setup(resModel => resModel.WorkflowXaml).Returns(WorkflowXAMLForTest());

            var dataListViewModel = CreateDataListViewModel(mockResourceModel, eventAggregator);
            var dataListItems = new OptomizedObservableCollection<IDataListItemModel>();
            IDataListItemModel dataListItem = new DataListItemModel("scalar1", enDev2ColumnArgumentDirection.Input, string.Empty);
            IDataListItemModel secondDataListItem = new DataListItemModel("scalar2", enDev2ColumnArgumentDirection.Input, string.Empty);

            dataListItems.Add(dataListItem);
            dataListItems.Add(secondDataListItem);

            DataListSingleton.SetDataList(dataListViewModel);

            dataListItems.ToList().ForEach(dataListViewModel.ScalarCollection.Add);
            dataListViewModel.RecsetCollection.Clear();
            WorkflowDesignerViewModel workflowDesigner = CreateWorkflowDesignerViewModel(eventAggregator, mockResourceModel.Object, null, false);
            workflowDesigner.DispatcherUpdateAction = (a => DataListSingleton.ActiveDataList.UpdateDataListItems(workflowDesigner.ResourceModel, a));
            workflowDesigner.AddMissingWithNoPopUpAndFindUnusedDataListItems();
            dataListViewModel.RemoveUnusedDataListItems();
            workflowDesigner.Dispose();
            Assert.AreEqual(0, dataListViewModel.ScalarCollection.Count);
        }
        private OptomizedObservableCollection<IDataListItemModel> ReturnDefaultDataListViewModel(IDataListViewModel dLVM, bool isRecordSet, string dataListItemName = null) {
            OptomizedObservableCollection<IDataListItemModel> CollectionObservableCollection = new OptomizedObservableCollection<IDataListItemModel>();
            Mock<IDataListItemModel> dataListItemViewModel = CreateDataListItemViewModel(dataListItemName, dLVM);
            if (isRecordSet) {

                    dataListItemViewModel.Setup(c => c.IsRecordset).Returns(true);
                    dataListItemViewModel.Setup(c => c.DisplayName).Returns("UnitTestRepresentationValue");
                    dataListItemViewModel.Setup(c => c.Children).Returns(CollectionObservableCollection);
                   
            }
            else {
                dataListItemViewModel.SetupGet(d => d.DisplayName).Returns(dataListItemName);
                

            }
            CollectionObservableCollection.Add(dataListItemViewModel.Object);

            return CollectionObservableCollection;
        }
Beispiel #19
0
        /// <summary>
        ///     Creates the full data list.
        /// </summary>
        /// <returns></returns>
        private OptomizedObservableCollection<IDataListItemModel> CreateFullDataList()
        {
            var fullDataList = new OptomizedObservableCollection<IDataListItemModel>();
            foreach(var item in ScalarCollection)
            {
                fullDataList.Add(item);
            }
            foreach(var item in RecsetCollection)
            {
                fullDataList.Add(item);
            }

            return fullDataList;
        }
Beispiel #20
0
        /// <summary>
        ///     Creates the list of data list item view model to bind to.
        /// </summary>
        /// <param name="errorString">The error string.</param>
        /// <returns></returns>
        public void CreateListsOfIDataListItemModelToBindTo(out string errorString)
        {
            errorString = string.Empty;
            if(!string.IsNullOrEmpty(Resource.DataList))
            {
                ErrorResultTO errors = new ErrorResultTO();
                try
                {
                    ConvertDataListStringToCollections(Resource.DataList);
                }
                catch(Exception)
                {
                    errors.AddError("Invalid variable list. Please insure that your variable list has valid entries");
                }
            }
            else
            {
                RecsetCollection.Clear();
                AddRecordSet();
                ScalarCollection.Clear();
            }

            BaseCollection = new OptomizedObservableCollection<DataListHeaderItemModel>();

            DataListHeaderItemModel varNode = DataListItemModelFactory.CreateDataListHeaderItem("Variable");
            if(ScalarCollection.Count == 0)
            {
                var dataListItemModel = DataListItemModelFactory.CreateDataListModel(string.Empty);
                ScalarCollection.Add(dataListItemModel);
            }
            varNode.Children = ScalarCollection;
            BaseCollection.Add(varNode);

            DataListHeaderItemModel recordsetsNode = DataListItemModelFactory.CreateDataListHeaderItem("Recordset");
            if(RecsetCollection.Count == 0)
            {
                AddRecordSet();
            }
            recordsetsNode.Children = RecsetCollection;
            BaseCollection.Add(recordsetsNode);
        }
        private OptomizedObservableCollection<IDataListItemModel> CreateChildren(IDataListItemModel parent, int numberOfChildrenToCreate)
        {
            OptomizedObservableCollection<IDataListItemModel> children = new OptomizedObservableCollection<IDataListItemModel>();
            for(int i = 1; i <= numberOfChildrenToCreate; i++)
            {
                children.Add(new DataListItemModel("child" + i, enDev2ColumnArgumentDirection.None, "", parent));
            }

            return children;
        }
        /// <summary>
        ///     Creates the list of data list item view model to bind to.
        /// </summary>
        /// <param name="errorString">The error string.</param>
        /// <returns></returns>
        public void CreateListsOfIDataListItemModelToBindTo(out string errorString)
        {
            errorString = string.Empty;
            IDataListCompiler compiler = DataListFactory.CreateDataListCompiler();
            if(!string.IsNullOrEmpty(Resource.DataList))
            {
                ErrorResultTO errors = new ErrorResultTO();
                try
                {
                    IBinaryDataList binarnyDl = CreateBinaryDataListFromXmlData(Resource.DataList, out errors);
                    if (!errors.HasErrors())
                    {
                        ConvertBinaryDataListToListOfIDataListItemModels(binarnyDl, out errorString);
                    }
                    else
                    {
                        string errorMessage = errors.FetchErrors().Aggregate(string.Empty, (current, error) => current + error);
                        throw new Exception(errorMessage);
                    }
                    if (binarnyDl != null)
                        compiler.ForceDeleteDataListByID(binarnyDl.UID);
                }
                catch(Exception)
                {
                    errors.AddError("Invalid variable list. Please insure that your variable list has valid entries");
                }
               

            }
            else
            {
                RecsetCollection.Clear();
                AddRecordSet();
                ScalarCollection.Clear();
            }

            BaseCollection = new OptomizedObservableCollection<DataListHeaderItemModel>();

            DataListHeaderItemModel varNode = DataListItemModelFactory.CreateDataListHeaderItem("Variable");
            if(ScalarCollection.Count == 0)
            {
                var dataListItemModel = DataListItemModelFactory.CreateDataListModel(string.Empty);
                ScalarCollection.Add(dataListItemModel);
            }
            varNode.Children = ScalarCollection;
            BaseCollection.Add(varNode);

            //AddRecordsetNamesIfMissing();

            DataListHeaderItemModel recordsetsNode = DataListItemModelFactory.CreateDataListHeaderItem("Recordset");
            if(RecsetCollection.Count == 0)
            {
                AddRecordSet();
            }
            recordsetsNode.Children = RecsetCollection;
            BaseCollection.Add(recordsetsNode);
        }