示例#1
0
        private OrderChange CreateOrderChangeByChangedProperties(ChangedProperty changedPropery)
        {
            PropertyChangeType changeProperties = PropertyChangeType.None;

            if (string.Compare(changedPropery.AutoLimitPrice, this.AutoLimitPrice) != 0)
            {
                changeProperties |= PropertyChangeType.AutoLimitPrice;
            }

            if (string.Compare(changedPropery.AutoStopPrice, this.AutoStopPrice) != 0)
            {
                changeProperties |= PropertyChangeType.AutoStopPrice;
            }

            if (changedPropery.PaidPledge != this.PaidPledge)
            {
                changeProperties |= PropertyChangeType.PaidPledge;
            }

            if (changedPropery.PaidPledgeBalance != this.PaidPledgeBalance)
            {
                changeProperties |= PropertyChangeType.PaidPledgeBalance;
            }

            if (changedPropery.IsInstalmentOverdue != this.IsInstalmentOverdue)
            {
                changeProperties |= PropertyChangeType.HasOverdue;
            }

            if (changeProperties != PropertyChangeType.None)
            {
                return(new OrderChange(this, Protocal.Commands.OrderChangeType.Changed, changeProperties));
            }
            return(null);
        }
示例#2
0
        internal override Boolean IsValidate(ChangedProperty property)
        {
            var internalValue = (property.Value + "").ToString();

            /*if (_canbeEmpty && String.IsNullOrEmpty(internalValue))
             * {
             *  return true;
             * }*/

            var valueLength = internalValue.Length;

            if (_min == 0 && valueLength <= _max)
            {
                return(true);
            }

            if (valueLength < _min || valueLength > _max)
            {
                return(false);
            }

            if (valueLength >= _min && valueLength <= _max)
            {
                return(true);
            }

            return(false);
        }
示例#3
0
#pragma warning restore IDE0051 // 使用されていないプライベート メンバーを削除する
        public void EmitStatusUpdate(ChangedProperty changedProps, BeatSaberEvent e)
        {
            this.GameStatus.updateCause = e.GetDescription();
            if ((changedProps & ChangedProperty.Game) == ChangedProperty.Game)
            {
                this.UpdateGameJSON();
            }
            if ((changedProps & ChangedProperty.Beatmap) == ChangedProperty.Beatmap)
            {
                this.UpdateBeatmapJSON();
            }
            if ((changedProps & ChangedProperty.Performance) == ChangedProperty.Performance)
            {
                this.UpdatePerformanceJSON();
            }
            if ((changedProps & ChangedProperty.NoteCut) == ChangedProperty.NoteCut)
            {
                this.UpdateNoteCutJSON();
            }
            if ((changedProps & ChangedProperty.Mod) == ChangedProperty.Mod)
            {
                this.UpdateModJSON();
                this.UpdatePlayerSettingsJSON();
            }
            if ((changedProps & ChangedProperty.BeatmapEvent) == ChangedProperty.BeatmapEvent)
            {
                this.UpdateBeatmapEventJSON();
            }
            this.EnqueueMessage(changedProps, e);
        }
示例#4
0
        private void EnqueueMessage(ChangedProperty changedProps, BeatSaberEvent e)
        {
            var eventJSON = this.JsonPool.Spawn();

            eventJSON["event"] = e.GetDescription();

            if ((changedProps & ChangedProperty.AllButNoteCut) == ChangedProperty.AllButNoteCut)
            {
                eventJSON["status"] = this.StatusJSON;
            }
            else
            {
                var status = new JSONObject();

                if ((changedProps & ChangedProperty.Game) == ChangedProperty.Game)
                {
                    status["game"] = this.StatusJSON["game"];
                }
                if ((changedProps & ChangedProperty.Beatmap) == ChangedProperty.Beatmap)
                {
                    status["beatmap"] = this.StatusJSON["beatmap"];
                }
                if ((changedProps & ChangedProperty.Performance) == ChangedProperty.Performance)
                {
                    status["performance"] = this.StatusJSON["performance"];
                }
                if ((changedProps & ChangedProperty.Mod) == ChangedProperty.Mod)
                {
                    status["mod"]            = this.StatusJSON["mod"];
                    status["playerSettings"] = this.StatusJSON["playerSettings"];
                }
                eventJSON["status"] = status;
            }
            if ((changedProps & ChangedProperty.NoteCut) == ChangedProperty.NoteCut)
            {
                eventJSON["noteCut"] = this.NoteCutJSON;
            }
            if ((changedProps & ChangedProperty.BeatmapEvent) == ChangedProperty.BeatmapEvent)
            {
                eventJSON["beatmapEvent"] = this.BeatmapEventJSON;
            }
            if ((changedProps & ChangedProperty.Other) != 0)
            {
                eventJSON["other"] = this.OtherJSON;
            }
            this.JsonQueue.Enqueue(eventJSON);
        }
示例#5
0
        public override Protocal.Commands.OrderPhaseChange Update(XElement orderElement)
        {
            ChangedProperty changedProperty = new ChangedProperty
            {
                AutoLimitPrice      = this.AutoLimitPrice,
                AutoStopPrice       = this.AutoStopPrice,
                PaidPledge          = this.PaidPledge,
                PaidPledgeBalance   = this.PaidPledgeBalance,
                IsInstalmentOverdue = this.IsInstalmentOverdue
            };
            var orderChange = base.Update(orderElement);

            if (orderChange != null)
            {
                return(orderChange);
            }
            return(this.CreateOrderChangeByChangedProperties(changedProperty));
        }
        internal override Boolean IsValidate(ChangedProperty property)
        {
            _changedProperty = property;

            //判断DefaultValueAttribute中传入的Type与EntityBase子类属性中的数据的实际类型
            //防止在DateTime类型的属性上使用DefaultValueAttribute向内传入不能转换成DateTime的数据,包括类似于"0000/00/01 00:00:00","WASD","123123"等无法转换为DateTime的数据
            if (property.Type != Type)
            {
                return(false);
            }

            try
            {
                Convert.ChangeType(Value, property.Type);
                return(true);
            }
            catch (System.Exception)
            {
                return(false);
            }
        }
        internal override Boolean IsValidate(ChangedProperty property)
        {
            try
            {
                Check.IfNullOrZero(property);
                Check.IfNullOrZero(property.Value);

                var type = property.Value.GetType();

                if (type.IsValueType && type.IsNumeric())
                {
                    Check.IfNullOrZero((ValueType)property.Value);
                }
                else
                {
                    Check.IfNullOrZero(property.Value);
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
示例#8
0
 internal override Boolean IsValidate(ChangedProperty property) => base.IsValidate(property);
示例#9
0
 /// <summary>
 /// 是否验证通过
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 internal virtual Boolean IsValidate(ChangedProperty property)
 {
     return(false);
 }
示例#10
0
 public Changed(Person person, ChangedProperty changedProperty, object value = null)
 {
     this.Person   = person;
     this.Property = changedProperty;
     this.Value    = value;
 }