internal WSTableSource Clone(MetaFunctions _Func, byte?_UserRole = null) { WSTableSource src = new WSTableSource(ReturnType, SecurityZone, NAME, _Func, _UserRole == null ? UserRole : (byte)_UserRole, false, AccessLevel, AVAILABLE_FORMATS, ALIACES); src.PrintStatus = PrintStatus; src.ShowMessageInaccessible = ShowMessageInaccessible; src.AllowOwnerAccess = AllowOwnerAccess; src.BaseFilter = BaseFilter == null ? null : BaseFilter.JString.ToJson(); src.DeletableFilter = DeletableFilter == null ? null : DeletableFilter.JString.ToJson(); src.EditableFilter = EditableFilter == null ? null : EditableFilter.JString.ToJson(); src.CreatableFilter = CreatableFilter == null ? null : CreatableFilter.JString.ToJson(); src.ReadableFilter = ReadableFilter == null ? null : ReadableFilter.JString.ToJson(); src.DefaultSchemaDeepness = DefaultSchemaDeepness; src._IsReadableBySchema = _IsReadableBySchema; src._IsCreatableBySchema = _IsCreatableBySchema; src._IsEditableBySchema = _IsEditableBySchema; src._IsDeletableBySchema = _IsDeletableBySchema; src.Params = Params.Select(x => x is WSTableParam ? ((WSTableParam)x).Clone() : x.Clone()); //PrimParams = PrimParams == null ? null : PrimParams.Select(c => c.Clone()); src.DeleteFlag = DeleteFlag == null ? null : DeleteFlag.Clone(); //Json = Json; //CoreSchema = CoreSchema; src./*_*/ SecurityZone = SecurityZone; src.BaseSchema = BaseSchema == null?null:(WSEntitySchema)BaseSchema.Clone(src); //src._IsReady = null; return(src); }
internal override WSMemberSchema Clone(WSTableSource _parent) { return(new WSEntityFieldSchema(Func, param.Clone(), new WSJProperty(Name, IOBaseOptions.Clone()), _parent.BaseSchema) { SOURCE = SOURCE }); }
private List <dynamic> readEntity(MetaFunctions CFunc, WSJProperty jProp, WSDynamicEntity _entity, bool multydimentional = false) { try { if (_entity != null) { WSTableSource src = (WSTableSource)_entity.getSource(CFunc); WSTableParam param = src.DBParams.FirstOrDefault(p => p.Match(jProp.Key)); PropertyInfo pInfo = src.ReturnType.GetProperties().FirstOrDefault(p => p.Name.Equals(param.WSColumnRef.NAME)); dynamic val = pInfo.GetValue(_entity, null); Type pType = pInfo.PropertyType.GetEntityType(); if (pInfo.PropertyType.IsCollectionOf <WSDynamicEntity>()) { IEnumerable <WSDynamicEntity> entities = (IEnumerable <WSDynamicEntity>)val; List <dynamic> subItems = new List <dynamic>(); foreach (WSDynamicEntity iEntity in entities) { subItems.AddRange(read(CFunc, jProp.Value, iEntity, multydimentional)); } return(subItems); } else { return(read(CFunc, jProp.Value, val, multydimentional)); } } } catch (Exception e) { WSStatus status = WSStatus.NONE.clone(); CFunc.RegError(GetType(), e, ref status, $"readEntity():284"); } return(null); }
private bool validateType(JsonWriter writer, WSParam xParam, object obj, List <Type> printedTypes, bool ignoreCurcularity, WSRequest Request, MetaFunctions CFunc) { bool isValid = false; if (obj != null && Request.Security != null && Request.Security.IsValid && xParam != null) { byte uRole = Request.Security.IsLogged ? Request.Security.AuthToken.User.role : WSConstants.ACCESS_LEVEL.READ; int paramAccessLevel = xParam.READ_ACCESS_MODE.ACCESS_LEVEL; WSTableSource xSource = (WSTableSource)CFunc.GetSourceByType(obj.GetType()); paramAccessLevel = (xSource != null && xSource.AccessLevel > paramAccessLevel) ? xSource.AccessLevel : paramAccessLevel; bool showCycledTypesMessage = uRole >= WSConstants.ACCESS_LEVEL.ADMIN && xSource != null && xSource.ShowMessageInaccessible; Type entityType = null; if (obj.IsCollection()) { if (obj.IsCollectionOf <WSEntity>()) { entityType = (obj as IList).GetEntityType(); } else if (obj.IsCollectionOf <WSRecord>() && (obj as IList).Count > 0) { entityType = ((WSRecord)(obj as IList)[0]).entity.GetType(); } } else if (obj is WSRecord) { entityType = ((WSRecord)obj).entity.GetType(); } else if (obj is WSEntity) { entityType = obj.GetType(); } bool Ignore = ignoreCurcularity ? false : (printedTypes != null && printedTypes.Any(t => t == entityType)); if (Ignore) { if (showCycledTypesMessage) { WritePropName(writer, xParam.NAME); writer.WriteValue("[unavailable : cycled references detected]"); } } else { if (entityType.IsValidDynamicEntity()) { WSSource src = CFunc.GetSourceByType(entityType); isValid = src != null && uRole >= src.AccessLevel; } else { isValid = true; } } } return(isValid); }
public void SaveDynamicSource(WSTableSource src) { try { if (src != null && !string.IsNullOrEmpty(src.DBName) && CoreSources.ContainsKey(src.DBName) && CoreSources[src.DBName].Any(x => x.Match(src))) { CoreSources[src.DBName].Single(x => x.Match(src)).Merge(src); } } catch (Exception e) { RegError(GetType(), e, ref LoadStatus); } }
private object getMemberValue(WSEntity entity, WSParam eParam, MetaFunctions CFunc) { WSTableSource xSource = (WSTableSource)CFunc.GetSourceByType(entity.GetType()); IEnumerable <MemberInfo> eMembers = xSource.ReturnType.GetMembers().Where(m => m is PropertyInfo || m is FieldInfo); MemberInfo eField = eMembers.FirstOrDefault(m => eParam.Match(m.Name)); return(eField is PropertyInfo ? ((PropertyInfo)eField).GetValue(entity, null) : eField is FieldInfo ? ((FieldInfo)eField).GetValue(entity) : null); }
internal override WSMemberSchema Clone(WSTableSource src) { return(new WSEntityListSchema(Param.Clone(), null, Func, src.BaseSchema) { EntitySchema = (WSEntitySchema)EntitySchema.Clone(src), Name = Name, Param = Param.Clone() }); }
public WSEntitySchema(WSTableSource _Source, WSJProperty _Json, MetaFunctions _Func, WSEntitySchema _Parent = null, bool _IsValidSchema = true) : base(_Func, _Parent) { try { IsValidSchema = _IsValidSchema; Source = _Source; setUp(_Json); } catch (Exception e) { Failed = true; WSStatus status = WSStatus.NONE.clone(); Func.RegError(GetType(), e, ref status); } }
public Dictionary <string, object> getIdentities(ClientFunctions CFunc) { if (_Identities == null) { _Identities = new Dictionary <string, object>(); WSTableSource src = (WSTableSource)getSource(CFunc); IEnumerable <string> ids = src.PrimParams.Select(x => x.WSColumnRef.NAME); if (ids == null || ids.FirstOrDefault() == null) { _Identities = GetType().GetProperties().Where(p => ids.Contains(p.Name)).ToDictionary(x => x.Name, x => x.GetValue(this, null)); } } return(_Identities); }
internal bool Configure(FileInfo file, out bool ForceReload) { ForceReload = false; bool configured = false; try { if (file != null && file.Exists) { using (XmlReader reader = XmlReader.Create(file.FullName)) { XmlNodeType cType = reader.MoveToContent(); if (cType != XmlNodeType.Element && reader.LocalName.Equals("sources")) { } else if (!reader.ReadToDescendant("source")) { } else { List <string> foundSources = new List <string>(); do { if (reader.GetAttribute("sourceType").Equals(typeof(WSTableSource).FullName)) { WSTableSource src = GetSource <WSTableSource>(reader); if (src != null) { src.ReadXml(reader, getTSource); foundSources.Add(src.NAME); } else { reader.MoveToElement(); ForceReload = true; } } } while (reader.ReadToNextSibling("source")); ForceReload = ForceReload || this.Any(x => !foundSources.Contains(x.NAME)); configured = reader.NodeType == XmlNodeType.EndElement && reader.LocalName.Equals("sources"); } } } } catch (Exception) { configured = false; } return(configured); }
public override Expression SortTable <TEntity>(MetaFunctions CFunc, WSDataContext dc, List <PropertyInfo> parents, Expression expression, ref WSStatus iostatus) { try { if (dc != null) { parents = parents != null ? parents : new List <PropertyInfo>(); Type srcType = parents.Any() ? parents.LastOrDefault().PropertyType.IsCollection() ? parents.LastOrDefault().PropertyType.GetEntityType() : parents.LastOrDefault().PropertyType : typeof(TEntity); ITable initSource = srcType == null ? null : dc.GetTable(typeof(TEntity)); ITable source = srcType == null ? null : dc.GetTable(srcType); WSTableSource schema = srcType == null ? null : (WSTableSource)CFunc.GetSourceByType(srcType); if (schema != null) { WSParam param = schema.GetXParam(Key); if (param != null && param is WSTableParam) { WSTableParam tParam = (WSTableParam)param; PropertyInfo property = srcType.GetProperties().FirstOrDefault(p => tParam.WSColumnRef.NAME.Equals(p.Name)); if (property == null) { iostatus.AddNote(string.Format("No PropertyInfo found for : [{0}]", tParam.WSColumnRef.NAME)); } else { parents.Add(property); if (tParam.DataType.IsSimple() && tParam.IsSortable) { bool IsDesc = false; if (Value is WSJValue) { IsDesc = ((WSJValue)Value).Value.ToLower().Equals("desc"); } expression = SortPrimitiveType <TEntity>(initSource, source, param, IsDesc, parents, expression, ref iostatus); } else if (tParam.DataType.IsSameOrSubclassOf(typeof(WSEntity)) || tParam.DataType.IsCollectionOf <WSEntity>()) { expression = Value.SortTable <TEntity>(CFunc, dc, parents, expression, ref iostatus); } } } } } } catch (Exception e) { CFunc.RegError(GetType(), e, ref iostatus); } return(expression); }
internal override WSMemberSchema Clone(WSTableSource src) { WSEntitySchema _Schema = new WSEntitySchema(Func) { Source = src, Name = src.NAME.ToLower(), CombineMode = CombineMode, Filters = Filters, Fields = Fields.Clone(src), OriginalJson = OriginalJson, Failed = Failed, Func = Func }; return(_Schema); }
private dynamic readPrimitive(MetaFunctions CFunc, WSJValue jVal, WSDynamicEntity _entity) { try { if (_entity != null) { Type eType = _entity.GetType(); WSTableSource src = ((WSTableSource)CFunc.GetSourceByType(eType)); WSTableParam param = src.DBParams.FirstOrDefault(p => p.Match(jVal.Value)); PropertyInfo pInfo = eType.GetProperties().FirstOrDefault(p => p.Name.Equals(param.WSColumnRef.NAME)); return(pInfo.GetValue(_entity, null)); } } catch (Exception e) { WSStatus status = WSStatus.NONE.clone(); CFunc.RegError(GetType(), e, ref status, $"readPrimitive():373"); } return(null); }
private bool Match(ClientFunctions CFunc, WSDynamicEntity refEntity) { try { if (refEntity == null) { return(false); } else if (refEntity.GetType() != GetType()) { return(false); } else { Type orgType = GetType(); WSTableSource orgSrc = (WSTableSource)getSource(CFunc); IEnumerable <WSTableParam> orgParams = orgSrc.DBParams.Where(p => p.DataType.IsSimple()); Type refType = refEntity.GetType(); WSTableSource refSrc = ((WSTableSource)CFunc.GetSourceByType(refType)); IEnumerable <WSTableParam> refParams = refSrc.DBParams.Where(p => p.DataType.IsSimple()); IEnumerable <WSTableParam> orgExceptParams = orgParams.Where(p1 => !refParams.Any(p2 => p2.Match(p1))); IEnumerable <WSTableParam> refExceptParams = refParams.Where(p1 => !orgParams.Any(p2 => p2.Match(p1))); if (orgExceptParams.Any() || refExceptParams.Any()) { return(false); } else { foreach (WSTableParam param in orgParams) { object orgInfo = orgType.GetProperties().FirstOrDefault(p => p.Name.Equals(param.WSColumnRef.NAME)).GetValue(this, null); object refInfo = refType.GetProperties().FirstOrDefault(p => p.Name.Equals(param.WSColumnRef.NAME)).GetValue(refEntity, null); if (!(orgInfo == null && refInfo == null) && !orgInfo.ToString().Equals(refInfo.ToString())) { return(false); } } return(true); } } } catch (Exception e) { WSStatus status = WSStatus.NONE.clone(); CFunc.RegError(GetType(), e, ref status, $"Match():321"); } return(false); }
public WSTableSource GetSourceByType(Type type) { WSTableSource src = null; if (Values != null) { foreach (WSUserDBSet srcs in Values) { src = srcs.FirstOrDefault(x => x.ReturnType == type); if (src != null) { break; } } } return(src); }
public bool IsRelationTo(ClientFunctions CFunc, WSDynamicEntity _RelationTEntity, ref WSStatus _statusLines, IEnumerable <Type> _refTypes = null) { bool _IsRelationTo = false; try { if (_RelationTEntity != null) { WSTableSource orgSrc = (WSTableSource)getSource(CFunc); WSTableSource relSrc = (WSTableSource)_RelationTEntity.getSource(CFunc); if (relSrc != null) { WSTableParam refParam = orgSrc.DBParams.FirstOrDefault(x => x.DataType == relSrc.ReturnType); if (refParam == null) { IEnumerable <Type> refTypes = _refTypes == null ? new List <Type>() : _refTypes.Select(x => x); IEnumerable <WSTableParam> eParams = orgSrc.DBParams.Any() ? orgSrc.DBParams.Where(x => x.DataType.IsValidDynamicEntity() && !x.DataType.IsCollection() && !refTypes.Any(t => t == x.DataType)) : null; if (eParams != null && eParams.Any()) { foreach (WSTableParam eParam in eParams) { object pValue = null; WSDynamicEntity pEntity = TryReadPropertyValue(eParam.WSColumnRef.NAME, out pValue, null) ? (WSDynamicEntity)pValue : null; _IsRelationTo = pEntity.IsRelationTo(CFunc, _RelationTEntity, ref _statusLines, refTypes); if (_IsRelationTo) { break; } } } } else { object PValue = null; WSDynamicEntity RefEntity = TryReadPropertyValue(refParam.WSColumnRef.NAME, out PValue, null) ? (WSDynamicEntity)PValue : null; _IsRelationTo = RefEntity != null && _RelationTEntity.Match(CFunc, RefEntity); } } } } catch (Exception e) { CFunc.RegError(GetType(), e, ref _statusLines, $"IsRelationTo():256"); } return(_IsRelationTo); }
public WSEntitySchema(MetaFunctions _Func, WSTableSource _Source = null, IEnumerable <WSTableSource> sources = null) : base(_Func, null) { try { if (_Source != null) { Source = _Source; Name = _Source.NAME.ToLower(); if (_Source != null && _Source.UserRole >= _Source.AccessLevel) { foreach (WSTableParam param in _Source.Params) { parseBaseParam(param, sources); } } } } catch (Exception e) { Failed = true; WSStatus status = WSStatus.NONE.clone(); Func.RegError(GetType(), e, ref status); } }
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); }
public void Merge(WSTableSource ext) { base.Merge(ext); AllowOwnerAccess = ext.AllowOwnerAccess; BaseFilter = ext.BaseFilter; DeletableFilter = ext.DeletableFilter; EditableFilter = ext.EditableFilter; CreatableFilter = ext.CreatableFilter; ReadableFilter = ext.ReadableFilter; foreach (WSTableParam orgParam in Params.OfType <WSTableParam>()) { WSTableParam extParam = ext.DBParams.FirstOrDefault(p => p.WSColumnRef.NAME.Equals(orgParam.WSColumnRef.NAME)); if (extParam != null) { orgParam.Merge(extParam); } } }
public WSDynamicEntity getRelatedParent <A>(ClientFunctions CFunc, ref WSStatus _statusLines, IEnumerable <Type> _refTypes = null) { WSDynamicEntity relEntity = null; try { WSTableSource orgSrc = (WSTableSource)getSource(CFunc); WSTableSource relSrc = (WSTableSource)CFunc.GetSourceByType(typeof(A)); if (relSrc != null) { WSTableParam refParam = orgSrc.DBParams.FirstOrDefault(x => x.DataType == relSrc.ReturnType); if (refParam == null) { IEnumerable <Type> refTypes = _refTypes == null ? new List <Type>() : _refTypes.Select(x => x); IEnumerable <WSTableParam> eParams = orgSrc.DBParams.Any() ? orgSrc.DBParams.Where(x => x.DataType.IsValidDynamicEntity() && !x.DataType.IsCollection() && !refTypes.Any(t => t == x.DataType)) : null; if (eParams != null && eParams.Any()) { foreach (WSTableParam eParam in eParams) { object pValue = null; WSDynamicEntity pEntity = TryReadPropertyValue(eParam.WSColumnRef.NAME, out pValue, null) ? (WSDynamicEntity)pValue : null; relEntity = pEntity.getRelatedParent <A>(CFunc, ref _statusLines, refTypes); if (relEntity != null) { break; } } } } else { object PValue = null; relEntity = TryReadPropertyValue(refParam.WSColumnRef.NAME, out PValue, null) ? (WSDynamicEntity)PValue : null; } } } catch (Exception e) { CFunc.RegError(GetType(), e, ref _statusLines, $"getRelatedParent():211"); } return(relEntity); }
public override bool Equals(object obj) { try { if (obj == null) { return(false); } if (obj.GetType() != GetType()) { return(false); } WSTableSource eSchema = WSServerMeta.SYSTEM_SOURCES.GetSourceByType(GetType()); if (eSchema == null) { return(base.Equals(obj)); } else { WSDynamicEntity eObj = (WSDynamicEntity)obj; foreach (WSTableParam param in eSchema.DBPrimitiveParams) { object p1 = readPropertyValue(param.WSColumnRef.NAME); object p2 = eObj.readPropertyValue(param.WSColumnRef.NAME); if (p1 != null) { if (!p1.Equals(p2)) { return(false); } } else if (p2 != null) { return(false); } } } } catch (Exception) { return(false); } return(true); }
public override WSFilter GetOptionFilter(MetaFunctions CFunc, Expression parent, int level, string state = null, bool?negate = null) { WSCombineFilter filter = new WSCombineFilter(WSCombineFilter.SQLMode.AndAlso); try { if (Value != null) { if (WSConstants.ALIACES.NOT.Match(Key)) { return(Value.GetOptionFilter(CFunc, parent, level, state, true)); } else if (WSConstants.ALIACES.ANY.Match(Key)) { return(Value.GetOptionFilter(CFunc, parent, level, Key, true)); } else { if (Value is WSJValue) { filter.Save(((WSJValue)Value).GetOptionFilter(CFunc, parent, level, state, negate)); } else { WSTableSource PSource = (WSTableSource)CFunc.GetSourceByType(parent.Type.GetEntityType()); WSTableParam subParam = PSource == null ? null : (WSTableParam)PSource.GetXParam(Key); //TODO@ANDVO:2016-11-15: implement deep filtering } return(filter.Any() ? (filter.Count == 1 && !filter.Negate) ? filter.FirstOrDefault() : filter : null); } } } catch (Exception e) { WSStatus status = WSStatus.NONE.clone(); CFunc.RegError(GetType(), e, ref status); } return(null); }
public override WSFilter GetOptionFilter(MetaFunctions CFunc, Expression parent, int level, string state = null, bool?negate = null) { try { if (Value.IsTrue() || Value.IsFalse()) { return(new WSBoolOFilter(this)); } else if (WSConstants.SPECIAL_CASES.Any(x => x.Match(Value))) { state = Value; if (parent.Type.IsSameOrSubclassOf(typeof(WSEntity)) || parent.Type.IsCollectionOf <WSEntity>()) { WSTableSource Source = (WSTableSource)CFunc.GetSourceByType/*<WSTableSource>*/ (parent.Type); if (parent.Type.IsSameOrSubclassOf(typeof(WSEntity)) && WSEntityFFilter.OPERATIONS.STATE_OPERATIONS.Any(x => x.Match(state))) { return(new WSEntityFilter(Source, parent, WSEntityFFilter.OPERATIONS.STATE_OPERATIONS.FirstOrDefault(x => x.Match(state)))); } } } } catch (Exception e) { WSStatus status = WSStatus.NONE.clone(); CFunc.RegError(GetType(), e, ref status); } return(null); }
public WSEntityFilter(WSTableSource _Source, Expression _member, WSOperation _Operation) : base(_Source?.ReturnType, _member) { Source = _Source; operation = _Operation != null ? _Operation : OPERATIONS.GetOperation(null); }
internal abstract WSMemberSchema Clone(WSTableSource _Parent);
public abstract bool MatchEntity(MetaFunctions CFunc, WSDynamicEntity entity, WSTableSource src, string key = null, string matchOperation = null);
public override bool MatchEntity(MetaFunctions CFunc, WSDynamicEntity entity, WSTableSource src, string key = null, string matchOperation = null) { bool isMatch = true; try { foreach (WSJProperty jProp in Value) { if (!jProp.MatchEntity(CFunc, entity, src, key)) { isMatch = false; } } } catch (Exception e) { isMatch = false; WSStatus status = WSStatus.NONE.clone(); CFunc.RegError(GetType(), e, ref status); } return(isMatch); }
public override bool MatchEntity(MetaFunctions CFunc, WSDynamicEntity entity, WSTableSource src, string key = null, string matchOperation = null) { bool isMatch = true; try { if (!string.IsNullOrEmpty(key) && IsValid) { matchOperation = matchOperation == null ? WSFieldFilter.GLOBAL_OPERATIONS.Equal.NAME : matchOperation; WSTableParam param = src.DBPrimitiveParams.FirstOrDefault(p => p.Match(key)); if (param != null) { isMatch = Match(entity.GetType().GetProperty(param.WSColumnRef.NAME).GetValue(entity, null), matchOperation, param.DataType); } } } catch (Exception e) { isMatch = false; WSStatus status = WSStatus.NONE.clone(); CFunc.RegError(GetType(), e, ref status); } return(isMatch); }
private WSStatus WriteCollapsedValues(JsonWriter writer, JsonSerializer serializer, WSEntity entity, WSSource xSource, WSJson collapseOption, WSRequest Request, MetaFunctions CFunc) { WSStatus status = WSStatus.NONE_Copy(); try { /******************************************************************************* * * // TODO @ANDVO : 2016-02-15 : IMPORTANT!!! => Implement security check like this : * * WSStatus status = Validate(obj, xParam, writer, serializer, security, schema); * if (status.CODE == WSStatus.SUCCESS.CODE) * { */ if (entity != null && collapseOption != null && collapseOption.IsValid) { WSTableSource childSource = (WSTableSource)CFunc.GetSourceByType(entity.GetType()); object fieldValue = null; WSParam field = null; if (collapseOption is WSJValue) { string fieldName = ((WSJValue)collapseOption).Value; field = entity.GetParam(xSource, fieldName); fieldValue = getMemberValue(entity, field, CFunc); WSPrimitiveFieldSchema fieldSchema = new WSPrimitiveFieldSchema(CFunc, (WSTableParam)field, new WSJProperty(fieldName, new WSJArray()), /*((WSTableSource)entity.getSource())*/ childSource.BaseSchema); if (Validate(fieldValue, field, writer, serializer, childSource.BaseSchema, childSource, null, ref status, Request, CFunc)) { object _obj = null; serializer.Serialize(writer, field.TryReadPrimitiveWithDefault(fieldValue, string.Empty, out _obj) ? _obj : string.Empty); writer.Flush(); status = WSStatus.SUCCESS_Copy(); } } else if (collapseOption is WSJObject) { WSJProperty collapseSrc = ((WSJObject)collapseOption).Value.FirstOrDefault(); field = entity.GetParam(childSource, collapseSrc.Key); fieldValue = getMemberValue(entity, field, CFunc); if (Validate(fieldValue, field, writer, serializer, childSource.BaseSchema, childSource, null, ref status, Request, CFunc)) { if (fieldValue == null) { serializer.Serialize(writer, "NULL"); writer.Flush(); } else if (fieldValue is WSEntity) { WSTableSource fieldSource = (WSTableSource)CFunc.GetSourceByType(fieldValue.GetType()); status = WriteCollapsedValues(writer, serializer, (WSEntity)fieldValue, fieldSource, collapseSrc.Value, Request, CFunc); } else if (fieldValue.IsCollectionOf <WSEntity>()) { WSTableSource fieldSource = (WSTableSource)CFunc.GetSourceByType(fieldValue.GetType().GetEntityType()); if (!((IEnumerable <WSEntity>)fieldValue).Any()) { serializer.Serialize(writer, "NULL"); writer.Flush(); } else { foreach (WSEntity eItem in (IEnumerable <WSEntity>)fieldValue) { status.childs.Add(WriteCollapsedValues(writer, serializer, eItem, fieldSource, collapseSrc.Value, Request, CFunc)); } status = status.IsPositive ? WSStatus.SUCCESS_Copy() : WSStatus.ERROR_Copy(); } } } } } /*} * *******************************************************************************/ } catch (Exception e) { CFunc.RegError(GetType(), e, ref status); } return(status); }
public virtual bool Match(string key, IEnumerable <WSTableSource> sources = null, Func <Type, WSTableSource> getTSource = null, bool TypeMatchAllowed = true) { try { if (!string.IsNullOrEmpty(NAME) && !string.IsNullOrEmpty(key)) { key = key.ToLower(); int _CODE = -1; if (CODE >= 0) { if (NAME.Equals(key)) { return(true); } else if (DISPLAY_NAME.Equals(key)) { return(true); } else if (ALIACES != null && ALIACES.Contains(key)) { return(true); } else if (this is WSTableParam) { WSTableParam p = (WSTableParam)this; if (p.WSColumnRef.NAME.ToLower().Equals(key)) { return(true); } else if (TypeMatchAllowed && p.DataType.IsValidDynamicEntity()) { WSTableSource src = null; if (getTSource != null) { src = getTSource(p.DataType.GetEntityType()); } else if (sources != null) { src = sources.FirstOrDefault(s => s.ReturnType == p.DataType.GetEntityType()); } else if (func != null) { src = (WSTableSource)func.GetSourceByType(p.DataType.GetEntityType()); } if (src != null && src.Match(key)) { return(true); } } } else if (int.TryParse(key, out _CODE) && _CODE == CODE) { return(true); } } ; } } catch (Exception) { } return(false); }