本文整理汇总了C#中IDependency类的典型用法代码示例。如果您正苦于以下问题:C# IDependency类的具体用法?C# IDependency怎么用?C# IDependency使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IDependency类属于命名空间,在下文中一共展示了IDependency类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: 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 listType = typeof(List<>).MakeGenericType(_serviceType);
var listCtor = module.ImportConstructor(listType, new Type[0]);
var listVariable = targetMethod.AddLocal(listType);
var IL = targetMethod.GetILGenerator();
IL.Emit(OpCodes.Newobj, listCtor);
IL.Emit(OpCodes.Stloc, listVariable);
var targetDependencies = (from d in serviceMap.Keys
where d.ServiceType == _serviceType
select d).ToArray();
var addItem = module.ImportMethod("Add", listType);
var serviceType = module.Import(_serviceType);
var currentService = targetMethod.AddLocal(_serviceType);
foreach(var currentDependency in targetDependencies)
{
IL.Emit(OpCodes.Ldloc, listVariable);
// Instantiate the current service type
var implementation = new ContainerCall(currentDependency.ServiceType, currentDependency.ServiceName);
implementation.Emit(currentDependency, serviceMap, targetMethod);
IL.Emit(OpCodes.Isinst, serviceType);
IL.Emit(OpCodes.Stloc, currentService);
// Call IInitialize.Initialize(container) on the current service type
_initializer.Initialize(IL, module, currentService);
IL.Emit(OpCodes.Ldloc, currentService);
IL.Emit(OpCodes.Callvirt, addItem);
}
var enumerableType = typeof(IEnumerable<>).MakeGenericType(_serviceType);
var importedEnumerableType = module.Import(enumerableType);
IL.Emit(OpCodes.Ldloc, listVariable);
IL.Emit(OpCodes.Isinst, importedEnumerableType);
}
开发者ID:juancastrodlc,项目名称:Hiro,代码行数:51,代码来源:EnumerableType.cs
示例17: Build
/// <summary>
/// Builds a service info response.
/// </summary>
/// <param name="serviceImplementation">
/// The service implementation that will be returning the response.
/// </param>
/// <param name="dependency">
/// The dependency that was provided to the service implementation on construction.
/// </param>
/// <param name="tenantIdStrategy">
/// The tenant ID strategy.
/// </param>
/// <returns>
/// A populated service info response.
/// </returns>
public static GetServiceInfoResponse Build(IMultitenantService serviceImplementation, IDependency dependency, ITenantIdentificationStrategy tenantIdStrategy)
{
object tenantId = null;
bool success = tenantIdStrategy.TryIdentifyTenant(out tenantId);
if (!success || tenantId == null)
{
tenantId = "[Default Tenant]";
}
var response = new GetServiceInfoResponse()
{
ServiceImplementationTypeName = serviceImplementation.GetType().Name,
DependencyInstanceId = dependency.InstanceId,
DependencyTypeName = dependency.GetType().Name,
TenantId = tenantId.ToString()
};
return response;
}
开发者ID:RoymanJing,项目名称:Autofac,代码行数:33,代码来源:ServiceInfoBuilder.cs
示例18: Emit
/// <summary>
/// Emits the <see cref="IFactory{T}.Create"/> method call that will instantiate the current service instance.
/// </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 factoryType = typeof (IFactory<>).MakeGenericType(_serviceType);
var getFactoryInstanceCall = new ContainerCall(factoryType, _serviceName);
var factoryName = _serviceName;
getFactoryInstanceCall.Emit(new Dependency(factoryType, factoryName), serviceMap, targetMethod);
var declaringType = targetMethod.DeclaringType;
var module = declaringType.Module;
var factoryTypeReference = module.Import(factoryType);
var createMethod = module.Import(factoryType.GetMethod("Create"));
var IL = targetMethod.GetILGenerator();
IL.Emit(OpCodes.Isinst, factoryTypeReference);
IL.Emit(OpCodes.Callvirt, createMethod);
}
开发者ID:juancastrodlc,项目名称:Hiro,代码行数:24,代码来源:FactoryCall.cs
示例19: EmitService
/// <summary>
/// Emits a service as a singleton type.
/// </summary>
/// <param name="targetMethod">The <see cref="IMicroContainer.GetInstance"/> method implementation.</param>
/// <param name="dependency">The dependency that will be instantiated by the container.</param>
/// <param name="implementation">The implementation that will be used to instantiate the dependency.</param>
/// <param name="serviceMap">The service map the contains the current application dependencies.</param>
public void EmitService(MethodDefinition targetMethod, IDependency dependency,
IImplementation implementation, IDictionary<IDependency, IImplementation> serviceMap)
{
MethodDefinition getInstanceMethod = null;
var worker = targetMethod.GetILGenerator();
// Emit only one singleton per dependency and call
// the singleton GetInstance() method on every subsequent emit call
if (_entries.ContainsKey(dependency))
{
getInstanceMethod = _entries[dependency];
worker.Emit(OpCodes.Call, getInstanceMethod);
return;
}
var declaringType = targetMethod.DeclaringType;
var module = declaringType.Module;
var serviceType = dependency.ServiceType;
var typeName = serviceType.Name;
var singletonName = string.Format("{0}ServiceSingleton-{1}", typeName, dependency.GetHashCode());
const TypeAttributes typeAttributes = TypeAttributes.NotPublic | TypeAttributes.AutoClass | TypeAttributes.Sealed |
TypeAttributes.BeforeFieldInit;
var objectType = module.Import(typeof(object));
var singletonType = AddDefaultSingletonConstructor(module, singletonName, typeAttributes, objectType);
var instanceField = new FieldDefinition("__instance", FieldAttributes.Assembly | FieldAttributes.InitOnly | FieldAttributes.Static, objectType);
DefineNestedType(module, singletonType, instanceField, serviceMap, implementation, dependency,
targetMethod);
getInstanceMethod = DefineGetInstance(singletonType, worker, instanceField);
worker.Emit(OpCodes.Call, getInstanceMethod);
var serviceTypeRef = module.Import(serviceType);
worker.Emit(OpCodes.Unbox_Any, serviceTypeRef);
// Cache the singleton method
_entries[dependency] = getInstanceMethod;
}
开发者ID:philiplaureano,项目名称:Hiro,代码行数:51,代码来源:SingletonEmitter.cs
示例20: Register
public static void Register(IDependency container)
{
#region Settings
container.Register<IHttpControllerActivator, WindsorCompositionRoot>();
container.Register<IConnection, ConnectionConfig>();
#endregion
#region Services
container.Register<IUserService, UserService>();
container.Register<BabySitterMessageService, BabySitterMessageService>();
container.Register<CarPullMessageService, CarPullMessageService>();
container.Register<IMessageService<BulletinBoardTable, BulletinBoardDto>, MessageService<BulletinBoardTable, BulletinBoardDto>>();
container.Register<IMessageService<GiveAndTakeTable, GiveAndTakeDto>, MessageService<GiveAndTakeTable, GiveAndTakeDto>>();
container.Register<ISurveyService, SurveyService>();
#endregion
#region Repositories
container.Register<IDataBase<UserTable>, DataBase<UserTable>>();
container.Register<IDataBase<BabySitterTable>, DataBase<BabySitterTable>>();
container.Register<IDataBase<CarPullTable>, DataBase<CarPullTable>>();
container.Register<IDataBase<BulletinBoardTable>, DataBase<BulletinBoardTable>>();
container.Register<IDataBase<SurveyTable>, DataBase<SurveyTable>>();
container.Register<IDataBase<GiveAndTakeTable>, DataBase<GiveAndTakeTable>>();
#endregion
#region Controllers
container.Register<LoginController, LoginController>();
container.Register<RegisterController, RegisterController>();
container.Register<UserController, UserController>();
container.Register<BabySitterController, BabySitterController>();
container.Register<CarpullController, CarpullController>();
container.Register<BulletinBoardController, BulletinBoardController>();
container.Register<SurveyController, SurveyController>();
container.Register<VoteController, VoteController>();
container.Register<GiveAndTakeController, GiveAndTakeController>();
container.Register<ForgotPasswordController, ForgotPasswordController>();
container.Register<SettingsController, SettingsController>();
#endregion
}
开发者ID:haimtz,项目名称:Moshavit-Server,代码行数:40,代码来源:Bootstrap.cs
注:本文中的IDependency类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论