Inheritance: IDataListItem, INotifyPropertyChanged
 IList<IDataListItem> ConvertToIDataListItem(IScalar scalar)
 {
     IList<IDataListItem> result = new List<IDataListItem>();
     var item = scalar;
     if (item != null)
     {
         IDataListItem singleRes = new DataListItem();
         singleRes.IsRecordset = false;
         singleRes.Field = item.Name;
         singleRes.DisplayValue = item.Name;
         try
         {
             singleRes.Value = item.Value;
         }
         catch (Exception)
         {
             singleRes.Value = null;
         }
         var desc = item.Description;
         singleRes.Description = string.IsNullOrWhiteSpace(desc) ? null : desc;
         result.Add(singleRes);
     }
     return result;
 }
        public void SetWorkflowInputData_AddRow_WhenNotAllColumnsInput_ExpectNewRowWithOnlyInputColumns()
        {
            //------------Setup for test--------------------------
            const string Shape = @"<DataList><rec Description="""" IsEditable=""True"" ColumnIODirection=""None"" ><a Description="""" IsEditable=""True"" ColumnIODirection=""Input"" /><b Description="""" IsEditable=""True"" ColumnIODirection=""None"" /></rec></DataList>";

            var rm = new Mock<IContextualResourceModel>();
            rm.Setup(r => r.ServerID).Returns(_serverID);
            rm.Setup(r => r.ResourceName).Returns(ResourceName);
            rm.Setup(r => r.WorkflowXaml).Returns(new StringBuilder(StringResourcesTest.DebugInputWindow_WorkflowXaml));
            rm.Setup(r => r.ID).Returns(_resourceID);
            rm.Setup(r => r.DataList).Returns(Shape);

            var serviceDebugInfoModel = new ServiceDebugInfoModel
            {
                DebugModeSetting = DebugMode.DebugInteractive,
                RememberInputs = true,
                ResourceModel = rm.Object,
                ServiceInputData = "xxxxx"
            };

            var debugVM = CreateDebugOutputViewModel();

            var itemToAdd = new DataListItem { DisplayValue = "rec(1).a", Field = "a", Recordset = "rec", IsRecordset = true, RecordsetIndex = "1", RecordsetIndexType = enRecordsetIndexType.Numeric, Value = "1" };

            //------------Execute Test---------------------------
            var workflowInputDataViewModel = new WorkflowInputDataViewModel(serviceDebugInfoModel, debugVM.SessionID);
            workflowInputDataViewModel.LoadWorkflowInputs();
            var inputs = workflowInputDataViewModel.WorkflowInputs;
            Assert.AreEqual(1, inputs.Count);
            inputs[0].Value = "1"; // trick it into thinking this happened from the UI ;)
            workflowInputDataViewModel.AddRow(itemToAdd);

            //------------Assert Results-------------------------
            inputs = workflowInputDataViewModel.WorkflowInputs;
            Assert.AreEqual(2, inputs.Count);
        }
        IList<IDataListItem> ConvertToIDataListItem(IRecordSet recordSet)
        {
            IList<IDataListItem> result = new List<IDataListItem>();
            var dataListEntry = recordSet;
            
            foreach(var column in dataListEntry.Columns)
            {
                var fields = column.Value.Where(c => c.IODirection == enDev2ColumnArgumentDirection.Both || c.IODirection == enDev2ColumnArgumentDirection.Input).ToList();
                foreach (var col in fields)
                {
                    IDataListItem singleRes = new DataListItem();
                    singleRes.IsRecordset = true;
                    singleRes.Recordset = recordSet.Name;
                    singleRes.Field = col.Name;
                    singleRes.RecordsetIndex = column.Key.ToString();
                    singleRes.Value = col.Value;
                    singleRes.DisplayValue = string.Concat(recordSet.Name, "(", column.Key, ").", col.Name);
                    singleRes.Description = col.Description;
                    result.Add(singleRes);

                }      
            }
                                 
            return result;
        }
        IList<IDataListItem> ConvertIBinaryDataListEntryToIDataListItem(IBinaryDataListEntry dataListEntry)
        {
            IList<IDataListItem> result = new List<IDataListItem>();
            if(dataListEntry.IsRecordset)
            {
                var sizeOfCollection = dataListEntry.ItemCollectionSize();
                if(sizeOfCollection == 0) { sizeOfCollection++; }
                var count = 0;

                var fields = dataListEntry.Columns.Where(c => c.ColumnIODirection == enDev2ColumnArgumentDirection.Both || c.ColumnIODirection == enDev2ColumnArgumentDirection.Input).ToList();

                while(count < sizeOfCollection)
                {
                    string error;
                    var items = dataListEntry.FetchRecordAt(count + 1, out error);
                    foreach(var item in items)
                    {
                        // check field mapping ;)
                        if(fields.Any(f => f.ColumnName == item.FieldName))
                        {
                            IDataListItem singleRes = new DataListItem();
                            singleRes.IsRecordset = true;
                            singleRes.Recordset = item.Namespace;
                            singleRes.Field = item.FieldName;
                            singleRes.RecordsetIndex = (count + 1).ToString(CultureInfo.InvariantCulture);
                            try
                            {
                                singleRes.Value = item.TheValue;
                            }
                            catch(Exception)
                            {
                                singleRes.Value = null;
                            }

                            singleRes.DisplayValue = item.DisplayValue;
                            var desc = dataListEntry.Columns.FirstOrDefault(c => c.ColumnName == item.FieldName);
                            singleRes.Description = desc == null ? null : desc.ColumnDescription;
                            result.Add(singleRes);
                        }
                    }
                    count++;
                }
            }
            else
            {
                var item = dataListEntry.FetchScalar();
                if(item != null)
                {
                    IDataListItem singleRes = new DataListItem();
                    singleRes.IsRecordset = false;
                    singleRes.Field = item.FieldName;
                    singleRes.DisplayValue = item.FieldName;
                    try
                    {
                        singleRes.Value = item.TheValue;
                    }
                    catch(Exception)
                    {
                        singleRes.Value = null;
                    }
                    var desc = dataListEntry.Description;
                    singleRes.Description = string.IsNullOrWhiteSpace(desc) ? null : desc;
                    result.Add(singleRes);
                }
            }
            return result;
        }