protected TPluginType GetInstance <TPluginType>()
        {
            ExplicitArgsExpression expression = ObjectFactory.With(_unitOfWork);

            injectedInstances.Keys.ForEach(type => { expression = expression.With(type, injectedInstances[type]); });
            return(expression.GetInstance <TPluginType>());
        }
Exemple #2
0
 public ExplicitArgsExpression Merge(ExplicitArgsExpression builder)
 {
     return builder
         .With("oldMode").EqualTo(_match.Groups["srcmode"].Value)
         .With("newMode").EqualTo(_match.Groups["dstmode"].Value)
         .With("oldSha").EqualTo(_match.Groups["srcsha1"].Value)
         .With("newSha").EqualTo(_match.Groups["dstsha1"].Value)
         .With("path").EqualTo(_match.Groups["srcpath"].Value)
         .With("pathTo").EqualTo(_match.Groups["dstpath"].Value);
 }
Exemple #3
0
        public object GetInstance(Type type, string key, params IResolutionArgument[] parameters)
        {
            object instance;

            //lol thanks stucturemap for your inconsistent API, I /love/ using reflection to call methods.

            try
            {
                ExplicitArgsExpression expression = null;

                if (parameters.OfType <ConstructorParameter, IResolutionArgument>().Length > 0)
                {
                    ConstructorParameter parameter1 = parameters.OfType <ConstructorParameter, IResolutionArgument>()[0];

                    expression = container.With(parameter1.Name).EqualTo(parameter1.Value);

                    if (parameters.Length > 1)
                    {
                        ConstructorParameter[] constructorArgs =
                            parameters.OfType <ConstructorParameter, IResolutionArgument>();

                        for (int i = 1; i < constructorArgs.Length; i++)
                        {
                            expression.With(constructorArgs[i].Name).EqualTo(constructorArgs[i].Value);
                        }
                    }
                }
                MethodInfo method =
                    typeof(ExplicitArgsExpression).GetMethods().Where(
                        m => m.IsGenericMethod && m.Name == "GetInstance" && m.GetParameters().Count() == 1).First();
                method = method.MakeGenericMethod(type);

                instance = expression != null
                               ? method.Invoke(expression, new object[] { key })
                               :
                           container.GetInstance(type, key);
            }
            catch (StructureMapException ex)
            {
                throw new RegistrationNotFoundException(type, key, ex);
            }

            if (instance == null)
            {
                throw new RegistrationNotFoundException(type, key);
            }

            return(instance);
        }
Exemple #4
0
        internal ExplicitQueueableTaskArgsExpression(IQueueableTaskManager queueableTaskManager,
                                                     ExplicitArgsExpression expression)
        {
            if (queueableTaskManager == null)
            {
                throw new ArgumentNullException(nameof(queueableTaskManager));
            }
            if (expression == null)
            {
                throw new ArgumentNullException(nameof(expression));
            }

            _queueableTaskManager = queueableTaskManager;
            _expression           = expression;
        }
Exemple #5
0
        public object GetInstance(Type type, params IResolutionArgument[] parameters)
        {
            ExplicitArgsExpression expression = null;

            if (parameters.OfType <ConstructorParameter, IResolutionArgument>().Length > 0)
            {
                ConstructorParameter parameter1 = parameters.OfType <ConstructorParameter, IResolutionArgument>()[0];

                expression = container.With(parameter1.Name).EqualTo(parameter1.Value);

                if (parameters.Length > 1)
                {
                    ConstructorParameter[] constructorArgs =
                        parameters.OfType <ConstructorParameter, IResolutionArgument>();

                    for (int i = 1; i < constructorArgs.Length; i++)
                    {
                        expression.With(constructorArgs[i].Name).EqualTo(constructorArgs[i].Value);
                    }
                }
            }

            return(expression != null?expression.GetInstance(type) : container.GetInstance(type));
        }
Exemple #6
0
 public IGitChangedFile ToGitChangedFile(ExplicitArgsExpression builder)
 {
     return(builder.With(this).GetInstance <IGitChangedFile>(Status));
 }
Exemple #7
0
 public IGitChangedFile ToGitChangedFile(ExplicitArgsExpression builder)
 {
     return builder.With(this).GetInstance<IGitChangedFile>(Status);
 }