Example #1
0
        protected override void DeserializeCore(XmlElement nodeElement, SaveContext context)
        {
            base.DeserializeCore(nodeElement, context);
            var wrapperName     = nodeElement.ChildNodes.Cast <XmlNode>().FirstOrDefault(x => x.Name == "listWrapper_name");
            var wrapperSelected = nodeElement.ChildNodes.Cast <XmlNode>().FirstOrDefault(x => x.Name == "listWrapper_selected");
            var wrapperIndex    = nodeElement.ChildNodes.Cast <XmlNode>().FirstOrDefault(x => x.Name == "listWrapper_index");

            if (wrapperName == null || wrapperSelected == null || wrapperIndex == null)
            {
                return;
            }
            if (wrapperName.Attributes == null || wrapperName.Attributes.Count <= 0)
            {
                return;
            }
            if (wrapperSelected.Attributes == null || wrapperSelected.Attributes.Count <= 0)
            {
                return;
            }
            if (wrapperIndex.Attributes == null || wrapperIndex.Attributes.Count <= 0)
            {
                return;
            }

            for (var i = 0; i <= wrapperName.Attributes.Count - 1; i++)
            {
                var name        = wrapperName.Attributes[i].Value;
                var selected    = wrapperSelected.Attributes[i].Value == "True";
                var index       = int.Parse(wrapperIndex.Attributes[i].Value);
                var itemWrapper = new ListItemWrapper {
                    Name = name, IsSelected = selected, Index = index
                };
                ItemsCollection.Add(itemWrapper);
            }
        }
Example #2
0
        public void GetNullableIntegerFromNullTest()
        {
            var item = CreateFakeItem();

            item["MyNumber"] = null;

            var mapper = new ListItemWrapper(item);
            var actual = mapper.GetNullableInt("MyNumber");

            Assert.IsNull(actual);
        }
Example #3
0
        public void GetBoolFromFalseTest()
        {
            const bool EXPECTED = false;
            var        item     = CreateFakeItem();

            item["MyBool"] = EXPECTED;

            var mapper = new ListItemWrapper(item);
            var actual = mapper.GetBool("MyBool");

            Assert.AreEqual(EXPECTED, actual);
        }
Example #4
0
        public void GetNullableBoolFromNullTest()
        {
            const object EXPECTED = null;
            var          item     = CreateFakeItem();

            item["MyBool"] = EXPECTED;

            var mapper = new ListItemWrapper(item);
            var actual = mapper.GetNullableBool("MyBool");

            Assert.AreEqual(EXPECTED, actual);
        }
Example #5
0
        public void GetStringArrayFromNullTest()
        {
            const object EXPECTED = null;
            var          item     = CreateFakeItem();

            item["MyStringArray"] = EXPECTED;

            var mapper = new ListItemWrapper(item);
            var actual = mapper.GetStringArray("MyStringArray");

            Assert.AreEqual(EXPECTED, actual);
        }
Example #6
0
        public void SetLookupIdFromValueTest()
        {
            var expected = 42;

            var item    = CreateFakeItem();
            var wrapper = new ListItemWrapper(item);

            wrapper.SetLookupId("MyLookup", expected);
            var actual = ((FieldLookupValue)item["MyLookup"]).LookupId;

            Assert.AreEqual(expected, actual);
        }
Example #7
0
        public void GetIntegerFromStringTest()
        {
            var expected = 42;
            var item     = CreateFakeItem();

            item["MyNumber"] = expected.ToString();

            var mapper = new ListItemWrapper(item);
            var actual = mapper.GetInt("MyNumber");

            Assert.AreEqual(expected, actual);
        }
Example #8
0
        public void GetStringFromStringTest()
        {
            var expected = "Everything is a list, when you are using SharePoint";
            var item     = CreateFakeItem();

            item["MyString"] = expected;

            var mapper = new ListItemWrapper(item);
            var actual = mapper.GetString("MyString");

            Assert.AreEqual(expected, actual);
        }
