예제 #1
0
        private void PopulatePrimitiveBagPropertyFromPaths(ComplexInstance instance, MemberProperty memberProperty, string propertyPath, IEnumerable <NamedValue> namedValues, PrimitiveDataType primitiveElementDataType)
        {
            int  i         = 0;
            bool completed = false;

            var primitiveCollection = new PrimitiveMultiValue(primitiveElementDataType.BuildMultiValueTypeName(), false);

            while (!completed)
            {
                IEnumerable <NamedValue> primitiveItemNamedValues = namedValues.Where(pp => pp.Name == propertyPath + "." + i).ToList();
                if (primitiveItemNamedValues.Count() == 0)
                {
                    completed = true;
                }
                else
                {
                    ExceptionUtilities.Assert(primitiveItemNamedValues.Count() < 2, "Should not get more than one value for a primitive Bag item for path '{0}'", propertyPath + "." + i);
                    var value = primitiveItemNamedValues.Single();

                    // Do something with the value
                    primitiveCollection.Add(PrimitiveValue(primitiveElementDataType, value.Value));
                }

                i++;
            }

            if (i > 1)
            {
                instance.Add(new PrimitiveMultiValueProperty(memberProperty.Name, primitiveCollection));
            }
        }
예제 #2
0
        private void PopulatePrimitiveBagPropertyFromPaths(ComplexInstance instance, MemberProperty memberProperty, string propertyPath, IEnumerable<NamedValue> namedValues, PrimitiveDataType primitiveElementDataType)
        {
            int i = 0;
            bool completed = false;

            var primitiveCollection = new PrimitiveMultiValue(primitiveElementDataType.BuildMultiValueTypeName(), false);
            while (!completed)
            {
                IEnumerable<NamedValue> primitiveItemNamedValues = namedValues.Where(pp => pp.Name == propertyPath + "." + i).ToList();
                if (primitiveItemNamedValues.Count() == 0)
                {
                    completed = true;
                }
                else
                {
                    ExceptionUtilities.Assert(primitiveItemNamedValues.Count() < 2, "Should not get more than one value for a primitive Bag item for path '{0}'", propertyPath + "." + i);
                    var value = primitiveItemNamedValues.Single();

                    // Do something with the value
                    primitiveCollection.Add(PrimitiveValue(primitiveElementDataType, value.Value));
                }

                i++;
            }

            if (i > 1)
            {
                instance.Add(new PrimitiveMultiValueProperty(memberProperty.Name, primitiveCollection));
            }
        }