protected void InitializeStrategies()
        {
            // Main strategy chain
            _strategies.Add(new BuildKeyMappingStrategy(), UnityBuildStage.TypeMapping);
            _strategies.Add(new LifetimeStrategy(), UnityBuildStage.Lifetime);
            _strategies.Add(new BuildPlanStrategy(), UnityBuildStage.Creation);

            // Build plan strategy chain
            _buildPlanStrategies.Add(new DynamicMethodConstructorStrategy(), BuilderStage.Creation);
            _buildPlanStrategies.Add(new DynamicMethodPropertySetterStrategy(), BuilderStage.Initialization);
            _buildPlanStrategies.Add(new DynamicMethodCallStrategy(), BuilderStage.Initialization);

            // Default Policies - mostly used by the build plan strategies
            this[null, null] = new LinkedMap<Type, IBuilderPolicy>(typeof(IResolverPolicy), new DefaultResolverPolicy())
            {
                [typeof(IBuildPlanCreatorPolicy)] = new DynamicMethodBuildPlanCreatorPolicy(_buildPlanStrategies),
                [typeof(IConstructorSelectorPolicy)] = new DefaultUnityConstructorSelectorPolicy(),
                [typeof(IPropertySelectorPolicy)] = new DefaultUnityPropertySelectorPolicy(),
                [typeof(IMethodSelectorPolicy)] = new DefaultUnityMethodSelectorPolicy()
            };

            // Special Cases
            this[typeof(Func<>), null, typeof(ILifetimePolicy)]  = new PerResolveLifetimeManager();
            this[typeof(Func<>), null, typeof(IBuildPlanPolicy)] = new DeferredResolveBuildPlanPolicy();
            this[typeof(Lazy<>), null, typeof(IBuildPlanCreatorPolicy)] = new LazyDynamicMethodBuildPlanCreatorPolicy();
            this[typeof(Array),  null, typeof(IBuildPlanCreatorPolicy)] = new ArrayBuildPlanCreatorPolicy();
            this[typeof(IEnumerable<>), null, typeof(IBuildPlanCreatorPolicy)] = new EnumerableDynamicMethodBuildPlanCreatorPolicy();
        }
Example #2
0
 public void RemoveMap(LinkedMap map)
 {
     foreach (WarpLink warp in map.mapLinks)
     {
         map.DestroyLink(warp);
     }
     maps.Remove(map);
 }
Example #3
0
 public void AddLink(LinkedMap source, WarpController sourceWarp, LinkedMap destination, WarpController destinationWarp, bool reciprocal)
 {
     source.mapLinks.Add(new WarpLink(sourceWarp, destinationWarp, destination));
     if (reciprocal == true)
     {
         destination.mapLinks.Add(new WarpLink(destinationWarp, sourceWarp, destination));
     }
 }
Example #4
0
 public WarpLink(WarpController source, WarpController destination, LinkedMap linkedMap)
 {
     sourceWarp      = source;
     this.linkedMap  = linkedMap;
     destinationWarp = destination;
 }
 /**
  * Transforms a map.
  * <p>
  * The transformer itself may throw an exception if necessary.
  *
  * @param map  the map to transform
  * @throws the transformed object
  */
 protected virtual java.util.Map<Object, Object> transformMap(java.util.Map<Object, Object> map)
 {
     if (map.isEmpty())
     {
         return map;
     }
     java.util.Map<Object, Object> result = new LinkedMap(map.size());
     for (java.util.Iterator<java.util.MapNS.Entry<Object, Object>> it = map.entrySet().iterator(); it.hasNext(); )
     {
         java.util.MapNS.Entry<Object, Object> entry = it.next();
         result.put(transformKey(entry.getKey()), transformValue(entry.getValue()));
     }
     return result;
 }
Example #6
0
 public void SetUp()
 {
     _linkedMap = new LinkedMap <string, string>();
 }