Ejemplo n.º 1
0
        /// <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;
        }
Ejemplo n.º 2
0
        /// <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));
        }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
        /// <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;
        }
Ejemplo n.º 5
0
 /// <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);
Ejemplo n.º 6
0
 /// <inheritdoc/>
 protected override ResourceEventDefinition <TResource> Create(ResourceEventChangeType type, string id)
 {
     return(new ResourceEventDefinition <TResource>(type, id));
 }
Ejemplo n.º 7
0
 /// <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;
 }
Ejemplo n.º 8
0
 /// <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;
 }