private void Initialize()
            {
                this.entitySetToConstraintsMap = new Dictionary <EntitySet, List <PropertyWithConstraints> >();

                foreach (AssociationSet associationSet in this.data.EntityContainer.AssociationSets
                         .Where(s => s.AssociationType.ReferentialConstraint != null && this.data[s].Rows.Count > 0))
                {
                    ReferentialConstraint refConstraint = associationSet.AssociationType.ReferentialConstraint;

                    EntitySet dependentEntitySet = associationSet.Ends.Where(e => e.AssociationEnd == refConstraint.DependentAssociationEnd).Select(e => e.EntitySet).Single();

                    List <PropertyWithConstraints> propertiesWithConstraints;
                    if (!this.entitySetToConstraintsMap.TryGetValue(dependentEntitySet, out propertiesWithConstraints))
                    {
                        propertiesWithConstraints = new List <PropertyWithConstraints>();
                        this.entitySetToConstraintsMap[dependentEntitySet] = propertiesWithConstraints;
                    }

                    for (int i = 0; i < refConstraint.DependentProperties.Count; i++)
                    {
                        MemberProperty          dependentProperty       = refConstraint.DependentProperties[i];
                        PropertyWithConstraints propertyWithConstraints = propertiesWithConstraints.Where(p => p.Property == dependentProperty).SingleOrDefault();

                        if (propertyWithConstraints == null)
                        {
                            propertyWithConstraints = new PropertyWithConstraints(dependentProperty);
                            propertiesWithConstraints.Add(propertyWithConstraints);
                        }

                        propertyWithConstraints.AddConstraint(new PropertyConstraint(associationSet, i));
                    }
                }
            }
Beispiel #2
0
        public void FindMemberProperty()
        {
            var connection = TestHelper.CreateConnectionToSsas();

            connection.Open();

            CubeDef cube = TestHelper.GetCube(connection);

            KpiCollection kpis = cube.Kpis;

            MeasureCollection meas = cube.Measures;

            DimensionCollection dims = cube.Dimensions;

            HierarchyCollection hiers = dims[0].Hierarchies;

            LevelCollection levels = hiers[0].Levels;

            MemberCollection members = levels[1].GetMembers();

            MemberProperty prop = members[0].MemberProperties.Find("PARENT_UNIQUE_NAME");

            Assert.IsTrue(!string.IsNullOrEmpty(prop.Value.ToString()));

            connection.Close();
        }
