コード例 #1
0
 static Converter()
 {
     BoolConverter.Initialize();
     CharConverter.Initialize();
     ByteConverter.Initialize();
     SByteConverter.Initialize();
     Int16Converter.Initialize();
     UInt16Converter.Initialize();
     Int32Converter.Initialize();
     UInt32Converter.Initialize();
     Int64Converter.Initialize();
     UInt64Converter.Initialize();
     SingleConverter.Initialize();
     DoubleConverter.Initialize();
     DecimalConverter.Initialize();
     BigIntegerConverter.Initialize();
     BytesConverter.Initialize();
     CharsConverter.Initialize();
     StringConverter.Initialize();
     StringBuilderConverter.Initialize();
     DateTimeConverter.Initialize();
     TimeSpanConverter.Initialize();
     GuidConverter.Initialize();
     MemoryStreamConverter.Initialize();
     StreamConverter.Initialize();
 }
コード例 #2
0
        public StbTextBox(List <string> parts, string[] lines) : this
            (
                1,
                parts[0] == "textentrylimited" ? int.Parse(parts[8]) : byte.MaxValue,
                int.Parse(parts[3]),
                style : FontStyle.BlackBorder | FontStyle.CropTexture,
                hue : (ushort)(UInt16Converter.Parse(parts[5]) + 1)
            )
        {
            X            = int.Parse(parts[1]);
            Y            = int.Parse(parts[2]);
            Width        = _rendererText.MaxWidth; //int.Parse(parts[3]);
            Height       = _rendererText.MaxHeight = int.Parse(parts[4]);
            Multiline    = false;
            _fromServer  = true;
            LocalSerial  = SerialHelper.Parse(parts[6]);
            IsFromServer = true;

            int index = int.Parse(parts[7]);

            if (index >= 0 && index < lines.Length)
            {
                SetText(lines[index]);
            }
        }
コード例 #3
0
ファイル: ResizePic.cs プロジェクト: dissident76/ClassicUO
 public ResizePic(List <string> parts) : this(UInt16Converter.Parse(parts[3]))
 {
     X      = int.Parse(parts[1]);
     Y      = int.Parse(parts[2]);
     Width  = int.Parse(parts[4]);
     Height = int.Parse(parts[5]);
 }
コード例 #4
0
 public StaticPic(List <string> parts) : this
     (UInt16Converter.Parse(parts[3]), parts.Count > 4 ? UInt16Converter.Parse(parts[4]) : (ushort)0)
 {
     X            = int.Parse(parts[1]);
     Y            = int.Parse(parts[2]);
     IsFromServer = true;
 }
コード例 #5
0
        public void PropertiesTest()
        {
            var converter = new UInt16Converter();

            Assert.AreEqual(true, converter.AcceptsNativeType);
            Assert.AreEqual(typeof(ushort), converter.ConvertedType);
        }
コード例 #6
0
    public void ShouldThrowExceptionIfDataIndexIsOutOfRange()
    {
      var converter = new UInt16Converter();

      var action = new Action(() => converter.ConvertBack(new byte[] {0x01, 0x02}, 1));

      action.Should().Throw<ArgumentException>();
    }
コード例 #7
0
 public GumpPicTiled(List <string> parts) : this(UInt16Converter.Parse(parts[5]))
 {
     X            = int.Parse(parts[1]);
     Y            = int.Parse(parts[2]);
     Width        = int.Parse(parts[3]);
     Height       = int.Parse(parts[4]);
     IsFromServer = true;
 }
コード例 #8
0
    public void ShouldReturnDataValueAndNextDataIndex()
    {
      var converter = new UInt16Converter();

      var (dataValue, nextDataIndex) = converter.ConvertBack(new byte[] {0x55, 0x03, 0x00}, 1);

      dataValue.Should().Be(3);
      nextDataIndex.Should().Be(0x03);
    }
コード例 #9
0
        /// <summary>
        /// Extends ConvertTo so that methods that return a specific type object given a Type parameter can be
        /// used as generic method and casting is not required.
        /// <example>
        /// typeconverter.ConvertTo<int>(value);
        /// </example>
        /// </summary>
        public static T ConvertTo <T>(this UInt16Converter typeconverter, Object value)
        {
            if (typeconverter == null)
            {
                throw new ArgumentNullException("typeconverter");
            }

            return((T)typeconverter.ConvertTo(value, typeof(T)));
        }
