Exemple #1
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);
        }