Exemplo n.º 1
0
        public unsafe static TReturn GenericMultiply <TReturn>(TReturn l, TReturn r) where TReturn : struct
        {
            Tuple <TReturn, TReturn> value = new Tuple <TReturn, TReturn>(l, r);

            switch (value)
            {
            case Tuple <Byte, Byte> v:
                return(JemUtil.ValToGenericStruct <Byte, TReturn>((byte)(v.Item1 * v.Item2)));

            case Tuple <SByte, SByte> v:
                return(JemUtil.ValToGenericStruct <SByte, TReturn>((SByte)(v.Item1 * v.Item2)));

            case Tuple <UInt16, UInt16> v:
                return(JemUtil.ValToGenericStruct <UInt16, TReturn>((UInt16)(v.Item1 * v.Item2)));

            case Tuple <Int16, Int16> v:
                return(JemUtil.ValToGenericStruct <Int16, TReturn>((Int16)(v.Item1 * v.Item2)));

            case Tuple <UInt32, UInt32> v:
                return(JemUtil.ValToGenericStruct <UInt32, TReturn>((UInt32)(v.Item1 * v.Item2)));

            case Tuple <Int32, Int32> v:
                return(JemUtil.ValToGenericStruct <Int32, TReturn>((Int32)(v.Item1 * v.Item2)));

            case Tuple <UInt64, UInt64> v:
                return(JemUtil.ValToGenericStruct <UInt64, TReturn>((UInt64)(v.Item1 * v.Item2)));

            case Tuple <Int64, Int64> v:
                return(JemUtil.ValToGenericStruct <Int64, TReturn>((Int64)(v.Item1 * v.Item2)));

            default:
                return(default);
            }
        }
Exemplo n.º 2
0
        public unsafe static TReturn GenericMultiply <TReturn>(TReturn l, TReturn r) where TReturn : struct
        {
            Tuple <TReturn, TReturn> value = new Tuple <TReturn, TReturn>(l, r);

            switch (value)
            {
            case Tuple <Byte, Byte> v:
                return(JemUtil.ValToGenericStruct <Byte, TReturn>(checked ((byte)(v.Item1 * v.Item2))));

            case Tuple <SByte, SByte> v:
                return(JemUtil.ValToGenericStruct <SByte, TReturn>(checked ((SByte)(v.Item1 * v.Item2))));

            case Tuple <UInt16, UInt16> v:
                return(JemUtil.ValToGenericStruct <UInt16, TReturn>(checked ((UInt16)(v.Item1 * v.Item2))));

            case Tuple <Int16, Int16> v:
                return(JemUtil.ValToGenericStruct <Int16, TReturn>(checked ((Int16)(v.Item1 * v.Item2))));

            case Tuple <UInt32, UInt32> v:
                return(JemUtil.ValToGenericStruct <UInt32, TReturn>((checked (v.Item1 * v.Item2))));

            case Tuple <Int32, Int32> v:
                return(JemUtil.ValToGenericStruct <Int32, TReturn>((checked (v.Item1 * v.Item2))));

            case Tuple <UInt64, UInt64> v:
                return(JemUtil.ValToGenericStruct <UInt64, TReturn>((checked (v.Item1 * v.Item2))));

            case Tuple <Int64, Int64> v:
                return(JemUtil.ValToGenericStruct <Int64, TReturn>((checked (v.Item1 * v.Item2))));

            default:
                throw new Exception($"Unsupported type: {typeof(TReturn).Name}");
            }
        }