コード例 #1
0
    public static void Execute()
    {
        SomeClass someClass = new SomeClass {
            Property = "Value"
        };
        var search = new ClassSearch(s => ((SomeClass)s).Property);

        Console.Out.WriteLine("{0} = '{1}'", search.Property.Name, search.Property.GetValue(someClass));
    }
コード例 #2
0
    public static void Execute()
    {
        SomeClass someClass = new SomeClass {
            Property = "Value"
        };
        var prop = new ClassSearch <SomeClass, string>(s => s.Property);

        Console.Out.WriteLine("{0} = '{1}'", prop.Property.Name, prop.Property.GetValue(someClass));
    }
コード例 #3
0
        public async Task OnSearchClass()
        {
            if (String.IsNullOrEmpty(ClassSearch) || String.IsNullOrWhiteSpace(ClassSearch))
            {
                await _confirmationDialogHelper.ErrorWindowShow("Veuillez remplir le champ de recherche.");
            }
            else
            {
                Classes.Clear();
                if (firstNameOrLastName.IsMatch(ClassSearch))
                {
                    for (int i = 0; i < GetClasses.Count; i++)
                    {
                        if (GetClasses[i].Code.ToLower().Contains(ClassSearch.ToLower()))
                        {
                            Classes.Add(GetClasses[i]);
                        }
                        else if (GetClasses[i].Name.ToLower().Contains(ClassSearch.ToLower()))
                        {
                            Classes.Add(GetClasses[i]);
                        }
                    }
                }
                else if (fullNameRx.IsMatch(ClassSearch))
                {
                    var word      = ClassSearch.Split(' ');
                    var countWord = word.Length;

                    foreach (var @class in GetClasses)
                    {
                        int i        = 0;
                        var fullname = @class.Name;
                        do
                        {
                            if (fullname.ToLower().Contains((word[i]).ToLower()))
                            {
                                if (i == countWord - 1)
                                {
                                    Classes.Add(@class);
                                }
                                i++;
                            }
                            else
                            {
                                break;
                            }
                        } while (i < countWord);
                    }
                }
            }
        }
コード例 #4
0
        public async Task <PagedSearchResult <Class> > SearchClasses(ClassSearch classSearch)
        {
            var filter = "";

            if (!string.IsNullOrEmpty(classSearch.Name))
            {
                filter = $"Name eq '{classSearch.Name}'";
            }
            if (classSearch.ContentType.HasValue && classSearch.ContentType != ContentType.None)
            {
                if (!string.IsNullOrEmpty(filter))
                {
                    filter = $"{filter} and";
                }
                filter = $"{filter} ContentType eq '{classSearch.ContentType.ToString()}'";
            }

            var query   = new TableQuery <Class>().Where(filter);
            var classes = await _tableStorage.QueryAsync("classes", query);

            switch (classSearch.ClassSearchOrdering)
            {
            case ClassSearchOrdering.NameAscending:
                classes = classes.OrderBy(p => p.Name);
                break;

            case ClassSearchOrdering.NameDescending:
                classes = classes.OrderByDescending(p => p.Name);
                break;

            case ClassSearchOrdering.ContentTypeAscending:
                classes = classes.OrderBy(p => p.ContentType);
                break;

            case ClassSearchOrdering.ContentTypeDescending:
                classes = classes.OrderByDescending(p => p.ContentType);
                break;
            }

            return(new PagedSearchResult <Class>(classes.ToList(), classSearch.PageSize, classSearch.CurrentPage));
        }
コード例 #5
0
        public async Task <ActionResult <List <PagedSearchResult <Class> > > > Get([FromQuery] ClassSearch classSearch)
        {
            var classes = await _classManager.SearchClasses(classSearch);

            return(Ok(classes));
        }