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

            return(result);
        }
예제 #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);
        }
예제 #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()}'."));
        }
예제 #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);
        }