当前位置: 首页>>代码示例>>C#>>正文


C# IDependency类代码示例

本文整理汇总了C#中IDependency的典型用法代码示例。如果您正苦于以下问题:C# IDependency类的具体用法?C# IDependency怎么用?C# IDependency使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IDependency类属于命名空间,在下文中一共展示了IDependency类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HomeController

 public HomeController(IDependency dependency, ITenantIdentificationStrategy tenantIdStrategy, IMultitenantService standardService, IMetadataConsumer metadataService)
 {
     this.Dependency = dependency;
     this.TenantIdentificationStrategy = tenantIdStrategy;
     this.StandardServiceProxy = standardService;
     this.MetadataServiceProxy = metadataService;
 }
开发者ID:Mart-Bogdan,项目名称:autofac-examples,代码行数:7,代码来源:HomeController.cs

示例2: OnDependencyReady

		private void OnDependencyReady(IDependency dependency)
		{
			dependency.Ready -= OnDependencyReady;
			DependencyReadyStatus[dependency] = true;
			if (DependencyReadyStatus.Values.All(status => status))
				DoStart();
		}
开发者ID:BenjaminHamon,项目名称:Overmind.GoldenAge,代码行数:7,代码来源:GameView.cs

示例3: Emit

        /// <summary>
        /// Emits the instructions that will instantiate the current implementation using the given factory functor.
        /// </summary>
        /// <param name="dependency">The dependency that describes the service to be instantiated.</param>
        /// <param name="serviceMap">The service map that contains the list of dependencies in the application.</param>
        /// <param name="targetMethod">The target method.</param>
        public void Emit(IDependency dependency,
            IDictionary<IDependency, IImplementation> serviceMap,
            MethodDefinition targetMethod)
        {
            var declaringType = targetMethod.DeclaringType;
            var module = declaringType.Module;

            var serviceType = module.Import(_serviceType);
            var createInstanceMethod = typeof(FunctorRegistry).GetMethod("CreateInstance");
            var createInstance = module.Import(createInstanceMethod);

            // Register the functor
            RegisterFunctor();

            var body = targetMethod.Body;
            var IL = body.GetILProcessor();

            // Instantiate the instance at runtime using the
            // given functor associated with the functor id
            IL.Emit(OpCodes.Ldstr, _functorId);
            IL.Emit(OpCodes.Ldarg_0);
            IL.Emit(OpCodes.Call, createInstance);

            if (serviceType.IsValueType)
                return;

            IL.Emit(OpCodes.Castclass, serviceType);
        }
开发者ID:unintelligible,项目名称:Hiro,代码行数:34,代码来源:FunctorCall.cs

示例4: GetDependencyNodes

 private static IEnumerable<INode> GetDependencyNodes(this TreeContext context, IDependency dep1)
 {
     return dep1.Type == DependencyType.Single
         ? new[] { context.Tree.Nodes[dep1.Token] }
         : context.Tree.GetNode(dep1.Token)
                  .Provider.Dependencies
                  .SelectMany(context.GetDependencyNodes);
 }
开发者ID:repinvv,项目名称:TestingContext,代码行数:8,代码来源:NodeWeigthsService.cs

示例5: ContainerInitialized

        /// <inheritdoc />
        public override void ContainerInitialized(Container container)
        {
            base.ContainerInitialized(container);

            Log.Info("ExtensionWhichNeedsDependency is using the initialized container.");

            this.Dependency = this.Container.Resolve<IDependency>();
        }
开发者ID:WenningQiu,项目名称:appccelerate,代码行数:9,代码来源:ExtensionWhichNeedsDependency.cs

示例6: AddService

        /// <summary>
        /// Associates the given <paramref name="implementation"/> with the target <paramref name="dependency"/>.
        /// </summary>
        /// <param name="dependency">The dependency that will be associated with the implementation.</param>
        /// <param name="implementation">The implementation itself.</param>
        public void AddService(IDependency dependency, IImplementation implementation)
        {
            var currentImplementation = implementation;

            if (Injector != null)
                currentImplementation = Injector.Inject(dependency, currentImplementation);

            _entries.Add(dependency, currentImplementation);
        }
开发者ID:philiplaureano,项目名称:Hiro,代码行数:14,代码来源:BaseDependencyMap.cs

示例7: GetDependencyNode

 // can be used after the tree is built
 public static INode GetDependencyNode(this TreeContext context, IDependency dependency)
 {
     var node = context.Tree.GetNode(dependency.Token);
     return dependency.Type == DependencyType.CollectionValidity
                ? node.Parent
                : dependency.Type == DependencyType.Collection
                      ? node.SourceParent
                      : node;
 }
开发者ID:repinvv,项目名称:TestingContext,代码行数:10,代码来源:TreeBuildingExtensions.cs

示例8: Constructor

        public Constructor(IDependency dependency, ConstructorInfo constructor)
            : base(dependency)
        {
            ConstructorInfo = constructor;

            _requiredDependencies = constructor.GetParameters()
                .Select(p => new Dependency(p.ParameterType))
                .ToArray();
        }
开发者ID:philiplaureano,项目名称:Hiro2,代码行数:9,代码来源:Constructor.cs

示例9: SetNodeWeights

        private static void SetNodeWeights(TreeContext context, IDependency dependency, IDependency dep2)
        {
            if (context.IsParent(dependency.Token, dep2.Token) || context.IsParent(dep2.Token, dependency.Token))
            {
                return;
            }

            SetNodeWeights(context, dependency);
            SetNodeWeights(context, dep2);
        }
开发者ID:repinvv,项目名称:TestingContext,代码行数:10,代码来源:NodeWeigthsService.cs

