Esempio n. 1
0
        public void Setup(Type markedType, IContainerSetup setup)
        {
            if (!setup.GetRegisteredPlugins <ControllerCollectorPlugin>().Any())
            {
                setup.RegisterPlugin(s => s.CustomInstanceCreators.Add(new ControllerCollectorPlugin()));
            }

            setup.For(markedType)
            .Use(markedType)
            .WithBehavior <ControllerBehavior>(SetupBehavior);
        }
Esempio n. 2
0
        public void Setup(Type markedType, IContainerSetup setup)
        {
            if (!setup.GetRegisteredPlugins <EntityPlugin>().Any())
            {
                setup.RegisterPlugin(p => p.CustomInstanceCreators.Add(new EntityPlugin(new DefaultRobOrmSetup())));
            }

            if (!setup.GetRegisteredPlugins <EntityCollectorPlugin>().Any())
            {
                setup.RegisterPlugin(p => p.CustomInstanceCreators.Add(new EntityCollectorPlugin()));
                setup.For <IEntityCollector>();
            }

            var entityName = EntityName;

            if (string.IsNullOrWhiteSpace(entityName))
            {
                entityName = NamingHelper.GetDefaultEntityName(markedType);
            }

            var pkProperty = PrimaryKeyProperty;

            if (string.IsNullOrWhiteSpace(pkProperty))
            {
                pkProperty = "Id";
            }

            if (ReflectionUtil.GetProperty(markedType, pkProperty) == null)
            {
                throw new InvalidOperationException($"{markedType.Name} - Primary Key property \"{pkProperty}\" not found");
            }

            setup.For(markedType)
            .WithBehavior <EntityBehavior>(db =>
            {
                db.EntityName         = entityName;
                db.PrimaryKeyProperty = pkProperty;
            })
            .WithBehavior <LifecycleBehavior>(lb => lb.AlwaysNewInstance = true)
            .WithBehavior <DisposeBehavior>(db => db.Dispose             = false);
        }