/// <summary> /// Processes the composition. /// </summary> /// <param name="notConstructed">The not constructed instances.</param> /// <param name="constructed">The constructed instances.</param> /// <param name="toRemove">Instances to be removed from composition.</param> private void processComposition(IEnumerable <Instance> notConstructed, IEnumerable <Instance> constructed, IEnumerable <Instance> toRemove) { if (notConstructed == null) { notConstructed = new Instance[0]; } if (constructed == null) { constructed = new Instance[0]; } if (toRemove == null) { toRemove = new Instance[0]; } var composition = new CompositionContext(CallingAssemblyServices, Context); notConstructed = notConstructed.Except(toRemove); constructed = constructed.Except(toRemove); //add components that needs importing constructor call composition.AddNotConstructedComponents(notConstructed); //add instances that doesn't need constructor call composition.AddConstructedComponents(constructed); //create composition var compositionResult = CompositionProvider.Compose(composition); CompositionResult.Set(compositionResult); if (!compositionResult.Failed) { //if composition building is OK then process composition Context.DynamicCall("$dynamic_composition", composition.Generator, composition.InputInstances); } }
/// <summary> /// Runtime member definition. /// </summary> public void _method_Compose() { var path = AssemblyPath.Get(); var compositionContext = new CompositionContext(Services, Context); if (path != null) { var assembly = Services.LoadAssembly(path); var notConstructed = new List <Instance>(); foreach (var componentInfo in assembly.GetComponents()) { var instance = Context.Machine.CreateInstance(componentInfo.ComponentType); notConstructed.Add(instance); } compositionContext.AddNotConstructedComponents(notConstructed); } var parts = Parts.Get(); compositionContext.AddConstructedComponents(parts); compose(compositionContext); }