Exemplo n.º 1
0
 public bool Match(string value)
 {
     try {
         value = value == null ? null : value.ToLower();
         return(isValid && value != null && (ALIACES.Any(x => value.Equals(x)) || NAME.ToLower().Equals(value)));
     } catch (Exception) { return(false); }
 }
Exemplo n.º 2
0
 public WSParam(int _CODE, string _NAME, Type _DataType, MetaFunctions _func)
 {
     func = _func;
     if (_CODE < 0)
     {
         throw new ArgumentNullException("_CODE");
     }
     if (string.IsNullOrEmpty(_NAME))
     {
         throw new ArgumentNullException("_NAME");
     }
     CODE         = _CODE;
     NAME         = _NAME;
     DISPLAY_NAME = _NAME;
     if (!ALIACES.Any(a => a.Equals(NAME.ToLower())))
     {
         ALIACES.Add(NAME.ToLower());
     }
     DataType = _DataType;
     if (_DataType != null)
     {
         if (!_DataType.IsSimple() && !_DataType.IsSimpleCollection())
         {
             Type eType = _DataType.GetEntityType();
             if (eType.IsValidDynamicEntity() && !ALIACES.Any(a => a.Equals(eType.Name.ToLower())))
             {
                 ALIACES.Add(eType.Name.ToLower());
             }
         }
     }
 }
Exemplo n.º 3
0
 internal WSValue Clone()
 {
     return(new WSValue()
     {
         NAME = NAME,
         DESCRIPTION = DESCRIPTION,
         ALIACES = ALIACES.Select(x => x).ToList()
     });
 }
Exemplo n.º 4
0
        private string LoadJson()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("\"ALIACES\":[");
            if (ALIACES != null && ALIACES.Any())
            {
                sb.Append(ALIACES.Select(x => "\"" + x + "\"").Aggregate((a, b) => a + "," + b));
            }
            sb.Append("]");
            return(sb.ToString());
        }
Exemplo n.º 5
0
 private void MergeAliaces(IEnumerable <string> _ALIACES)
 {
     try
     {
         if (_ALIACES != null && _ALIACES.Any())
         {
             _ALIACES = _ALIACES.Select(x => x.ToLower());
             ALIACES.AddRange(_ALIACES);
             ALIACES = ALIACES.Distinct().ToList();
         }
     }
     catch (Exception) { }
 }
Exemplo n.º 6
0
 private void init(string _NAME, IEnumerable <string> _ALIACES)
 {
     if (string.IsNullOrEmpty(_NAME))
     {
         throw new ArgumentNullException("'NAME' can not be empty");
     }
     this.NAME = _NAME;
     if (_ALIACES != null && _ALIACES.Any())
     {
         _ALIACES = _ALIACES.Select(x => x.ToLower());
         ALIACES.AddRange(_ALIACES);
         ALIACES = ALIACES.Distinct().ToList();
     }
 }
Exemplo n.º 7
0
        internal WSParam Clone()
        {
            WSParam param = new WSParam(CODE, NAME, DataType, func);

            param.DISPLAY_NAME     = DISPLAY_NAME;
            param.READ_ACCESS_MODE = READ_ACCESS_MODE != null?READ_ACCESS_MODE.Clone() : new WSAccessMode(WSConstants.ACCESS_LEVEL.READ);

            param.WRITE_ACCESS_MODE = WRITE_ACCESS_MODE != null?WRITE_ACCESS_MODE.Clone() : new WSAccessMode(WSConstants.ACCESS_LEVEL.UPDATE);

            param.SkipEmpty      = SkipEmpty;
            param.ALLOWED_VALUES = (ALLOWED_VALUES != null && ALLOWED_VALUES.Any()) ? ALLOWED_VALUES.Select(x => x.Clone()).ToList() : new List <WSValue>();
            param.ALIACES        = (ALIACES != null && ALIACES.Any()) ? ALIACES.Select(x => x).ToList() : new List <string>();
            param.DESCRIPTION    = DESCRIPTION;

            return(param);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
 public override string ToString()
 {
     return("{" + NAME + ":[" + (ALIACES == null || ALIACES.Count == 0 ? string.Empty : ALIACES.Aggregate((a, b) => a + "," + b)) + "]}");
 }
Exemplo n.º 10
0
 public bool Match(WSValue value)
 {
     try {
         return(value != null && (ALIACES.Any(x => value.ALIACES.Any(v => x.Equals(v))) || value.NAME.ToLower().Equals(NAME.ToLower())));
     } catch (Exception) { } return(false);
 }