コード例 #1
0
 public C1QueryProvider(C1MetadataProvider metadata)
 {
     _metadata = metadata;
 }
コード例 #2
0
 public C1DataService()
 {
     _metadata = GetMetadataProvider(typeof(T));
     _query    = GetQueryProvider(_metadata);
 }
コード例 #3
0
        private C1MetadataProvider GetMetadataProvider(Type dataSourceType)
        {
            C1MetadataProvider metadata = new C1MetadataProvider();

            foreach (Type type in DataFacade.GetAllKnownInterfaces())
            {
                // "Minimal" security
                if (type.FullName.StartsWith("Composite.Data.Types.IUser") ||
                    type.FullName.StartsWith("Composite.Community.Extranet.") ||
                    type == typeof(ISqlConnection) ||
                    type == typeof(ILockingInformation))
                {
                    continue;
                }

                Guid          typeId = default(Guid);
                List <string> keys   = type.GetKeyPropertyNames();
                bool          hasKey = false;

                foreach (object ca in type.GetCustomAttributes(typeof(ImmutableTypeIdAttribute), true))
                {
                    typeId = ((ImmutableTypeIdAttribute)ca).ImmutableTypeId;
                }

                var rType = new ResourceType(
                    type,
                    ResourceTypeKind.EntityType,
                    null,
                    type.Namespace,
                    type.Name,
                    false
                    );

                foreach (PropertyInfo pi in type.GetProperties())
                {
                    ResourceProperty rProperty;
                    if (keys.Contains(pi.Name))
                    {
                        hasKey    = true;
                        rProperty = new ResourceProperty(
                            pi.Name,
                            ResourcePropertyKind.Key | ResourcePropertyKind.Primitive,
                            ResourceType.GetPrimitiveResourceType(pi.PropertyType)
                            );
                    }
                    else
                    {
                        rProperty = new ResourceProperty(
                            pi.Name,
                            ResourcePropertyKind.Primitive,
                            ResourceType.GetPrimitiveResourceType(pi.PropertyType)
                            );
                    }
                    rType.AddProperty(rProperty);
                }

                if (typeId != default(Guid))
                {
                    Data.DynamicTypes.DataTypeDescriptor dd = Data.DynamicTypes.DynamicTypeManager.GetDataTypeDescriptor(typeId);
                    if (dd != null)
                    {
                        foreach (Type superType in dd.SuperInterfaces)
                        {
                            keys = type.GetKeyPropertyNames();
                            foreach (PropertyInfo pi in superType.GetProperties())
                            {
                                ResourceProperty rProperty;
                                if (keys.Contains(pi.Name))
                                {
                                    hasKey    = true;
                                    rProperty = new ResourceProperty(
                                        pi.Name,
                                        ResourcePropertyKind.Key | ResourcePropertyKind.Primitive,
                                        ResourceType.GetPrimitiveResourceType(pi.PropertyType)
                                        );
                                }
                                else
                                {
                                    rProperty = new ResourceProperty(
                                        pi.Name,
                                        ResourcePropertyKind.Primitive,
                                        ResourceType.GetPrimitiveResourceType(pi.PropertyType)
                                        );
                                }
                                rProperty.CanReflectOnInstanceTypeProperty = false;
                                rType.AddProperty(rProperty);
                            }
                        }
                    }
                }
                if (hasKey)
                {
                    metadata.AddResourceType(rType);
                    metadata.AddResourceSet(new ResourceSet(type.FullName.Replace('.', '_'), rType));
                }
            }
            return(metadata);
        }
コード例 #4
0
 private C1QueryProvider <T> GetQueryProvider(C1MetadataProvider metadata)
 {
     return(new C1QueryProvider <T>(metadata));
 }