/// <summary> /// Initialises a new instance of the <see cref="ResourceEvent" /> class. /// </summary> /// <param name="changeType">The type of change.</param> /// <param name="eventId">The id of this specific event.</param> /// <param name="resourceType">The type of resource that has been modified.</param> /// <param name="selfQuery">An operation that, when executed, will load the associated resource.</param> public ResourceEvent(ResourceEventChangeType changeType, string eventId, Type resourceType, IQuery selfQuery) { Guard.EnumDefined(nameof(changeType), changeType); Guard.NotNull(nameof(resourceType), resourceType); Guard.NotNull(nameof(selfQuery), selfQuery); this._changeType = changeType; this._eventId = eventId; this._resourceType = resourceType; this._selfQuery = selfQuery; this._created = SystemTime.UtcNow; }
/// <inheritdoc/> protected override ResourceEventDefinitionWithMapper <TResource> Create(ResourceEventChangeType type, string id) { return(this._mapper != null ? new ResourceEventDefinitionWithMapper <TResource>( type, id, this._mapper) : new ResourceEventDefinitionWithMapper <TResource>( type, id, this._queryMapper)); }
public ResourceEvent(ResourceEventChangeType changeType, string eventId, object data) { Guard.EnumDefined(nameof(changeType), changeType); Guard.NotNull(nameof(data), data); this.ChangeType = changeType; this.EventId = eventId; this.ResourceType = data.GetType(); this.ResourceObject = ApiResource.GetTypeName(this.ResourceType); this.Data = data; this.Created = SystemTime.UtcNow; }
/// <summary> /// Initialises a new instance of the <see cref="ResourceEvent" /> class. /// </summary> /// <param name="changeType">The type of change.</param> /// <param name="eventId">The id of this specific event.</param> /// <param name="resourceType">The type of resource that has been modified.</param> /// <param name="selfQuery">An operation that, when executed, will load the associated resource.</param> public ResourceEvent(ResourceEventChangeType changeType, string eventId, Type resourceType, IQuery selfQuery) { Guard.EnumDefined(nameof(changeType), changeType); Guard.NotNull(nameof(resourceType), resourceType); Guard.NotNull(nameof(selfQuery), selfQuery); this.ChangeType = changeType; this.EventId = eventId; this.ResourceType = resourceType; this.ResourceObject = ApiResource.GetTypeName(resourceType); this.SelfQuery = selfQuery; this.Created = SystemTime.UtcNow; }
/// <summary> /// Creates the actual mapper from this factory. /// </summary> /// <param name="type">The change type.</param> /// <param name="id">The Id.</param> /// <returns>A mapper for the given arguments.</returns> protected abstract TReturn Create(ResourceEventChangeType type, string id);
/// <inheritdoc/> protected override ResourceEventDefinition <TResource> Create(ResourceEventChangeType type, string id) { return(new ResourceEventDefinition <TResource>(type, id)); }
/// <summary> /// Initialises a new instance of the <see cref="ResourceEventDefinition{TResource}" /> class. /// </summary> /// <param name="changeType">The type of change.</param> /// <param name="eventId">The specific event type.</param> /// <param name="mapper">A mapper to construct the final resource.</param> public ResourceEventDefinitionWithMapper(ResourceEventChangeType changeType, string eventId, Func <TResource> mapper) : base(changeType, eventId) { this._mapper = mapper; }
/// <summary> /// Initialises a new instance of the <see cref="ResourceEventDefinition{TResource}" /> class. /// </summary> /// <param name="changeType">The type of change.</param> /// <param name="eventId">The specific event type.</param> /// <param name="queryMapper">A mapper to construct a "self" API operation.</param> public ResourceEventDefinitionWithMapper(ResourceEventChangeType changeType, string eventId, Func <IQuery <TResource> > queryMapper) : base(changeType, eventId) { this._queryMapper = queryMapper; }