Beispiel #1
0
        public GetIdFromObjectOp <TId, TObject> DeepCloneWithObjectToDetermineIdFrom(TObject objectToDetermineIdFrom)
        {
            var result = new GetIdFromObjectOp <TId, TObject>(
                objectToDetermineIdFrom);

            return(result);
        }
Beispiel #2
0
        /// <inheritdoc />
        public async Task <TId> ExecuteAsync(
            GetIdFromObjectOp <TId, TObject> operation)
        {
            var syncResult = this.Execute(operation);
            var result     = await Task.FromResult(syncResult);

            return(result);
        }
Beispiel #3
0
        /// <inheritdoc />
        public TId Execute(
            GetIdFromObjectOp <TId, TObject> operation)
        {
            if (operation.ObjectToDetermineIdFrom is IIdentifiableBy <TId> identifiableObject)
            {
                return(identifiableObject.Id);
            }

            throw new ArgumentException(FormattableString.Invariant($"Cannot extract an Id from type '{typeof(TObject).ToStringReadable()}' because it does not implement '{typeof(IIdentifiableBy<TId>).ToStringReadable()}'."));
        }
Beispiel #4
0
        /// <inheritdoc />
        public bool Equals(GetIdFromObjectOp <TId, TObject> other)
        {
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            if (ReferenceEquals(other, null))
            {
                return(false);
            }

            var result = this.ObjectToDetermineIdFrom.IsEqualTo(other.ObjectToDetermineIdFrom);

            return(result);
        }