コード例 #1
0
        private static bool IsCustomUpdateMethod(MethodInfo method, MetadataProvider metadataProvider)
        {
            ParameterInfo[] parameters = method.GetParameters();
            if (parameters.Length == 0)
            {
                return false;
            }
            if (method.ReturnType != typeof(void))
            {
                return false;
            }

            return metadataProvider.IsEntityType(parameters[0].ParameterType);
        }
コード例 #2
0
        /// <summary>
        /// Adds the specified entity type and any associated entity types recursively to the specified set.
        /// </summary>
        /// <param name="entityType">The entity Type to add.</param>
        /// <param name="entityTypes">The types set to accumulate in.</param>
        /// <param name="metadataProvider">The metadata provider.</param>
        private static void AddEntityType(Type entityType, HashSet<Type> entityTypes, MetadataProvider metadataProvider)
        {
            if (entityTypes.Contains(entityType))
            {
                // already added this type
                return;
            }

            entityTypes.Add(entityType);
            RegisterDataControllerTypeDescriptionProvider(entityType, metadataProvider);

            foreach (PropertyDescriptor pd in TypeDescriptor.GetProperties(entityType))
            {
                // for any "exposed" association members, recursively add the associated
                // entity type
                if (pd.Attributes[typeof(AssociationAttribute)] != null && TypeUtility.IsDataMember(pd))
                {
                    Type includedEntityType = TypeUtility.GetElementType(pd.PropertyType);
                    if (metadataProvider.IsEntityType(entityType))
                    {
                        AddEntityType(includedEntityType, entityTypes, metadataProvider);
                    }
                }
            }

            // Recursively add any derived entity types specified by [KnownType]
            // attributes
            IEnumerable<Type> knownTypes = TypeUtility.GetKnownTypes(entityType, true);
            foreach (Type knownType in knownTypes)
            {
                if (entityType.IsAssignableFrom(knownType))
                {
                    AddEntityType(knownType, entityTypes, metadataProvider);
                }
            }
        }