Exemple #1
0
 public CompositionContext()
 {
     //foreach (var mut in Mutators.Get(t)) mut(val);
     Singletons = new Dictionary <Type, object>();
     Factories  = new TypedFactory();
     Factories.Mutate((t, o) => {
         foreach (var mut in Mutators.Get(t))
         {
             mut(o);
         }
     });
     TaggedFactories = new FactoryDictionary <Type, TypedFactory>();
     TaggedFactories.Loader((t) => {
         var fac = new TypedFactory();
         fac.Mutate((t2, o) => {
             foreach (var mut in TaggedMutators.Get(t).Get(t2))
             {
                 mut(o);
             }
         });
         return(fac);
     });
     Mutators = new FactoryDictionary <Type, IList <Action <object> > >();
     Mutators.Loader((t) => new List <Action <object> >());
     TaggedMutators = new FactoryDictionary <Type, FactoryDictionary <Type, IList <Action <object> > > >();
     TaggedMutators.Loader((t) => {
         var muts = new FactoryDictionary <Type, IList <Action <object> > >();
         muts.Loader((t2) => new List <Action <object> >());
         return(muts);
     });
 }
Exemple #2
0
 public void Mutate <TTag, TMut>(Action <TMut> mutator) where TTag : IContextTag
 {
     // TODO: Following contains a suspicious cast, need to make all these functions behave better
     TaggedMutators.Get(typeof(TTag)).Get(typeof(TMut)).Add(o => mutator((TMut)o));
 }