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 override void applyMembers <A>(WSDynamicResponse <A> response) { if (response != null) { try { if (Fields != null && Fields.Any()) { foreach (WSMemberSchema field in Fields) { field.apply(response); } } if (Filters != null && Filters.Any()) { foreach (WSMemberSchema field in Filters) { field.apply(response); } } } catch (Exception e) { Func.RegError(GetType(), e, ref response.iostatus); } } }