protected void Calculate(int pageNumber)
        {
            var upperLimit = pageNumber * PageSize;

            CurrentPageItems =
                new ObservableCollection <T>(
                    AllObjects.Where(x => AllObjects.IndexOf(x) > upperLimit - (PageSize + 1) && AllObjects.IndexOf(x) < upperLimit));
        }
        public IEnumerable <ClrObject> EnumerateClrObjects(string typeName)
        {
            if (typeName.Contains("*"))
            {
                var regex = new Regex($"^{Regex.Escape(typeName).Replace("\\*", ".*")}$",
                                      RegexOptions.Compiled | RegexOptions.IgnoreCase);

                return(AllObjects.Where(item => regex.IsMatch(item.TypeName)));
            }

            return(AllObjects.Where(item => item.TypeName == typeName));
        }
Beispiel #3
0
        protected override void FilterCollections(object obj)
        {
            var filter = obj as string;

            var cards = AllObjects
                        .Where(c => c.CardType.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0)
                        .ToList();

            FilteredCollection = new ObservableCollection <Card>(cards);

            ChangeStyle(filter);
        }
Beispiel #4
0
        public SearchResults SearchInDb(string query = "", ObjectTypes searchIn = ObjectTypes.All, Sort sort = Sort.asc)
        {
            Results = new SearchResults();

            if (DB == null || !DB.IsConnected)
            {
                Results.Error        = true;
                Results.ErrorMessage = "There is no database connection!";
                return(Results);
            }

            SearchQuery = query;

            if (AllObjects == null)
            {
                AllObjects = DB.GetObjects().ToList();
            }

            Results.FoundDbObjects = AllObjects.Where(o =>
                                                      o is Table <T> && (searchIn.HasFlag(ObjectTypes.Tables) | searchIn.HasFlag(ObjectTypes.Columns)) ||
                                                      o is View <T> && searchIn.HasFlag(ObjectTypes.Views) ||
                                                      o is StoredProcedure <T> && searchIn.HasFlag(ObjectTypes.StoredProcedures)
                                                      ).ToList();

            if (query != "")
            {
                var foundColumns = searchIn.HasFlag(ObjectTypes.Columns) ? DB.FindColumn(query) : null;
                var foundScripts = (searchIn.HasFlag(ObjectTypes.StoredProcedures) | searchIn.HasFlag(ObjectTypes.Views)) ? DB.FindInScripts(query) : null;

                Results.FoundDbObjects = Results.FoundDbObjects.Where(o =>

                                                                      (searchIn.HasFlag(ObjectTypes.Tables) && o.Name.ToLowerInvariant().Contains(query.ToLowerInvariant()))

                                                                      || (searchIn.HasFlag(ObjectTypes.Columns) && foundColumns.Any(a => a == o.Name))

                                                                      //|| (searchIn.HasFlag(EDbObjects.Triggers) && o is Table<T> && ((Table<T>)o).Triggers.Any(t => t.Name.ToLowerInvariant().Contains(query.ToLowerInvariant())))

                                                                      || ((searchIn.HasFlag(ObjectTypes.StoredProcedures) | searchIn.HasFlag(ObjectTypes.Views)) && foundScripts.Any(a => a == o.Name))

                                                                      ).ToList();
            }

            if (sort != Sort.none)
            {
                Results.FoundDbObjects = sort == Sort.asc ?
                                         Results.FoundDbObjects.OrderBy(o => o.Name).ToList() :
                                         Results.FoundDbObjects.OrderByDescending(o => o.Name).ToList();
            }

            return(Results);
        }
Beispiel #5
0
        public IEnumerable <ClrObject> EnumerateClrObjects(string typeName)
        {
            if (typeName.Contains("*"))
            {
                string typeNameRegex = "^" + Regex.Escape(typeName).Replace("\\*", ".*") + "$";
                Regex  regex         = new Regex(typeNameRegex, RegexOptions.Compiled | RegexOptions.IgnoreCase);

                return(AllObjects.Where(item => regex.IsMatch(item.Type.Name)));
            }

            typeName = ObfuscateType(typeName);

            return(AllObjects.Where(item => item.Type.Name == typeName));
        }
Beispiel #6
0
        private void CheckForPowerUps()
        {
            IEnumerable <PowerUp> pups = AllObjects
                                         .Where((m) => CollidesWith(m))
                                         .Select((m) => m as PowerUp);

            foreach (PowerUp pup in pups)
            {
                if (pup != null)
                {
                    pup.ApplyOn(this);
                }
            }
        }
Beispiel #7
0
        private void CheckForCollision()
        {
            IEnumerable <EnemyShip> collisions = AllObjects
                                                 .Where((m) => CollidesWith(m))
                                                 .Select((m) => m as EnemyShip);

            foreach (EnemyShip enemy in collisions)
            {
                if (enemy != null)
                {
                    enemy.Explode();
                    Delete();
                }
            }
        }
        private bool CheckForCollision()
        {
            IEnumerable <EnemyShip> collisions = AllObjects
                                                 .Where((m) => CollidesWith(m))
                                                 .Select((m) => m as EnemyShip)
                                                 .Where((m) => m != null);

            if (collisions.Count() == 0)
            {
                return(false);
            }
            foreach (EnemyShip enemy in collisions)
            {
                enemy.Explode();
            }
            return(true);
        }
Beispiel #9
0
        public IEnumerable <ClrDynamic> EnumerateDynamicObjects(string typeName)
        {
            if (!typeName.Contains("*"))
            {
                return(AllObjects.Where(item => item.TypeName == typeName));
            }

            var regex = new Regex($"^{Regex.Escape(typeName).Replace("\\*", ".*")}$",
                                  RegexOptions.Compiled | RegexOptions.IgnoreCase);

            var types =
                from type in Heap.EnumerateTypes()
                let deobfuscator = GetTypeDeobfuscator(type)
                                   where regex.IsMatch(deobfuscator.OriginalName)
                                   select type;

            var typeSet = new HashSet <ClrType>(types);

            return(AllObjects.Where(o => typeSet.Contains(o.Type)));
        }
Beispiel #10
0
        public IEnumerable <ClrDynamic> EnumerateDynamicObjects(IEnumerable <ClrType> types)
        {
            if (types == null)
            {
                return(EnumerateDynamicObjects());
            }

            IList <ClrType> castedTypes = types as IList <ClrType> ?? types.ToList();

            if (castedTypes.Count == 0)
            {
                return(EnumerateDynamicObjects());
            }

            if (castedTypes.Count == 1)
            {
                return(EnumerateDynamicObjects(castedTypes[0]));
            }

            HashSet <ClrType> set = new HashSet <ClrType>(castedTypes);

            return(AllObjects.Where(o => set.Contains(o.Type)));
        }
Beispiel #11
0
 public IEnumerable <ClrDynamic> EnumerateDynamicObjects(ClrType type)
 {
     return(AllObjects.Where(item => item.Type == type));
 }