Beispiel #3
0
        /// <summary>
        /// Parse a Property from its XElement
        /// </summary>
        /// <param name="propertyElement">XElement to parse Property from</param>
        /// <returns>A memberProperty</returns>
        protected override MemberProperty ParseProperty(XElement propertyElement)
        {
            MemberProperty memberProperty = base.ParseProperty(propertyElement);

            string defaultValueString = propertyElement.GetOptionalAttributeValue("DefaultValue", null);

            if (defaultValueString != null)
            {
                memberProperty.DefaultValue = this.ParseDefaultValueString(defaultValueString, memberProperty.PropertyType);
            }

            string getteraccess = propertyElement.GetOptionalAttributeValue(EdmConstants.CodegenNamespace + "GetterAccess", null);
            string setteraccess = propertyElement.GetOptionalAttributeValue(EdmConstants.CodegenNamespace + "SetterAccess", null);

            if (getteraccess != null || setteraccess != null)
            {
                AccessModifier setter;
                AccessModifier getter;
                this.GetGetterAndSetterModifiers(getteraccess, setteraccess, out setter, out getter);
                memberProperty.Annotations.Add(new PropertyAccessModifierAnnotation(setter, getter));
            }

            string collectionKindString = propertyElement.GetOptionalAttributeValue("CollectionKind", null);

            if (collectionKindString != null)
            {
                CollectionKind kind = (CollectionKind)Enum.Parse(typeof(CollectionKind), collectionKindString, false);
                memberProperty.Annotations.Add(new CollectionKindAnnotation(kind));
            }

            return(memberProperty);
        }
        private void PopulatePropertiesFromObject(ComplexInstance instance, IEnumerable <MemberProperty> properties, object anonymous)
        {
            ExceptionUtilities.CheckArgumentNotNull(instance, "instance");
            ExceptionUtilities.CheckArgumentNotNull(properties, "properties");
            ExceptionUtilities.CheckArgumentNotNull(anonymous, "anonymous");

            Type anonymousType = anonymous.GetType();

            foreach (PropertyInfo info in anonymousType.GetProperties())
            {
                object value = info.GetValue(anonymous, null);

                MemberProperty property = properties.SingleOrDefault(p => p.Name == info.Name);
                if (property == null)
                {
                    instance.Add(this.DynamicProperty(info.Name, info.PropertyType, value));
                }
                else if (property.PropertyType is ComplexDataType)
                {
                    instance.Add(this.ComplexProperty(property, value));
                }
                else if (property.PropertyType is CollectionDataType)
                {
                    instance.Add(this.MultiValueProperty(property, value));
                }
                else
                {
                    instance.Add(this.PrimitiveProperty(property, value));
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// Gets the member properties that correspond to a given path for the entity type
        /// </summary>
        /// <param name="entityType">The entity type</param>
        /// <param name="pathPieces">The property names from the path</param>
        /// <returns>The series of properties for the path</returns>
        public static IEnumerable <MemberProperty> GetPropertiesForPath(this EntityType entityType, string[] pathPieces)
        {
            var currentProperties = entityType.AllProperties;

            foreach (string propertyName in pathPieces)
            {
                MemberProperty property = currentProperties.Single(p => p.Name == propertyName);

                var complexDataType = property.PropertyType as ComplexDataType;
                if (complexDataType != null)
                {
                    currentProperties = complexDataType.Definition.Properties;
                }

                var collectionDataType = property.PropertyType as CollectionDataType;
                if (collectionDataType != null)
                {
                    var complexElementType = collectionDataType.ElementDataType as ComplexDataType;
                    if (complexElementType != null)
                    {
                        currentProperties = complexElementType.Definition.Properties;
                    }
                }

                yield return(property);
            }
        }
        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);
            }
        }
        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));
            }
        }
 /// <summary>
 /// Marks the member property as being declared in metadata
 /// </summary>
 /// <param name="memberProperty">The member property.</param>
 public static void MakeMetadataDeclared(this MemberProperty memberProperty)
 {
     if (!memberProperty.IsMetadataDeclaredProperty())
     {
         memberProperty.Annotations.Add(new MetadataDeclaredPropertyAnnotation());
     }
 }
Beispiel #9
0
        //=====================================================================

        /// <summary>
        /// This is overridden to allow cloning of a PDI object
        /// </summary>
        /// <returns>A clone of the object</returns>
        public override object Clone()
        {
            MemberProperty o = new MemberProperty();

            o.Clone(this);
            return(o);
        }
            /// <summary>
            /// Returns the structural property for the given payload element (only for properties).
            /// </summary>
            /// <param name="expectedTypeAnnotation">The expected type annotation.</param>
            /// <param name="model">The model to get the structural property from.</param>
            /// <returns>The expected structural property for the specified payload element.</returns>
            private static IEdmStructuralProperty GetExpectedStructuralProperty(ExpectedTypeODataPayloadElementAnnotation expectedTypeAnnotation, IEdmModel model)
            {
                ExceptionUtilities.Assert(model != null, "model != null");

                if (expectedTypeAnnotation != null)
                {
                    if (expectedTypeAnnotation.EdmProperty != null)
                    {
                        return(expectedTypeAnnotation.EdmProperty as IEdmStructuralProperty);
                    }
                    MemberProperty expectedStructuralProperty = expectedTypeAnnotation.MemberProperty;
                    if (expectedStructuralProperty != null)
                    {
                        NamedStructuralType expectedOwningType = expectedTypeAnnotation.OwningType;
                        ExceptionUtilities.Assert(expectedOwningType != null, "Need an owning type if a structural property is specified.");

                        IEdmStructuredType owningType = model.FindType(expectedOwningType.FullName) as IEdmStructuredType;
                        ExceptionUtilities.Assert(owningType != null, "Did not find expected structured type in the model.");

                        IEdmStructuralProperty structuralProperty = owningType.FindProperty(expectedStructuralProperty.Name) as IEdmStructuralProperty;
                        ExceptionUtilities.Assert(structuralProperty != null, "Did not find expected structural property in the model.");

                        return(structuralProperty);
                    }
                }

                return(null);
            }
