Exemplo n.º 1
0
        private IEnumerable <NamedValue> AddPrimitiveValuesToCollection(CollectionHelper collectionHelper, object collection, IEnumerable <NamedValue> namedValues)
        {
            var        addedNamedValues = new List <NamedValue>();
            NamedValue namedValue;
            int        i = 0;

            while ((namedValue = namedValues.Where(nv => nv.Name.EndsWith("." + i, StringComparison.Ordinal)).SingleOrDefault()) != null)
            {
                var value = this.TranslateClrTypeIfEnum(collectionHelper.ElementType, namedValue.Value);

                collectionHelper.AddTo(collection, value);
                addedNamedValues.Add(new NamedValue(namedValue.Name, value));
                i++;
            }

            return(addedNamedValues);
        }
Exemplo n.º 2
0
        private IEnumerable <NamedValue> AddComplexValuesToCollection(CollectionHelper collectionHelper, object collection, IEnumerable <NamedValue> namedValues, string collectionPath)
        {
            var               addedNamedValues = new List <NamedValue>();
            int               i = 0;
            string            currentElementPath = collectionPath + i + ".";
            List <NamedValue> elementNamedValues;

            while ((elementNamedValues = namedValues.Where(nv => nv.Name.StartsWith(currentElementPath, StringComparison.Ordinal)).ToList()).Count > 0)
            {
                var element           = collectionHelper.CreateNewElement();
                var settedNamedValues = this.SetMemberValues(element, elementNamedValues, currentElementPath);
                collectionHelper.AddTo(collection, element);

                addedNamedValues.AddRange(settedNamedValues);

                i++;
                currentElementPath = collectionPath + i + ".";
            }

            return(addedNamedValues);
        }