Ejemplo n.º 1
0
        /// <summary>
        ///   Checks if the handler is able to, at very least, satisfy
        ///   the dependencies for the constructor with less parameters
        /// </summary>
        /// <remarks>
        ///   For each non*optional dependency, the implementation will invoke
        ///   <see cref = "AddDependency" />
        /// </remarks>
        protected virtual void EnsureDependenciesCanBeSatisfied(IDependencyAwareActivator activator)
        {
            if (activator != null && activator.CanProvideRequiredDependencies(ComponentModel))
            {
                return;
            }

            foreach (var property in ComponentModel.Properties)
            {
                AddDependency(property.Dependency);
            }

            // The following dependencies were added by - for example -
            // facilities, for some reason, and we need to satisfy the non-optional
            foreach (var dependency in ComponentModel.Dependencies)
            {
                AddDependency(dependency);
            }

            if (ComponentModel.Constructors.Count == 0)
            {
                return;
            }
            foreach (var constructor in ComponentModel.Constructors)
            {
                foreach (var dependency in constructor.Dependencies)
                {
                    AddDependency(dependency);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///   Checks if the handler is able to, at very least, satisfy
        ///   the dependencies for the constructor with less parameters
        /// </summary>
        /// <remarks>
        ///   For each non*optional dependency, the implementation will invoke
        ///   <see cref = "AddDependency" />
        /// </remarks>
        protected virtual void EnsureDependenciesCanBeSatisfied(IDependencyAwareActivator activator)
        {
            if (activator != null && activator.CanProvideRequiredDependencies(ComponentModel))
            {
                return;
            }

            foreach (var dependency in ComponentModel.Dependencies)
            {
                AddDependency(dependency);
            }
        }
Ejemplo n.º 3
0
		/// <summary>
		///   Checks if the handler is able to, at very least, satisfy
		///   the dependencies for the constructor with less parameters
		/// </summary>
		/// <remarks>
		///   For each non*optional dependency, the implementation will invoke
		///   <see cref = "AddDependency" />
		/// </remarks>
		protected virtual void EnsureDependenciesCanBeSatisfied(IDependencyAwareActivator activator)
		{
			if (activator != null && activator.CanProvideRequiredDependencies(ComponentModel))
			{
				return;
			}

			// Property dependencies may not be optional

			foreach (var property in ComponentModel.Properties)
			{
				var dependency = property.Dependency;

				if (dependency.IsOptional == false &&
				    (dependency.DependencyType == DependencyType.Service ||
				     dependency.DependencyType == DependencyType.ServiceOverride))
				{
					AddDependency(dependency);
				}
			}

			// The following dependencies were added by - for example - 
			// facilities, for some reason, and we need to satisfy the non-optional

			foreach (var dependency in ComponentModel.Dependencies)
			{
				if (dependency.IsOptional == false &&
				    (dependency.DependencyType == DependencyType.Service ||
				     dependency.DependencyType == DependencyType.ServiceOverride))
				{
					AddDependency(dependency);
				}
			}

			foreach (var dependency in GetSecuredDependencies())
			{
				if (dependency.HasDefaultValue)
				{
					continue;
				}

				if (dependency.DependencyType == DependencyType.Service ||
				    dependency.DependencyType == DependencyType.ServiceOverride)
				{
					AddDependency(dependency);
				}
				else if (dependency.DependencyType == DependencyType.Parameter &&
				         !ComponentModel.Constructors.HasAmbiguousFewerArgumentsCandidate &&
				         !ComponentModel.Parameters.Contains(dependency.DependencyKey))
				{
					AddDependency(dependency);
				}
			}
		}
		/// <summary>
		///   Checks if the handler is able to, at very least, satisfy
		///   the dependencies for the constructor with less parameters
		/// </summary>
		/// <remarks>
		///   For each non*optional dependency, the implementation will invoke
		///   <see cref = "AddDependency" />
		/// </remarks>
		protected virtual void EnsureDependenciesCanBeSatisfied(IDependencyAwareActivator activator)
		{
			if (activator != null && activator.CanProvideRequiredDependencies(ComponentModel))
			{
				return;
			}

			foreach (var dependency in ComponentModel.Dependencies)
			{
				AddDependency(dependency);
			}
		}
		/// <summary>
		///   Checks if the handler is able to, at very least, satisfy
		///   the dependencies for the constructor with less parameters
		/// </summary>
		/// <remarks>
		///   For each non*optional dependency, the implementation will invoke
		///   <see cref = "AddDependency" />
		/// </remarks>
		protected virtual void EnsureDependenciesCanBeSatisfied(IDependencyAwareActivator activator)
		{
			if(activator != null && activator.CanProvideRequiredDependencies(ComponentModel))
				return;
			
			// Custom activators should deal with this case
			if (ComponentModel.Constructors.Count == 0)
				return;

			// Property dependencies may not be optional

			foreach (PropertySet property in ComponentModel.Properties)
			{
				DependencyModel dependency = property.Dependency;

				if (dependency.IsOptional == false &&
				    (dependency.DependencyType == DependencyType.Service ||
				     dependency.DependencyType == DependencyType.ServiceOverride))
					AddDependency(dependency);
			}

			// The following dependencies were added by - for example - 
			// facilities, for some reason, and we need to satisfy the non-optional

			foreach (DependencyModel dependency in ComponentModel.Dependencies)
			{
				if (dependency.IsOptional == false &&
				    (dependency.DependencyType == DependencyType.Service ||
				     dependency.DependencyType == DependencyType.ServiceOverride))
					AddDependency(dependency);
			}

			foreach (DependencyModel dependency in GetSecuredDependencies())
			{
				if (dependency.DependencyType == DependencyType.Service ||
				    dependency.DependencyType == DependencyType.ServiceOverride)
					AddDependency(dependency);
				else if (dependency.DependencyType == DependencyType.Parameter &&
				         !ComponentModel.Constructors.HasAmbiguousFewerArgumentsCandidate &&
				         !ComponentModel.Parameters.Contains(dependency.DependencyKey))
					AddDependency(dependency);
			}
		}
Ejemplo n.º 6
0
		/// <summary>
		///   Checks if the handler is able to, at very least, satisfy
		///   the dependencies for the constructor with less parameters
		/// </summary>
		/// <remarks>
		///   For each non*optional dependency, the implementation will invoke
		///   <see cref = "AddDependency" />
		/// </remarks>
		protected virtual void EnsureDependenciesCanBeSatisfied(IDependencyAwareActivator activator)
		{
			if (activator != null && activator.CanProvideRequiredDependencies(ComponentModel))
			{
				return;
			}

			foreach (var property in ComponentModel.Properties)
			{
				AddDependency(property.Dependency);
			}

			// The following dependencies were added by - for example - 
			// facilities, for some reason, and we need to satisfy the non-optional
			foreach (var dependency in ComponentModel.Dependencies)
			{
				AddDependency(dependency);
			}

			if (ComponentModel.Constructors.Count == 0)
			{
				return;
			}
			foreach (var constructor in ComponentModel.Constructors)
			{
				foreach (var dependency in constructor.Dependencies)
				{
					AddDependency(dependency);
				}
			}
		}