/// <summary>
        /// Includes server validation metadata to a reactive property.
        /// When this is included, the property value will be sent to the server when it changed.
        /// </summary>
        /// <param name="prop">Property to include.</param>
        /// <param name="vm">View model of the property.</param>
        /// <param name="validate">Validation function.</param>
        /// <param name="message">Validation message.</param>
        /// <param name="category">Validation category.</param>
        /// <returns>Property.</returns>
        public static ReactiveProperty <TProp> WithServerValidation <TProp>(this ReactiveProperty <TProp> prop,
                                                                            IReactiveProperties vm, Func <TProp, bool> validate, string message, Validation.Categories category = Validation.Categories.Error)
        {
            var serverValidation  = new ServerValidation(message);
            var validationMsgProp = typeof(BaseVM).IsAssignableFrom(vm.GetType()) ?
                                    (vm as BaseVM).AddProperty <bool>(ToValidationMessageName(prop, serverValidation.Id))
            : vm.AddProperty <bool>(ToValidationMessageName(prop, serverValidation.Id));

            validationMsgProp.SubscribeTo(prop.Select(val => validate(val)));
            return(prop.WithValidation(vm, serverValidation));
        }
        /// <summary>
        /// Includes attribute metadata to a reactive property.
        /// </summary>
        /// <param name="prop">Property to include.</param>
        /// <param name="vm">View model of the property.</param>
        /// <param name="attr">Object that contains the attribute data.</param>
        /// <returns>Property.</returns>
        public static ReactiveProperty <TProp> WithAttribute <TProp, TAttr>(this ReactiveProperty <TProp> prop, IReactiveProperties vm, TAttr attr)
        {
            var attrDictionary = prop.GetAttributes(vm) ?? new AttributeDictionary();

            // Convert the attribute object to key-value dictionary.
            attrDictionary = attrDictionary
                             .Concat(attr.GetType().GetProperties().ToDictionary(x => x.Name, x => x.GetValue(attr)))
                             .Where(x => x.Value != null)
                             .ToDictionary(x => x.Key, x => x.Value);

            // Store the attribute data in a special-purpose property.
            vm.AddProperty(prop.ToAttributeName(), attrDictionary);
            return(prop);
        }
        /// <summary>
        /// Includes validation metadata to a reactive property.
        /// </summary>
        /// <param name="prop">Property to include.</param>
        /// <param name="vm">View model of the property.</param>
        /// <param name="validation">Object that contains the validation data.</param>
        /// <returns>Property.</returns>
        public static ReactiveProperty <TProp> WithValidation <TProp>(this ReactiveProperty <TProp> prop, IReactiveProperties vm, Validation validation)
        {
            var validationProp = vm.RuntimeProperties.FirstOrDefault(x => x.Name == prop.ToValidationName());

            List <Validation> validationEntries = null;

            if (validationProp?.Value is List <Validation> )
            {
                validationEntries = validationProp.Value as List <Validation>;
            }
            else
            {
                validationEntries = new List <Validation>();
                vm.AddProperty(prop.ToValidationName(), validationEntries);
            }
            validationEntries.Add(validation);
            return(prop);
        }
 /// <summary>
 /// Includes CRUD item key to a reactive property.
 /// </summary>
 /// <param name="prop">Property to include.</param>
 /// <param name="vm">View model of the property.</param>
 /// <param name="itemKey">Item key.</param>
 /// <returns>Property.</returns>
 public static ReactiveProperty <TProp> WithItemKey <TProp>(this ReactiveProperty <TProp> prop, IReactiveProperties vm, string itemKey)
 {
     vm.AddProperty($"{prop.Name}_itemKey", itemKey);
     return(prop);
 }