示例10: TflRoot

 public TflRoot(
         string cfg, 
         Dictionary<string, string> parameters = null,
         IDependency logger = null)
     : base(
           new DefaultReader(new SourceDetector(), new FileReader(), new ReTryingReader(new WebReader(), 3)), 
           logger
     ) {
     Load(cfg, parameters);
 }
开发者ID:modulexcite,项目名称:Transformalize,代码行数:10,代码来源:TflRoot.cs

示例11: GenericTypeInstantiation

        public GenericTypeInstantiation(IDependency dependency, Constructor constructor, IEnumerable<Type> typeArguments) : base(dependency)
        {
            if (dependency == null)
                throw new ArgumentNullException(nameof(dependency));

            if (constructor == null)
                throw new ArgumentNullException(nameof(constructor));

            Constructor = constructor;
            TypeArguments = typeArguments;
        }
开发者ID:philiplaureano,项目名称:Hiro2,代码行数:11,代码来源:GenericTypeInstantiation.cs

示例12: Emit

        /// <summary>
        /// Emits the instructions that will instantiate the current implementation.
        /// </summary>
        /// <param name="dependency">The dependency that describes the service to be instantiated.</param>
        /// <param name="serviceMap">The service map that contains the list of dependencies in the application.</param>
        /// <param name="targetMethod">The target method.</param>
        public void Emit(IDependency dependency, IDictionary<IDependency, IImplementation> serviceMap, MethodDefinition targetMethod)
        {
            var declaringType = targetMethod.DeclaringType;
            var module = declaringType.Module;

            var microContainerType = module.ImportType<IMicroContainer>();

            var il = targetMethod.GetILGenerator();

            // if (this is IMicroContainer && this.NextContainer != null) {
            il.Emit(OpCodes.Ldarg_0);
            il.Emit(OpCodes.Isinst, microContainerType);

            var skipCreate = il.Create(OpCodes.Nop);
            il.Emit(OpCodes.Brfalse, skipCreate);

            EmitGetContainerInstance(module, microContainerType, il, skipCreate);

            var getInstance = module.ImportMethod<IMicroContainer>("GetInstance");
            var getTypeFromHandleMethod = typeof(System.Type).GetMethod("GetTypeFromHandle", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
            var getTypeFromHandle = module.Import(getTypeFromHandleMethod);

            // Push the service type onto the stack
            var serviceType = module.Import(_serviceType);
            il.Emit(OpCodes.Ldtoken, serviceType);
            il.Emit(OpCodes.Call, getTypeFromHandle);

            var loadString = string.IsNullOrEmpty(_serviceName)
                                 ? il.Create(OpCodes.Ldnull)
                                 : il.Create(OpCodes.Ldstr, _serviceName);

            il.Append(loadString);
            il.Emit(OpCodes.Callvirt, getInstance);

            var endLabel = il.Create(OpCodes.Nop);
            il.Emit(OpCodes.Br, endLabel);

            il.Append(skipCreate);

            var serviceNotFoundExceptionCtor = module.ImportConstructor<ServiceNotFoundException>(typeof(string),
                                                                                                  typeof(System.Type));
            var serviceName = dependency.ServiceName ?? string.Empty;
            il.Emit(OpCodes.Ldstr, serviceName);
            il.Emit(OpCodes.Ldtoken, serviceType);
            il.Emit(OpCodes.Call, getTypeFromHandle);

            il.Emit(OpCodes.Newobj, serviceNotFoundExceptionCtor);
            il.Emit(OpCodes.Throw);

            il.Append(endLabel);

            // }
        }
开发者ID:philiplaureano,项目名称:Hiro,代码行数:59,代码来源:BaseContainerCall.cs

示例13: CompareTo

        public int CompareTo(IDependency other)
        {
            var areEqual = (other.Name == this.Name && other.DependencyType == this.DependencyType);
            if (areEqual)
                return 0;

            var otherHash = other.GetHashCode();
            var thisHash = this.GetHashCode();

            var isGreater = otherHash > thisHash;

            return isGreater ? 1 : -1;
        }
开发者ID:philiplaureano,项目名称:Hiro2,代码行数:13,代码来源:Dependency.cs

示例14: ReorderNodes

        public static void ReorderNodes(this TreeContext context,
            IDepend depend,
            IDependency dependency1,
            IDependency dependency2)
        {
            var node1 = context.GetDependencyNode(dependency1);
            var node2 = context.GetDependencyNode(dependency2);
            if (node1 == node2)
            {
                return;
            }

            ReorderNodes(node1, node2, depend.DiagInfo);
            context.CreateNonEqualFilter(node1, node2, context.GetParentGroup(depend), depend.DiagInfo);
        }
开发者ID:repinvv,项目名称:TestingContext,代码行数:15,代码来源:NodeReorderingService.cs

示例15: Inject

        /// <summary>
        /// Injects the target <paramref name="IImplementation"/> instance.
        /// </summary>
        /// <param name="dependency">The target dependency.</param>
        /// <param name="originalImplementation">The target implementation that will be intercepted by this method.</param>
        /// <returns>The <see cref="IImplementation"/> instance that will be injected in place of the original implementation.</returns>
        public IImplementation Inject(IDependency dependency, IImplementation originalImplementation)
        {
            var staticImplementation = originalImplementation as IStaticImplementation;

            // HACK: Ignore primitive types by default
            var serviceType = dependency.ServiceType;
            if (serviceType.IsValueType || serviceType==typeof(string))
                return originalImplementation;

            // Property injection can only be performend on early-bound instantiations
            if (staticImplementation == null)
                return originalImplementation;

            return new PropertyInjectionCall(staticImplementation);
        }
开发者ID:juancastrodlc,项目名称:Hiro,代码行数:21,代码来源:PropertyInjector.cs


注:本文中的IDependency类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。