Пример #1
0
        public void Update(TimeSpan frameTime)
        {
            List <object> toRemove = new List <object>();

            foreach (KeyValuePair <ValueAccess, Dictionary <object, ValueChangeRequest> > buffer in
                     FieldChangeBuffer.BufferedChanges)
            {
                ValueAccess access = buffer.Key;
                foreach (KeyValuePair <object, ValueChangeRequest> instanceBuffer in buffer.Value)
                {
                    object instance = instanceBuffer.Key;
                    if (CheckShouldRemove(access, instance, instanceBuffer.Value))
                    {
                        toRemove.Add(instanceBuffer.Key);
                    }
                    else if (!instanceBuffer.Value.RequestProcessed)
                    {
                        access.GetHandler(instance)?.Invoke(instanceBuffer.Value.RequestedValue);
                        instanceBuffer.Value.RequestProcessed = true;
                    }
                }

                toRemove.ForEach(o => buffer.Value.Remove(o));
                toRemove.Clear();
            }

            m_RailClient.Update();
        }
Пример #2
0
        private bool CheckShouldRemove(
            ValueAccess access,
            object instance,
            ValueChangeRequest buffer)
        {
            if (buffer.RequestProcessed && Equals(buffer.RequestedValue, buffer.LatestActualValue))
            {
                return(true);
            }

            object currentValue = access.Get(instance);

            if (Equals(currentValue, buffer.LatestActualValue))
            {
                return(false);
            }

            if (buffer.RequestProcessed)
            {
                return(true);
            }

            buffer.LatestActualValue = currentValue;
            return(false);
        }
 public void RaiseRelationReadEvent(
     DomainObject domainObject,
     IRelationEndPointDefinition relationEndPointDefinition,
     ReadOnlyDomainObjectCollectionAdapter <DomainObject> relatedObjects,
     ValueAccess valueAccess)
 {
 }
Пример #4
0
 internal void AddOutputValue(ValueAccess valueAccess)
 {
     _elements.Add(new OutputValueTemplateElement
     {
         ValueAccess = valueAccess
     });
 }
Пример #5
0
 public virtual void RelationReading(
     ClientTransaction clientTransaction,
     DomainObject domainObject,
     IRelationEndPointDefinition relationEndPointDefinition,
     ValueAccess valueAccess)
 {
 }
