示例#1
0
        bool INodeDeserializer.Deserialize(EventReader reader, Type expectedType, Func <EventReader, Type, object> nestedObjectDeserializer, out object value)
        {
            var scalar = reader.Allow <Scalar>();

            if (scalar == null)
            {
                value = null;
                return(false);
            }

            if (expectedType.IsEnum)
            {
                value = Enum.Parse(expectedType, scalar.Value);
            }
            else
            {
                TypeCode typeCode = Type.GetTypeCode(expectedType);
                switch (typeCode)
                {
                case TypeCode.Boolean:
                    value = bool.Parse(scalar.Value);
                    break;

                case TypeCode.Byte:
                    value = Byte.Parse(scalar.Value, numberFormat);
                    break;

                case TypeCode.Int16:
                    value = Int16.Parse(scalar.Value, numberFormat);
                    break;

                case TypeCode.Int32:
                    value = Int32.Parse(scalar.Value, numberFormat);
                    break;

                case TypeCode.Int64:
                    value = Int64.Parse(scalar.Value, numberFormat);
                    break;

                case TypeCode.SByte:
                    value = SByte.Parse(scalar.Value, numberFormat);
                    break;

                case TypeCode.UInt16:
                    value = UInt16.Parse(scalar.Value, numberFormat);
                    break;

                case TypeCode.UInt32:
                    value = UInt32.Parse(scalar.Value, numberFormat);
                    break;

                case TypeCode.UInt64:
                    value = UInt64.Parse(scalar.Value, numberFormat);
                    break;

                case TypeCode.Single:
                    value = Single.Parse(scalar.Value, numberFormat);
                    break;

                case TypeCode.Double:
                    value = Double.Parse(scalar.Value, numberFormat);
                    break;

                case TypeCode.Decimal:
                    value = Decimal.Parse(scalar.Value, numberFormat);
                    break;

                case TypeCode.String:
                    value = scalar.Value;
                    break;

                case TypeCode.Char:
                    value = scalar.Value[0];
                    break;

                case TypeCode.DateTime:
                    // TODO: This is probably incorrect. Use the correct regular expression.
                    value = DateTime.Parse(scalar.Value, CultureInfo.InvariantCulture);
                    break;

                default:
                    if (expectedType == typeof(object))
                    {
                        // Default to string
                        value = scalar.Value;
                    }
                    else
                    {
                        value = TypeConverter.ChangeType(scalar.Value, expectedType);
                    }
                    break;
                }
            }
            return(true);
        }
示例#2
0
 internal static unsafe IntPtr ConvertSByteByrefToPtr(ref SByte value) {
     fixed (SByte *x = &value) {
         AssertByrefPointsToStack(new IntPtr(x));
         return new IntPtr(x);
     }
 }
示例#3
0
 public GetRssiEventArgs(Byte connection, SByte rssi)
 {
     this.connection = connection;
     this.rssi = rssi;
 }
	public static decimal ToDecimal(SByte value) {}
示例#5
0
 public void SetAsByrefI1(ref SByte value) {
     Debug.Assert(IsEmpty); // The setter can only be called once as VariantClear might be needed otherwise
     VariantType = (VarEnum.VT_I1 | VarEnum.VT_BYREF);
     _typeUnion._unionTypes._byref = UnsafeMethods.ConvertSByteByrefToPtr(ref value);
 }
	public static ushort ToUInt16(SByte value) {}
	public static long ToInt64(SByte value) {}
示例#8
0
 public static IntPtr ConvertSByteByrefToPtr(ref SByte value) { return s_convertSByteByrefToPtr(ref value); }
