private FluentBuilder(
            FluentBuilder parent,
            Func <Type, object> factory,
            IPackage packageContext,
            IDataCatalog dataCatalog,
            IDataDependencyFactory dataDependencyFactory,
            IDataSupplierFactory dataSupplierFactory)
        {
            _nameManager           = parent._nameManager;
            _assemblies            = parent._assemblies;
            _types                 = parent._types;
            _packageContext        = packageContext;
            _dataCatalog           = dataCatalog;
            _dataDependencyFactory = dataDependencyFactory;
            _dataSupplierFactory   = dataSupplierFactory;
            _factory               = factory;

            ModuleBuilder       = parent.ModuleBuilder;
            PageBuilder         = parent.PageBuilder;
            LayoutBuilder       = parent.LayoutBuilder;
            RegionBuilder       = parent.RegionBuilder;
            ComponentBuilder    = parent.ComponentBuilder;
            ServiceBuilder      = parent.ServiceBuilder;
            PackageBuilder      = parent.PackageBuilder;
            DataProviderBuilder = parent.DataProviderBuilder;
        }
示例#2
0
        /// <summary>
        /// This is called when a module is discovered through reflection and it needs
        /// to be consutucted and initialized, or when a package is explicitly registered
        /// with a custom namespace
        /// </summary>
        private IPackage BuildPackage(IPackage package, Type type, Func <Type, object> factory, string namespaceName)
        {
            if (package == null && factory != null && typeof(IPackage).IsAssignableFrom(type))
            {
                package = factory(type) as IPackage;
            }

            var packageDefinition = BuildUpPackage(package, type);

            package = packageDefinition.Build();

            if (!string.IsNullOrEmpty(namespaceName))
            {
                package.NamespaceName = namespaceName;
            }

            var packageBuilder = new FluentBuilder(
                this,
                package,
                _dataCatalog,
                _dataDependencyFactory,
                _dataSupplierFactory);

            package.Build(packageBuilder);

            return(package);
        }
        /// <summary>
        /// This is called when a package is discovered through reflection and it needs
        /// to be consutucted and initialized, or when a package is explicitly registered
        /// with a custom namespace
        /// </summary>
        private IPackage BuildPackage(IPackage package, Type type, Func <Type, object> factory, string namespaceName)
        {
            if (_debugLogging)
            {
                var message = "Fluent builder is building";

                if (package != null)
                {
                    message += " an instance of package " + package.GetType().DisplayName();
                    if (type != null)
                    {
                        message += " using attributes from " + type.DisplayName();
                    }
                }
                else
                {
                    if (type == null)
                    {
                        message += " a package of unspecified type";
                    }
                    else
                    {
                        message += " a package of type " + type.DisplayName();
                    }

                    if (factory == null)
                    {
                        message += " using the default public constructor";
                    }
                    else
                    {
                        message += " using a factory";
                    }
                }

                if (!string.IsNullOrEmpty(namespaceName))
                {
                    message += " defining the '" + namespaceName + "' namespace";
                }

                Trace.WriteLine(message);
            }

            if (package == null && factory != null && typeof(IPackage).IsAssignableFrom(type))
            {
                package = factory(type) as IPackage;
            }

            var packageDefinition = BuildUpPackage(package, type, factory);

            package = packageDefinition.Build();

            if (!string.IsNullOrEmpty(namespaceName))
            {
                package.NamespaceName = namespaceName;
            }

            var packageBuilder = new FluentBuilder(
                this,
                factory,
                package,
                _dataCatalog,
                _dataDependencyFactory,
                _dataSupplierFactory);

            package.Build(packageBuilder);

            return(package);
        }