protected virtual IEnumerable <IEngineConfigurationTypeMember> GetAllTypeHierarchyMembers(IEngineConfiguration baseConfiguration, IEngineConfigurationType sourceType)
        {
            Stack <IEngineConfigurationType> configurationStack = new Stack <IEngineConfigurationType>();
            Type currentType = sourceType.RegisteredType;
            IEngineConfigurationType currentTypeConfiguration = null;

            // Get all the base types into a stack, where the base-most type is at the top
            while (currentType != null)
            {
                currentTypeConfiguration = baseConfiguration.GetRegisteredType(currentType);
                if (currentTypeConfiguration != null)
                {
                    configurationStack.Push(currentTypeConfiguration);
                }
                currentType = currentType.BaseType;
            }

            // Put all the implemented interfaces on top of that
            foreach (var interfaceType in sourceType.RegisteredType.GetInterfaces())
            {
                currentTypeConfiguration = baseConfiguration.GetRegisteredType(interfaceType);
                if (currentTypeConfiguration != null)
                {
                    configurationStack.Push(currentTypeConfiguration);
                }
            }

            var membersToApply = (from typeConfig in configurationStack
                                  from memberConfig in typeConfig.GetRegisteredMembers()
                                  select memberConfig).ToArray();

            return(membersToApply);
        }
        protected virtual IEnumerable<IEngineConfigurationTypeMember> GetAllTypeHierarchyMembers(IEngineConfiguration baseConfiguration, IEngineConfigurationType sourceType)
        {
            Stack<IEngineConfigurationType> configurationStack = new Stack<IEngineConfigurationType>();
            Type currentType = sourceType.RegisteredType;
            IEngineConfigurationType currentTypeConfiguration = null;

            // Get all the base types into a stack, where the base-most type is at the top
            while (currentType != null)
            {
                currentTypeConfiguration = baseConfiguration.GetRegisteredType(currentType);
                if (currentTypeConfiguration != null) { configurationStack.Push(currentTypeConfiguration); }
                currentType = currentType.BaseType;
            }

            // Put all the implemented interfaces on top of that
            foreach (var interfaceType in sourceType.RegisteredType.GetInterfaces())
            {
                currentTypeConfiguration = baseConfiguration.GetRegisteredType(interfaceType);
                if (currentTypeConfiguration != null)
                {
                    configurationStack.Push(currentTypeConfiguration);
                }
            }

            var membersToApply = (from typeConfig in configurationStack
                                  from memberConfig in typeConfig.GetRegisteredMembers()
                                  select memberConfig).ToArray();

            return membersToApply;
        }
        private IObjectBuilder CreateBuilderForType(Type searchType)
        {
            EnsureTypeExists(searchType);
            IEngineConfigurationType type = mConfiguration.GetRegisteredType(searchType);
            var builder = new ObjectBuilder(type);

            mObjectBuilders.Add(builder);
            return(builder);
        }
        public void Setup()
        {
            this.Builder.Conventions(x =>
            {
                x.Register<TestTypeConvention>();
            });
            this.Builder.Include<TestTypeClass>();

            mConfiguration = new EngineConfigurationFactory().Create(this.Builder, this.Builder.ConventionProvider);
            mType = mConfiguration.GetRegisteredType(typeof(TestTypeClass));
        }
        public void Setup()
        {
            this.Builder.Conventions(x =>
            {
                x.Register <TestTypeConvention>();
            });
            this.Builder.Include <TestTypeClass>();

            mConfiguration = new EngineConfigurationFactory().Create(this.Builder, this.Builder.ConventionProvider);
            mType          = mConfiguration.GetRegisteredType(typeof(TestTypeClass));
        }
        protected virtual void TryRegisterType(IEngineConfiguration configuration, Type configType)
        {
            var configuredType = configuration.GetRegisteredType(configType);

            if (configuredType == null)
            {
                configuration.RegisterType(configType);
                configuredType = configuration.GetRegisteredType(configType);
            }

            foreach (var interfaceType in configType.GetInterfaces())
            {
                TryRegisterType(configuration, interfaceType);
            }

            Type baseType = configType.BaseType;

            if (baseType != null)
            {
                TryRegisterType(configuration, baseType);
            }
        }
        public void Setup()
        {
            this.Builder.Conventions(x =>
            {
                x.Register <TestFieldConvention>();
            });
            this.Builder.Include <TestFieldClass>()
            .Setup(x => x.Test).Default()
            .Setup(x => x.TestIgnore);

            mConfiguration   = new EngineConfigurationFactory().Create(this.Builder, this.Builder.ConventionProvider);
            mType            = mConfiguration.GetRegisteredType(typeof(TestFieldClass));
            mTestField       = mType.GetRegisteredMembers().Where(x => x.Member.Name == "Test").Single();
            mTestIgnoreField = mType.GetRegisteredMembers().Where(x => x.Member.Name == "TestIgnore").Single();
        }
        public void Setup()
        {
            this.Builder.Conventions(x =>
            {
                x.Register<TestPropertyConvention>();
            });
            this.Builder.Include<TestPropertyClass>()
                .Setup(x => x.Test).Default()
                .Setup(x => x.TestIgnore);

            mConfiguration = new EngineConfigurationFactory().Create(this.Builder, this.Builder.ConventionProvider);
            mType = mConfiguration.GetRegisteredType(typeof(TestPropertyClass));
            mTestProperty = mType.GetRegisteredMembers().Where(x => x.Member.Name == "Test").Single();
            mTestIgnoreProperty = mType.GetRegisteredMembers().Where(x => x.Member.Name == "TestIgnore").Single();
        }
        public void SetupObjects()
        {
            this.Builder.Include <SimpleMethodClass>()
            .Invoke(x => x.SetSomething("Literal"))
            .Invoke(x => x.SetSomething(
                        Use.Source <String, FirstNameSource>(),
                        Use.Source <String, LastNameSource>()));

            Configuration = new EngineConfigurationFactory().Create(this.Builder, this.Builder.ConventionProvider);

            // Get some info for the tests
            mEngineConfigurationType = Configuration.GetRegisteredType(typeof(SimpleMethodClass));
            mSingleArgMethod         = (EngineTypeMethodMember)ReflectionHelper.GetMember(
                typeof(SimpleMethodClass).GetMethod("SetSomething", new Type[] { typeof(string) }));
            mDoubleArgMethod = (EngineTypeMethodMember)ReflectionHelper.GetMember(
                typeof(SimpleMethodClass).GetMethod("SetSomething", new Type[] { typeof(string), typeof(string) }));
        }
        protected virtual void TryRegisterType(IEngineConfiguration configuration, Type configType)
        {
            IEngineConfigurationType configuredType = configuration.GetRegisteredType(configType);
            if (configuredType == null)
            {
                configuration.RegisterType(configType);
                configuredType = configuration.GetRegisteredType(configType);
            }

            foreach (Type interfaceType in configType.GetInterfaces())
            {
                TryRegisterType(configuration, interfaceType);
            }

            Type baseType = configType.BaseType;
            if (baseType != null)
            {
                TryRegisterType(configuration, baseType);
            }
        }
        public void SetupObjects()
        {
            this.Builder.Include<SimpleMethodClass>()
                .Invoke(x=>x.SetSomething("Literal"))
                .Invoke(x=>x.SetSomething(
                    Use.Source<String, FirstNameSource>(),
                    Use.Source<String, LastNameSource>()));

            Configuration = new EngineConfigurationFactory().Create(this.Builder, this.Builder.ConventionProvider);

            // Get some info for the tests
            mEngineConfigurationType = Configuration.GetRegisteredType(typeof(SimpleMethodClass));
            mSingleArgMethod = (EngineTypeMethodMember)ReflectionHelper.GetMember(
                typeof(SimpleMethodClass).GetMethod("SetSomething", new Type[] { typeof(string) }));
            mDoubleArgMethod = (EngineTypeMethodMember)ReflectionHelper.GetMember(
                typeof(SimpleMethodClass).GetMethod("SetSomething", new Type[] { typeof(string), typeof(string) }));
        }