コード例 #10
0
        /// <summary>
        /// Extends ConvertTo so that methods that return a specific type object given a Type parameter can be
        /// used as generic method and casting is not required.
        /// <example>
        /// basenumberconverter.ConvertTo<int>(context, culture, value);
        /// </example>
        /// </summary>
        public static T ConvertTo <T>(this UInt16Converter basenumberconverter, ITypeDescriptorContext context, System.Globalization.CultureInfo culture, Object value)
        {
            if (basenumberconverter == null)
            {
                throw new ArgumentNullException("basenumberconverter");
            }

            return((T)basenumberconverter.ConvertTo(context, culture, value, typeof(T)));
        }
コード例 #11
0
        public void ShouldReturnByteArray()
        {
            var          converter = new UInt16Converter();
            const ushort data      = 3;

            var bytes = converter.Convert(data).ToArray();

            bytes.Should().HaveCount(2);
            bytes[0].Should().Be(0x03);
            bytes[1].Should().Be(0x00);
        }
コード例 #12
0
ファイル: Label.cs プロジェクト: seand88/ClassicUO
 public Label(List <string> parts, string[] lines) : this
     (
         int.TryParse(parts[4], out int lineIndex) && lineIndex >= 0 && lineIndex < lines.Length ?
         lines[lineIndex] :
         string.Empty, true, (ushort)(UInt16Converter.Parse(parts[3]) + 1), 0, style : FontStyle.BlackBorder
     )
 {
     X            = int.Parse(parts[1]);
     Y            = int.Parse(parts[2]);
     IsFromServer = true;
 }
コード例 #13
0
 public CroppedText(List <string> parts, string[] lines) : this
     (
         int.TryParse(parts[6], out int lineIndex) && lineIndex >= 0 && lineIndex < lines.Length ?
         lines[lineIndex] :
         string.Empty, (ushort)(UInt16Converter.Parse(parts[5]) + 1), int.Parse(parts[3])
     )
 {
     X            = int.Parse(parts[1]);
     Y            = int.Parse(parts[2]);
     Width        = int.Parse(parts[3]);
     Height       = int.Parse(parts[4]);
     IsFromServer = true;
 }
コード例 #14
0
ファイル: JsonFxAOT.cs プロジェクト: davidstl/examples-csharp
        private JsonFxAOT()
        {
            TypeConverter c;

            c          = new ArrayConverter();
            m_fakeFlag = c.Equals(c);
            //c = new BaseNumberConverter();
            //m_fakeFlag = c.Equals(c);
            c          = new BooleanConverter();
            m_fakeFlag = c.Equals(c);
            c          = new ByteConverter();
            m_fakeFlag = c.Equals(c);
            c          = new CollectionConverter();
            m_fakeFlag = c.Equals(c);
            c          = new ComponentConverter(typeof(int));
            m_fakeFlag = c.Equals(c);
            c          = new CultureInfoConverter();
            m_fakeFlag = c.Equals(c);
            c          = new DateTimeConverter();
            m_fakeFlag = c.Equals(c);
            c          = new DecimalConverter();
            m_fakeFlag = c.Equals(c);
            c          = new DoubleConverter();
            m_fakeFlag = c.Equals(c);
            c          = new EnumConverter(typeof(int));
            m_fakeFlag = c.Equals(c);
            c          = new ExpandableObjectConverter();
            m_fakeFlag = c.Equals(c);
            c          = new Int16Converter();
            m_fakeFlag = c.Equals(c);
            c          = new Int32Converter();
            m_fakeFlag = c.Equals(c);
            c          = new Int64Converter();
            m_fakeFlag = c.Equals(c);
            c          = new NullableConverter(typeof(object));
            m_fakeFlag = c.Equals(c);
            c          = new SByteConverter();
            m_fakeFlag = c.Equals(c);
            c          = new SingleConverter();
            m_fakeFlag = c.Equals(c);
            c          = new StringConverter();
            m_fakeFlag = c.Equals(c);
            c          = new TimeSpanConverter();
            m_fakeFlag = c.Equals(c);
            c          = new UInt16Converter();
            m_fakeFlag = c.Equals(c);
            c          = new UInt32Converter();
            m_fakeFlag = c.Equals(c);
            c          = new UInt64Converter();
            m_fakeFlag = c.Equals(c);
        }
