/// <summary> /// 현재 <see cref="IFrameworkContainer"/> 에 자식 <see cref="IFrameworkContainer"/> 를 추가합니다. /// </summary> /// <param name="parentContainer">부모 <see cref="IFrameworkContainer"/> 객체입니다.</param> /// <returns>자식 <see cref="IFrameworkContainer"/> 를 추가한 후, 현재의 <see cref="IFrameworkContainer"/> 를 반환합니다.</returns> public IFrameworkContainer AddChildContainer(IFrameworkContainer parentContainer) { var container = (FrameworkContainer <TContainer>)parentContainer; if (container.ChildContainers == null) { container.ChildContainers = new Dictionary <object, List <IFrameworkContainer> >(); container.ChildContainers.Add(this.Key, new List <IFrameworkContainer>() { this }); } else if (container.ChildContainers.ContainsKey(parentContainer.Key) == false) { container.ChildContainers.Add(this.Key, new List <IFrameworkContainer>() { this }); } else { container.ChildContainers[this.Key].Add(this); } this.Parent = container; return(this); }
/// <summary> /// <para><see cref="IFrameworkContainer"/> 컨테이너에 등록할 개체를 Task Parallel Library 를 이용하여 병렬로 처리합니다.</para> /// <para>단, 컨테이너에 개체를 등록할 때 CPU Process 의 개수를 이용하여 등록합니다.</para> /// <para>단, 오버헤드가 높을 수 있는 작업이므로 <see cref="IFrameworkContainer"/> 의 내부적인 모든 작업을 병렬화 합니다.</para> /// <para>단, 병렬 작업은 .NET Framework 4.0 빌드에서만 동작합니다.</para> /// </summary> /// <param name="container"></param> /// <param name="action"></param> public static void RegisterTypeAsParallel(this IFrameworkContainer container, IEnumerable <Action> action) { ConcurrentQueue <Exception> exceptions = null; try { exceptions = new ConcurrentQueue <Exception>(); try { action.AsParallel() .WithDegreeOfParallelism(Environment.ProcessorCount) .WithExecutionMode(ParallelExecutionMode.ForceParallelism) .ForAll(o => o()); } catch (Exception ex) { exceptions.Enqueue(ex); } } catch (Exception) { if (exceptions != null) { exceptions.ToList().ForEach(o => Trace.WriteLine(o.Message)); } throw; } }
public FrameworkContainer(object key, IFrameworkContainer parentContainer) { this.Key = key; this.ContainerObject = this.CreateContainer((FrameworkContainer <TContainer>)parentContainer); this.AddChildContainer((FrameworkContainer <TContainer>)parentContainer); }
private static IFrameworkContainer SetupFrameworkContainer(string path, ref IFrameworkContainer container) { if (File.Exists(path) == false) throw new FileNotFoundException(path); if (container == null) container = new FrameworkContainerForUnity(); return container; }
public static T New <T>(this T type, IFrameworkContainer container) { var resolve = container.Resolve <T>(); if (resolve == null) { container.RegisterType <T>(); } return(container.Resolve <T>()); }
/// <summary> /// 구성 파일에서 <see cref="IFrameworkContainer"/> 로 구성을 합니다. /// </summary> /// <remarks> /// Umc, 2011-01-13. /// </remarks> /// <param name="container"> The container to act on. </param> /// <param name="path"> Full pathname of the file. </param> public static void Load(this IFrameworkContainer container, string path) { container = SetupFrameworkContainer(path, ref container); var xs = new XmlSerializer(typeof(UmcCoreIoCElement)); var containerElement = (UmcCoreIoCElement)xs.Deserialize(File.OpenRead(path)); containerElement.Verify(); IFrameworkComposable resolver = new FrameworkCompositionResolverForUnity((FrameworkContainerForUnity)container, containerElement); resolver.Compose(); }
private static IFrameworkContainer SetupFrameworkContainer(string path, ref IFrameworkContainer container) { if (File.Exists(path) == false) { throw new FileNotFoundException(path); } if (container == null) { container = new FrameworkContainerForUnity(); } return(container); }
public FrameworkContainerForCastleChild(object key, IFrameworkContainer parentContainer) : base(key, parentContainer) { }
public FrameworkContainerForUnity(object key, IFrameworkContainer parentContainer) : base(key, parentContainer) { }
public FrameworkContainerForUnityChild(object key, IFrameworkContainer parentContainer) : base(key, parentContainer) { }
public FrameworkControllerFactory(IFrameworkContainer container) { this.container = container; }
static NxContainer() { container = new FrameworkContainerForUnity(); }
public MvcController() { this.ModelContainer = new FrameworkContainerForUnity(); }
public FrameworkContainer(object key, IFrameworkContainer parentContainer) : base(key, parentContainer) { createLifetimeMapping(); }