示例#1
0
        protected EntityDataSourceReferenceValueColumn(MetadataWorkspace ocWorkspace, NavigationProperty navigationProperty)
            : base(EntityDataSourceUtil.CheckArgumentNull(navigationProperty, "navigationProperty").Name)
        {
            EntityDataSourceUtil.CheckArgumentNull(ocWorkspace, "ocWorkspace");

            this.navigationProperty = navigationProperty;
        }
示例#2
0
        protected EntityDataSourceColumn(string displayName, EntityDataSourceColumn controllingColumn)
        {
            EntityDataSourceUtil.CheckArgumentNull(displayName, "displayName");

            this.DisplayName       = displayName;
            this.ControllingColumn = controllingColumn;
        }
        internal static EntityDataSourceReferenceGroup Create(Type entityType, AssociationSetEnd end)
        {
            EntityDataSourceUtil.CheckArgumentNull(entityType, "entityType");

            Type groupType = typeof(EntityDataSourceReferenceGroup <>).MakeGenericType(entityType);

            return((EntityDataSourceReferenceGroup)Activator.CreateInstance(groupType, new object[] { end }));
        }
        internal EntityDataSourceWrapperPropertyDescriptor(EntityDataSourceWrapperCollection collection, EntityDataSourceColumn column)
            : base(EntityDataSourceUtil.CheckArgumentNull(column, "column").DisplayName, new Attribute[] { })
        {
            EntityDataSourceUtil.CheckArgumentNull(collection, "collection");

            _collection = collection;
            _column     = column;
        }
示例#5
0
        internal static EntityDataSourceReferenceValueColumn Create(Type clrToType, MetadataWorkspace ocWorkspace, NavigationProperty navigationProperty)
        {
            EntityDataSourceUtil.CheckArgumentNull(clrToType, "clrToType");

            Type columnType = typeof(EntityDataSourceReferenceValueColumn <>).MakeGenericType(clrToType);
            EntityDataSourceReferenceValueColumn result = (EntityDataSourceReferenceValueColumn)Activator.CreateInstance(columnType, ocWorkspace, navigationProperty);

            return(result);
        }
        private EntityDataSourceWrapper GetWrapper(object component)
        {
            // Validate that the component comes from the collection to which
            // this descriptor is bound. Elements of the collection are
            // non-null wrappers instances.
            EntityDataSourceUtil.CheckArgumentNull(component, "component");

            EntityDataSourceWrapper wrapper = component as EntityDataSourceWrapper;

            if (null == wrapper || this._collection != wrapper.Collection)
            {
                throw new ArgumentException(Strings.ComponentNotFromProperCollection, "component");
            }

            return(wrapper);
        }
        internal EntityDataSourceMemberPath(MetadataWorkspace ocWorkspace, EntityDataSourceMemberPath parent, EdmProperty property, bool isLocallyInteresting)
        {
            EntityDataSourceUtil.CheckArgumentNull(ocWorkspace, "ocWorkspace");
            EntityDataSourceUtil.CheckArgumentNull(property, "property");

            this.property             = property;
            this.parent               = parent;
            this.isLocallyInteresting = isLocallyInteresting;
            this.clrType              = EntityDataSourceUtil.GetMemberClrType(ocWorkspace, property);
            this.isKey = IsPropertyAKey(property);

            // retrieve PropertyInfo (with respect to parent CLR type)
            StructuralType parentType    = property.DeclaringType;
            Type           parentClrType = EntityDataSourceUtil.GetClrType(ocWorkspace, parentType);

            this.propertyInfo = EntityDataSourceUtil.GetPropertyInfo(parentClrType, this.property.Name);
        }
示例#8
0
        internal EntityDataSourceWrapperCollection(ObjectContext context, EntitySet entitySet, EntityType restrictedEntityType)
        {
            EntityDataSourceUtil.CheckArgumentNull(context, "context");
            EntityDataSourceUtil.CheckArgumentNull(entitySet, "entitySet");

            _context     = context;
            _wrapperList = new List <EntityDataSourceWrapper>();

            // get handles on the relevant workspaces
            MetadataWorkspace csWorkspace = ((EntityConnection)context.Connection).GetMetadataWorkspace();
            MetadataWorkspace ocWorkspace = context.MetadataWorkspace;

            // if no restricted type is given, we assume the entity set element type is exposed
            EntityType entityType = restrictedEntityType ?? entitySet.ElementType;

            _clrEntityType = EntityDataSourceUtil.GetClrType(ocWorkspace, entityType);

            // if no restricted type is given and the set is polymorphic, make the collection readonly
            if (null == restrictedEntityType &&
                1 < EntityDataSourceUtil.GetTypeAndSubtypesOf(entityType, csWorkspace.GetItemCollection(DataSpace.CSpace), true).Count())
            {
                _isReadOnly = true;
            }

            // gather the properties
            ReadOnlyCollection <EntityDataSourceColumn> columns  = EntityDataSourceUtil.GetNamedColumns(csWorkspace, ocWorkspace, entitySet, entityType);
            List <PropertyDescriptor> visiblePropertyDescriptors = new List <PropertyDescriptor>(columns.Count);
            List <EntityDataSourceWrapperPropertyDescriptor> propertyDescriptors = new List <EntityDataSourceWrapperPropertyDescriptor>(columns.Count);

            foreach (EntityDataSourceColumn column in columns)
            {
                var descriptor = new EntityDataSourceWrapperPropertyDescriptor(this, column);
                propertyDescriptors.Add(descriptor);

                // if the descriptor does not have a dependent, it is exposed to the user
                if (!descriptor.Column.IsHidden)
                {
                    visiblePropertyDescriptors.Add(descriptor);
                }
            }

            _visiblePropertyDescriptors = new PropertyDescriptorCollection(visiblePropertyDescriptors.ToArray(), true);
            AllPropertyDescriptors      = propertyDescriptors.AsReadOnly();
        }