Пример #6
0
 public virtual void RelationRead(
     ClientTransaction clientTransaction,
     DomainObject domainObject,
     IRelationEndPointDefinition relationEndPointDefinition,
     ReadOnlyDomainObjectCollectionAdapter <DomainObject> relatedObjects,
     ValueAccess valueAccess)
 {
 }
 public virtual void RelationRead(
     ClientTransaction clientTransaction,
     DomainObject domainObject,
     IRelationEndPointDefinition relationEndPointDefinition,
     DomainObject relatedObject,
     ValueAccess valueAccess)
 {
     // Handled by Begin event
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ValueAccessComparisonValidator"/> class.
 /// </summary>
 /// <param name="valueAccess">The <see cref="ValueAccess"/> to use when extracting the comparison operand.</param>
 /// <param name="comparisonOperator">The <see cref="ComparisonOperator"/> that specifies the kind of 
 /// comparison to perform.</param>
 /// <param name="messageTemplate">The message template to use when logging validation failures.</param>
 /// <param name="negated">Indicates if the validation logic represented by the validator should be negated.</param>
 public ValueAccessComparisonValidator(ValueAccess valueAccess,
     ComparisonOperator comparisonOperator,
     string messageTemplate,
     bool negated)
     : this(valueAccess, comparisonOperator, messageTemplate, null, negated)
 {
     this.valueAccess = valueAccess;
     this.comparisonOperator = comparisonOperator;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ValueAccessComparisonValidator"/> class.
 /// </summary>
 /// <param name="valueAccess">The <see cref="ValueAccess"/> to use when extracting the comparison operand.</param>
 /// <param name="comparisonOperator">The <see cref="ComparisonOperator"/> that specifies the kind of 
 /// comparison to perform.</param>
 /// <param name="messageTemplate">The message template to use when logging validation failures.</param>
 /// <param name="tag">The tag that describes the purpose of the validator.</param>
 public ValueAccessComparisonValidator(ValueAccess valueAccess,
     ComparisonOperator comparisonOperator,
     string messageTemplate,
     string tag)
     : this(valueAccess, comparisonOperator, messageTemplate, tag, false)
 {
     this.valueAccess = valueAccess;
     this.comparisonOperator = comparisonOperator;
 }
 public ValueAccessComparisonValidator(ValueAccess valueAccess, ComparisonOperator comparisonOperator, string messageTemplate, string tag, bool negated) : base(messageTemplate, tag, negated)
 {
     if (valueAccess == null)
     {
         throw new ArgumentNullException("valueAccess");
     }
     this.valueAccess        = valueAccess;
     this.comparisonOperator = comparisonOperator;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ValueAccessComparisonValidator"/> class.
 /// </summary>
 /// <param name="valueAccess">The <see cref="ValueAccess"/> to use when extracting the comparison operand.</param>
 /// <param name="comparisonOperator">The <see cref="ComparisonOperator"/> that specifies the kind of
 /// comparison to perform.</param>
 /// <param name="messageTemplate">The message template to use when logging validation failures.</param>
 /// <param name="negated">Indicates if the validation logic represented by the validator should be negated.</param>
 public ValueAccessComparisonValidator(ValueAccess valueAccess,
                                       ComparisonOperator comparisonOperator,
                                       string messageTemplate,
                                       bool negated)
     : this(valueAccess, comparisonOperator, messageTemplate, null, negated)
 {
     this.valueAccess        = valueAccess;
     this.comparisonOperator = comparisonOperator;
 }
Пример #12
0
        public object GetValueWithoutEvents(PropertyDefinition propertyDefinition, ValueAccess valueAccess = ValueAccess.Current)
        {
            ArgumentUtility.CheckNotNull("propertyDefinition", propertyDefinition);
            CheckNotDiscarded();

            var propertyValue = GetPropertyValue(propertyDefinition);

            return(GetValueWithoutEvents(propertyValue, valueAccess));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ValueAccessComparisonValidator"/> class.
 /// </summary>
 /// <param name="valueAccess">The <see cref="ValueAccess"/> to use when extracting the comparison operand.</param>
 /// <param name="comparisonOperator">The <see cref="ComparisonOperator"/> that specifies the kind of
 /// comparison to perform.</param>
 /// <param name="messageTemplate">The message template to use when logging validation failures.</param>
 /// <param name="tag">The tag that describes the purpose of the validator.</param>
 public ValueAccessComparisonValidator(ValueAccess valueAccess,
                                       ComparisonOperator comparisonOperator,
                                       string messageTemplate,
                                       string tag)
     : this(valueAccess, comparisonOperator, messageTemplate, tag, false)
 {
     this.valueAccess        = valueAccess;
     this.comparisonOperator = comparisonOperator;
 }
Пример #14
0
 private object GetValueWithoutEvents(PropertyValue propertyValue, ValueAccess valueAccess)
 {
     if (valueAccess == ValueAccess.Current)
     {
         return(propertyValue.Value);
     }
     else
     {
         return(propertyValue.OriginalValue);
     }
 }
Пример #15
0
        /// <summary>
        /// <para>Initializes a new instance of the <see cref="ValueAccessValidator"/> class with an upper bound constraint.</para>
        /// </summary>
        /// <param name="valueAccess">The <see cref="ValueAccess"/> to use when extracting values from the 
        /// validated objects.</param>
        /// <param name="valueValidator">The <see cref="Validator"/> to use when validating the values extracted
        /// from the validated objects.</param>
        /// <exception cref="ArgumentNullException">when <paramref name="valueAccess"/> is <see langword="null"/>.</exception>
        /// <exception cref="ArgumentNullException">when <paramref name="valueValidator"/> is <see langword="null"/>.</exception>
        public ValueAccessValidator(ValueAccess valueAccess, Validator valueValidator)
            : base(null, null)
        {
            if (null == valueAccess)
                throw new ArgumentNullException("valueAccess");
            if (null == valueValidator)
                throw new ArgumentNullException("valueValidator");

            this.valueAccess = valueAccess;
            this.valueValidator = valueValidator;
        }
Пример #16
0
 internal void Append(ValueAccess valueAccess)
 {
     if (Next == null)
     {
         Next = valueAccess;
     }
     else
     {
         Next.Append(valueAccess);
     }
 }
        public void Parse_return_OutputValueTemplateElement_for_property_in_template()
        {
            TemplateModel templateModel = _parser.Parse("{{ Name }}");

            TemplateElement[] elements = templateModel.Elements.ToArray();
            Assert.AreEqual(1, elements.Length);
            var         element     = (OutputValueTemplateElement)elements[0];
            ValueAccess valueAccess = element.ValueAccess;

            Assert.AreEqual("Name", valueAccess.Name);
        }
        public override void RelationReading(
            ClientTransaction clientTransaction,
            DomainObject domainObject,
            IRelationEndPointDefinition relationEndPointDefinition,
            ValueAccess valueAccess)
        {
            ArgumentUtility.CheckNotNull("clientTransaction", clientTransaction);
            ArgumentUtility.CheckNotNull("domainObject", domainObject);
            ArgumentUtility.CheckNotNull("relationEndPointDefinition", relationEndPointDefinition);

            PropertyReading(clientTransaction, domainObject, relationEndPointDefinition.PropertyInfo);
        }
Пример #19
0
 public ValueAccessValidator(ValueAccess valueAccess, Validator valueValidator) : base(null, null)
 {
     if (valueAccess == null)
     {
         throw new ArgumentNullException("valueAccess");
     }
     if (valueValidator == null)
     {
         throw new ArgumentNullException("valueValidator");
     }
     this.valueAccess    = valueAccess;
     this.valueValidator = valueValidator;
 }
        //TODO move to TemplateEvaluator
        internal object GetValue(ValueAccess valueAccess)
        {
            ValueAccess currentValueAccess = valueAccess;
            object      value = _source;

            do
            {
                value = value.GetType().GetProperty(currentValueAccess.Name).GetValue(value);
                currentValueAccess = currentValueAccess.Next;
            } while (currentValueAccess != null);

            return(value);
        }
Пример #21
0
        public void RaiseRelationReadEvent(
            DomainObject domainObject,
            IRelationEndPointDefinition relationEndPointDefinition,
            ReadOnlyDomainObjectCollectionAdapter <DomainObject> relatedObjects,
            ValueAccess valueAccess)
        {
            ArgumentUtility.CheckNotNull("domainObject", domainObject);
            ArgumentUtility.CheckNotNull("relationEndPointDefinition", relationEndPointDefinition);
            ArgumentUtility.CheckNotNull("relatedObjects", relatedObjects);

            _extensionCollection.RelationRead(_clientTransaction, domainObject, relationEndPointDefinition, relatedObjects, valueAccess);
            _listenerCollection.RelationRead(_clientTransaction, domainObject, relationEndPointDefinition, relatedObjects, valueAccess);
        }
Пример #22
0
        public object GetValue(PropertyDefinition propertyDefinition, ValueAccess valueAccess = ValueAccess.Current)
        {
            ArgumentUtility.CheckNotNull("propertyDefinition", propertyDefinition);
            CheckNotDiscarded();

            var propertyValue = GetPropertyValue(propertyDefinition);

            RaisePropertyValueReadingNotification(propertyDefinition, valueAccess);
            object value = GetValueWithoutEvents(propertyValue, valueAccess);

            RaisePropertyValueReadNotification(propertyDefinition, value, valueAccess);

            return(value);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ValueAccessComparisonValidator"/> class.
        /// </summary>
        /// <param name="valueAccess">The <see cref="ValueAccess"/> to use when extracting the comparison operand.</param>
        /// <param name="comparisonOperator">The <see cref="ComparisonOperator"/> that specifies the kind of 
        /// comparison to perform.</param>
        /// <param name="messageTemplate">The message template to use when logging validation failures.</param>
        /// <param name="tag">The tag that describes the purpose of the validator.</param>
        /// <param name="negated">Indicates if the validation logic represented by the validator should be negated.</param>
        public ValueAccessComparisonValidator(ValueAccess valueAccess,
            ComparisonOperator comparisonOperator,
            string messageTemplate,
            string tag,
            bool negated)
            : base(messageTemplate, tag, negated)
        {
            if (valueAccess == null)
            {
                throw new ArgumentNullException("valueAccess");
            }

            this.valueAccess = valueAccess;
            this.comparisonOperator = comparisonOperator;
        }
 public void RelationReading(
     ClientTransaction clientTransaction,
     DomainObject domainObject,
     IRelationEndPointDefinition relationEndPointDefinition,
     ValueAccess valueAccess)
 {
     if (s_log.IsDebugEnabled())
     {
         s_log.DebugFormat(
             "{0} RelationReading: {1} ({2}, {3})",
             clientTransaction.ID,
             relationEndPointDefinition.PropertyName,
             valueAccess,
             GetDomainObjectString(domainObject));
     }
 }
        public void Parse_return_OutputValueTemplateElement_for_property_dot_property()
        {
            TemplateModel templateModel = _parser.Parse("{{ Model.Name }}");

            TemplateElement[] elements = templateModel.Elements.ToArray();
            Assert.AreEqual(1, elements.Length);
            var element = (OutputValueTemplateElement)elements[0];

            ValueAccess modelValueAccess = element.ValueAccess;

            Assert.AreEqual("Model", modelValueAccess.Name);

            ValueAccess nameValueAccess = modelValueAccess.Next;

            Assert.AreEqual("Name", nameValueAccess.Name);
            Assert.IsNull(nameValueAccess.Next);
        }
        public void Parse_return_TextTemplateElement_and_OutputValueTemplateElement()
        {
            TemplateModel templateModel = _parser.Parse("text{{ Count }}");

            TemplateElement[] elements = templateModel.Elements.ToArray();
            Assert.AreEqual(2, elements.Length);

            var textTemplateElement = (TextTemplateElement)elements[0];

            Assert.AreEqual("text", textTemplateElement.Text);

            var         outputValueTemplateElement = (OutputValueTemplateElement)elements[1];
            ValueAccess valueAccess = outputValueTemplateElement.ValueAccess;

            Assert.AreEqual("Count", valueAccess.Name);
            Assert.IsNull(valueAccess.Next);
        }
        public void Parse_return_ConditionTemplateElement_for_property_dot_property()
        {
            TemplateModel templateModel = _parser.Parse("{{ #if Model.Flag }}{{ /if }}");

            TemplateElement[] elements = templateModel.Elements.ToArray();
            Assert.AreEqual(1, elements.Length);

            var conditionTemplateElement = (ConditionTemplateElement)elements[0];

            ValueAccess modelValueAccess = conditionTemplateElement.ValueAccess;

            Assert.AreEqual("Model", modelValueAccess.Name);

            ValueAccess flagValueAccessNext = modelValueAccess.Next;

            Assert.AreEqual("Flag", flagValueAccessNext.Name);
            Assert.IsNull(flagValueAccessNext.Next);
        }
 public void RelationRead(
     ClientTransaction clientTransaction,
     DomainObject domainObject,
     IRelationEndPointDefinition relationEndPointDefinition,
     ReadOnlyDomainObjectCollectionAdapter <DomainObject> relatedObjects,
     ValueAccess valueAccess)
 {
     if (s_log.IsDebugEnabled())
     {
         var domainObjectsString = relatedObjects.IsDataComplete ? GetDomainObjectsString(relatedObjects) : "<data not loaded>";
         s_log.DebugFormat(
             "{0} RelationRead: {1} ({2}, {3}): {4}",
             clientTransaction.ID,
             relationEndPointDefinition.PropertyName,
             valueAccess,
             domainObject.ID,
             domainObjectsString);
     }
 }
        public void Parse_return_OutputValueTemplateElement_for_property_dot_property_dot_property()
        {
            TemplateModel templateModel = _parser.Parse("{{ First.Second.Third }}");

            TemplateElement[] elements = templateModel.Elements.ToArray();
            Assert.AreEqual(1, elements.Length);
            var element = (OutputValueTemplateElement)elements[0];

            ValueAccess firstValueAccess = element.ValueAccess;

            Assert.AreEqual("First", firstValueAccess.Name);

            ValueAccess secondValueAccess = firstValueAccess.Next;

            Assert.AreEqual("Second", secondValueAccess.Name);

            ValueAccess thirdValueAccess = secondValueAccess.Next;

            Assert.AreEqual("Third", thirdValueAccess.Name);

            Assert.IsNull(thirdValueAccess.Next);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ValueAccessComparisonValidator"/> class.
 /// </summary>
 /// <param name="valueAccess">The <see cref="ValueAccess"/> to use when extracting the comparison operand.</param>
 /// <param name="comparisonOperator">The <see cref="ComparisonOperator"/> that specifies the kind of 
 /// comparison to perform.</param>
 public ValueAccessComparisonValidator(ValueAccess valueAccess, ComparisonOperator comparisonOperator)
     : this(valueAccess, comparisonOperator, null, null)
 { }
Пример #31
0
 /// <summary>
 /// <para>Initializes a new instance of the <see cref="MemberAccessValidator{T}"/> class.</para>
 /// </summary>
 /// <param name="valueAccess">The <see cref="ValueAccess"/> to use when accessing the
 /// value of the validated member.</param>
 /// <param name="valueValidator">The <see cref="Validator"/> to validate the value of the
 /// validated member.</param>
 protected MemberAccessValidator(ValueAccess valueAccess, Validator valueValidator)
     : base(null, null)
 {
     this.valueAccessValidator = new ValueAccessValidator(valueAccess, valueValidator);
     Validator = valueValidator;
 }
Пример #32
0
		/// <summary>
		/// Initializes a new instance of the <see cref="PropertyComparisonValidator"/> class.
		/// </summary>
		/// <param name="valueAccess">The <see cref="ValueAccess"/> to use to extract the value to compare.</param>
		/// <param name="comparisonOperator">The <see cref="ComparisonOperator"/> representing the kind of comparison to perform.</param>
		/// <param name="negated">Indicates if the validation logic represented by the validator should be negated.</param>
		public PropertyComparisonValidator(ValueAccess valueAccess, ComparisonOperator comparisonOperator, bool negated)
			: base(valueAccess, comparisonOperator, null, negated)
		{ }
Пример #33
0
		/// <summary>
		/// Initializes a new instance of the <see cref="PropertyComparisonValidator"/> class.
		/// </summary>
		/// <param name="valueAccess">The <see cref="ValueAccess"/> to use to extract the value to compare.</param>
		/// <param name="comparisonOperator">The <see cref="ComparisonOperator"/> representing the kind of comparison to perform.</param>
		public PropertyComparisonValidator(ValueAccess valueAccess, ComparisonOperator comparisonOperator)
			: base(valueAccess, comparisonOperator)
		{ }
Пример #34
0
 public void RelationRead(ClientTransaction clientTransaction, DomainObject domainObject, IRelationEndPointDefinition relationEndPointDefinition, DomainObject relatedObject, ValueAccess valueAccess)
 {
     throw CreateException();
 }
Пример #35
0
 public void PropertyValueRead(ClientTransaction clientTransaction, DomainObject domainObject, PropertyDefinition propertyDefinition, object value, ValueAccess valueAccess)
 {
     throw CreateException();
 }
 protected MemberAccessValidator(ValueAccess valueAccess, Validator valueValidator)
     : base((string)null, (string)null)
 {
     this.valueAccessValidator = new ValueAccessValidator(valueAccess, valueValidator);
 }
Пример #37
0
 public PropertyComparisonValidator(ValueAccess valueAccess, ComparisonOperator comparisonOperator) : base(valueAccess, comparisonOperator)
 {
 }