Example #9
0
        public void SetFromDoubleTest()
        {
            var expected = 3.14;

            var item    = CreateFakeItem();
            var wrapper = new ListItemWrapper(item);

            wrapper.Set("MyDouble", expected);
            var actual = (double)item["MyDouble"];

            Assert.AreEqual(expected, actual);
        }
Example #10
0
        public void GetDoubleFromDoubleTest()
        {
            var expected = 3.14;
            var item     = CreateFakeItem();

            item["MyNumber"] = expected;

            var mapper = new ListItemWrapper(item);
            var actual = mapper.GetDouble("MyNumber");

            Assert.AreEqual(expected, actual);
        }
Example #11
0
        public void GetDoubleFromStringTest()
        {
            var expected = 3.14;
            var item     = CreateFakeItem();

            item["MyNumber"] = expected.ToString(CultureInfo.InvariantCulture);

            var mapper = new ListItemWrapper(item);
            var actual = mapper.GetDouble("MyNumber");

            Assert.AreEqual(expected, actual);
        }
Example #12
0
        public void GetLongFromDoubleTest()
        {
            long expected = 42;
            var  item     = CreateFakeItem();

            item["MyNumber"] = (double)expected;

            var mapper = new ListItemWrapper(item);
            var actual = mapper.GetLong("MyNumber");

            Assert.AreEqual(expected, actual);
        }
Example #13
0
        public void SetFromLongTest()
        {
            var expected = (long)42;

            var item    = CreateFakeItem();
            var wrapper = new ListItemWrapper(item);

            wrapper.Set("MyLong", expected);
            var actual = (long)item["MyLong"];

            Assert.AreEqual(expected, actual);
        }
Example #14
0
        public void GetLookupValueFromValueTest()
        {
            var expected = "Test Value";
            var item     = CreateFakeItem();

            item["MyLookup"] = new FieldLookupValueDummy(42, expected);

            var mapper = new ListItemWrapper(item);
            var actual = mapper.GetLookupValue("MyLookup");

            Assert.AreEqual(expected, actual);
        }
Example #15
0
        public void SetFromIntTest()
        {
            var expected = 42;

            var item    = CreateFakeItem();
            var wrapper = new ListItemWrapper(item);

            wrapper.Set("MyInt", expected);
            var actual = (int)item["MyInt"];

            Assert.AreEqual(expected, actual);
        }
Example #16
0
        public void GetNullableDateTimeFromNowTest()
        {
            var expected = DateTime.Now;
            var utc      = expected.ToUniversalTime();
            var item     = CreateFakeItem();

            item["MyDateTime"] = utc;

            var mapper = new ListItemWrapper(item);
            var actual = mapper.GetNullableDateTime("MyDateTime");

            Assert.AreEqual(expected, actual);
        }
Example #17
0
        public void GetIntegerErrorFromStringTest()
        {
            var item = CreateFakeItem();

            item["MyNumber"] = "Not a number";

            var mapper = new ListItemWrapper(item);

            Assert.ThrowsException <FormatException>(() =>
            {
                mapper.GetInt("MyNumber");
            });
        }
Example #18
0
        public void GetIntegerErrorFromNullTest()
        {
            var item = CreateFakeItem();

            item["MyNumber"] = null;

            var mapper = new ListItemWrapper(item);

            Assert.ThrowsException <NullReferenceException>(() =>
            {
                mapper.GetInt("MyNumber");
            });
        }
Example #19
0
        public void GetLookupIdFromValueTest()
        {
            var expected = 42;
            var item     = CreateFakeItem();

            item["MyLookup"] = new FieldLookupValue
            {
                LookupId = expected
            };

            var mapper = new ListItemWrapper(item);
            var actual = mapper.GetLookupId("MyLookup");

            Assert.AreEqual(expected, actual);
        }
