public bool Equals(IReadonlyModel other)
        {
            if (other == this)
            {
                return(true);
            }
            var j = other as ReadonlyJsonModel;

            if (j == null)
            {
                return(false);
            }
            return(this._Internals.Equals(j._Internals));
        }
 public bool Equals(IReadonlyModel other)
 {
     if (other == this)
     {
         return(true);
     }
     if (this.Current.Equals(other))
     {
         return(true);
     }
     if (this.Super != null || this.Super.Equals(other))
     {
         return(true);
     }
     return(false);
 }
Example #3
0
        public IDictionary <string, ValidationResult> ValidateFilter(IReadonlyModel dp)
        {
            var results = new Dictionary <string, ValidationResult>();
            var ds      = dp;

            foreach (var prop in this.Members)
            {
                object value = null;

                switch (prop.FilterType)
                {
                case FilterTypes.Equal:
                    value = ds.Get(prop.PropertyType, prop.Name);
                    if (!value.IsNullOrEmpty())
                    {
                        var rs = prop.ValidateValue(value, ValidateOptions.IgnoreRequire);
                        if (rs != null)
                        {
                            results.Add(prop.Name, rs);
                        }
                    }

                    break;

                case FilterTypes.Like:
                    value = ds.Get(prop.PropertyType, prop.Name);
                    if (!value.IsNullOrEmpty())
                    {
                        var rs = prop.ValidateValue(value, ValidateOptions.IgnoreRequire);
                        if (rs != null)
                        {
                            results.Add(prop.Name, rs);
                        }
                    }



                    break;

                case FilterTypes.Range:
                    var  minKey   = prop.Name + "_MIN";
                    bool hasRange = false;
                    value = ds.Get(prop.PropertyType, minKey);
                    if (!value.IsNullOrEmpty())
                    {
                        var rs = prop.ValidateValue(value, ValidateOptions.IgnoreRequire);
                        if (rs != null)
                        {
                            results.Add(minKey, rs);
                        }
                        hasRange = true;
                    }
                    var maxKey = prop.Name + "_MAX";
                    value = ds.Get(prop.PropertyType, maxKey);
                    if (!value.IsNullOrEmpty())
                    {
                        var rs = prop.ValidateValue(value, ValidateOptions.IgnoreRequire);
                        if (rs != null)
                        {
                            results.Add(maxKey, rs);
                        }
                        hasRange = true;
                    }
                    if (!hasRange)
                    {
                        value = ds.Get(prop.PropertyType, prop.Name);
                        if (!value.IsNullOrEmpty())
                        {
                            var rs = prop.ValidateValue(value, ValidateOptions.IgnoreRequire);
                            if (rs != null)
                            {
                                results.Add(minKey, rs);
                            }
                        }
                    }

                    break;
                }
            }


            return(results);
        }
 public ReadonlyCascadeModel(IReadonlyModel current = null, IReadonlyModel super = null)
 {
     this.Super   = super;
     this.Current = current;
 }