Beispiel #1
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="NativeParameterInfo" /> struct.
 /// </summary>
 /// <param name="type">The type.</param>
 public NativeParameterInfo(NativeParameterType type)
 {
     Type           = type;
     LengthIndex    = 0;
     RequiresLength = CalcRequiresLength(type);
     ArgumentType   = CalcCommandArgument(type);
 }
Beispiel #2
0
        private static ServerCommandArgument CalcCommandArgument(NativeParameterType type)
        {
            var value = ServerCommandArgument.Terminator;

            switch (type & ArgumentMask)
            {
            case NativeParameterType.Int32:
            case NativeParameterType.Single:
            case NativeParameterType.Bool:
                value = ServerCommandArgument.Value;
                break;

            case NativeParameterType.String:
                value = ServerCommandArgument.String;
                break;
            }

            if (type.HasFlag(NativeParameterType.Array))
            {
                value = ServerCommandArgument.Array;
            }

            if (type.HasFlag(NativeParameterType.Reference))
            {
                value |= ServerCommandArgument.Reference;
            }

            return(value);
        }
Beispiel #3
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="NativeParameterInfo" /> struct.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="isOutput">A value indicating whether this parameter has no input.</param>
 public NativeParameterInfo(NativeParameterType type, bool isOutput)
 {
     Type         = type;
     LengthIndex  = 0;
     ArgumentType = CalcCommandArgument(type);
     IsOutput     = isOutput;
 }
Beispiel #4
0
        private static bool CalcRequiresLength(NativeParameterType type)
        {
            var isArray     = type.HasFlag(NativeParameterType.Array);
            var isReference = type.HasFlag(NativeParameterType.Reference);
            var isValue     = (type & (NativeParameterType.Int32 | NativeParameterType.Single | NativeParameterType.Bool)) != 0;

            return(isArray || isReference && !isValue);
        }
 private static void EmitConvertToInt(ILGenerator ilGenerator, NativeParameterType type)
 {
     if (type.HasFlag(NativeParameterType.Single))
     {
         ilGenerator.EmitConvert <float, int>();
     }
     if (type.HasFlag(NativeParameterType.Bool))
     {
         ilGenerator.EmitConvert <bool, int>();
     }
 }
 /// <summary>
 ///     Initializes a new instance of the <see cref="NativeParameterInfo" /> struct.
 /// </summary>
 /// <param name="type">The type.</param>
 public NativeParameterInfo(NativeParameterType type)
 {
     Type        = type;
     LengthIndex = 0;
 }
 /// <summary>
 ///     Initializes a new instance of the <see cref="NativeParameterInfo" /> struct.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="lengthIndex">Index of the length.</param>
 public NativeParameterInfo(NativeParameterType type, uint lengthIndex)
 {
     Type        = type;
     LengthIndex = lengthIndex;
 }