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();
        }
 private void ApplyToType(IEngineConfigurationType type)
 {
     foreach (IEngineConfigurationTypeMember member in type.GetRegisteredMembers())
     {
         ApplyToTypeMember(member);
     }
 }
Example #4
0
 private void ApplyToType(IEngineConfigurationType type)
 {
     foreach (var member in type.GetRegisteredMembers())
     {
         ApplyToTypeMember(member);
     }
 }
        /// <summary>
        /// Creates this object builder
        /// </summary>
        /// <param name="type"></param>
        public ObjectBuilder(IEngineConfigurationType type)
        {
            InnerType = type.RegisteredType;

            if (type.GetFactory() != null)
            {
                mFactory = type.GetFactory().Build();
            }

            type.GetRegisteredMembers()
                .ToList()
                .ForEach(x =>
                             {
                                 List<IDatasource> sources = x.GetDatasources().Select(s => s.Build()).ToList();

                                 if (x.Member.IsField)
                                 {
                                     if (sources.Count == 0)
                                     {
                                         return;
                                     }

                                     AddAction(new ObjectFieldSetFromSourceAction(
                                                   (EngineTypeFieldMember) x.Member,
                                                   sources.First()));
                                 }
                                 else if (x.Member.IsProperty)
                                 {
                                     if (sources.Count == 0)
                                     {
                                         return;
                                     }

                                     AddAction(new ObjectPropertySetFromSourceAction(
                                                   (EngineTypePropertyMember) x.Member,
                                                   sources.First()));
                                 }
                                 else if (x.Member.IsMethod)
                                 {
                                     AddAction(new ObjectMethodInvokeFromSourceAction(
                                                   (EngineTypeMethodMember) x.Member,
                                                   sources
                                                   ));
                                 }
                             });
        }
        /// <summary>
        /// Creates this object builder
        /// </summary>
        /// <param name="type"></param>
        public ObjectBuilder(IEngineConfigurationType type)
        {
            this.InnerType = type.RegisteredType;

            if (type.GetFactory() != null)
            {
                mFactory = type.GetFactory().Build();
            }

            type.GetRegisteredMembers()
            .ToList()
            .ForEach(x =>
            {
                var sources = x.GetDatasources().Select(s => s.Build()).ToList();

                if (x.Member.IsField)
                {
                    if (sources.Count == 0)
                    {
                        return;
                    }

                    this.AddAction(new ObjectFieldSetFromSourceAction(
                                       (EngineTypeFieldMember)x.Member,
                                       sources.First()));
                }
                else if (x.Member.IsProperty)
                {
                    if (sources.Count == 0)
                    {
                        return;
                    }

                    this.AddAction(new ObjectPropertySetFromSourceAction(
                                       (EngineTypePropertyMember)x.Member,
                                       sources.First()));
                }
                else if (x.Member.IsMethod)
                {
                    this.AddAction(new ObjectMethodInvokeFromSourceAction(
                                       (EngineTypeMethodMember)x.Member,
                                       sources
                                       ));
                }
            });
        }
 public void BothMethodsAreRegistered()
 {
     Assert.AreEqual(2, mEngineConfigurationType.GetRegisteredMembers().Count());
 }