Ejemplo n.º 1
0
            /// <summary>
            /// コンストラクタ
            /// </summary>
            public NeedAckInfo(PbConnection connection, DataId dataId,
                               PbSendData sendData, TimeSpan timeout)
            {
                DataId   = dataId;
                SendData = sendData;
                Timeout  = timeout;

                this.connection = connection;
                this.timer      = new Timer(
                    Timer_Callback,
                    null,
                    timeout,
                    TimeSpan.FromMilliseconds(-1));
            }
Ejemplo n.º 2
0
        /// <summary>
        /// 準備したデータをシリアライズします。
        /// </summary>
        private void Serialize()
        {
            if (Data == null)
            {
                throw new PbException("Dataがnullです。");
            }

            SerializedData = PbUtil.Serialize(Data, Data.GetType());

            // 型名はPbConnectionでエンコードします。
            TypeName        = TypeSerializer.Serialize(Data.GetType());
            EncodedTypeName = PbConnection.EncodeTypeName(TypeName);
            EncodedTypeData = Encoding.UTF8.GetBytes(EncodedTypeName);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// オブジェクトのプロパティ変更通知を送信します。
        /// </summary>
        public static void SendObjectChangedCommand(
            this PbConnection connection,
            string objectName, string propertyName,
            Type propertyType, object propertyValue)
        {
            if (string.IsNullOrEmpty(objectName))
            {
                throw new ArgumentNullException("objectName");
            }

            if (string.IsNullOrEmpty(propertyName))
            {
                throw new ArgumentNullException("propertyName");
            }

            if (propertyType == null)
            {
                throw new ArgumentNullException("propertyType");
            }

            if (propertyValue == null)
            {
                throw new ArgumentNullException("propertyValue");
            }

            var command = new PbPropertyChanged()
            {
                ObjectId      = objectName,
                PropertyName  = propertyName,
                PropertyType  = propertyType,
                PropertyValue = propertyValue,
            };

            // プロパティ値をデシリアライズします。
            command.SerializePropertyValue();

            connection.SendCommand(command);
        }