コード例 #1
0
        protected void OnPropertyChanged(string proName)
        {
            if (mHostPlayer == null)
            {
                return;
            }
            var proInfo = this.GetType().GetProperty(proName);

            if (proInfo == null)
            {
                return;
            }

            RPC.PackageWriter pkg = new RPC.PackageWriter();

            RPC.DataWriter dw = new RPC.DataWriter();
            if (proInfo.PropertyType == typeof(Byte))
            {
                dw.Write(System.Convert.ToByte(proInfo.GetValue(this, null)));
            }
            else if (proInfo.PropertyType == typeof(UInt16))
            {
                dw.Write(System.Convert.ToUInt16(proInfo.GetValue(this, null)));
            }
            else if (proInfo.PropertyType == typeof(UInt32))
            {
                dw.Write(System.Convert.ToUInt32(proInfo.GetValue(this, null)));
            }
            else if (proInfo.PropertyType == typeof(UInt64))
            {
                dw.Write(System.Convert.ToUInt64(proInfo.GetValue(this, null)));
            }
            else if (proInfo.PropertyType == typeof(SByte))
            {
                dw.Write(System.Convert.ToSByte(proInfo.GetValue(this, null)));
            }
            else if (proInfo.PropertyType == typeof(Int16))
            {
                dw.Write(System.Convert.ToInt16(proInfo.GetValue(this, null)));
            }
            else if (proInfo.PropertyType == typeof(Int32))
            {
                dw.Write(System.Convert.ToInt32(proInfo.GetValue(this, null)));
            }
            else if (proInfo.PropertyType == typeof(Int64))
            {
                dw.Write(System.Convert.ToInt64(proInfo.GetValue(this, null)));
            }
            else if (proInfo.PropertyType == typeof(float))
            {
                dw.Write(System.Convert.ToSingle(proInfo.GetValue(this, null)));
            }
            else if (proInfo.PropertyType == typeof(double))
            {
                dw.Write(System.Convert.ToDouble(proInfo.GetValue(this, null)));
            }
            else if (proInfo.PropertyType == typeof(System.Guid))
            {
                dw.Write(System.Guid.Parse(proInfo.GetValue(this, null).ToString()));
            }
            else
            {
                return;
            }

            mHostPlayer.OnValueChanged(proName, dw);
        }