private void OnDependencyReady(IDependency dependency) { dependency.Ready -= OnDependencyReady; DependencyReadyStatus[dependency] = true; if (DependencyReadyStatus.Values.All(status => status)) DoStart(); }
/// <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); }
public HomeController(IDependency dependency, ITenantIdentificationStrategy tenantIdStrategy, IMultitenantService standardService, IMetadataConsumer metadataService) { this.Dependency = dependency; this.TenantIdentificationStrategy = tenantIdStrategy; this.StandardServiceProxy = standardService; this.MetadataServiceProxy = metadataService; }
/// <inheritdoc /> public override void ContainerInitialized(Container container) { base.ContainerInitialized(container); Log.Info("ExtensionWhichNeedsDependency is using the initialized container."); this.Dependency = this.Container.Resolve<IDependency>(); }
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); }
static void Main(string[] args) { Console.WriteLine("Start run settings....."); _resolver = new CastleFactory(); LoadTemplateMail(); Console.WriteLine("Finish settings"); Console.ReadLine(); }
public Constructor(IDependency dependency, ConstructorInfo constructor) : base(dependency) { ConstructorInfo = constructor; _requiredDependencies = constructor.GetParameters() .Select(p => new Dependency(p.ParameterType)) .ToArray(); }
/// <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); }
// 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; }
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); }
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); }
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; }
public State(State oState) { JobName = oState.JobName; CurrentDependency = oState.CurrentDependency; CurrentExecutingMode = oState.CurrentExecutingMode; ExecutionState = oState.ExecutionState; CurrentJobCode = oState.CurrentJobCode; CurrentJobHash = oState.CurrentJobHash; CurrentParameters = oState.CurrentParameters; CurrentStatusCollection = oState.CurrentStatusCollection; SourceFileName = oState.SourceFileName; }
/// <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); // } }
private static void SetNodeWeights(TreeContext context, IDependency dependency) { if (context.WeightedDependencies.Contains(dependency)) { return; } context.WeightedDependencies.Add(dependency); context.GetDependencyNodes(dependency) .OrderByDescending(x => x.Weight) .First() .Weight++; }
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; }
/// <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); }
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); }
/// <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); }
/// <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; }
/// <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); }
/// <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; }
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 }
public RootType(IDependency dependency) { }
public ClassWithAbstractDependenciesAndManyConstructors(IDependency dependency, AbstractDependency abstractDependency) { this.abstractDependency = abstractDependency; }
public ClassWithFuncDependencies(Func <IDependency> dependency) { this.dependency = dependency(); }
public virtual bool HasChildren(IDependency dependency) { return(dependency.DependencyIDs.Length != 0); }
public ADependency(BDependency dep, IDependency nested) { this.dep = dep; this.idep = nested; }
public SubjectWithBadDependencies(NoConstructorDependency dep, ADependency dep2, IDependency dep3) : base(dep3, dep2) { }
public virtual bool ShouldApplyChanges(string nodeProjectPath, string updatedSnapshotProjectPath, IDependency updatedDependency) { return(nodeProjectPath.Equals(updatedSnapshotProjectPath, StringComparisons.Paths)); }
protected override void ProcessInputNode(IGraphContext graphContext, GraphNode inputGraphNode, IDependency dependency, IDependenciesSnapshot snapshot, IDependenciesGraphViewProvider viewProvider, string projectPath, ref bool trackChanges) { inputGraphNode.SetValue(DependenciesGraphSchema.DependencyIdProperty, dependency.Id); inputGraphNode.SetValue(DependenciesGraphSchema.ResolvedProperty, dependency.Resolved); if (viewProvider.HasChildren(dependency)) { inputGraphNode.SetValue(DgmlNodeProperties.ContainsChildren, true); } }
public override bool HasChildren(IDependency dependency) { ITargetedDependenciesSnapshot?targetedSnapshot = _aggregateSnapshotProvider.GetSnapshot(dependency); return(targetedSnapshot?.TopLevelDependencies.Length != 0); }
/// <summary> /// Emits the instructions that will instantiate each property value and assign it to the target property. /// </summary> /// <param name="serviceMap">The service map that contains the application dependencies.</param> /// <param name="targetMethod">The target method.</param> /// <param name="module">The module that hosts the container type.</param> /// <param name="il">The <see cref="ILProcessor"/> that points to the target method body.</param> /// <param name="property">The target property.</param> /// <param name="curentDependency">The <see cref="IDependency"/> that describes the service instance that will be assigned to the target property.</param> private static void EmitPropertySetter(IDictionary<IDependency, IImplementation> serviceMap, MethodDefinition targetMethod, ModuleDefinition module, ILProcessor il, PropertyInfo property, IDependency curentDependency) { // Push the target onto the stack il.Emit(OpCodes.Dup); // Get the code that will instantiate the property value var propertyValueImplementation = serviceMap[curentDependency]; propertyValueImplementation.Emit(curentDependency, serviceMap, targetMethod); // Call the setter var setterMethod = property.GetSetMethod(); var setter = module.Import(setterMethod); var callInstruction = setterMethod.IsVirtual ? il.Create(OpCodes.Callvirt, setter) : il.Create(OpCodes.Call, setter); il.Append(callInstruction); }
private int ProcessDependency(JobExeWrapper jobWrapper, DateTime jobkey, IDependency<IModule> d) { log.InfoFormat("Considering dependency {0}-[{1}] for {2}.", jobWrapper.Job.JobName, d.Name, jobWrapper.Mode.ToString()); if (((State)jobWrapper.JobGlobalState).CurrentState.CompareTo(State.CurrentStateEnum.Suspended) == 0) return 0; int retval = 0; switch (jobWrapper.Mode) { case State.ExecutionModeEnum.Initialization: jobWrapper.States[d.Name] = State.CurrentStateEnum.Initializing; try { log.InfoFormat("Starting {2}: {0}-[{1}].", jobWrapper.Job.JobName, d.Name, jobWrapper.Mode.ToString()); retval = d.Module.Initialize(jobWrapper.Job as IJob, flatFileLoader, timeManager); } catch (Exception ex) { log.ErrorFormat("Module Initialization Error: {0}", ex); retval = -1; } finally { log.InfoFormat("Finished {0}: {1}:{2}", jobWrapper.Mode.ToString(), jobWrapper.Job.JobName, d.Name); } if (retval == 0) jobWrapper.States[d.Name] = State.CurrentStateEnum.InitializationSuccessful; else if (retval == 1) jobWrapper.States[d.Name] = State.CurrentStateEnum.WaitState; else jobWrapper.States[d.Name] = State.CurrentStateEnum.InitializationFailed; break; case State.ExecutionModeEnum.Execution: jobWrapper.States[d.Name] = State.CurrentStateEnum.Executing; if (d.Name == jobWrapper.Job.JobName) break; Hashtable inputData = new Hashtable(); if (d.Module.Inputs != null && d.Parents != null) { foreach (IDependency<IModule> p in d.Parents) { Hashtable ht = ((IModule)jobWrapper.HistoricalJobs[jobkey].Modules[p.Module.Name]).OutputData; foreach (string key in ht.Keys) inputData[key] = ht[key]; } } try { log.InfoFormat("Starting {2} on {0}-[{1}].", jobWrapper.Job.JobName, d.Name, jobWrapper.Mode.ToString()); ((State)jobWrapper.JobGlobalState).Dependency = d; UpdateProcessStatus(State.Status.Running, (State)jobWrapper.JobGlobalState); // THIS IS THE MAIN [ONLY!] ENTRY POINT TO MODULE EXECUTION retval = d.Module.Execute(this, jobWrapper.JobGlobalState, inputData); } catch (Exception ex) { UpdateProcessStatus(State.Status.Error, (State)jobWrapper.JobGlobalState); log.ErrorFormat(jobWrapper.Job.KeyCode, "Module Execution Error: {0}", ex); } finally { log.InfoFormat(jobWrapper.Job.KeyCode, "Finished {0}: {1}:{2}", jobWrapper.Mode.ToString(), jobWrapper.Job.JobName, d.Name); ((IModule)jobWrapper.HistoricalJobs[jobkey].Modules[d.Module.Name]).OutputData = d.Module.OutputData; if (jobsWaitingForExecution.ContainsKey(d.Name)) if (d.Parents[0].Parents.Count != 0) jobsWaitingForExecution.Remove(d.Name); else jobWrapper.States[d.Name] = State.CurrentStateEnum.WaitState; //importatn; reset job back to wait state if (jobWrapper.States[d.Name] != State.CurrentStateEnum.WaitState) { switch (retval) { case 0: case -1: jobWrapper.States[d.Name] = State.CurrentStateEnum.ExecutionSuccessful; break; case 1: jobWrapper.States[d.Name] = State.CurrentStateEnum.PendingExecution; break; //case -1: // jobWrapper.States[d.Name] = State.CurrentStateEnum.ExecutionFailed; // break; case -99: default: jobWrapper.States[d.Name] = State.CurrentStateEnum.ExecutionFailed; break; } } switch (retval) { case 0: UpdateProcessStatus(State.Status.Success, (State)jobWrapper.JobGlobalState); break; case 1: UpdateProcessStatus(State.Status.Running, (State)jobWrapper.JobGlobalState); break; case -1: UpdateProcessStatus(State.Status.Warnings, (State)jobWrapper.JobGlobalState); break; case -99: default: UpdateProcessStatus(State.Status.Error, (State)jobWrapper.JobGlobalState); break; } //BroadcastStatus("Idle", jobWrapper); } jobWrapper.Job.Modules[d.Name] = d.Module as IModule; break; } return retval; }
private void ReenableJob(JobExeWrapper jobWrapper, ArrayList trackWaitState, IDependency<IModule> d) { if (jobWrapper.Mode.Equals(State.ExecutionModeEnum.Execution)) foreach (IDependency<IModule> dChild in d.Children) { if (jobWrapper.States[d.Name].Equals(State.CurrentStateEnum.WaitState)) { ResetState(jobWrapper, dChild, State.CurrentStateEnum.PendingExecution); if (!trackWaitState.Contains(d.Name)) trackWaitState.Add(d.Name); } else ResetState(jobWrapper, dChild, State.CurrentStateEnum.PendingExecution); } }
public ClassWithVirtualDependencies(IDependency dependency, VirtualDependency virtualDependency) { _virtualDependency = virtualDependency; Dependency = dependency; }
public Tenant1Implementation(IDependency dependency, ITenantIdentificationStrategy tenantIdStrategy) { this.Dependency = dependency; this.TenantIdentificationStrategy = tenantIdStrategy; }
public Service1(IDependency dependency) { Autofac.boostraper(); this.dependency = dependency; }
public ConstructorExample(IDependency dependency) { this.dependency = dependency; }
public abstract void BuildGraph( IGraphContext graphContext, string projectPath, IDependency dependency, GraphNode dependencyGraphNode, ITargetedDependenciesSnapshot targetedSnapshot);
public InstancePerTest(IServiceProvider provider) { _serviceScope = provider.GetRequiredService <IServiceScopeFactory>().CreateScope(); _d = _serviceScope.ServiceProvider.GetRequiredService <IDependency>(); }
public AsyncFactory(IDependency x, IDependency2 y) : base(async() => new AppModel( x.CalculateA(await y.CalculateB()));
public override bool SupportsDependency(IDependency dependency) { // Only supports project reference dependencies return(dependency.IsProject()); }
public bool Equals(IDependency other) => other != null && other.Id.Equals(Id, StringComparison.OrdinalIgnoreCase);
public ASubject(IDependency dep2, ADependency dep) { this.dep = dep; this.dep2 = dep2; }
public ClassWithDependencies(IDependency dependency) { Dependency = dependency; }
public bool Equals(IDependency other) => StringComparer.OrdinalIgnoreCase.Equals(Id, other?.Id);
public virtual bool SupportsDependency(IDependency dependency) { // Supports all dependencies return(true); }
/// <inheritdoc /> public ValuesController(IDependency dependency) { this.dependency = dependency; }
/// <summary> /// Returns true if the updated dependency's path matches the updated snapshot's project path, /// meaning the project dependency has changed and we want to try and update. /// </summary> /// <inheritdoc /> public override bool ShouldApplyChanges(string nodeProjectPath, string updatedSnapshotProjectPath, IDependency updatedDependency) { string dependencyProjectPath = updatedDependency.FullPath; return(!string.IsNullOrEmpty(dependencyProjectPath) && dependencyProjectPath.Equals(updatedSnapshotProjectPath, StringComparisons.Paths)); }
public VirtualDependency(IDependency dependency) { _dependency = dependency; }
/// <summary> /// Initializes a new instance of the <see cref="DependencyUsingBehavior"/> class. /// </summary> /// <param name="dependency">The dependency.</param> public DependencyUsingBehavior(IDependency dependency) { this.dependency = dependency; }
private IEnumerator<IDependency<IModule>> GetDependencyEnumerator(JobExeWrapper jobWrapper, IDependency<IModule> dep, IEnumerator<IDependency<IModule>> iEnumerator) { switch (jobWrapper.Job.DependencyTraversalMode) { case "Breadth-first": iEnumerator = dep.GetBreadthFirstEnumerator(); break; case "Depth-first": iEnumerator = dep.GetDepthFirstEnumerator(); break; } return iEnumerator; }
/// <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); }
/// <summary> /// Initializes a new instance of the <see cref="MultitenantExample.ConsoleApplication.Consumer"/> class. /// </summary> /// <param name="dependency">The dependency this class consumes.</param> public Consumer(IDependency dependency) { this.Dependency = dependency; }
public SomeService(IDependency dependency) { _dependency = dependency ?? throw new ArgumentNullException(nameof(dependency)); }
/// <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 body = targetMethod.Body; var il = body.GetILProcessor(); // Emit the target implementation _implementation.Emit(dependency, serviceMap, targetMethod); // Determine the properties that need injection Func<PropertyInfo, bool> propertyFilter = p => _propertyFilter(p) && _propertyDependencyResolver(p) != null && p.CanWrite; var targetProperties = TargetType.GetProperties(BindingFlags.Public | BindingFlags.Instance); foreach (var property in targetProperties) { if (!propertyFilter(property)) continue; var curentDependency = _propertyDependencyResolver(property); if (!serviceMap.ContainsKey(curentDependency)) continue; EmitPropertySetter(serviceMap, targetMethod, module, il, property, curentDependency); } }
public IRule GetRule(IDependency dependency, IProjectCatalogSnapshot catalogs) { Requires.NotNull(dependency, nameof(dependency)); ConfiguredProject project = null; if (dependency.TargetFramework.Equals(TargetFramework.Any)) { project = ActiveConfiguredProject; } else { ThreadHelper.JoinableTaskFactory.Run(async() => { project = await DependenciesHost.GetConfiguredProject(dependency.TargetFramework) .ConfigureAwait(false) ?? ActiveConfiguredProject; }); } var configuredProjectExports = GetActiveConfiguredProjectExports(project); var namedCatalogs = GetNamedCatalogs(catalogs); Requires.NotNull(namedCatalogs, nameof(namedCatalogs)); var browseObjectsCatalog = namedCatalogs[PropertyPageContexts.BrowseObject]; var schema = browseObjectsCatalog.GetSchema(dependency.SchemaName); var itemSpec = string.IsNullOrEmpty(dependency.OriginalItemSpec) ? dependency.Path : dependency.OriginalItemSpec; var context = ProjectPropertiesContext.GetContext(UnconfiguredProject, itemType: dependency.SchemaItemType, itemName: itemSpec); IRule rule = null; if (schema != null) { if (dependency.Resolved) { rule = configuredProjectExports.RuleFactory.CreateResolvedReferencePageRule( schema, context, dependency.Name, dependency.Properties); } else { rule = browseObjectsCatalog.BindToContext(schema.Name, context); } } else { // Since we have no browse object, we still need to create *something* so // that standard property pages can pop up. var emptyRule = RuleExtensions.SynthesizeEmptyRule(context.ItemType); return(configuredProjectExports.PropertyPagesDataModelProvider.GetRule( emptyRule, context.File, context.ItemType, context.ItemName)); } return(rule); }
/// <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 IL = targetMethod.GetILGenerator(); IL.Emit(OpCodes.Ldarg_0); }
public override IDependency BeforeAdd( string projectPath, ITargetFramework targetFramework, IDependency dependency, ImmutableDictionary <string, IDependency> .Builder worldBuilder, ImmutableHashSet <IDependency> .Builder topLevelBuilder, Dictionary <string, IProjectDependenciesSubTreeProvider> subTreeProviders, HashSet <string> projectItemSpecs, out bool filterAnyChanges) { filterAnyChanges = false; IDependency resultDependency = dependency; IDependency matchingDependency = null; foreach (IDependency x in topLevelBuilder) { if (!x.Id.Equals(dependency.Id, StringComparison.OrdinalIgnoreCase) && x.ProviderType.Equals(dependency.ProviderType, StringComparison.OrdinalIgnoreCase) && x.Caption.Equals(dependency.Caption, StringComparison.OrdinalIgnoreCase)) { matchingDependency = x; break; } } // If found node with same caption, or if there were nodes with same caption but with Alias already applied // NOTE: Performance sensitive, so avoid formatting the Caption with parenthesis if it's possible to avoid it. bool shouldApplyAlias = matchingDependency != null; if (!shouldApplyAlias) { int adjustedLength = dependency.Caption.Length + " (".Length; foreach (IDependency x in topLevelBuilder) { if (!x.Id.Equals(dependency.Id) && x.ProviderType.Equals(dependency.ProviderType, StringComparison.OrdinalIgnoreCase) && x.Caption.StartsWith(dependency.Caption, StringComparison.OrdinalIgnoreCase) && x.Caption.Length >= adjustedLength && string.Compare(x.Caption, adjustedLength, x.OriginalItemSpec, 0, x.OriginalItemSpec.Length, StringComparison.OrdinalIgnoreCase) == 0) { shouldApplyAlias = true; break; } } } if (shouldApplyAlias) { filterAnyChanges = true; if (matchingDependency != null) { matchingDependency = matchingDependency.SetProperties(caption: matchingDependency.Alias); worldBuilder.Remove(matchingDependency.Id); worldBuilder.Add(matchingDependency.Id, matchingDependency); topLevelBuilder.Remove(matchingDependency); topLevelBuilder.Add(matchingDependency); } resultDependency = resultDependency.SetProperties(caption: dependency.Alias); } return(resultDependency); }