Esempio n. 1
0
            public static void Run(string[] args)
            {
                try
                {
                    object param = new DumpCacheParam();
                    CommandLineArgumentParser.CommandLineParser(ref param, args);
                    cParam = (DumpCacheParam)param;

                    if (cParam.IsUsage)
                    {
                        AssemblyUsage.PrintLogo(cParam.IsLogo);
                        AssemblyUsage.PrintUsage();
                        return;
                    }
                    if (!ValidateParameters())
                    {
                        return;
                    }

                    Cache cache = Factory.InitializeCache(cParam.CacheId);
                    cache.ExceptionsEnabled = true;

                    System.Console.WriteLine("Cache count: {0}.", cache.Count);
                    IDictionaryEnumerator keys = (IDictionaryEnumerator)cache.GetEnumerator();

                    if (keys != null)
                    {
                        long index       = 0;
                        bool checkFilter = (cParam.KeyFilter != "");
                        cParam.KeyFilter = cParam.KeyFilter.Trim();
                        while (keys.MoveNext())
                        {
                            if ((cParam.KeyCount > 0) && (index >= cParam.KeyCount))
                            {
                                break;
                            }

                            if (checkFilter == true)
                            {
                                string tmpKey = (string)keys.Key;

                                if (tmpKey.Contains(cParam.KeyFilter) == true)
                                {
                                    System.Console.WriteLine(tmpKey);
                                }
                            }
                            else
                            {
                                System.Console.WriteLine(keys.Key);
                            }
                            index++;
                        } //end while
                    }     //end if
                    cache.Dispose();
                }         //end try block
                catch (Exception e)
                {
                    Console.Error.WriteLine("Error: " + e.Message);
                    Console.Error.WriteLine();
                    Console.Error.WriteLine(e.ToString());
                }
            }
Esempio n. 2
0
            public static void Run(string[] args)
            {
                try
                {
                    object param = new DumpCacheParam();
                    CommandLineArgumentParser.CommandLineParser(ref param, args);
                    cParam = (DumpCacheParam)param;

                    if (cParam.IsUsage)
                    {
                        AssemblyUsage.PrintLogo(cParam.IsLogo);
                        AssemblyUsage.PrintUsage();
                        return;
                    }
                    if (!ValidateParameters()) return;

                    Cache cache = Factory.InitializeCache(cParam.CacheId);
                    cache.ExceptionsEnabled = true;

                    System.Console.WriteLine("Cache count: {0}.", cache.Count);
                    IDictionaryEnumerator keys = (IDictionaryEnumerator)cache.GetEnumerator();

                    if (keys != null)
                    {
                        long index = 0;
                        bool checkFilter = (cParam.KeyFilter != "");
                        cParam.KeyFilter = cParam.KeyFilter.Trim();
                        while (keys.MoveNext())
                        {
                            if ((cParam.KeyCount > 0) && (index >= cParam.KeyCount))
                                break;

                            if (checkFilter == true)
                            {
                                string tmpKey = (string)keys.Key;

                                if (tmpKey.Contains(cParam.KeyFilter) == true)
                                {
                                    System.Console.WriteLine(tmpKey);
                                }
                            }
                            else
                            {
                                System.Console.WriteLine(keys.Key);
                            }
                            index++;
                        }//end while
                    }//end if
                    cache.Dispose();
                }//end try block
                catch (Exception e)
                {
                    Console.Error.WriteLine("Error: " + e.Message);
                    Console.Error.WriteLine();
                    Console.Error.WriteLine(e.ToString());
                }
            }