コード例 #15
0
    public static string _________________________(string a, string b, string c, string d, string e)
    {
        string _________ = null;

        char[]   _  = MessageDigest_Algorithm.getMd5Hash(a + b + c + d + e).ToCharArray();
        UInt16[] __ = new UInt16[8];

        for (int ____________ = 0; ____________ < 8; ++____________)
        {
            StringBuilder ___ = new StringBuilder();
            ___.Append(_[____________ * 4]).Append(_[____________ * 4 + 1]).Append(_[____________ * 4 + 2]).Append(_[____________ * 4 + 3]);
            UInt16 ___________ = UInt16.Parse(___.ToString(), System.Globalization.NumberStyles.HexNumber);
            __[____________] = ___________;
        }

        char[] ____ = new char[________________];
        for (int ____________ = 0; ____________ < ________________; ++____________)
        {
            int _____________ = NetRandom.Instance.Next(16);

            ____[____________] = ______________[_____________];
        }

        string _____ = Convert.ToString(____[_________________ - 1]) + Convert.ToString(____[__________________ - 1]) + Convert.ToString(____[___________________ - 1])
                       + Convert.ToString(____[____________________ - 1]);

        UInt16 ______ = UInt16.Parse(_____, System.Globalization.NumberStyles.HexNumber);

        UInt16 _______ = 0;

        foreach (UInt16 __________ in __)
        {
            unchecked {
                _______ = (UInt16)(_______ + (__________ ^ ______));
            };
        }


        UInt16Converter ________ = _______;

        ____[_____________________ - 1]    = _______________[________.__________________________].ToCharArray()[0];
        ____[______________________ - 1]   = _______________[________.__________________________].ToCharArray()[1];
        ____[_______________________ - 1]  = _______________[________._________________________].ToCharArray()[0];
        ____[________________________ - 1] = _______________[________._________________________].ToCharArray()[1];

        _________ = new string(____);
        return(_________);
    }
コード例 #16
0
        public Button(List <string> parts) : this
            (
                parts.Count >= 8 ? int.Parse(parts[7]) : 0, UInt16Converter.Parse(parts[3]), UInt16Converter.Parse(parts[4])
            )
        {
            X = int.Parse(parts[1]);
            Y = int.Parse(parts[2]);

            if (parts.Count >= 6)
            {
                int action = int.Parse(parts[5]);

                ButtonAction = action == 0 ? ButtonAction.SwitchPage : ButtonAction.Activate;
            }

            ToPage           = parts.Count >= 7 ? int.Parse(parts[6]) : 0;
            WantUpdateSize   = false;
            ContainsByBounds = true;
            IsFromServer     = true;
        }
コード例 #17
0
        public void ConvertFromExcelTest()
        {
            var converter            = new UInt16Converter();
            var typeConverterOptions = new TypeConverterOptions {
                CultureInfo = CultureInfo.CurrentCulture
            };

            Assert.AreEqual((ushort)123, converter.ConvertFromExcel(typeConverterOptions, (double)123));
            Assert.AreEqual((ushort)123, converter.ConvertFromExcel(typeConverterOptions, "123"));
            Assert.AreEqual((ushort)123, converter.ConvertFromExcel(typeConverterOptions, " 123 "));
            Assert.AreEqual((ushort)0, converter.ConvertFromExcel(typeConverterOptions, null));

            typeConverterOptions.NumberStyle = NumberStyles.HexNumber;
            Assert.AreEqual((ushort)0x123, converter.ConvertFromExcel(typeConverterOptions, "123"));

            try {
                converter.ConvertFromExcel(typeConverterOptions, "");
                Assert.Fail();
            } catch (ExcelTypeConverterException) {
            }
        }
コード例 #18
0
        public ButtonTileArt(List <string> gparams) :
            base(gparams)
        {
            X = int.Parse(gparams[1]);
            Y = int.Parse(gparams[2]);
            ushort graphic = UInt16Converter.Parse(gparams[8]);

            _hue             = UInt16Converter.Parse(gparams[9]);
            _tileX           = int.Parse(gparams[10]);
            _tileY           = int.Parse(gparams[11]);
            ContainsByBounds = true;
            IsFromServer     = true;
            _texture         = ArtLoader.Instance.GetTexture(graphic);

            if (_texture == null)
            {
                Dispose();
                return;
            }

            _isPartial = TileDataLoader.Instance.StaticData[graphic].IsPartialHue;
        }
コード例 #19
0
 public void SetUp()
 {
     converter = new UInt16Converter();
 }
コード例 #20
0
        public TextBox(List <string> parts, string[] lines) : this(1, parts[0] == "textentrylimited" ? int.Parse(parts[8]) : byte.MaxValue, 0, int.Parse(parts[3]), style : FontStyle.BlackBorder | FontStyle.CropTexture, hue : (ushort)(UInt16Converter.Parse(parts[5]) + 1))
        {
            X           = int.Parse(parts[1]);
            Y           = int.Parse(parts[2]);
            Width       = int.Parse(parts[3]);
            Height      = int.Parse(parts[4]);
            LocalSerial = SerialHelper.Parse(parts[6]);
            TxEntry.SetHeight(Height);

            int index = int.Parse(parts[7]);

            if (index >= 0 && index < lines.Length)
            {
                SetText(lines[index]);
            }
        }
