Exemple #1
0
        private Tuple <IEnumerable <IAssociationSpecImmutable>, IImmutableDictionary <string, ITypeSpecBuilder> > CreateCollectionSpecs(IEnumerable <PropertyInfo> collectionProperties, IObjectSpecImmutable spec, IImmutableDictionary <string, ITypeSpecBuilder> metamodel)
        {
            var specs = new List <IAssociationSpecImmutable>();

            foreach (PropertyInfo property in collectionProperties)
            {
                IIdentifier identifier = new IdentifierImpl(FullName, property.Name);

                // create a collection property spec
                Type returnType  = property.PropertyType;
                Type defaultType = typeof(object);
                var  result      = reflector.LoadSpecification(returnType, metamodel);

                metamodel = result.Item2;
                var returnSpec = result.Item1 as IObjectSpecImmutable;
                result    = reflector.LoadSpecification(defaultType, metamodel);
                metamodel = result.Item2;
                var defaultSpec = result.Item1 as IObjectSpecImmutable;

                var collection = ImmutableSpecFactory.CreateOneToManyAssociationSpecImmutable(identifier, spec, returnSpec, defaultSpec);

                metamodel = FacetFactorySet.Process(reflector, property, new IntrospectorMethodRemover(methods), collection, FeatureType.Collections, metamodel);
                specs.Add(collection);
            }
            return(new Tuple <IEnumerable <IAssociationSpecImmutable>, IImmutableDictionary <string, ITypeSpecBuilder> >(specs, metamodel));
        }
        private IEnumerable <IAssociationSpecImmutable> CreateCollectionSpecs(IEnumerable <PropertyInfo> collectionProperties, IObjectSpecImmutable spec)
        {
            var specs = new List <IAssociationSpecImmutable>();

            foreach (PropertyInfo property in collectionProperties)
            {
                IIdentifier identifier = new IdentifierImpl(FullName, property.Name);

                // create a collection property spec
                Type returnType  = property.PropertyType;
                var  returnSpec  = reflector.LoadSpecification <IObjectSpecImmutable>(returnType);
                Type defaultType = typeof(object);
                var  defaultSpec = reflector.LoadSpecification <IObjectSpecImmutable>(defaultType);

                var collection = ImmutableSpecFactory.CreateOneToManyAssociationSpecImmutable(identifier, spec, returnSpec, defaultSpec);

                FacetFactorySet.Process(reflector, property, new IntrospectorMethodRemover(methods), collection, FeatureType.Collections);
                specs.Add(collection);
            }
            return(specs);
        }