Beispiel #11
0
        /// <summary>
        /// 绑定数据
        /// </summary>
        private void BindData()
        {
            MemberProperty mt = FacadeManage.aideAccountsFacade.GetMemberProperty(IntParam);

            if (mt == null)
            {
                return;
            }

            CtrlHelper.SetText(lbCardName, mt.MemberName);
            CtrlHelper.SetText(txtTaskRate, mt.TaskRate.ToString());
            CtrlHelper.SetText(txtShopRate, mt.ShopRate.ToString());
            CtrlHelper.SetText(txtInsureRate, mt.InsureRate.ToString());
            CtrlHelper.SetText(txtPresentScore, mt.DayPresent.ToString());
            ddlDayGiftID.SelectedValue = mt.DayGiftID.ToString();

            //用户权限
            int intUserRight = mt.UserRight;

            if (ckbUserRight.Items.Count > 0)
            {
                foreach (ListItem item in ckbUserRight.Items)
                {
                    item.Selected = int.Parse(item.Value) == (intUserRight & int.Parse(item.Value));
                }
            }
        }
        /// <summary>
        /// Sets the expected property for the top-level property instance.
        /// </summary>
        /// <param name="property">The property instance to set the expected property for.</param>
        /// <param name="owningType">The type owning the expected property.</param>
        /// <param name="expectedPropertyName">The name of the property to set as the expected property.</param>
        /// <returns>The <paramref name="property"/> after its expected property was set.</returns>
        public static PropertyInstance ExpectedProperty(
            this PropertyInstance property,
            NamedStructuralType owningType,
            string expectedPropertyName)
        {
            ExceptionUtilities.CheckArgumentNotNull(property, "property");
            ExceptionUtilities.CheckArgumentNotNull(owningType, "owningType");
            ExceptionUtilities.CheckStringArgumentIsNotNullOrEmpty(expectedPropertyName, "expectedPropertyName");

            ExpectedTypeODataPayloadElementAnnotation annotation = AddExpectedTypeAnnotation(property);

            annotation.OwningType = owningType;
            MemberProperty memberProperty = owningType.GetProperty(expectedPropertyName);

            if (memberProperty != null)
            {
                annotation.MemberProperty = memberProperty;
                annotation.ExpectedType   = memberProperty.PropertyType;
            }
            else
            {
                ExceptionUtilities.Assert(owningType.IsOpen, "For non-declared properties the owning type must be open.");
                annotation.OpenMemberPropertyName = expectedPropertyName;
            }

            return(property);
        }
Beispiel #13
0
        private IDataGenerator GetPropertyDataGenerator(MemberProperty property, bool isUnique)
        {
            if (property.PropertyType == null)
            {
                throw new TaupoInvalidOperationException(
                          string.Format(CultureInfo.InvariantCulture, "Cannot create data generator for the property '{0}' because it's type is null.", property.Name));
            }

            // First check if custom data generator has been specified for this property and use it.
            var customDataGen = property.Annotations.OfType <DataGeneratorAnnotation>().SingleOrDefault();

            if (customDataGen != null)
            {
                return(customDataGen.DataGenerator);
            }

            // If there is no custom data generator create data generator based on data generation hints.
            List <DataGenerationHint> dataGenHints = property.Annotations.OfType <DataGenerationHintsAnnotation>().SelectMany(a => a.Hints).ToList();

            CollectionDataType collectionDataType = property.PropertyType as CollectionDataType;

            if (collectionDataType != null)
            {
                return(this.ResolveCollectionDataGenerator(collectionDataType, dataGenHints));
            }
            else
            {
                return(this.ResolveNonCollectionDataGenerator(property.PropertyType, property.IsPrimaryKey || isUnique, dataGenHints));
            }
        }
