public WSFieldSchema(MetaFunctions _Func, WSTableParam _param, WSJProperty _Json, WSEntitySchema _Parent) : base(_Func, _Parent) { param = _param; if (_Json != null) { Name = _Json.Key; IOBaseOptions.Save(_Json.Value); } }
public override WSFilter GetCustomFilter(Expression _EntityExpression, int _level) { WSCombineFilter mainFilter = !IsFiltrable ? null : new WSCombineFilter(CombineMode); if (mainFilter != null && _EntityExpression != null) { Expression member = null; if (_EntityExpression.Type == Source.ReturnType) { member = _EntityExpression; } else if (Parent != null) { WSTableParam paramExt = (WSTableParam)Parent.Source.GetXParam(Name); if (paramExt != null) { member = Expression.Property(_EntityExpression, paramExt.WSColumnRef.NAME); } } if (member != null && IsFiltrable) { if (Fields != null && Fields.Any()) { WSCombineFilter cFields = new WSCombineFilter(Fields.CombineMode); mainFilter.Save(cFields); foreach (WSSchema field in Fields) { cFields.Save(field.GetCustomFilter(member, _level)); } } if (Filters != null && Filters.Any()) { WSCombineFilter cFilters = new WSCombineFilter(Filters.CombineMode); mainFilter.Save(cFilters); foreach (WSSchema field in Filters) { cFilters.Save(field.GetCustomFilter(member, _level)); } } } if (IOBaseOptions != null && !IOBaseOptions.IsEmpty) { mainFilter.Save(IOBaseOptions.GetOptionFilter(Func, member, _level + 1)); } } return(mainFilter != null && mainFilter.IsValid ? mainFilter.Reduce() : mainFilter); }
private void proceedFieldFilter(WSJValue jField, ref WSFieldFilters filters) { bool replace = true; List <WSMemberSchema> schemas = readFieldSchema(jField, out replace); if (schemas != null && schemas.Any()) { foreach (WSMemberSchema schema in schemas) { saveFieldSchema(schema, replace, ref filters); } } else { IOBaseOptions.Save(jField); } }
private void proceedFieldFilter(WSJProperty jField, ref WSFieldFilters filters) { bool replace = true; List <WSMemberSchema> schemas = readFieldSchema(jField, out replace); if (schemas.Any()) { foreach (WSMemberSchema schema in schemas) { saveFieldSchema(schema, replace, ref filters); } } else { IOBaseOptions.Save(new WSJObject(new List <WSJProperty> { jField })); } }
internal override WSMemberSchema Clone(WSTableSource _parent) { return(new WSEntityFieldSchema(Func, param.Clone(), new WSJProperty(Name, IOBaseOptions.Clone()), _parent.BaseSchema) { SOURCE = SOURCE }); }
public override WSFilter GetCustomFilter(Expression parent, int level) { WSFilter filter = !IsFiltrable ? null : IOBaseOptions.GetFieldFilter(Func, param, parent, level); return(filter != null && filter.IsValid ? filter : null); }
public WSEntityListSchema(WSTableParam _Param, WSJProperty _Json, MetaFunctions _Func, WSEntitySchema _Parent) : base(_Func, _Parent) { Param = _Param; if (_Json != null && !_Json.IsEmpty) { if (WSEntityFilter.OPERATIONS.STATE_OPERATIONS.Any(x => x.Match(_Json.Key))) { IOBaseOptions.Save(new WSJObject(new List <WSJProperty>() { _Json })); } else if (_Json.Value != null) { if (_Json.Value is WSJArray) { WSJArray arr = (WSJArray)_Json.Value; WSJArray temp = new WSJArray(); foreach (WSJson item in arr.Value) { if (item is WSJValue && WSEntityFilter.OPERATIONS.STATE_OPERATIONS.Any(x => x.Match(((WSJValue)item).Value))) { IOBaseOptions.Save(item); } else { temp.Value.Add(item); } } _Json.Value = temp; } else if (_Json.Value is WSJObject) { WSJObject obj = (WSJObject)_Json.Value; List <WSJProperty> tempItems = new List <WSJProperty>(); WSJObject temp = new WSJObject(tempItems); WSJObject baseLocal = new WSJObject(tempItems); foreach (WSJProperty item in obj.Value) { if (WSEntityFilter.OPERATIONS.STATE_OPERATIONS.Any(x => x.Match(item.Key))) { baseLocal.Value.Add(item); } else if (item.Value is WSJValue && WSEntityFilter.OPERATIONS.STATE_OPERATIONS.Any(x => x.Match(((WSJValue)item.Value).Value))) { baseLocal.Value.Add(item); } else if (item.Value is WSJArray && !item.Value.IsEmpty && !((WSJArray)item.Value).Value.Any(v => !(v is WSJValue) || !WSEntityFilter.OPERATIONS.STATE_OPERATIONS.Any(x => x.Match(((WSJValue)v).Value)))) { baseLocal.Value.Add(item); } else if (item.Value is WSJObject && !item.Value.IsEmpty && !((WSJObject)item.Value).Value.Any(p => !(p.Value is WSJValue) || !WSEntityFilter.OPERATIONS.STATE_OPERATIONS.Any(x => x.Match(((WSJValue)p.Value).Value)))) { baseLocal.Value.Add(item); } else { temp.Value.Add(item); } } _Json.Value = temp; if (!baseLocal.IsEmpty) { IOBaseOptions.Save(baseLocal); } } } } if (Param != null) { EntitySchema = new WSEntitySchema((WSTableSource)Func.GetSourceByType(Param.DataType.GetEntityType()), _Json, Func, Parent); if (EntitySchema != null) { Name = EntitySchema.Name; } } }