Example #20
0
        public void GetLinkUrlFromValueTest()
        {
            var expected = "https://www.microsoft.com";

            var item = CreateFakeItem();

            item["MyLink"] = new FieldUrlValue
            {
                Url = expected
            };

            var wrapper = new ListItemWrapper(item);
            var actual  = wrapper.GetLinkUrl("MyLink");

            Assert.AreEqual(expected, actual);
        }
Example #21
0
        public void SetLookupIdsFromListTest()
        {
            var expected = new List <int> {
                1, 2, 3, 5, 7, 11, 13
            };

            var item    = CreateFakeItem();
            var wrapper = new ListItemWrapper(item);

            wrapper.SetLookupIds("MyLookup", expected);
            var actualFields = (FieldLookupValue[])item["MyLookup"];
            var actual       = actualFields.Select(f => f.LookupId).ToList();

            Assert.IsTrue(expected.All(v => actual.Contains(v)));
            Assert.IsTrue(actual.All(v => expected.Contains(v)));
        }
Example #22
0
        public void GetLookupIdListFromArray()
        {
            var expected = new List <int> {
                1, 2, 3, 5, 7, 11, 13
            };
            var item = CreateFakeItem();

            item["MyLookup"] = expected.Select(val => new FieldLookupValue {
                LookupId = val
            }).ToArray();

            var mapper = new ListItemWrapper(item);
            var actual = mapper.GetLookupIdList("MyLookup");

            Assert.AreNotEqual(expected, actual);
        }
Example #23
0
        public void GetLinkDescriptionFromValueTest()
        {
            var expected = "Test Value";

            var item = CreateFakeItem();

            item["MyLink"] = new FieldUrlValue
            {
                Description = expected
            };

            var wrapper = new ListItemWrapper(item);
            var actual  = wrapper.GetLinkDescription("MyLink");

            Assert.AreEqual(expected, actual);
        }
Example #24
0
        private void ItemChecked(ListItemWrapper w)
        {
            w.IsSelected = !w.IsSelected;

            // (Konrad) Let's update the ItemsCollection because otherwise when output is generated
            // the last item selected will be missing.
            ItemsCollection.ForEach(x =>
            {
                if (x.Index == w.Index)
                {
                    x.IsSelected = !w.IsSelected;
                }
            });

            OnNodeModified(true);
        }
Example #25
0
        public void GetStringArrayFromStringArrayTest()
        {
            var expected = new[]
            {
                "I'm",
                "a",
                "list"
            };
            var item = CreateFakeItem();

            item["MyStringArray"] = expected;

            var mapper = new ListItemWrapper(item);
            var actual = mapper.GetStringArray("MyStringArray");

            Assert.AreEqual(expected, actual);
        }
Example #26
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="selectedItems"></param>
        public void PopulateItems(IList selectedItems)
        {
            if (!InPorts.Any() || !InPorts[0].Connectors.Any())
            {
                return;
            }

            var owner      = InPorts[0].Connectors[0].Start.Owner;
            var index      = InPorts[0].Connectors[0].Start.Index;
            var mirrorName = owner.GetAstIdentifierForOutputIndex(index).Name;
            var mirror     = EngineController.GetMirror(mirrorName);

            var data = mirror?.GetData();

            if (data == null)
            {
                return;
            }

            if (data.IsCollection)
            {
                var counter = 0;
                foreach (var item in data.GetElements())
                {
                    var i       = item.Data;
                    var wrapper = new ListItemWrapper
                    {
                        Name  = i.ToString(),
                        Index = counter
                    };

                    var existing = ItemsCollection.IndexOf(wrapper);
                    if (existing != -1)
                    {
                        ItemsCollection[existing].IsSelected = selectedItems.Contains(wrapper);
                    }
                    else
                    {
                        ItemsCollection.Add(wrapper);
                    }

                    counter++;
                }
            }
        }
Example #27
0
 protected override void Map(SimpleItem entity, ListItemWrapper item)
 {
     throw new NotImplementedException();
 }
Example #28
0
 protected override void MapItemToEntity(ListItemWrapper item, SimpleItem entity)
 {
     entity.Title = item.GetString("Title");
 }