示例#9
0
        public static bool TryParse(string value, Type type, CultureInfo ci, out object result)
        {
            if (type == typeof(string))
            {
                result = value;
                return(true);
            }

            result = null;

            if (string.IsNullOrEmpty(value))
            {
                if (Nullable.GetUnderlyingType(type) == null && type.IsValueType)
                {
                    return(false);
                }
                return(true);
            }

            Type utype = type.UnNullify();

            if (utype.IsEnum)
            {
                if (EnumExtensions.TryParse(value, utype, true, out Enum _result))
                {
                    result = _result;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (utype == typeof(bool))
            {
                if (bool.TryParse(value, out bool _result))
                {
                    result = _result;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (utype == typeof(char))
            {
                if (char.TryParse(value, out char _result))
                {
                    result = _result;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (utype == typeof(SByte))
            {
                if (SByte.TryParse(value, NumberStyles.Integer, ci, out sbyte _result))
                {
                    result = _result;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (utype == typeof(byte))
            {
                if (byte.TryParse(value, NumberStyles.Integer, ci, out byte _result))
                {
                    result = _result;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (utype == typeof(Int16))
            {
                if (Int16.TryParse(value, NumberStyles.Integer, ci, out short _result))
                {
                    result = _result;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (utype == typeof(UInt16))
            {
                if (UInt16.TryParse(value, NumberStyles.Integer, ci, out ushort _result))
                {
                    result = _result;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (utype == typeof(Int32))
            {
                if (Int32.TryParse(value, NumberStyles.Integer, ci, out int _result))
                {
                    result = _result;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (utype == typeof(UInt32))
            {
                if (UInt32.TryParse(value, NumberStyles.Integer, ci, out uint _result))
                {
                    result = _result;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (utype == typeof(Int64))
            {
                if (Int64.TryParse(value, NumberStyles.Integer, ci, out long _result))
                {
                    result = _result;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (utype == typeof(UInt64))
            {
                if (UInt64.TryParse(value, NumberStyles.Integer, ci, out ulong _result))
                {
                    result = _result;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (utype == typeof(float))
            {
                if (float.TryParse(value, NumberStyles.Number, ci, out float _result))
                {
                    result = _result;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (utype == typeof(double))
            {
                if (double.TryParse(value, NumberStyles.Number, ci, out double _result))
                {
                    result = _result;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (utype == typeof(decimal))
            {
                if (decimal.TryParse(value, NumberStyles.Number, ci, out decimal _result))
                {
                    result = _result;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (utype == typeof(DateTime))
            {
                if (DateTime.TryParse(value, ci, DateTimeStyles.None, out DateTime _result))
                {
                    result = _result;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (utype == typeof(Guid))
            {
                if (Guid.TryParse(value, out Guid _result))
                {
                    result = _result;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (utype == typeof(object))
            {
                result = value;
                return(true);
            }
            else
            {
                TypeConverter converter = TypeDescriptor.GetConverter(utype);
                if (converter.CanConvertFrom(typeof(string)))
                {
                    try
                    {
                        result = converter.ConvertFromString(null, ci, value);
                        return(true);
                    }
                    catch (Exception)
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
        }
示例#10
0
        public override void callPropertysSetMethods()
        {
            ScriptModule sm = EntityDef.moduledefs["Avatar"];
            Dictionary <UInt16, Property> pdatas = sm.idpropertys;

            compMatchAvatar.callPropertysSetMethods();

            component1.callPropertysSetMethods();

            component2.callPropertysSetMethods();

            component3.callPropertysSetMethods();

            Vector3  oldval_direction = direction;
            Property prop_direction   = pdatas[2];

            if (prop_direction.isBase())
            {
                if (inited && !inWorld)
                {
                    onDirectionChanged(oldval_direction);
                }
            }
            else
            {
                if (inWorld)
                {
                    if (prop_direction.isOwnerOnly() && !isPlayer())
                    {
                    }
                    else
                    {
                        onDirectionChanged(oldval_direction);
                    }
                }
            }

            string   oldval_name = name;
            Property prop_name   = pdatas[8];

            if (prop_name.isBase())
            {
                if (inited && !inWorld)
                {
                    onNameChanged(oldval_name);
                }
            }
            else
            {
                if (inWorld)
                {
                    if (prop_name.isOwnerOnly() && !isPlayer())
                    {
                    }
                    else
                    {
                        onNameChanged(oldval_name);
                    }
                }
            }

            Vector3  oldval_position = position;
            Property prop_position   = pdatas[1];

            if (prop_position.isBase())
            {
                if (inited && !inWorld)
                {
                    onPositionChanged(oldval_position);
                }
            }
            else
            {
                if (inWorld)
                {
                    if (prop_position.isOwnerOnly() && !isPlayer())
                    {
                    }
                    else
                    {
                        onPositionChanged(oldval_position);
                    }
                }
            }

            SByte    oldval_teamID = teamID;
            Property prop_teamID   = pdatas[9];

            if (prop_teamID.isBase())
            {
                if (inited && !inWorld)
                {
                    onTeamIDChanged(oldval_teamID);
                }
            }
            else
            {
                if (inWorld)
                {
                    if (prop_teamID.isOwnerOnly() && !isPlayer())
                    {
                    }
                    else
                    {
                        onTeamIDChanged(oldval_teamID);
                    }
                }
            }
        }
示例#11
0
 /// <summary>
 /// 一个字节 8位 最大127
 /// </summary>
 public void WriteSByte(SByte value)
 {
     byte[] bytes = new byte[] { (Byte)value };
     WriteBuffer(bytes);
 }
示例#12
0
 public virtual void onTeamIDChanged(SByte oldValue)
 {
 }
示例#13
0
        public override void onUpdatePropertys(MemoryStream stream)
        {
            ScriptModule sm = EntityDef.moduledefs["Avatar"];
            Dictionary <UInt16, Property> pdatas = sm.idpropertys;

            while (stream.length() > 0)
            {
                UInt16 _t_utype       = 0;
                UInt16 _t_child_utype = 0;

                {
                    if (sm.usePropertyDescrAlias)
                    {
                        _t_utype       = stream.readUint8();
                        _t_child_utype = stream.readUint8();
                    }
                    else
                    {
                        _t_utype       = stream.readUint16();
                        _t_child_utype = stream.readUint16();
                    }
                }

                Property prop = null;

                if (_t_utype == 0)
                {
                    prop = pdatas[_t_child_utype];
                }
                else
                {
                    Property pComponentPropertyDescription = pdatas[_t_utype];
                    switch (pComponentPropertyDescription.properUtype)
                    {
                    case 17:
                        compMatchAvatar.onUpdatePropertys(_t_child_utype, stream, -1);
                        break;

                    case 8:
                        component1.onUpdatePropertys(_t_child_utype, stream, -1);
                        break;

                    case 11:
                        component2.onUpdatePropertys(_t_child_utype, stream, -1);
                        break;

                    case 15:
                        component3.onUpdatePropertys(_t_child_utype, stream, -1);
                        break;

                    default:
                        break;
                    }

                    return;
                }

                switch (prop.properUtype)
                {
                case 17:
                    compMatchAvatar.createFromStream(stream);
                    break;

                case 8:
                    component1.createFromStream(stream);
                    break;

                case 11:
                    component2.createFromStream(stream);
                    break;

                case 15:
                    component3.createFromStream(stream);
                    break;

                case 40001:
                    Vector3 oldval_direction = direction;
                    direction = stream.readVector3();

                    if (prop.isBase())
                    {
                        if (inited)
                        {
                            onDirectionChanged(oldval_direction);
                        }
                    }
                    else
                    {
                        if (inWorld)
                        {
                            onDirectionChanged(oldval_direction);
                        }
                    }

                    break;

                case 4:
                    string oldval_name = name;
                    name = stream.readUnicode();

                    if (prop.isBase())
                    {
                        if (inited)
                        {
                            onNameChanged(oldval_name);
                        }
                    }
                    else
                    {
                        if (inWorld)
                        {
                            onNameChanged(oldval_name);
                        }
                    }

                    break;

                case 40000:
                    Vector3 oldval_position = position;
                    position = stream.readVector3();

                    if (prop.isBase())
                    {
                        if (inited)
                        {
                            onPositionChanged(oldval_position);
                        }
                    }
                    else
                    {
                        if (inWorld)
                        {
                            onPositionChanged(oldval_position);
                        }
                    }

                    break;

                case 40002:
                    stream.readUint32();
                    break;

                case 7:
                    SByte oldval_teamID = teamID;
                    teamID = stream.readInt8();

                    if (prop.isBase())
                    {
                        if (inited)
                        {
                            onTeamIDChanged(oldval_teamID);
                        }
                    }
                    else
                    {
                        if (inWorld)
                        {
                            onTeamIDChanged(oldval_teamID);
                        }
                    }

                    break;

                default:
                    break;
                }
                ;
            }
        }
示例#14
0
        public static object ConvertT <T>(object myvalue)
        {
            TypeCode typeCode = System.Type.GetTypeCode(typeof(T));

            if (myvalue != null)
            {
                string value = Convert.ToString(myvalue);
                switch (typeCode)
                {
                case TypeCode.Boolean:
                    bool flag = false;
                    if (bool.TryParse(value, out flag))
                    {
                        return(flag);
                    }
                    break;

                case TypeCode.Char:
                    char c;
                    if (Char.TryParse(value, out c))
                    {
                        return(c);
                    }
                    break;

                case TypeCode.SByte:
                    sbyte s = 0;
                    if (SByte.TryParse(value, out s))
                    {
                        return(s);
                    }
                    break;

                case TypeCode.Byte:
                    byte b = 0;
                    if (Byte.TryParse(value, out b))
                    {
                        return(b);
                    }
                    break;

                case TypeCode.Int16:
                    Int16 i16 = 0;
                    if (Int16.TryParse(value, out i16))
                    {
                        return(i16);
                    }
                    break;

                case TypeCode.UInt16:
                    UInt16 ui16 = 0;
                    if (UInt16.TryParse(value, out ui16))
                    {
                        return(ui16);
                    }
                    break;

                case TypeCode.Int32:
                    int i = 0;
                    if (Int32.TryParse(value, out i))
                    {
                        return(i);
                    }
                    break;

                case TypeCode.UInt32:
                    UInt32 ui32 = 0;
                    if (UInt32.TryParse(value, out ui32))
                    {
                        return(ui32);
                    }
                    break;

                case TypeCode.Int64:
                    Int64 i64 = 0;
                    if (Int64.TryParse(value, out i64))
                    {
                        return(i64);
                    }
                    break;

                case TypeCode.UInt64:
                    UInt64 ui64 = 0;
                    if (UInt64.TryParse(value, out ui64))
                    {
                        return(ui64);
                    }
                    break;

                case TypeCode.Single:
                    Single single = 0;
                    if (Single.TryParse(value, out single))
                    {
                        return(single);
                    }
                    break;

                case TypeCode.Double:
                    double d = 0;
                    if (Double.TryParse(value, out d))
                    {
                        return(d);
                    }
                    break;

                case TypeCode.Decimal:
                    decimal de = 0;
                    if (Decimal.TryParse(value, out de))
                    {
                        return(de);
                    }
                    break;

                case TypeCode.DateTime:
                    DateTime dt;
                    if (DateTime.TryParse(value, out dt))
                    {
                        return(dt);
                    }
                    break;

                case TypeCode.String:
                    if (!string.IsNullOrEmpty(value))
                    {
                        return(value.ToString());
                    }
                    break;
                }
            }
            return(default(T));
        }
	public static SByte ToSByte(SByte value) {}
 private static bool IsDefined(SByte arg)
 {
     return(true);
 }
	public static short ToInt16(SByte value) {}
示例#18
0
 private void ValidateResult(Vector128<SByte> result, [CallerMemberName] string method = "")
 {
     SByte[] resultElements = new SByte[ElementCount];
     Unsafe.WriteUnaligned(ref Unsafe.As<SByte, byte>(ref resultElements[0]), result);
     ValidateResult(resultElements, method);
 }
	public static int ToInt32(SByte value) {}
示例#20
0
 public void SetAsByrefI1(ref SByte value)
 {
     Debug.Assert(IsEmpty); // The setter can only be called once as VariantClear might be needed otherwise
     VariantType = (VarEnum.VT_I1 | VarEnum.VT_BYREF);
     _typeUnion._unionTypes._byref = UnsafeMethods.ConvertSByteByrefToPtr(ref value);
 }
	public static float ToSingle(SByte value) {}
示例#22
0
 /// <summary>
 /// Build condition phrase of 'NOT BETWEEN'.
 /// </summary>
 /// <param name="begin">Begin value.</param>
 /// <param name="end">End value.</param>
 /// <returns>Condition phrase of 'NOT BETWEEN'.</returns>
 public APSqlConditionPhrase NotBetween(SByte begin, SByte end)
 {
     return(new APSqlConditionPhrase(this, APSqlConditionOperator.NotBetween, new SByte[2] {
         begin, end
     }));
 }
	public static bool ToBoolean(SByte value) {}
示例#24
0
        /// <summary>
        /// Instantiate a 'Primitive' Type.
        /// </summary>
        /// <param name="typeCode">a typeCode.</param>
        /// <returns>An object.</returns>
        public static object InstantiatePrimitiveType(TypeCode typeCode)
        {
            object resultObject = null;

            switch (typeCode)
            {
            case TypeCode.Boolean:
                resultObject = new Boolean();
                break;

            case TypeCode.Byte:
                resultObject = new Byte();
                break;

            case TypeCode.Char:
                resultObject = new Char();
                break;

            case TypeCode.DateTime:
                resultObject = new DateTime();
                break;

            case TypeCode.Decimal:
                resultObject = new Decimal();
                break;

            case TypeCode.Double:
                resultObject = new Double();
                break;

            case TypeCode.Int16:
                resultObject = new Int16();
                break;

            case TypeCode.Int32:
                resultObject = new Int32();
                break;

            case TypeCode.Int64:
                resultObject = new Int64();
                break;

            case TypeCode.SByte:
                resultObject = new SByte();
                break;

            case TypeCode.Single:
                resultObject = new Single();
                break;

            case TypeCode.String:
                resultObject = "";
                break;

            case TypeCode.UInt16:
                resultObject = new UInt16();
                break;

            case TypeCode.UInt32:
                resultObject = new UInt32();
                break;

            case TypeCode.UInt64:
                resultObject = new UInt64();
                break;
            }
            return(resultObject);
        }
示例#25
0
 private static void VerifySByteExplicitCastFromBigInteger(SByte value)
 {
     BigInteger bigInteger = new BigInteger(value);
     VerifySByteExplicitCastFromBigInteger(value, bigInteger);
 }
示例#26
0
 private SByte Abs(SByte value)
 {
     return(System.Math.Abs(value));
 }
 internal static Exception TryToSByte(string s, out SByte result) {
     if (!SByte.TryParse(s, NumberStyles.AllowLeadingSign|NumberStyles.AllowLeadingWhite|NumberStyles.AllowTrailingWhite, NumberFormatInfo.InvariantInfo, out result)) {
         return new FormatException(Res.GetString(Res.XmlConvert_BadFormat, s, "SByte"));
     }
     return null;
 }
示例#28
0
        static void Main()
        {
            #region TIPO ENTERO

            // 8-bits == 1 byte. ----------------------------------------------------------------------------

            // Entero sin signo. Rango de valores - Desde 0 hasta 255.
            byte a = 0;
            Byte b = 255;

            // Entero con signo. Rango de valores - Desde -128 hasta +127.
            sbyte c = -128;
            SByte d = +127;


            // 16-bits == 2 bytes. -------------------------------------------------------------------------

            // Entero sin signo. Rango de valores -Desde 0 hasta 65535.
            ushort e = 0;
            UInt16 f = 65535;

            // Entero con signo. Rango de valores - Desde -32768 hasta +32767.
            short g = -32768;
            Int16 h = +32767;


            // 32-bits = 4 bytes. ---------------------------------------------------------------------------

            // Entero sin signo. Rango de valores - Desde 0 hasta 4294967295.
            uint   i = 0u;
            UInt32 j = 4294967295U;

            // Entero con signo. Rango de valores - Desde -2147483648 hasta +2147483647.
            int   k = -2147483648;
            Int32 l = +2147483647;


            // 64-bits = 8 bytes. ---------------------------------------------------------------------------

            // Entero sin signo. Rango de valores - Desde 0 hasta 18446744073709551615.
            ulong  m = 0ul;
            UInt64 n = 18446744073709551615UL;

            // Entero con signo. Rango de valores - Desde -9223372036854775808 hasta +9223372036854775807.
            long  o = -9223372036854775808L;
            Int64 p = +9223372036854775807L;

            #endregion


            #region TIPO REAL

            // El tipo real es asigando  para el uso de franciones o decimales.

            // 32-bits = 4 bytes. ---------------------------------------------------------------------------

            // real con signo . Rango de valores - Desde +/-1.5 x 10^-45 hasta +/-3.4 x 10^38.
            float  q = -0.123456789f; // el uso del sufijo  f, es siempre necesario,
            Single r = +1.123456789F; // porque, el compilador integra el numero dado como double.


            // 64-bits = 8 bytes. ---------------------------------------------------------------------------

            // real con signo. Rango de valores - Desde +/-5.0 x 10^-324 hasta +/-1.7 x 10^308.
            double s = -0.123456789d;
            Double t = +1.123456789;

            #endregion


            #region TIPO DECIMAL

            // 128-bits = 16 bytes. -----------------------------------------------------------------------

            // Deciaml con signo. Rango de valores - Desde +/-1.0 x 10^-28 hasta +/-7.9 x 10^28.
            decimal u = -0.12345m;   // el uso del sufijo  m, es siempre necesario,
            Decimal v = +1.1234567M; // porque, el compilador integra el numero dado como double.

            #endregion


            #region TIPO LOGICO

            // 8-bits == 1 byte. ----------------------------------------------------------------------------

            // Lógica binaria verdad/falsedad.
            bool    w = true;
            Boolean x = false;

            #endregion


            #region TIPO SIMBOLICO

            // 16-bits == 2 bytes. -------------------------------------------------------------------------

            // Simbolo en formato  UNICODE(un solo caracter).
            char y = 'a';
            Char z = 'A';

            #endregion


            #region TIPO CADENA

            //  Simbolo en formato UNICODE.(pero aqui acepta varios codigos)
            string firstString  = "hello";
            String secondString = "HELLO";

            #endregion


            // Pausa.
            Console.ReadKey();
        }
示例#29
0
 public static string ToString(SByte value)
 {
     return value.ToString();
 }
示例#30
0
        static void Main(string[] args)
        {
            sbyte example1 = 1;

            Console.WriteLine(example1.GetType());
            SByte example2 = 1;

            Console.WriteLine(example2.GetType());

            short example3 = 1;

            Console.WriteLine(example3.GetType());
            Int16 example4 = 1;

            Console.WriteLine(example4.GetType());

            int example5 = 1;

            Console.WriteLine(example5.GetType());
            Int32 example6 = 1;

            Console.WriteLine(example6.GetType());

            long example7 = 1;

            Console.WriteLine(example7.GetType());
            Int64 example8 = 1;

            Console.WriteLine(example8.GetType());

            byte example9 = 1;

            Console.WriteLine(example9.GetType());
            Byte example10 = 1;

            Console.WriteLine(example10.GetType());

            ushort example11 = 1;

            Console.WriteLine(example11.GetType());
            UInt16 example12 = 1;

            Console.WriteLine(example12.GetType());

            char example13 = '1';

            Console.WriteLine(example13.GetType());
            Char example14 = '1';

            Console.WriteLine(example14.GetType());

            uint example15 = 1;

            Console.WriteLine(example15.GetType());
            UInt32 example16 = 1;

            Console.WriteLine(example16.GetType());

            ulong example17 = 1;

            Console.WriteLine(example17.GetType());
            UInt64 example18 = 1;

            Console.WriteLine(example18.GetType());

            float example19 = 1;

            Console.WriteLine(example19.GetType());
            Single example20 = 1;

            Console.WriteLine(example20.GetType());

            double example21 = 1;

            Console.WriteLine(example21.GetType());
            Double example22 = 1;

            Console.WriteLine(example22.GetType());

            decimal example23 = 1;

            Console.WriteLine(example23.GetType());
            Decimal example24 = 1;

            Console.WriteLine(example24.GetType());
        }
示例#31
0
 public static IntPtr ConvertSByteByrefToPtr(ref SByte value) { return s_convertSByteByrefToPtr(ref value); }
示例#32
0
    public Boolean runTest()
    {
        int iCountTestcases = 0;
        int iCountErrors    = 0;

        Console.Error.WriteLine(strName + ": " + strTest + " runTest started...");
        String strMade  = null;
        String strKnown = null;;
        SByte  SByteVal = (SByte)1;

        do
        {
            try
            {
                ++iCountTestcases;
                SByteVal = (SByte)(-3);
                strMade  = SByteVal.ToString();
                Console.Out.WriteLine(strMade);
                if (strMade == null)
                {
                    ++iCountErrors;
                    print("E_hg45");
                }
                strKnown = "-3";
                if (strMade.CompareTo(strKnown) != 0)
                {
                    ++iCountErrors;
                    print("E_k565");
                }
                ++iCountTestcases;
                SByteVal = 3;
                strMade  = SByteVal.ToString();
                if (strMade == null)
                {
                    ++iCountErrors;
                    print("E_kt50");
                }
                iCountTestcases++;
                strKnown = ("3");
                if (strMade.Equals(strKnown) == false)
                {
                    ++iCountErrors;
                    print("E_kfy4");
                }
                ++iCountTestcases;
                SByteVal = 0;
                strMade  = SByteVal.ToString();
                if (strMade == null)
                {
                    ++iCountErrors;
                    print("E_ot6");
                }
                iCountTestcases++;
                strKnown = ("0");
                if (strMade.Equals(strKnown) == false)
                {
                    ++iCountErrors;
                    print("E_hr8");
                }
                ++iCountTestcases;
                SByteVal = unchecked ((SByte)0x80);
                strMade  = SByteVal.ToString();
                if (strMade == null)
                {
                    ++iCountErrors;
                    print("E_fi");
                }
                strKnown = ("-128");
                if (strMade.Equals(strKnown) == false)
                {
                    ++iCountErrors;
                    print("E_fi2");
                }
                ++iCountTestcases;
                SByteVal = (SByte)0x7F;
                strMade  = SByteVal.ToString();
                if (strMade == null)
                {
                    ++iCountErrors;
                    print("E_k387");
                }
                strKnown = ("127");
                if (strMade.Equals(strKnown) == false)
                {
                    ++iCountErrors;
                    print("E_fho");
                }
                ++iCountTestcases;
                SByteVal = unchecked ((SByte)0xFF);
                strMade  = SByteVal.ToString();
                if (strMade == null)
                {
                    ++iCountErrors;
                    print("E_ro");
                }
                strKnown = ("-1");
                if (strMade.Equals(strKnown) == false)
                {
                    ++iCountErrors;
                    print("E_e3reu");
                }
            }
            catch (Exception exc)
            {
                ++iCountErrors;
                print("E_ej2");
                printexc(exc);
            }
        }while (false);
        if (iCountErrors == 0)
        {
            Console.Error.WriteLine("paSs. " + strTest + "   iCountTestCases == " + iCountTestcases);
            return(true);
        }
        else
        {
            Console.Error.WriteLine("FAiL. " + strTest + "    iCountErrors==" + iCountErrors);
            return(false);
        }
    }
	public static byte ToByte(SByte value) {}
示例#34
0
 public SByte Action_SByte(SByte p)
 {
     return(p);
 }
	public static string ToString(SByte value) {}
示例#36
0
        public static object GetValueFromXml(string xtype, string xdata)
        {
            switch (xtype)
            {
            case "bool":
                return(xdata == "1");

            case "byte":
                return(Byte.Parse(xdata, CultureInfo.InvariantCulture));

            case "i16":
                return(Int16.Parse(xdata, CultureInfo.InvariantCulture));

            case "i32":
                return(Int32.Parse(xdata, CultureInfo.InvariantCulture));

            case "i64":
                return(Int64.Parse(xdata, CultureInfo.InvariantCulture));

            case "sbyte":
                return(SByte.Parse(xdata, CultureInfo.InvariantCulture));

            case "u16":
                return(UInt16.Parse(xdata, CultureInfo.InvariantCulture));

            case "u32":
                return(UInt32.Parse(xdata, CultureInfo.InvariantCulture));

            case "u64":
                return(UInt64.Parse(xdata, CultureInfo.InvariantCulture));

            case "datetime":
                return(DateTime.ParseExact(xdata, "s", CultureInfo.InvariantCulture));

            case "dtex":
                return(DateTimeEx.ParseNormalized(xdata));

            case "date":
                return(DateEx.ParseNormalized(xdata));

            case "time":
                return(TimeEx.ParseNormalized(xdata));

            case "str":
                return(xdata);

            case "decimal":
                return(Decimal.Parse(xdata, CultureInfo.InvariantCulture));

            case "float":
                return(Single.Parse(xdata, CultureInfo.InvariantCulture));

            case "double":
                return(Double.Parse(xdata, CultureInfo.InvariantCulture));

            case "guid":
                return(new Guid(xdata));

            case "blob":
                return(Convert.FromBase64String(xdata));
                //case "array":
                //    values[pos] = CdlArray.Parse(xdata);
                //    break;
            }
            return(null);
        }
	public static string ToString(SByte value, IFormatProvider provider) {}
示例#38
0
 public virtual void onStateChanged(SByte oldValue)
 {
 }
	public static uint ToUInt32(SByte value) {}
示例#40
0
        public override void onUpdatePropertys(MemoryStream stream)
        {
            ScriptModule sm = EntityDef.moduledefs["Avatar"];
            Dictionary <UInt16, Property> pdatas = sm.idpropertys;

            while (stream.length() > 0)
            {
                UInt16 _t_utype       = 0;
                UInt16 _t_child_utype = 0;

                {
                    if (sm.usePropertyDescrAlias)
                    {
                        _t_utype       = stream.readUint8();
                        _t_child_utype = stream.readUint8();
                    }
                    else
                    {
                        _t_utype       = stream.readUint16();
                        _t_child_utype = stream.readUint16();
                    }
                }

                Property prop = null;

                if (_t_utype == 0)
                {
                    prop = pdatas[_t_child_utype];
                }
                else
                {
                    Property pComponentPropertyDescription = pdatas[_t_utype];
                    switch (pComponentPropertyDescription.properUtype)
                    {
                    default:
                        break;
                    }

                    return;
                }

                switch (prop.properUtype)
                {
                case 48005:
                    UInt32 oldval_Die_Count = Die_Count;
                    Die_Count = stream.readUint32();

                    if (prop.isBase())
                    {
                        if (inited)
                        {
                            onDie_CountChanged(oldval_Die_Count);
                        }
                    }
                    else
                    {
                        if (inWorld)
                        {
                            onDie_CountChanged(oldval_Die_Count);
                        }
                    }

                    break;

                case 47005:
                    Int32 oldval_EXP = EXP;
                    EXP = stream.readInt32();

                    if (prop.isBase())
                    {
                        if (inited)
                        {
                            onEXPChanged(oldval_EXP);
                        }
                    }
                    else
                    {
                        if (inWorld)
                        {
                            onEXPChanged(oldval_EXP);
                        }
                    }

                    break;

                case 47006:
                    Int32 oldval_EXP_Max = EXP_Max;
                    EXP_Max = stream.readInt32();

                    if (prop.isBase())
                    {
                        if (inited)
                        {
                            onEXP_MaxChanged(oldval_EXP_Max);
                        }
                    }
                    else
                    {
                        if (inWorld)
                        {
                            onEXP_MaxChanged(oldval_EXP_Max);
                        }
                    }

                    break;

                case 47001:
                    Int32 oldval_HP = HP;
                    HP = stream.readInt32();

                    if (prop.isBase())
                    {
                        if (inited)
                        {
                            onHPChanged(oldval_HP);
                        }
                    }
                    else
                    {
                        if (inWorld)
                        {
                            onHPChanged(oldval_HP);
                        }
                    }

                    break;

                case 47002:
                    Int32 oldval_HP_Max = HP_Max;
                    HP_Max = stream.readInt32();

                    if (prop.isBase())
                    {
                        if (inited)
                        {
                            onHP_MaxChanged(oldval_HP_Max);
                        }
                    }
                    else
                    {
                        if (inWorld)
                        {
                            onHP_MaxChanged(oldval_HP_Max);
                        }
                    }

                    break;

                case 48006:
                    UInt32 oldval_Kill_Count = Kill_Count;
                    Kill_Count = stream.readUint32();

                    if (prop.isBase())
                    {
                        if (inited)
                        {
                            onKill_CountChanged(oldval_Kill_Count);
                        }
                    }
                    else
                    {
                        if (inWorld)
                        {
                            onKill_CountChanged(oldval_Kill_Count);
                        }
                    }

                    break;

                case 47003:
                    Int32 oldval_MP = MP;
                    MP = stream.readInt32();

                    if (prop.isBase())
                    {
                        if (inited)
                        {
                            onMPChanged(oldval_MP);
                        }
                    }
                    else
                    {
                        if (inWorld)
                        {
                            onMPChanged(oldval_MP);
                        }
                    }

                    break;

                case 47004:
                    Int32 oldval_MP_Max = MP_Max;
                    MP_Max = stream.readInt32();

                    if (prop.isBase())
                    {
                        if (inited)
                        {
                            onMP_MaxChanged(oldval_MP_Max);
                        }
                    }
                    else
                    {
                        if (inWorld)
                        {
                            onMP_MaxChanged(oldval_MP_Max);
                        }
                    }

                    break;

                case 48003:
                    UInt32 oldval_Rank = Rank;
                    Rank = stream.readUint32();

                    if (prop.isBase())
                    {
                        if (inited)
                        {
                            onRankChanged(oldval_Rank);
                        }
                    }
                    else
                    {
                        if (inWorld)
                        {
                            onRankChanged(oldval_Rank);
                        }
                    }

                    break;

                case 48001:
                    Int32 oldval_Round = Round;
                    Round = stream.readInt32();

                    if (prop.isBase())
                    {
                        if (inited)
                        {
                            onRoundChanged(oldval_Round);
                        }
                    }
                    else
                    {
                        if (inWorld)
                        {
                            onRoundChanged(oldval_Round);
                        }
                    }

                    break;

                case 48002:
                    Int32 oldval_Round_Max = Round_Max;
                    Round_Max = stream.readInt32();

                    if (prop.isBase())
                    {
                        if (inited)
                        {
                            onRound_MaxChanged(oldval_Round_Max);
                        }
                    }
                    else
                    {
                        if (inWorld)
                        {
                            onRound_MaxChanged(oldval_Round_Max);
                        }
                    }

                    break;

                case 48004:
                    UInt32 oldval_Score = Score;
                    Score = stream.readUint32();

                    if (prop.isBase())
                    {
                        if (inited)
                        {
                            onScoreChanged(oldval_Score);
                        }
                    }
                    else
                    {
                        if (inWorld)
                        {
                            onScoreChanged(oldval_Score);
                        }
                    }

                    break;

                case 12:
                    UInt16 oldval_cruiseSpeed = cruiseSpeed;
                    cruiseSpeed = stream.readUint16();

                    if (prop.isBase())
                    {
                        if (inited)
                        {
                            onCruiseSpeedChanged(oldval_cruiseSpeed);
                        }
                    }
                    else
                    {
                        if (inWorld)
                        {
                            onCruiseSpeedChanged(oldval_cruiseSpeed);
                        }
                    }

                    break;

                case 40001:
                    Vector3 oldval_direction = direction;
                    direction = stream.readVector3();

                    if (prop.isBase())
                    {
                        if (inited)
                        {
                            onDirectionChanged(oldval_direction);
                        }
                    }
                    else
                    {
                        if (inWorld)
                        {
                            onDirectionChanged(oldval_direction);
                        }
                    }

                    break;

                case 41002:
                    UInt16 oldval_level = level;
                    level = stream.readUint16();

                    if (prop.isBase())
                    {
                        if (inited)
                        {
                            onLevelChanged(oldval_level);
                        }
                    }
                    else
                    {
                        if (inWorld)
                        {
                            onLevelChanged(oldval_level);
                        }
                    }

                    break;

                case 42006:
                    UInt32 oldval_modelID = modelID;
                    modelID = stream.readUint32();

                    if (prop.isBase())
                    {
                        if (inited)
                        {
                            onModelIDChanged(oldval_modelID);
                        }
                    }
                    else
                    {
                        if (inWorld)
                        {
                            onModelIDChanged(oldval_modelID);
                        }
                    }

                    break;

                case 42007:
                    Byte oldval_modelScale = modelScale;
                    modelScale = stream.readUint8();

                    if (prop.isBase())
                    {
                        if (inited)
                        {
                            onModelScaleChanged(oldval_modelScale);
                        }
                    }
                    else
                    {
                        if (inWorld)
                        {
                            onModelScaleChanged(oldval_modelScale);
                        }
                    }

                    break;

                case 11:
                    UInt16 oldval_moveSpeed = moveSpeed;
                    moveSpeed = stream.readUint16();

                    if (prop.isBase())
                    {
                        if (inited)
                        {
                            onMoveSpeedChanged(oldval_moveSpeed);
                        }
                    }
                    else
                    {
                        if (inWorld)
                        {
                            onMoveSpeedChanged(oldval_moveSpeed);
                        }
                    }

                    break;

                case 42003:
                    string oldval_name = name;
                    name = stream.readUnicode();

                    if (prop.isBase())
                    {
                        if (inited)
                        {
                            onNameChanged(oldval_name);
                        }
                    }
                    else
                    {
                        if (inWorld)
                        {
                            onNameChanged(oldval_name);
                        }
                    }

                    break;

                case 40000:
                    Vector3 oldval_position = position;
                    position = stream.readVector3();

                    if (prop.isBase())
                    {
                        if (inited)
                        {
                            onPositionChanged(oldval_position);
                        }
                    }
                    else
                    {
                        if (inWorld)
                        {
                            onPositionChanged(oldval_position);
                        }
                    }

                    break;

                case 40002:
                    stream.readUint32();
                    break;

                case 42008:
                    UInt32 oldval_spaceUType = spaceUType;
                    spaceUType = stream.readUint32();

                    if (prop.isBase())
                    {
                        if (inited)
                        {
                            onSpaceUTypeChanged(oldval_spaceUType);
                        }
                    }
                    else
                    {
                        if (inWorld)
                        {
                            onSpaceUTypeChanged(oldval_spaceUType);
                        }
                    }

                    break;

                case 44006:
                    SByte oldval_state = state;
                    state = stream.readInt8();

                    if (prop.isBase())
                    {
                        if (inited)
                        {
                            onStateChanged(oldval_state);
                        }
                    }
                    else
                    {
                        if (inWorld)
                        {
                            onStateChanged(oldval_state);
                        }
                    }

                    break;

                case 42004:
                    UInt32 oldval_uid = uid;
                    uid = stream.readUint32();

                    if (prop.isBase())
                    {
                        if (inited)
                        {
                            onUidChanged(oldval_uid);
                        }
                    }
                    else
                    {
                        if (inWorld)
                        {
                            onUidChanged(oldval_uid);
                        }
                    }

                    break;

                case 42005:
                    UInt32 oldval_utype = utype;
                    utype = stream.readUint32();

                    if (prop.isBase())
                    {
                        if (inited)
                        {
                            onUtypeChanged(oldval_utype);
                        }
                    }
                    else
                    {
                        if (inWorld)
                        {
                            onUtypeChanged(oldval_utype);
                        }
                    }

                    break;

                default:
                    break;
                }
                ;
            }
        }
	public static ulong ToUInt64(SByte value) {}
示例#42
0
        public override void callPropertysSetMethods()
        {
            ScriptModule sm = EntityDef.moduledefs["Avatar"];
            Dictionary <UInt16, Property> pdatas = sm.idpropertys;

            UInt32   oldval_Die_Count = Die_Count;
            Property prop_Die_Count   = pdatas[4];

            if (prop_Die_Count.isBase())
            {
                if (inited && !inWorld)
                {
                    onDie_CountChanged(oldval_Die_Count);
                }
            }
            else
            {
                if (inWorld)
                {
                    if (prop_Die_Count.isOwnerOnly() && !isPlayer())
                    {
                    }
                    else
                    {
                        onDie_CountChanged(oldval_Die_Count);
                    }
                }
            }

            Int32    oldval_EXP = EXP;
            Property prop_EXP   = pdatas[5];

            if (prop_EXP.isBase())
            {
                if (inited && !inWorld)
                {
                    onEXPChanged(oldval_EXP);
                }
            }
            else
            {
                if (inWorld)
                {
                    if (prop_EXP.isOwnerOnly() && !isPlayer())
                    {
                    }
                    else
                    {
                        onEXPChanged(oldval_EXP);
                    }
                }
            }

            Int32    oldval_EXP_Max = EXP_Max;
            Property prop_EXP_Max   = pdatas[6];

            if (prop_EXP_Max.isBase())
            {
                if (inited && !inWorld)
                {
                    onEXP_MaxChanged(oldval_EXP_Max);
                }
            }
            else
            {
                if (inWorld)
                {
                    if (prop_EXP_Max.isOwnerOnly() && !isPlayer())
                    {
                    }
                    else
                    {
                        onEXP_MaxChanged(oldval_EXP_Max);
                    }
                }
            }

            Int32    oldval_HP = HP;
            Property prop_HP   = pdatas[7];

            if (prop_HP.isBase())
            {
                if (inited && !inWorld)
                {
                    onHPChanged(oldval_HP);
                }
            }
            else
            {
                if (inWorld)
                {
                    if (prop_HP.isOwnerOnly() && !isPlayer())
                    {
                    }
                    else
                    {
                        onHPChanged(oldval_HP);
                    }
                }
            }

            Int32    oldval_HP_Max = HP_Max;
            Property prop_HP_Max   = pdatas[8];

            if (prop_HP_Max.isBase())
            {
                if (inited && !inWorld)
                {
                    onHP_MaxChanged(oldval_HP_Max);
                }
            }
            else
            {
                if (inWorld)
                {
                    if (prop_HP_Max.isOwnerOnly() && !isPlayer())
                    {
                    }
                    else
                    {
                        onHP_MaxChanged(oldval_HP_Max);
                    }
                }
            }

            UInt32   oldval_Kill_Count = Kill_Count;
            Property prop_Kill_Count   = pdatas[9];

            if (prop_Kill_Count.isBase())
            {
                if (inited && !inWorld)
                {
                    onKill_CountChanged(oldval_Kill_Count);
                }
            }
            else
            {
                if (inWorld)
                {
                    if (prop_Kill_Count.isOwnerOnly() && !isPlayer())
                    {
                    }
                    else
                    {
                        onKill_CountChanged(oldval_Kill_Count);
                    }
                }
            }

            Int32    oldval_MP = MP;
            Property prop_MP   = pdatas[10];

            if (prop_MP.isBase())
            {
                if (inited && !inWorld)
                {
                    onMPChanged(oldval_MP);
                }
            }
            else
            {
                if (inWorld)
                {
                    if (prop_MP.isOwnerOnly() && !isPlayer())
                    {
                    }
                    else
                    {
                        onMPChanged(oldval_MP);
                    }
                }
            }

            Int32    oldval_MP_Max = MP_Max;
            Property prop_MP_Max   = pdatas[11];

            if (prop_MP_Max.isBase())
            {
                if (inited && !inWorld)
                {
                    onMP_MaxChanged(oldval_MP_Max);
                }
            }
            else
            {
                if (inWorld)
                {
                    if (prop_MP_Max.isOwnerOnly() && !isPlayer())
                    {
                    }
                    else
                    {
                        onMP_MaxChanged(oldval_MP_Max);
                    }
                }
            }

            UInt32   oldval_Rank = Rank;
            Property prop_Rank   = pdatas[12];

            if (prop_Rank.isBase())
            {
                if (inited && !inWorld)
                {
                    onRankChanged(oldval_Rank);
                }
            }
            else
            {
                if (inWorld)
                {
                    if (prop_Rank.isOwnerOnly() && !isPlayer())
                    {
                    }
                    else
                    {
                        onRankChanged(oldval_Rank);
                    }
                }
            }

            Int32    oldval_Round = Round;
            Property prop_Round   = pdatas[13];

            if (prop_Round.isBase())
            {
                if (inited && !inWorld)
                {
                    onRoundChanged(oldval_Round);
                }
            }
            else
            {
                if (inWorld)
                {
                    if (prop_Round.isOwnerOnly() && !isPlayer())
                    {
                    }
                    else
                    {
                        onRoundChanged(oldval_Round);
                    }
                }
            }

            Int32    oldval_Round_Max = Round_Max;
            Property prop_Round_Max   = pdatas[14];

            if (prop_Round_Max.isBase())
            {
                if (inited && !inWorld)
                {
                    onRound_MaxChanged(oldval_Round_Max);
                }
            }
            else
            {
                if (inWorld)
                {
                    if (prop_Round_Max.isOwnerOnly() && !isPlayer())
                    {
                    }
                    else
                    {
                        onRound_MaxChanged(oldval_Round_Max);
                    }
                }
            }

            UInt32   oldval_Score = Score;
            Property prop_Score   = pdatas[15];

            if (prop_Score.isBase())
            {
                if (inited && !inWorld)
                {
                    onScoreChanged(oldval_Score);
                }
            }
            else
            {
                if (inWorld)
                {
                    if (prop_Score.isOwnerOnly() && !isPlayer())
                    {
                    }
                    else
                    {
                        onScoreChanged(oldval_Score);
                    }
                }
            }

            UInt16   oldval_cruiseSpeed = cruiseSpeed;
            Property prop_cruiseSpeed   = pdatas[16];

            if (prop_cruiseSpeed.isBase())
            {
                if (inited && !inWorld)
                {
                    onCruiseSpeedChanged(oldval_cruiseSpeed);
                }
            }
            else
            {
                if (inWorld)
                {
                    if (prop_cruiseSpeed.isOwnerOnly() && !isPlayer())
                    {
                    }
                    else
                    {
                        onCruiseSpeedChanged(oldval_cruiseSpeed);
                    }
                }
            }

            Vector3  oldval_direction = direction;
            Property prop_direction   = pdatas[2];

            if (prop_direction.isBase())
            {
                if (inited && !inWorld)
                {
                    onDirectionChanged(oldval_direction);
                }
            }
            else
            {
                if (inWorld)
                {
                    if (prop_direction.isOwnerOnly() && !isPlayer())
                    {
                    }
                    else
                    {
                        onDirectionChanged(oldval_direction);
                    }
                }
            }

            UInt16   oldval_level = level;
            Property prop_level   = pdatas[17];

            if (prop_level.isBase())
            {
                if (inited && !inWorld)
                {
                    onLevelChanged(oldval_level);
                }
            }
            else
            {
                if (inWorld)
                {
                    if (prop_level.isOwnerOnly() && !isPlayer())
                    {
                    }
                    else
                    {
                        onLevelChanged(oldval_level);
                    }
                }
            }

            UInt32   oldval_modelID = modelID;
            Property prop_modelID   = pdatas[18];

            if (prop_modelID.isBase())
            {
                if (inited && !inWorld)
                {
                    onModelIDChanged(oldval_modelID);
                }
            }
            else
            {
                if (inWorld)
                {
                    if (prop_modelID.isOwnerOnly() && !isPlayer())
                    {
                    }
                    else
                    {
                        onModelIDChanged(oldval_modelID);
                    }
                }
            }

            Byte     oldval_modelScale = modelScale;
            Property prop_modelScale   = pdatas[19];

            if (prop_modelScale.isBase())
            {
                if (inited && !inWorld)
                {
                    onModelScaleChanged(oldval_modelScale);
                }
            }
            else
            {
                if (inWorld)
                {
                    if (prop_modelScale.isOwnerOnly() && !isPlayer())
                    {
                    }
                    else
                    {
                        onModelScaleChanged(oldval_modelScale);
                    }
                }
            }

            UInt16   oldval_moveSpeed = moveSpeed;
            Property prop_moveSpeed   = pdatas[20];

            if (prop_moveSpeed.isBase())
            {
                if (inited && !inWorld)
                {
                    onMoveSpeedChanged(oldval_moveSpeed);
                }
            }
            else
            {
                if (inWorld)
                {
                    if (prop_moveSpeed.isOwnerOnly() && !isPlayer())
                    {
                    }
                    else
                    {
                        onMoveSpeedChanged(oldval_moveSpeed);
                    }
                }
            }

            string   oldval_name = name;
            Property prop_name   = pdatas[21];

            if (prop_name.isBase())
            {
                if (inited && !inWorld)
                {
                    onNameChanged(oldval_name);
                }
            }
            else
            {
                if (inWorld)
                {
                    if (prop_name.isOwnerOnly() && !isPlayer())
                    {
                    }
                    else
                    {
                        onNameChanged(oldval_name);
                    }
                }
            }

            Vector3  oldval_position = position;
            Property prop_position   = pdatas[1];

            if (prop_position.isBase())
            {
                if (inited && !inWorld)
                {
                    onPositionChanged(oldval_position);
                }
            }
            else
            {
                if (inWorld)
                {
                    if (prop_position.isOwnerOnly() && !isPlayer())
                    {
                    }
                    else
                    {
                        onPositionChanged(oldval_position);
                    }
                }
            }

            UInt32   oldval_spaceUType = spaceUType;
            Property prop_spaceUType   = pdatas[22];

            if (prop_spaceUType.isBase())
            {
                if (inited && !inWorld)
                {
                    onSpaceUTypeChanged(oldval_spaceUType);
                }
            }
            else
            {
                if (inWorld)
                {
                    if (prop_spaceUType.isOwnerOnly() && !isPlayer())
                    {
                    }
                    else
                    {
                        onSpaceUTypeChanged(oldval_spaceUType);
                    }
                }
            }

            SByte    oldval_state = state;
            Property prop_state   = pdatas[23];

            if (prop_state.isBase())
            {
                if (inited && !inWorld)
                {
                    onStateChanged(oldval_state);
                }
            }
            else
            {
                if (inWorld)
                {
                    if (prop_state.isOwnerOnly() && !isPlayer())
                    {
                    }
                    else
                    {
                        onStateChanged(oldval_state);
                    }
                }
            }

            UInt32   oldval_uid = uid;
            Property prop_uid   = pdatas[24];

            if (prop_uid.isBase())
            {
                if (inited && !inWorld)
                {
                    onUidChanged(oldval_uid);
                }
            }
            else
            {
                if (inWorld)
                {
                    if (prop_uid.isOwnerOnly() && !isPlayer())
                    {
                    }
                    else
                    {
                        onUidChanged(oldval_uid);
                    }
                }
            }

            UInt32   oldval_utype = utype;
            Property prop_utype   = pdatas[25];

            if (prop_utype.isBase())
            {
                if (inited && !inWorld)
                {
                    onUtypeChanged(oldval_utype);
                }
            }
            else
            {
                if (inWorld)
                {
                    if (prop_utype.isOwnerOnly() && !isPlayer())
                    {
                    }
                    else
                    {
                        onUtypeChanged(oldval_utype);
                    }
                }
            }
        }
	public static double ToDouble(SByte value) {}
示例#44
0
      public bool IsValidInitialValue(string typeName = null, string initialValue = null)
      {
         typeName = typeName ?? Type;
         initialValue = initialValue ?? InitialValue;

         if (string.IsNullOrEmpty(initialValue))
            return true;

         // ReSharper disable UnusedVariable
         switch (typeName)
         {
            case "Binary":
            case "Geography":
            case "GeographyCollection":
            case "GeographyLineString":
            case "GeographyMultiLineString":
            case "GeographyMultiPoint":
            case "GeographyMultiPolygon":
            case "GeographyPoint":
            case "GeographyPolygon":
            case "Geometry":
            case "GeometryCollection":
            case "GeometryLineString":
            case "GeometryMultiLineString":
            case "GeometryMultiPoint":
            case "GeometryMultiPolygon":
            case "GeometryPoint":
            case "GeometryPolygon":
            case "LineString":
            case "MultiLineString":
            case "MultiPoint":
            case "MultiPolygon":
            case "Point":
            case "Polygon":
               return false; //string.IsNullOrEmpty(initialValue);
            case "Boolean":
               return bool.TryParse(initialValue, out _);
            case "Byte":
               return byte.TryParse(initialValue, out _);
            case "DateTime":
               switch (initialValue?.Trim())
               {
                  case "DateTime.Now":
                  case "DateTime.UtcNow":
                  case "DateTime.MinValue":
                  case "DateTime.MaxValue":
                     return true;
                  default:
                     return DateTime.TryParse(initialValue, out _);
               }
            case "DateTimeOffset":
               return DateTimeOffset.TryParse(initialValue, out _);
            case "Decimal":
               return Decimal.TryParse(initialValue, out _);
            case "Double":
               return Double.TryParse(initialValue, out _);
            case "Guid":
               return Guid.TryParse(initialValue, out _);
            case "Int16":
               return Int16.TryParse(initialValue, out _);
            case "UInt16":
               return UInt16.TryParse(initialValue, out _);
            case "Int32":
               return Int32.TryParse(initialValue, out _);
            case "UInt32":
               return UInt32.TryParse(initialValue, out _);
            case "Int64":
               return Int64.TryParse(initialValue, out _);
            case "UInt64":
               return UInt64.TryParse(initialValue, out _);
            case "SByte":
               return SByte.TryParse(initialValue, out _);
            case "Single":
               return Single.TryParse(initialValue, out _);
            case "String":
               return true;
            case "Time":
               return DateTime.TryParseExact(initialValue,
                                             new[] { "HH:mm:ss", "H:mm:ss", "HH:mm", "H:mm", "HH:mm:ss tt", "H:mm:ss tt", "HH:mm tt", "H:mm tt" },
                                             CultureInfo.InvariantCulture,
                                             DateTimeStyles.None,
                                             out _);
            default:
               if (initialValue.Contains("."))
               {
                  string[] parts = initialValue.Split('.');
                  ModelEnum enumType = ModelClass.ModelRoot.Enums.FirstOrDefault(x => x.Name == parts[0]);
                  return enumType != null && parts.Length == 2 && enumType.Values.Any(x => x.Name == parts[1]);
               }

               break;
         }

         return false;
      }
	public static DateTime ToDateTime(SByte value) {}
        internal static object ConvertTo(this object value, Type toType, Func <object> getConverter,
                                         IServiceProvider serviceProvider, out Exception exception)
        {
            exception = null;
            if (value == null)
            {
                return(null);
            }

            if (value is string str)
            {
                //If there's a [TypeConverter], use it
                object converter;
                try {                 //minforetriver can fail
                    converter = getConverter?.Invoke();
                }
                catch (Exception e) {
                    exception = e;
                    return(null);
                }
                try {
                    if (converter is IExtendedTypeConverter xfExtendedTypeConverter)
                    {
                        return(xfExtendedTypeConverter.ConvertFromInvariantString(str, serviceProvider));
                    }
                    if (converter is TypeConverter xfTypeConverter)
                    {
                        return(xfTypeConverter.ConvertFromInvariantString(str));
                    }
                }
                catch (Exception e)
                {
                    exception = e as XamlParseException ?? new XamlParseException($"Type converter failed: {e.Message}", serviceProvider, e);
                    return(null);
                }
                var converterType = converter?.GetType();
                if (converterType != null)
                {
                    var convertFromStringInvariant = converterType.GetRuntimeMethod("ConvertFromInvariantString",
                                                                                    new[] { typeof(string) });
                    if (convertFromStringInvariant != null)
                    {
                        try {
                            return(convertFromStringInvariant.Invoke(converter, new object[] { str }));
                        }
                        catch (Exception e) {
                            exception = new XamlParseException("Type conversion failed", serviceProvider, e);
                            return(null);
                        }
                    }
                }
                var ignoreCase = (serviceProvider?.GetService(typeof(IConverterOptions)) as IConverterOptions)?.IgnoreCase ?? false;

                //If the type is nullable, as the value is not null, it's safe to assume we want the built-in conversion
                if (toType.GetTypeInfo().IsGenericType&& toType.GetGenericTypeDefinition() == typeof(Nullable <>))
                {
                    toType = Nullable.GetUnderlyingType(toType);
                }

                //Obvious Built-in conversions
                try {
                    if (toType.GetTypeInfo().IsEnum)
                    {
                        return(Enum.Parse(toType, str, ignoreCase));
                    }
                    if (toType == typeof(SByte))
                    {
                        return(SByte.Parse(str, CultureInfo.InvariantCulture));
                    }
                    if (toType == typeof(Int16))
                    {
                        return(Int16.Parse(str, CultureInfo.InvariantCulture));
                    }
                    if (toType == typeof(Int32))
                    {
                        return(Int32.Parse(str, CultureInfo.InvariantCulture));
                    }
                    if (toType == typeof(Int64))
                    {
                        return(Int64.Parse(str, CultureInfo.InvariantCulture));
                    }
                    if (toType == typeof(Byte))
                    {
                        return(Byte.Parse(str, CultureInfo.InvariantCulture));
                    }
                    if (toType == typeof(UInt16))
                    {
                        return(UInt16.Parse(str, CultureInfo.InvariantCulture));
                    }
                    if (toType == typeof(UInt32))
                    {
                        return(UInt32.Parse(str, CultureInfo.InvariantCulture));
                    }
                    if (toType == typeof(UInt64))
                    {
                        return(UInt64.Parse(str, CultureInfo.InvariantCulture));
                    }
                    if (toType == typeof(Single))
                    {
                        return(Single.Parse(str, CultureInfo.InvariantCulture));
                    }
                    if (toType == typeof(Double))
                    {
                        return(Double.Parse(str, CultureInfo.InvariantCulture));
                    }
                    if (toType == typeof(Boolean))
                    {
                        return(Boolean.Parse(str));
                    }
                    if (toType == typeof(TimeSpan))
                    {
                        return(TimeSpan.Parse(str, CultureInfo.InvariantCulture));
                    }
                    if (toType == typeof(DateTime))
                    {
                        return(DateTime.Parse(str, CultureInfo.InvariantCulture));
                    }
                    if (toType == typeof(Char))
                    {
                        Char.TryParse(str, out var c);
                        return(c);
                    }
                    if (toType == typeof(String) && str.StartsWith("{}", StringComparison.Ordinal))
                    {
                        return(str.Substring(2));
                    }
                    if (toType == typeof(String))
                    {
                        return(value);
                    }
                    if (toType == typeof(Decimal))
                    {
                        return(Decimal.Parse(str, CultureInfo.InvariantCulture));
                    }
                }
                catch (FormatException fe) {
                    exception = fe;
                    return(null);
                }
            }

            //if the value is not assignable and there's an implicit conversion, convert
            if (value != null && !toType.IsAssignableFrom(value.GetType()))
            {
                var opImplicit = value.GetType().GetImplicitConversionOperator(fromType: value.GetType(), toType: toType)
                                 ?? toType.GetImplicitConversionOperator(fromType: value.GetType(), toType: toType);

                if (opImplicit != null)
                {
                    value = opImplicit.Invoke(null, new[] { value });
                    return(value);
                }
            }

            var nativeValueConverterService = DependencyService.Get <INativeValueConverterService>();

            object nativeValue = null;

            if (nativeValueConverterService != null && nativeValueConverterService.ConvertTo(value, toType, out nativeValue))
            {
                return(nativeValue);
            }

            return(value);
        }
	public static char ToChar(SByte value) {}
示例#48
0
 public SByte?Map(string from, IObjectMapperResolver resolver)
 {
     return(SByte.TryParse(from, out var value)
         ? value
         : default(SByte?));
 }
        private static void VerifySByteImplicitCastToComplex(SByte value)
        {
            Complex c_cast = value;

            Support.VerifyRealImaginaryProperties(c_cast, value, 0.0,
                string.Format("SByteImplicitCast ({0})", value));
            
            if (value != SByte.MaxValue)
            {
                Complex c_cast_plus = c_cast + 1;
                Support.VerifyRealImaginaryProperties(c_cast_plus, value + 1, 0.0,
                    string.Format("PLuS + SByteImplicitCast ({0})", value));
            }

            if (value != SByte.MinValue)
            {
                Complex c_cast_minus = c_cast - 1;
                Support.VerifyRealImaginaryProperties(c_cast_minus, value - 1, 0.0,
                    string.Format("Minus - SByteImplicitCast + 1 ({0})", value));
            }
        }
示例#50
0
        /// <summary>
        /// Takes a property value returned from WMI and maps it to an
        /// appropriate managed code representation.
        /// </summary>
        /// <param name="wmiValue"> </param>
        /// <param name="type"> </param>
        /// <param name="isArray"> </param>
        internal static object MapWmiValueToValue(object wmiValue, CimType type, bool isArray)
        {
            object val = null;

            if ((System.DBNull.Value != wmiValue) && (null != wmiValue))
            {
                if (isArray)
                {
                    Array wmiValueArray = (Array)wmiValue;
                    int   length        = wmiValueArray.Length;

                    switch (type)
                    {
                    case CimType.UInt16:
                        val = new UInt16 [length];

                        for (int i = 0; i < length; i++)
                        {
                            ((UInt16[])val) [i] = (UInt16)((Int32)(wmiValueArray.GetValue(i)));
                        }
                        break;

                    case CimType.UInt32:
                        val = new UInt32 [length];

                        for (int i = 0; i < length; i++)
                        {
                            ((UInt32[])val)[i] = (UInt32)((Int32)(wmiValueArray.GetValue(i)));
                        }
                        break;

                    case CimType.UInt64:
                        val = new UInt64 [length];

                        for (int i = 0; i < length; i++)
                        {
                            ((UInt64[])val) [i] = Convert.ToUInt64((String)(wmiValueArray.GetValue(i)), (IFormatProvider)CultureInfo.CurrentCulture.GetFormat(typeof(System.UInt64)));
                        }
                        break;

                    case CimType.SInt8:
                        val = new SByte [length];

                        for (int i = 0; i < length; i++)
                        {
                            ((SByte[])val) [i] = (SByte)((Int16)(wmiValueArray.GetValue(i)));
                        }
                        break;

                    case CimType.SInt64:
                        val = new Int64 [length];

                        for (int i = 0; i < length; i++)
                        {
                            ((Int64[])val) [i] = Convert.ToInt64((String)(wmiValueArray.GetValue(i)), (IFormatProvider)CultureInfo.CurrentCulture.GetFormat(typeof(System.Int64)));
                        }
                        break;

                    case CimType.Char16:
                        val = new Char [length];

                        for (int i = 0; i < length; i++)
                        {
                            ((Char[])val) [i] = (Char)((Int16)(wmiValueArray.GetValue(i)));
                        }
                        break;

                    case CimType.Object:
                        val = new ManagementBaseObject [length];

                        for (int i = 0; i < length; i++)
                        {
                            ((ManagementBaseObject[])val) [i] = new ManagementBaseObject(new IWbemClassObjectFreeThreaded(Marshal.GetIUnknownForObject(wmiValueArray.GetValue(i))));
                        }
                        break;

                    default:
                        val = wmiValue;
                        break;
                    }
                }
                else
                {
                    switch (type)
                    {
                    case CimType.SInt8:
                        val = (SByte)((Int16)wmiValue);
                        break;

                    case CimType.UInt16:
                        val = (UInt16)((Int32)wmiValue);
                        break;

                    case CimType.UInt32:
                        val = (UInt32)((Int32)wmiValue);
                        break;

                    case CimType.UInt64:
                        val = Convert.ToUInt64((String)wmiValue, (IFormatProvider)CultureInfo.CurrentCulture.GetFormat(typeof(System.UInt64)));
                        break;

                    case CimType.SInt64:
                        val = Convert.ToInt64((String)wmiValue, (IFormatProvider)CultureInfo.CurrentCulture.GetFormat(typeof(System.Int64)));
                        break;

                    case CimType.Char16:
                        val = (Char)((Int16)wmiValue);
                        break;

                    case CimType.Object:
                        val = new ManagementBaseObject(new IWbemClassObjectFreeThreaded(Marshal.GetIUnknownForObject(wmiValue)));
                        break;

                    default:
                        val = wmiValue;
                        break;
                    }
                }
            }

            return(val);
        }
示例#51
0
 private static void VerifySByteExplicitCastFromBigInteger(SByte value, BigInteger bigInteger)
 {
     Assert.Equal(value, (SByte)bigInteger);
 }
示例#52
0
 //---------------------------------------------------------------------------------
 public void writeInt8(SByte v)
 {
     datas_[wpos++] = (Byte)v;
 }
示例#53
0
        private static void VerifySByteImplicitCastToBigInteger(SByte value)
        {
            BigInteger bigInteger = value;

            Assert.Equal(value, bigInteger);
            Assert.Equal(value.ToString(), bigInteger.ToString());
            Assert.Equal(value, (SByte)bigInteger);

            if (value != SByte.MaxValue)
            {
                Assert.Equal((SByte)(value + 1), (SByte)(bigInteger + 1));
            }

            if (value != SByte.MinValue)
            {
                Assert.Equal((SByte)(value - 1), (SByte)(bigInteger - 1));
            }

            VerifyBigIntegerUsingIdentities(bigInteger, 0 == value);
        }
示例#54
0
        /// <summary>尝试读取</summary>
        /// <param name="type"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override Boolean TryRead(Type type, ref Object value)
        {
            if (type == null)
            {
                if (value == null)
                {
                    return(false);
                }
                type = value.GetType();
            }

            var reader = Host.GetReader();

            if (type == typeof(Guid))
            {
                value = new Guid(reader.ReadElementContentAsString());
                return(true);
            }
            else if (type == typeof(Byte[]))
            {
                // 用字符串长度作为预设缓冲区的长度
                var buf   = new Byte[reader.Value.Length];
                var count = reader.ReadElementContentAsBase64(buf, 0, buf.Length);
                value = buf.ReadBytes(0, count);
                return(true);
            }
            else if (type == typeof(Char[]))
            {
                value = reader.ReadElementContentAsString().ToCharArray();
                return(true);
            }
            else if (type == typeof(DateTimeOffset))
            {
                value = reader.ReadElementContentAs(type, null);
                return(true);
            }
            else if (type == typeof(TimeSpan))
            {
                value = reader.ReadElementContentAs(type, null);
                return(true);
            }

            var code = Type.GetTypeCode(type);

            if (code == TypeCode.Object)
            {
                return(false);
            }

            var v = reader.ReadElementContentAsString() + "";

            // 枚举
            if (type.IsEnum)
            {
                value = Enum.Parse(type, v);
                return(true);
            }

            switch (code)
            {
            case TypeCode.Boolean:
                value = v.ToBoolean();
                return(true);

            case TypeCode.Byte:
                value = Byte.Parse(v, NumberStyles.HexNumber);
                return(true);

            case TypeCode.Char:
                if (v.Length > 0)
                {
                    value = v[0];
                }
                return(true);

            case TypeCode.DBNull:
                value = DBNull.Value;
                return(true);

            case TypeCode.DateTime:
                value = v.ToDateTime();
                return(true);

            case TypeCode.Decimal:
                value = (Decimal)v.ToDouble();
                return(true);

            case TypeCode.Double:
                value = v.ToDouble();
                return(true);

            case TypeCode.Empty:
                value = null;
                return(true);

            case TypeCode.Int16:
                value = (Int16)v.ToInt();
                return(true);

            case TypeCode.Int32:
                value = v.ToInt();
                return(true);

            case TypeCode.Int64:
                value = Int64.Parse(v);
                return(true);

            case TypeCode.Object:
                break;

            case TypeCode.SByte:
                value = SByte.Parse(v, NumberStyles.HexNumber);
                return(true);

            case TypeCode.Single:
                value = (Single)v.ToDouble();
                return(true);

            case TypeCode.String:
                value = v;
                return(true);

            case TypeCode.UInt16:
                value = (UInt16)v.ToInt();
                return(true);

            case TypeCode.UInt32:
                value = (UInt32)v.ToInt();
                return(true);

            case TypeCode.UInt64:
                value = UInt64.Parse(v);
                return(true);

            default:
                break;
            }

            return(false);
        }
示例#55
0
 public ScanResponseEventArgs(SByte rssi, Byte packet_type, Byte[] sender, Byte address_type, Byte bond, Byte[] data)
 {
     this.rssi = rssi;
     this.packet_type = packet_type;
     this.sender = sender;
     this.address_type = address_type;
     this.bond = bond;
     this.data = data;
 }
示例#56
0
 INT8(SByte value)
 {
     this.value = value;
 }
示例#57
0
 public static string ToString(SByte value)
 {
     return value.ToString(null, NumberFormatInfo.InvariantInfo);
 }
	public static object ToObject(Type enumType, SByte value) {}
示例#59
0
 public int CompareTo(SByte value)
 {
     if (_value < value) return -1;
     else if (_value > value) return 1;
     return 0;
 }
示例#60
0
        /// 尝试解析字符串
        /// </summary>
        /// <param name="type">所要解析成的类型</param>
        /// <param name="value">字符串</param>
        /// <param name="result">解析结果,解析失败将返回null</param>
        /// <returns>解析失败将返回具体错误消息,否则将返回null,解析结果通过result获得</returns>
        public static bool TryParse(Type type, string value, out object result)
        {
            if (value == null)
            {
                result = null;

                return(false);
            }

            bool   succeed     = false;
            object parsedValue = null;

            bool isNullable = type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable <>);

            if (isNullable)
            {
                type = type.GetGenericArguments()[0];
            }

            if (type.IsEnum)
            {
                try
                {
                    parsedValue = Enum.Parse(type, value, true);
                    succeed     = true;
                }
                catch
                {
                }
            }
            else if (type == typeof(Guid))
            {
                //TODO:此处需要改善性能

                try
                {
                    parsedValue = new Guid(value);
                    succeed     = true;
                }
                catch
                {
                }
            }
            else
            {
                TypeCode typeCode = Type.GetTypeCode(type);

                switch (typeCode)
                {
                case TypeCode.String:
                    parsedValue = value;
                    succeed     = true;
                    break;

                case TypeCode.Boolean:
                {
                    if (value == "1")
                    {
                        parsedValue = true;
                        succeed     = true;
                    }
                    else if (value == "0")
                    {
                        parsedValue = false;
                        succeed     = true;
                    }
                    else
                    {
                        Boolean temp;
                        succeed = Boolean.TryParse(value, out temp);

                        if (succeed)
                        {
                            parsedValue = temp;
                        }
                    }
                }
                break;

                case TypeCode.Byte:
                {
                    Byte temp;
                    succeed = Byte.TryParse(value, out temp);

                    if (succeed)
                    {
                        parsedValue = temp;
                    }
                }
                break;

                case TypeCode.Decimal:
                {
                    Decimal temp;
                    succeed = Decimal.TryParse(value, out temp);

                    if (succeed)
                    {
                        parsedValue = temp;
                    }
                }
                break;

                case TypeCode.Double:
                {
                    Double temp;
                    succeed = Double.TryParse(value, out temp);

                    if (succeed)
                    {
                        parsedValue = temp;
                    }
                }
                break;

                case TypeCode.Int16:
                {
                    Int16 temp;
                    succeed = Int16.TryParse(value, out temp);

                    if (succeed)
                    {
                        parsedValue = temp;
                    }
                }
                break;

                case TypeCode.Int32:
                {
                    Int32 temp;
                    succeed = Int32.TryParse(value, out temp);

                    if (succeed)
                    {
                        parsedValue = temp;
                    }
                }
                break;

                case TypeCode.Int64:
                {
                    Int64 temp;
                    succeed = Int64.TryParse(value, out temp);

                    if (succeed)
                    {
                        parsedValue = temp;
                    }
                }
                break;

                case TypeCode.SByte:
                {
                    SByte temp;
                    succeed = SByte.TryParse(value, out temp);

                    if (succeed)
                    {
                        parsedValue = temp;
                    }
                }
                break;

                case TypeCode.Single:
                {
                    Single temp;
                    succeed = Single.TryParse(value, out temp);

                    if (succeed)
                    {
                        parsedValue = temp;
                    }
                }
                break;

                case TypeCode.UInt16:
                {
                    UInt16 temp;
                    succeed = UInt16.TryParse(value, out temp);

                    if (succeed)
                    {
                        parsedValue = temp;
                    }
                }
                break;

                case TypeCode.UInt32:
                {
                    UInt32 temp;
                    succeed = UInt32.TryParse(value, out temp);

                    if (succeed)
                    {
                        parsedValue = temp;
                    }
                }
                break;

                case TypeCode.UInt64:
                {
                    UInt64 temp;
                    succeed = UInt64.TryParse(value, out temp);

                    if (succeed)
                    {
                        parsedValue = temp;
                    }
                }
                break;

                case TypeCode.DateTime:
                {
                    DateTime temp;
                    succeed = DateTime.TryParse(value, out temp);
                    if (succeed)
                    {
                        parsedValue = temp;
                    }
                }
                break;
                }
            }

            result = parsedValue;

            return(succeed);
        }