예제 #1
0
        /// <summary>
        /// Relay handler. Called from the SelectorMapper's For(...).
        /// This creates the default handler for when the type is
        /// not found.
        /// </summary>
        /// <returns></returns>
        public IDefaultChain <T> Default()
        {
            SelectorMapper <T> newSelector = null;

            Selector.Configure <T>(cfg => newSelector = (SelectorMapper <T>)cfg);
            return(new SelectorRelayDefault <T, T>(newSelector));
        }
        /// <summary>
        /// Configures the current mapping using the current type value.
        /// </summary>
        /// <param name="configure">Lambda express used to configure the mapped type.</param>
        public void Configure(Action <IConfigureChain <T> > configure)
        {
            SelectorMapper <T> mapper = new SelectorMapper <T>();

            Selector.AddConditionItem(Condition, mapper);
            configure(mapper);
        }
예제 #3
0
        /// <summary>
        /// Called cfg.For().Configure(...). Used to create a sub configuration
        /// with a property accessor for the specified type.
        /// </summary>
        /// <typeparam name="TSub">The new subt type to configure.</typeparam>
        /// <param name="accessor">Lambda accessor that takes the current type
        /// object and returns the sub object type.</param>
        /// <param name="configure">Lambda expression that builds the configuration
        /// for the new type.</param>
        public void Configure <TSub>(Func <T, TSub> accessor, Action <IConfigureChain <TSub> > configure)
        {
            // We are in the context of a For<type>(...).Configure<type2>() method and
            // therefore we have a ParentType, For Type, and now a new SubType. Basically
            // you have the following:
            //
            //   cfg.For<Type1>().Configure<Type2>(...)
            //
            // The cfg object carries the parent type (TParent),
            // the For carries the sub type (T),
            // and the Confgirure (this call), carries the third type (TSub).
            //
            // In this case, we create two mapper objects. The reason is because you
            // may have a TypeName specification which will go with the For<type> and
            // not the TSub type. Therefore we create a new SelectorMapper and
            // associate the TypeName accessors to that node and then create another
            // one for this configuration.

            SelectorMapper <T> mapper = null;

            Selector.Configure <T>(cfg => mapper = (SelectorMapper <T>)cfg, LookupStrategyEnum.InheritChain, TypeNameResourceKey, TypeNameAccessor);


            SelectorMapper <TSub> subMapper = new SelectorMapperSub <T, TSub>(accessor, LookupStrategyEnum.ConcreteOnly);

            mapper.Mapper.Add <T>(subMapper);
            configure(subMapper);
        }
        /// <summary>
        /// Configures the current mapping using the current type value.
        /// </summary>
        /// <param name="configure">Lambda express used to configure the mapped type.</param>
        public void Configure(Action <IConfigureChain <T> > configure)
        {
            SelectorMapper <T> mapper = new SelectorMapper <T>();

            Selector.DefaultItem = mapper;
            configure(mapper);
        }
예제 #5
0
 /// <summary>
 /// Resets and Clears all current configuration. After calling
 /// Clear, you must configure again before attepting to
 /// retrieve a message.
 /// </summary>
 public static void Clear()
 {
     lock (lockObj)
     {
         MainMapper = null;
     }
 }
예제 #6
0
        /// <summary>
        /// Configures the ObjectMessageMap for the givin type.
        /// </summary>
        /// <typeparam name="T">Type to configure</typeparam>
        /// <param name="configure">Lambda: All configuration methods.</param>
        public static void Configure <T>(Action <IConfigureChain <T> > configure)
        {
            if (MainMapper == null)
            {
                lock (lockObj)
                {
                    if (MainMapper == null)
                    {
                        MainMapper = new SelectorMapper <dynamic>(LookupStrategyEnum.InheritChain);
                    }
                }
            }

            MainMapper.Configure <T>(configure, LookupStrategyEnum.InheritChain);
        }
예제 #7
0
 public SelectorRelayFor(SelectorMapper <TParent> selectorMapper, T value)
 {
     Selector   = selectorMapper;
     Value      = value;
     ValueBased = true;
 }
예제 #8
0
 public SelectorRelayFor(SelectorMapper <TParent> selectorMapper)
 {
     Selector = selectorMapper;
 }
 public SelectorRelayDefault(SelectorMapper <TParent> selectorMapper)
 {
     Selector = selectorMapper;
 }