示例#9
0
        internal EntityDataSourceReferenceKeyColumn(MetadataWorkspace workspace, EntityDataSourceReferenceGroup group, EdmProperty keyMember, EntityDataSourceColumn dependent)
            : base(CreateDisplayName(group, keyMember), dependent)
        {
            EntityDataSourceUtil.CheckArgumentNull(group, "group");
            EntityDataSourceUtil.CheckArgumentNull(keyMember, "keyMember");
            Debug.Assert(EntityDataSourceUtil.IsScalar(keyMember.TypeUsage.EdmType), "Expected primitive or enum type for key members.");

            this.group     = group;
            this.keyMember = keyMember;
            this.clrType   = EntityDataSourceUtil.GetMemberClrType(workspace, keyMember);

            // if the association end is optional (0..1), make sure the CLR type
            // is also nullable
            if (this.group.End.CorrespondingAssociationEndMember.RelationshipMultiplicity == RelationshipMultiplicity.ZeroOrOne)
            {
                this.clrType    = EntityDataSourceUtil.MakeNullable(clrType);
                this.isNullable = true;
            }
        }
示例#10
0
        /// <summary>
        /// Get the Clr type for the primitive enum or complex type member. The member must not be null.
        /// </summary>
        internal static Type GetMemberClrType(MetadataWorkspace ocWorkspace, EdmMember member)
        {
            EntityDataSourceUtil.CheckArgumentNull(member, "member");

            EdmType memberType = member.TypeUsage.EdmType;

            Debug.Assert(EntityDataSourceUtil.IsScalar(memberType) ||
                         memberType.BuiltInTypeKind == BuiltInTypeKind.ComplexType ||
                         memberType.BuiltInTypeKind == BuiltInTypeKind.EntityType, "member type must be primitive, enum, entity or complex type");

            Type clrType;

            if (EntityDataSourceUtil.IsScalar(memberType))
            {
                clrType = memberType.BuiltInTypeKind == BuiltInTypeKind.PrimitiveType ?
                          ((PrimitiveType)memberType).ClrEquivalentType :
                          GetClrType(ocWorkspace, (EnumType)memberType);

                if (!NullCanBeAssignedTo(clrType))
                {
                    Facet facet;
                    if (member.TypeUsage.Facets.TryGetValue("Nullable", true, out facet))
                    {
                        if ((bool)facet.Value)
                        {
                            clrType = MakeNullable(clrType);
                        }
                    }
                }
            }
            else
            {
                Debug.Assert(
                    memberType.BuiltInTypeKind == BuiltInTypeKind.EntityType || memberType.BuiltInTypeKind == BuiltInTypeKind.ComplexType,
                    "Complex or Entity type expected");

                clrType = GetClrType(ocWorkspace, (StructuralType)memberType);
            }

            return(clrType);
        }
示例#11
0
        private static string CreateDisplayName(EntityDataSourceReferenceGroup group, EdmProperty keyMember)
        {
            EntityDataSourceUtil.CheckArgumentNull(group, "group");
            EntityDataSourceUtil.CheckArgumentNull(keyMember, "keyMember");

            NavigationProperty navigationProperty;

            string result;

            if (EntityDataSourceUtil.TryGetCorrespondingNavigationProperty(group.End.CorrespondingAssociationEndMember, out navigationProperty))
            {
                result = navigationProperty.Name + "." + keyMember.Name;
            }
            else
            {
                // if there is no Navigation property, use the TargetTole and KeyMember name
                // TargetRole.KeyMember
                result = group.End.Name + "." + keyMember.Name;
            }

            return(result);
        }
示例#12
0
 internal static string GetQualifiedEntitySetName(EntitySet entitySet)
 {
     EntityDataSourceUtil.CheckArgumentNull(entitySet, "entitySet");
     // ContainerName.EntitySetName
     return(entitySet.EntityContainer.Name + "." + entitySet.Name);
 }
示例#13
0
 internal EntityDataSourcePropertyColumn(EntityDataSourceMemberPath memberPath)
     : base(EntityDataSourceUtil.CheckArgumentNull(memberPath, "memberPath").GetDescription())
 {
     this.memberPath = memberPath;
 }
        protected EntityDataSourceReferenceGroup(AssociationSetEnd end)
        {
            EntityDataSourceUtil.CheckArgumentNull(end, "end");

            this.end = end;
        }