public FlowArguments(IOrganizationServiceWrapper orgServiceWrapper, ITracingService tracingService, IEventBus eventBus, ICommandBus commandBus) { this.OrgServiceWrapper = orgServiceWrapper ?? throw new ArgumentNullException(nameof(orgServiceWrapper)); this.EventBus = eventBus ?? throw new ArgumentNullException(nameof(eventBus)); this.CommandBus = commandBus ?? throw new ArgumentNullException(nameof(commandBus)); this.TracingService = tracingService ?? throw new ArgumentNullException(nameof(tracingService)); }
private ResolvedParameter QueryResolver(ILifetimeScope scope, IOrganizationServiceWrapper orgServiceWrapper) { return(new ResolvedParameter( (pi, ctx) => { // Determine if we're looking for a parameter that is of a type that extends CrmQuery<> bool isCrmQuery = pi.ParameterType.IsClass && pi.ParameterType.BaseType.IsGenericType && pi.ParameterType.BaseType.GetGenericTypeDefinition() == typeof(CrmQuery <>); return isCrmQuery; }, (pi, ctx) => { // Check if it has the [InUserContext] attribute bool useUserContextService = pi.CustomAttributes.Any(attr => attr.AttributeType == typeof(InUserContextAttribute)); // Inject the correct CRM service reference object resolvedQueryHandler = scope.Resolve(pi.ParameterType, new ResolvedParameter( (_pi, _ctx) => _pi.ParameterType == typeof(IOrganizationService), (_pi, _ctx) => useUserContextService ? orgServiceWrapper.OrgService : orgServiceWrapper.OrgServiceAsSystem )); return resolvedQueryHandler; } )); }
public SampleEventHandler(IOrganizationServiceWrapper orgServiceWrapper, IEventBus eventBus) : base(orgServiceWrapper, eventBus) { }