コード例 #21
0
        private static TypeConverter GetCoreConverterFromCoreType(Type type)
        {
            TypeConverter result = null;

            if (type == typeof(int))
            {
                result = new Int32Converter();
            }
            else if (type == typeof(short))
            {
                result = new Int16Converter();
            }
            else if (type == typeof(long))
            {
                result = new Int64Converter();
            }
            else if (type == typeof(uint))
            {
                result = new UInt32Converter();
            }
            else if (type == typeof(ushort))
            {
                result = new UInt16Converter();
            }
            else if (type == typeof(ulong))
            {
                result = new UInt64Converter();
            }
            else if (type == typeof(bool))
            {
                result = new BooleanConverter();
            }
            else if (type == typeof(double))
            {
                result = new DoubleConverter();
            }
            else if (type == typeof(float))
            {
                result = new SingleConverter();
            }
            else if (type == typeof(byte))
            {
                result = new ByteConverter();
            }
            else if (type == typeof(sbyte))
            {
                result = new SByteConverter();
            }
            else if (type == typeof(char))
            {
                result = new CharConverter();
            }
            else if (type == typeof(decimal))
            {
                result = new DecimalConverter();
            }
            else if (type == typeof(TimeSpan))
            {
                result = new TimeSpanConverter();
            }
            else if (type == typeof(Guid))
            {
                result = new GuidConverter();
            }
            else if (type == typeof(string))
            {
                result = new StringConverter();
            }
            else if (type == typeof(CultureInfo))
            {
                result = new CultureInfoConverter();
            }
            else if (type == typeof(Type))
            {
                result = new TypeTypeConverter();
            }
            else if (type == typeof(DateTime))
            {
                result = new DateTimeConverter2();
            }
            else if (ReflectionHelper.IsNullableType(type))
            {
                result = new NullableConverter(type);
            }
            return(result);
        }
コード例 #22
0
        internal static TypeConverter GetCoreConverterFromCustomType(Type type)
        {
            TypeConverter result = null;

            if (type.IsEnum)
            {
                result = new EnumConverter(type);
            }
            else if (typeof(int).IsAssignableFrom(type))
            {
                result = new Int32Converter();
            }
            else if (typeof(short).IsAssignableFrom(type))
            {
                result = new Int16Converter();
            }
            else if (typeof(long).IsAssignableFrom(type))
            {
                result = new Int64Converter();
            }
            else if (typeof(uint).IsAssignableFrom(type))
            {
                result = new UInt32Converter();
            }
            else if (typeof(ushort).IsAssignableFrom(type))
            {
                result = new UInt16Converter();
            }
            else if (typeof(ulong).IsAssignableFrom(type))
            {
                result = new UInt64Converter();
            }
            else if (typeof(bool).IsAssignableFrom(type))
            {
                result = new BooleanConverter();
            }
            else if (typeof(double).IsAssignableFrom(type))
            {
                result = new DoubleConverter();
            }
            else if (typeof(float).IsAssignableFrom(type))
            {
                result = new SingleConverter();
            }
            else if (typeof(byte).IsAssignableFrom(type))
            {
                result = new ByteConverter();
            }
            else if (typeof(sbyte).IsAssignableFrom(type))
            {
                result = new SByteConverter();
            }
            else if (typeof(char).IsAssignableFrom(type))
            {
                result = new CharConverter();
            }
            else if (typeof(decimal).IsAssignableFrom(type))
            {
                result = new DecimalConverter();
            }
            else if (typeof(TimeSpan).IsAssignableFrom(type))
            {
                result = new TimeSpanConverter();
            }
            else if (typeof(Guid).IsAssignableFrom(type))
            {
                result = new GuidConverter();
            }
            else if (typeof(string).IsAssignableFrom(type))
            {
                result = new StringConverter();
            }
            else if (typeof(CultureInfo).IsAssignableFrom(type))
            {
                result = new CultureInfoConverter();
            }
            else if (typeof(Type).IsAssignableFrom(type))
            {
                result = new TypeTypeConverter();
            }
            else if (typeof(DateTime).IsAssignableFrom(type))
            {
                result = new DateTimeConverter2();
            }
            return(result);
        }