Beispiel #14
0
        public static bool IsMultiValue(this MemberProperty property)
        {
            ExceptionUtilities.CheckArgumentNotNull(property, "property");

            var bagType = property.PropertyType as CollectionDataType;

            return((bagType != null) && (bagType.ElementDataType is PrimitiveDataType || bagType.ElementDataType is ComplexDataType));
        }
Beispiel #15
0
 public object this[MemberProperty property]
 {
     get
     {
         _memberData.TryGetValue(property, out var value);
         return(value);
     }
     private set => _memberData[property] = value;
 private static void AddDataGenerationHints(MemberProperty property, Type clrType)
 {
     DataGenerationHint[] hints;
     if (predefinedHintsPerType.TryGetValue(clrType, out hints))
     {
         property.WithDataGenerationHints(hints);
     }
 }
 /// <summary>
 /// Adds an annotation to the given collection property to indicate that it should use the given information for the collection instance type
 /// </summary>
 /// <param name="property">The property to annotate</param>
 /// <param name="typeName">The full type name to use for the collection type</param>
 /// <param name="isGeneric">Whether or not the collection type is generic</param>
 /// <returns>The given property</returns>
 public static MemberProperty WithCollectionInstanceType(this MemberProperty property, string typeName, bool isGeneric)
 {
     ExceptionUtilities.CheckArgumentNotNull(property, "property");
     property.Annotations.Add(new CollectionInstanceTypeAnnotation()
     {
         FullTypeName = typeName, IsGeneric = isGeneric
     });
     return(property);
 }
Beispiel #18
0
 /// <summary>
 /// Adds initialization for a property if any is needed
 /// </summary>
 /// <param name="memberProperty">The property to initialize</param>
 /// <param name="parentClassConstructor">The constructor to add to</param>
 protected virtual void DeclareOptionalPropertyInitializer(MemberProperty memberProperty, CodeConstructor parentClassConstructor)
 {
     // right now, we only need to initialize bag properties
     if (memberProperty.PropertyType is CollectionDataType)
     {
         var type = this.GetPropertyType(memberProperty, CodeGenerationTypeUsage.Instantiation);
         parentClassConstructor.Statements.Add(Code.This().Property(memberProperty.Name).Assign(Code.New(type)));
     }
 }
            private object ResolvePropertyValue(EntitySetDataRow row, MemberProperty property, List <PropertyConstraint> constraints)
            {
                if (this.resolved.Any(kv => kv.Key == row && kv.Value == property))
                {
                    return(row[property.Name]);
                }

                KeyValuePair <EntitySetDataRow, MemberProperty> sameItem = this.visited.Where(kv => kv.Key == row && kv.Value == property).SingleOrDefault();

                if (sameItem.Key != null)
                {
                    int           indexCycleStartsWith = this.visited.IndexOf(sameItem);
                    List <object> values = this.visited.Where((kv, i) => i >= indexCycleStartsWith).Select(kv => kv.Key[kv.Value.Name]).Distinct(ValueComparer.Instance).ToList();
                    if (values.Count > 1)
                    {
                        throw new TaupoInvalidOperationException("Referential constraint cycle detected: " + GetReferentialConstraintCycleDescription(this.visited, indexCycleStartsWith));
                    }

                    return(values[0]);
                }

                var candidates = new List <object>();

                foreach (PropertyConstraint constraint in constraints)
                {
                    object candidate;
                    if (this.ResolveConstraintValue(row, property, constraint, out candidate))
                    {
                        candidates.Add(candidate);
                    }
                }

                if (candidates.Distinct(ValueComparer.Instance).Count() > 1)
                {
                    throw new TaupoInvalidOperationException("Overlapping foreign keys with conflicting values detected: " + GetOverlappingForeignKeyDescription(constraints));
                }

                object value;

                if (candidates.Count > 0)
                {
                    value = candidates[0];
                    if (!ValueComparer.Instance.Equals(value, row[property.Name]))
                    {
                        row[property.Name] = value;
                    }
                }
                else
                {
                    value = row[property.Name];
                }

                this.resolved.Add(new KeyValuePair <EntitySetDataRow, MemberProperty>(row, property));

                return(value);
            }
Beispiel #20
0
        /// <summary>
        /// Parse a Property from its XElement
        /// </summary>
        /// <param name="propertyElement">XElement to parse Property from</param>
        /// <returns>A memberProperty</returns>
        protected virtual MemberProperty ParseProperty(XElement propertyElement)
        {
            var      name     = propertyElement.GetRequiredAttributeValue("Name");
            DataType dataType = this.ParsePropertyDataType(propertyElement);

            var memberProperty = new MemberProperty(name, dataType);

            this.ParseAnnotations(memberProperty, propertyElement);
            return(memberProperty);
        }
Beispiel #21
0
        /// <summary>
        /// Builds a complex property instance for the given metadata property with the given flattened values
        /// </summary>
        /// <param name="property">The metadata for the property</param>
        /// <param name="propertyPath">Property Path to start on for the memberProperty</param>
        /// <param name="namedValues">The flattened values</param>
        /// <returns>A complex property instance</returns>
        private ComplexProperty ComplexProperty(MemberProperty property, string propertyPath, IEnumerable <NamedValue> namedValues)
        {
            ExceptionUtilities.CheckArgumentNotNull(property, "property");

            ComplexDataType complexType = property.PropertyType as ComplexDataType;

            ExceptionUtilities.CheckObjectNotNull(complexType, "Property '{0}' was not complex", property.Name);

            return(new ComplexProperty(property.Name, this.ComplexInstance(complexType.Definition, propertyPath, namedValues)));
        }
Beispiel #22
0
        /// <summary>
        /// Builds a complex property instance for the given metadata property with the given anonymous type value
        /// </summary>
        /// <param name="memberProperty">The metadata for the property</param>
        /// <param name="anonymous">An anonymous type describing the property values of the complex instance</param>
        /// <returns>A complex property instance</returns>
        public ComplexProperty ComplexProperty(MemberProperty memberProperty, object anonymous)
        {
            ExceptionUtilities.CheckArgumentNotNull(memberProperty, "memberProperty");

            ComplexDataType complexType = memberProperty.PropertyType as ComplexDataType;

            ExceptionUtilities.CheckObjectNotNull(complexType, "Property '{0}' was not complex", memberProperty.Name);

            return(new ComplexProperty(memberProperty.Name, this.ComplexInstance(complexType.Definition, anonymous)));
        }
        /// <summary>
        /// Generates the concurrency token attribute.
        /// </summary>
        /// <param name="memberProperty">The property.</param>
        /// <returns>Generated attribute</returns>
        protected override XAttribute GenerateStoreGeneratedPattern(MemberProperty memberProperty)
        {
            StoreGeneratedPatternAnnotation annotation = memberProperty.Annotations.OfType <StoreGeneratedPatternAnnotation>().SingleOrDefault();

            if (annotation == null)
            {
                return(null);
            }

            return(new XAttribute(EdmConstants.AnnotationNamespace.GetName("StoreGeneratedPattern"), annotation.Name));
        }
        /// <summary>
        /// Generates the concurrency token attribute.
        /// </summary>
        /// <param name="memberProperty">The property.</param>
        /// <returns>Generated attribute</returns>
        protected override XAttribute GenerateConcurrencyToken(MemberProperty memberProperty)
        {
            ConcurrencyTokenAnnotation annotation = memberProperty.Annotations.OfType <ConcurrencyTokenAnnotation>().SingleOrDefault();

            if (annotation == null)
            {
                return(null);
            }

            return(new XAttribute("ConcurrencyMode", "Fixed"));
        }
Beispiel #25
0
 /// <summary>
 /// Generates Property element for a given <see cref="MemberProperty"/>
 /// </summary>
 /// <param name="xmlNamespace">XML namespace to use</param>
 /// <param name="prop">Entity or ComplexType property</param>
 /// <returns>Property XElement</returns>
 protected virtual XElement GenerateProperty(XNamespace xmlNamespace, MemberProperty prop)
 {
     return(new XElement(
                xmlNamespace + "Property",
                prop.Name != null ? new XAttribute("Name", prop.Name) : null,
                this.GenerateDocumentation(xmlNamespace, prop),
                this.GetDataTypeGenerator().GeneratePropertyType(prop, xmlNamespace),
                this.GenerateDefaultValue(prop.DefaultValue),
                this.GenerateStoreGeneratedPattern(prop),
                this.GenerateAnnotations(xmlNamespace, prop)));
 }
        /// <summary>
        /// Returns the type to use when declaring or instantiating the property
        /// </summary>
        /// <param name="property">The property being declared/instantiated</param>
        /// <param name="usage">Whether the type is for declaration or instantiation</param>
        /// <returns>The type of the property</returns>
        protected CodeTypeReference GetPropertyType(MemberProperty property, CodeGenerationTypeUsage usage)
        {
            var collectionDataType = property.PropertyType as CollectionDataType;

            if (collectionDataType != null)
            {
                return(this.GetCollectionType(usage, property.Annotations, collectionDataType.ElementDataType));
            }

            return(this.BackingTypeResolver.ResolveClrTypeReference(property.PropertyType));
        }
Beispiel #27
0
        /// <summary>
        /// Adds a (primitive, complex or collection) property to the <paramref name="structuralType"/>.
        /// Returns the modified structural type for composability.
        /// </summary>
        /// <typeparam name="T">The type of the structural type to add the property to.</typeparam>
        /// <param name="structuralType">The structural type to add the new property to.</param>
        /// <param name="propertyName">The name of the property to add.</param>
        /// <param name="type">The data type of the property.</param>
        /// <param name="isETagProperty">true if the property is an ETag property; otherwise false (default).</param>
        /// <returns>The <paramref name="structuralType"/> instance after adding the property to it.</returns>
        public static T Property <T>(this T structuralType, string propertyName, DataType type, bool isETagProperty = false)
            where T : NamedStructuralType
        {
            ExceptionUtilities.CheckArgumentNotNull(structuralType, "structuralType");
            ExceptionUtilities.CheckArgumentNotNull(type, "type");

            MemberProperty property = new MemberProperty(propertyName, type);

            structuralType.Add(property);
            return(structuralType);
        }
Beispiel #28
0
 /// <summary>
 /// Adds a property to the given type declaration based on the given metadata
 /// </summary>
 /// <param name="memberProperty">The property's metadata</param>
 /// <param name="parentClass">The type declaration</param>
 protected override void DeclareMemberProperty(MemberProperty memberProperty, CodeTypeDeclaration parentClass)
 {
     if (memberProperty.IsStream())
     {
         this.DeclareNamedStreamProperty(memberProperty, parentClass);
     }
     else
     {
         parentClass.AddAutoImplementedProperty(this.GetPropertyType(memberProperty, CodeGenerationTypeUsage.Declaration), memberProperty.Name);
     }
 }
Beispiel #29
0
 /// <summary>
 /// Adds a property to the given type declaration based on the given metadata
 /// </summary>
 /// <param name="memberProperty">The property's metadata</param>
 /// <param name="parentClass">The type declaration</param>
 protected override void DeclareMemberProperty(MemberProperty memberProperty, CodeTypeDeclaration parentClass)
 {
     if (memberProperty.IsStream())
     {
         this.DeclareNamedStreamProperty(memberProperty, parentClass);
     }
     else
     {
         this.AddPropertyWithChangeNotification(parentClass, this.GetPropertyType(memberProperty, CodeGenerationTypeUsage.Declaration), memberProperty.Name);
     }
 }
 private void CompareComplexType(ComplexType expectedComplexType, ComplexType actualComplexType)
 {
     foreach (MemberProperty memberProperty in expectedComplexType.Properties)
     {
         List <MemberProperty> members = actualComplexType.Properties.Where(p => p.Name == memberProperty.Name).ToList();
         if (!this.WriteErrorIfFalse(members.Count == 1, "Cannot find member '{0}'", memberProperty.Name))
         {
             MemberProperty ymemberProperty = members.Single();
             this.CompareMemberProperty(memberProperty, ymemberProperty);
         }
     }
 }
        internal void FromMemberProperty(MemberProperty mp)
        {
            this.SetAllNull();

            if (mp.Name != null) this.Name = mp.Name.Value;
            if (mp.ShowCell != null) this.ShowCell = mp.ShowCell.Value;
            if (mp.ShowTip != null) this.ShowTip = mp.ShowTip.Value;
            if (mp.ShowAsCaption != null) this.ShowAsCaption = mp.ShowAsCaption.Value;
            if (mp.NameLength != null) this.NameLength = mp.NameLength.Value;
            if (mp.PropertyNamePosition != null) this.PropertyNamePosition = mp.PropertyNamePosition.Value;
            if (mp.PropertyNameLength != null) this.PropertyNameLength = mp.PropertyNameLength.Value;
            if (mp.Level != null) this.Level = mp.Level.Value;
            if (mp.Field != null) this.Field = mp.Field.Value;
        }
Beispiel #32
0
        private void SetDataFromPropertyInfo(object item, PropertyInfo propertyInfo, MemberProperty memberProperty, string currentPath)
        {
            object propertyValue = propertyInfo.GetValue(item, null);
            if (memberProperty.PropertyType is PrimitiveDataType || memberProperty.PropertyType is EnumDataType)
            {
                this[currentPath + memberProperty.Name] = propertyValue;
            }
            else if (memberProperty.PropertyType is ComplexDataType)
            {
                this.ImportFrom(propertyValue, currentPath + memberProperty.Name, (memberProperty.PropertyType as ComplexDataType).Definition);
            }
            else
            {
                var collectionDataType = memberProperty.PropertyType as CollectionDataType;
                ExceptionUtilities.Assert(collectionDataType != null, "Only properties with primitive, complex, or collection of primitive and complex data types are supported. Property: '{0}', type: '{1}'.", memberProperty.Name, memberProperty.PropertyType);

                var primitiveElementDataType = collectionDataType.ElementDataType as PrimitiveDataType;
                var complexElementDataType = collectionDataType.ElementDataType as ComplexDataType;

                ExceptionUtilities.CheckObjectNotNull(propertyValue, "Collection Property MUST not be Null at PropertyPath '{0}'", currentPath + memberProperty.Name);
                var enumerableItem = propertyValue as IEnumerable;
                ExceptionUtilities.CheckObjectNotNull(enumerableItem, "propertyValue should be IEnumerable but is not, its type is '{0};", propertyValue.GetType().Name);
                if (primitiveElementDataType != null)
                {
                    int i = 0;
                    foreach (object o in enumerableItem)
                    {
                        this[currentPath + memberProperty.Name + "." + i] = o;
                        i++;
                    }
                }
                else
                {
                    ExceptionUtilities.Assert(complexElementDataType != null, "ElementType {0} of CollectionType Property is not supported", collectionDataType.ElementDataType);
                    int i = 0;
                    foreach (object o in enumerableItem)
                    {
                        this.ImportFrom(o, currentPath + memberProperty.Name + "." + i, complexElementDataType.Definition);
                        i++;
                    }
                }
            }
        }
        internal MemberProperty ToMemberProperty()
        {
            MemberProperty mp = new MemberProperty();
            if (this.Name != null && this.Name.Length > 0) mp.Name = this.Name;
            if (this.ShowCell != false) mp.ShowCell = this.ShowCell;
            if (this.ShowTip != false) mp.ShowTip = this.ShowTip;
            if (this.ShowAsCaption != false) mp.ShowAsCaption = this.ShowAsCaption;
            if (this.NameLength != null) mp.NameLength = this.NameLength.Value;
            if (this.PropertyNamePosition != null) mp.PropertyNamePosition = this.PropertyNamePosition.Value;
            if (this.PropertyNameLength != null) mp.PropertyNameLength = this.PropertyNameLength.Value;
            if (this.Level != null) mp.Level = this.Level.Value;
            mp.Field = this.Field;

            return mp;
        }
Beispiel #34
0
 public Member SetProperty(MemberProperty newProperty)
 {
     this.MemberProperty = newProperty;
     return this;
 }