コード例 #1
0
        private WSJProperty getFieldJson(WSTableParam param, WSJson json)
        {
            WSJProperty fJson = null;

            if (json is WSJObject)
            {
                fJson = ((WSJObject)json).Value.FirstOrDefault(x => param.Match(x.Key));
            }
            else if (json is WSJArray)
            {
                fJson = ((WSJArray)json).Value.OfType <WSJObject>().FirstOrDefault(x => param.Match(x.Value[0].Key)).Value[0];
            }
            return(fJson);
        }
コード例 #2
0
        private List <WSMemberSchema> readFieldSchema(WSJProperty json, out bool replace)// json => WSJValue || WSJProperty || WSJObject
        {
            replace = true;
            List <WSMemberSchema> fSchema = new List <WSMemberSchema>();

            try
            {
                if (json != null && Source != null)
                {
                    if (!string.IsNullOrEmpty(json.Key))
                    {
                        WSTableParam param = (WSTableParam)Source.GetXParam(json.Key);
                        if (param != null && param.isValid)
                        {
                            replace = true;
                            if (param.DataType.IsSimple() || param.DataType.IsSimpleCollection())
                            {
                                fSchema.Add(new WSPrimitiveFieldSchema(Func, param, json, this));
                            }
                            else if (json.IsValid)
                            {
                                WSTableSource source = (WSTableSource)Func.GetSourceByType(param.DataType.GetEntityType());
                                if (source != null)
                                {
                                    if (param.Match(json.Key))
                                    {
                                        if (param.DataType.IsSameOrSubclassOf(typeof(WSEntity)))
                                        {
                                            fSchema.Add(new WSEntitySchema(source, json, Func, this));
                                        }
                                        else if (param.DataType.IsCollectionOf <WSEntity>())
                                        {
                                            fSchema.Add(new WSEntityListSchema(param, json, Func, this));
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            #region SET '*' [ALL PRIMITIVE FIELDS] Filter
                            if (WSConstants.ALIACES.ALL_PRIMITIVE_FIELDS.Match(json.Key))
                            {
                                replace = false;

                                IEnumerable <WSTableParam> DBPrimitiveParams =
                                    Source.DBPrimitiveParams.Any() ?
                                    Source.DBPrimitiveParams.Where(x => Func.IsAccessible(x.READ_ACCESS_MODE.ACCESS_LEVEL)) :
                                    new List <WSTableParam>();
                                IEnumerable <WSJValue> all_primitive_params =
                                    DBPrimitiveParams.Any() ?
                                    DBPrimitiveParams.Select(x => new WSJValue(x.DISPLAY_NAME)) :
                                    new List <WSJValue>();

                                foreach (WSJValue _item in all_primitive_params)
                                {
                                    WSMemberSchema schema = Source.BaseSchema.Fields.FirstOrDefault(x => x.Name.Equals(_item.Value));
                                    if (schema != null)
                                    {
                                        fSchema.Add(schema);
                                    }
                                }
                            }
                            #endregion
                        }
                    }
                }
            }
            catch (Exception e) { WSStatus status = WSStatus.NONE.clone(); Func.RegError(GetType(), e, ref status); }
            return(fSchema);
        }