Esempio n. 1
0
        public PropertyInstance MultiValuePropertyEmptyOrNull(MemberProperty memberProperty, object value)
        {
            var bagPropertyType = memberProperty.PropertyType as CollectionDataType;

            ExceptionUtilities.CheckObjectNotNull(bagPropertyType, "Expected property to be a BagProperty instead its a '{0}'", memberProperty.PropertyType);

            DataType elementDataType = bagPropertyType.ElementDataType;

            if (value == null)
            {
                return(new NullPropertyInstance(memberProperty.Name, elementDataType.BuildMultiValueTypeName()));
            }
            else
            {
                ExceptionUtilities.Assert(value == EmptyData.Value, "value MUST be null or EmptyData.Value");
                PropertyInstance collectionProperty = null;
                if (elementDataType is ComplexDataType)
                {
                    collectionProperty = new ComplexMultiValueProperty(memberProperty.Name, new ComplexMultiValue(elementDataType.BuildMultiValueTypeName(), false));
                }
                else
                {
                    ExceptionUtilities.Assert(elementDataType is PrimitiveDataType, "DataType is not a PrimitiveDataType '{0}'", elementDataType);
                    collectionProperty = new PrimitiveMultiValueProperty(memberProperty.Name, new PrimitiveMultiValue(elementDataType.BuildMultiValueTypeName(), false));
                }

                // Add an empty one if specified to
                return(collectionProperty);
            }
        }