Beispiel #1
0
        public static bool TryInvoke(this ILockingAtomic <Action> @this)
        {
            var valueLocal = @this.Value;

            if (valueLocal == null)
            {
                return(false);
            }
            valueLocal();
            return(true);
        }
Beispiel #2
0
        public static bool TryInvoke <T1, T2, T3>(this ILockingAtomic <Action <T1, T2, T3> > @this, T1 arg1, T2 arg2, T3 arg3)
        {
            var valueLocal = @this.Value;

            if (valueLocal is null)
            {
                return(false);
            }
            valueLocal(arg1, arg2, arg3);
            return(true);
        }
Beispiel #3
0
        public static bool TryInvoke <T1>(this ILockingAtomic <Action <T1> > @this, T1 arg1)
        {
            var valueLocal = @this.Value;

            if (valueLocal == null)
            {
                return(false);
            }
            valueLocal(arg1);
            return(true);
        }
Beispiel #4
0
        public static bool TryInvoke <T1, T2, T3, T4, T5, T6, T7>(this ILockingAtomic <Action <T1, T2, T3, T4, T5, T6, T7> > @this, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7)
        {
            var valueLocal = @this.Value;

            if (valueLocal is null)
            {
                return(false);
            }
            valueLocal(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
            return(true);
        }
Beispiel #5
0
        public static bool TryDynamicInvoke <T>(this ILockingAtomic <T> @this, object?[] args, out object?returnValue) where T : MulticastDelegate
        {
            var valueLocal = @this.Value;

            if (valueLocal == null)
            {
                returnValue = default;
                return(false);
            }
            returnValue = valueLocal.DynamicInvoke(args);
            return(true);
        }
Beispiel #6
0
        public static bool TryInvoke <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TOut>(this ILockingAtomic <Func <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TOut> > @this, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, out TOut returnValue)
        {
            var valueLocal = @this.Value;

            if (valueLocal is null)
            {
#pragma warning disable CS8653 // "A default expression introduces a null value for a type parameter." -- That's fine here, we just can't mark TOut as nullable
                returnValue = default;
#pragma warning restore CS8653
                return(false);
            }
            returnValue = valueLocal(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
            return(true);
        }
Beispiel #7
0
        public static bool TryInvoke <TOut>(this ILockingAtomic <Func <TOut> > @this, out TOut returnValue)
        {
            var valueLocal = @this.Value;

            if (valueLocal is null)
            {
#pragma warning disable CS8653 // "A default expression introduces a null value for a type parameter." -- That's fine here, we just can't mark TOut as nullable
                returnValue = default;
#pragma warning restore CS8653
                return(false);
            }
            returnValue = valueLocal();
            return(true);
        }
 public static Int32 Add(this ILockingAtomic <Int32> @this, Int32 operand, out Int32 previousValue) => @this.Set(i => i + operand, out previousValue);
 public static Int32 Add(this ILockingAtomic <Int32> @this, Int32 operand) => @this.Set(i => i + operand);
 public static Int32 Decrement(this ILockingAtomic <Int32> @this, out Int32 previousValue) => @this.Set(i => -- i, out previousValue);
 public static Int32 Decrement(this ILockingAtomic <Int32> @this) => @this.Set(i => -- i);
 public static UInt16 Add(this ILockingAtomic <UInt16> @this, UInt16 operand) => @this.Set(i => (UInt16)(i + operand));
 public static UInt16 Divide(this ILockingAtomic <UInt16> @this, UInt16 operand) => @this.Set(i => (UInt16)(i / operand));
 public static UInt16 Multiply(this ILockingAtomic <UInt16> @this, UInt16 operand) => @this.Set(i => (UInt16)(i * operand));
 public static UInt16 Multiply(this ILockingAtomic <UInt16> @this, UInt16 operand, out UInt16 previousValue) => @this.Set(i => (UInt16)(i * operand), out previousValue);
 public static UInt16 Subtract(this ILockingAtomic <UInt16> @this, UInt16 operand, out UInt16 previousValue) => @this.Set(i => (UInt16)(i - operand), out previousValue);
 public static UInt16 Subtract(this ILockingAtomic <UInt16> @this, UInt16 operand) => @this.Set(i => (UInt16)(i - operand));
 public static SByte Increment(this ILockingAtomic <SByte> @this) => @this.Set(i => ++ i);
 public static UInt16 Increment(this ILockingAtomic <UInt16> @this) => @this.Set(i => ++ i);
 public static UInt16 Decrement(this ILockingAtomic <UInt16> @this) => @this.Set(i => -- i);
Beispiel #21
0
        public static bool TryInvoke <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(this ILockingAtomic <Action <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> > @this, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15, T16 arg16)
        {
            var valueLocal = @this.Value;

            if (valueLocal is null)
            {
                return(false);
            }
            valueLocal(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16);
            return(true);
        }
Beispiel #22
0
 public static void RemoveAll <T>(this ILockingAtomic <T> @this, T delegateToRemove) where T : MulticastDelegate
 {
     @this.Set(v => (T)Delegate.RemoveAll(v, delegateToRemove));
 }
 public static Int16 Add(this ILockingAtomic <Int16> @this, Int16 operand, out Int16 previousValue) => @this.Set(i => (Int16)(i + operand), out previousValue);
 public static Int16 Increment(this ILockingAtomic <Int16> @this, out Int16 previousValue) => @this.Set(i => ++ i, out previousValue);
 public static UInt16 Divide(this ILockingAtomic <UInt16> @this, UInt16 operand, out UInt16 previousValue) => @this.Set(i => (UInt16)(i / operand), out previousValue);
 public static UInt16 Decrement(this ILockingAtomic <UInt16> @this, out UInt16 previousValue) => @this.Set(i => -- i, out previousValue);
Beispiel #27
0
 public static void Combine <T>(this ILockingAtomic <T> @this, T delegateToCombine) where T : MulticastDelegate
 {
     @this.Set(v => (T)Delegate.Combine(v, delegateToCombine));
 }
 public static SByte Increment(this ILockingAtomic <SByte> @this, out SByte previousValue) => @this.Set(i => ++ i, out previousValue);
 public static Int32 Increment(this ILockingAtomic <Int32> @this) => @this.Set(i => ++ i);
 public static Byte Divide(this ILockingAtomic <Byte> @this, Byte operand, out Byte previousValue) => @this.Set(i => (Byte)(i / operand), out previousValue);