private void parseBaseParam(WSTableParam param, IEnumerable <WSTableSource> sources = null) { try { if (param == null) { } else { bool isValidFields = (Fields == null || !Fields.Any(x => x is WSFieldSchema && ((WSFieldSchema)x).param.Match(param.NAME, sources))); if (!isValidFields) { } else { if (param.DataType.IsSimple() || param.DataType.IsSimpleCollection()) { Fields.Add(new WSPrimitiveFieldSchema(Func, param, new WSJProperty(param.DISPLAY_NAME.ToLower(), new WSJArray()), this)); } else { Fields.Add(new WSEntityFieldSchema(Func, param, new WSJProperty(param.DISPLAY_NAME.ToLower(), new WSJArray()), this)); } } } } catch (Exception e) { Failed = true; WSStatus status = WSStatus.NONE.clone(); Func.RegError(GetType(), e, ref status); } }
private bool saveFieldSchema(WSMemberSchema field, bool replace, ref WSFieldFilters filters) { if (field != null) { Func <WSMemberSchema, bool> func = x => x is WSFieldSchema && ((WSFieldSchema)x).param.Match(field.Name); if (!filters.Any(func)) { filters.Add(field); } else { if (replace) { /* TODO@ANDVO : 2016-03-08 : combine redundant field's options somehow,... (when field used more than once in schema) * fx.: 'userid:{less:10}&schema={user:[*,{userid:{more:1}}]}' * note: ofcourse we can combine them like: 'schema={user:[*,{userid:{less:10,more:1}}]}', * but what if there will be need for option's separation as : AND <-> OR? */ filters[filters.IndexOf(filters.FirstOrDefault(func))] = field; } } return(true); } return(false); }
internal WSFieldFilters Clone(WSTableSource src) { WSFieldFilters filters = new WSFieldFilters() { CombineMode = CombineMode }; foreach (WSMemberSchema i in this) { if (i is WSPrimitiveFieldSchema) { filters.Add(((WSPrimitiveFieldSchema)i).Clone(src)); } else if (i is WSEntityFieldSchema) { filters.Add(((WSEntityFieldSchema)i).Clone(src)); } } return(filters); }