Ejemplo n.º 1
0
 public ConstructorFrame(ConstructorInstance instance, DisposeTracking disposal, Variable[] arguments)
 {
     Disposal            = disposal;
     _arguments          = arguments;
     Variable            = new ServiceVariable(instance, this);
     _implementationType = instance.ImplementationType;
 }
Ejemplo n.º 2
0
        public InstanceConstructorFrame(ConstructorInstance instance, DisposeTracking disposal, Variable[] arguments,
                                        SetterArg[] setterParameters) : base(instance.ImplementationType, instance.Constructor, f => new ServiceVariable(instance, f, ServiceDeclaration.ServiceType))
        {
            Disposal = disposal;

            Parameters = arguments;

            switch (disposal)
            {
            case DisposeTracking.None:
                Mode = ConstructorCallMode.Variable;
                break;

            case DisposeTracking.WithUsing:
                Mode = ConstructorCallMode.UsingNestedVariable;
                break;

            case DisposeTracking.RegisterWithScope:
                Mode = ConstructorCallMode.Variable;
                var addDisposable = MethodCall.For <Scope>(s => s.TryAddDisposable(null));
                addDisposable.Arguments[0] = Variable;
                ActivatorFrames.Add(addDisposable);
                break;
            }

            Setters.AddRange(setterParameters);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Shortcut method to define a child dependency inline and configure
        /// the child dependency
        /// </summary>
        /// <typeparam name="TConcreteType"></typeparam>
        /// <returns></returns>
        public ConstructorInstance Is <TConcreteType>(Action <ConstructorInstance <TConcreteType> > configure) where TConcreteType : TChild
        {
            var instance = new ConstructorInstance <TConcreteType>(typeof(TChild), ServiceLifetime.Transient);

            configure(instance);
            return(Is(instance));
        }
Ejemplo n.º 4
0
 public CallFuncBuilderFrame(ConstructorInstance instance, DisposeTracking disposal, Variable func, Variable[] arguments)
 {
     Disposal   = disposal;
     _func      = func;
     _arguments = arguments;
     Variable   = new ServiceVariable(instance, this);
 }
Ejemplo n.º 5
0
        public CallFuncBuilderFrame(ConstructorInstance instance, DisposeTracking disposal, Variable func, Variable[] arguments)
        {
            // HACK, and I hate this but it's necessary.
            for (int i = 0; i < arguments.Length; i++)
            {
                if (arguments[i] is OptionalArgumentVariable)
                {
                    arguments[i] = ((OptionalArgumentVariable)arguments[i]).Inner;
                }
            }

            Disposal   = disposal;
            _func      = func;
            _arguments = arguments;
            Variable   = new ServiceVariable(instance, this);
        }
Ejemplo n.º 6
0
 internal DependencyExpression(ConstructorInstance instance, string propertyName)
 {
     _instance     = instance;
     _propertyName = propertyName;
 }