コード例 #1
0
        private static CacheInitParams GetInitParams(ref ToolArgs toolArgs)
        {
            CacheInitParams initParams = new CacheInitParams();
            string          ip         = "";

            if (string.IsNullOrEmpty(toolArgs.Server))
            {
                return(initParams);
            }
            else
            {
                int port = toolArgs.Port != 0 ? toolArgs.Port : 9800;
                CacheServerInfo[] cacheServerInfos = new CacheServerInfo[1];
                cacheServerInfos[0]   = new CacheServerInfo(ip, port);
                initParams.ServerList = cacheServerInfos;
                return(initParams);
            }
        }
コード例 #2
0
        static private bool ApplyParameters(string[] args, out ToolArgs toolArgs)
        {
            bool usage         = false;
            bool printLogo     = true;
            bool portspecified = false;

            toolArgs = new ToolArgs();

            for (int i = 0; i < args.Length; i++)
            {
                switch (args[i].ToLower(CultureInfo.InvariantCulture))
                {
                case @"/?":
                    usage = true;
                    break;

                case @"/G":
                case @"/nologo":
                    printLogo = false;
                    break;

                case @"/s":
                case @"/server-name":
                    if (i + 1 < args.Length)
                    {
                        toolArgs.Server = args[++i];
                    }
                    break;

                case @"/p":
                    if (i + 1 < args.Length)
                    {
                        try
                        {
                            toolArgs.Port = Int32.Parse(args[++i], null);
                            portspecified = true;
                        }
                        catch (FormatException) { }
                        catch (OverflowException) { }
                    }
                    break;


                default:
                    if (toolArgs.Cache == null || toolArgs.Cache == string.Empty)
                    {
                        toolArgs.Cache = args[i];
                    }
                    break;
                }
            }
            if (!portspecified)
            {
                toolArgs.Port = 0;
            }

            AssemblyUsage.PrintLogo(printLogo);
            if (usage)
            {
                if (!printLogo)
                {
                    Console.WriteLine();
                }
                AssemblyUsage.PrintUsage();
                return(false);
            }

            if (toolArgs.Cache == null || toolArgs.Cache == string.Empty)
            {
                Console.Error.WriteLine("Error: Cache name not specified.");
                return(false);
            }
            return(true);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: javithalion/NCache
        private static bool ApplyParameters(string[] args, out ToolArgs toolArgs)
        {
            bool usage = false;
            bool printLogo = true;
            bool portspecified = false;
            toolArgs = new ToolArgs();

            for (int i = 0; i < args.Length; i++)
            {
                switch (args[i].ToLower(CultureInfo.InvariantCulture))
                {
                    case @"/?":
                        usage = true;
                        break;

                    case @"/G":
                    case @"/nologo":
                        printLogo = false;
                        break;

                    case @"/s":
                    case @"/server-name":
                        if (i + 1 < args.Length)
                            toolArgs.Server = args[++i];
                        break;

                    case @"/p":
                        if (i + 1 < args.Length)
                        {
                            try
                            {
                                toolArgs.Port = Int32.Parse(args[++i], null);
                                portspecified = true;
                            }
                            catch (FormatException) { }
                            catch (OverflowException) { }
                        }
                        break;

                    default:
                        if (toolArgs.Cache == null || toolArgs.Cache == string.Empty)
                            toolArgs.Cache = args[i];
                        break;
                }
            }
            if (!portspecified) toolArgs.Port = 0;

            AssemblyUsage.PrintLogo(printLogo);
            if (usage)
            {
                if (!printLogo)
                    Console.WriteLine();
                AssemblyUsage.PrintUsage();
                return false;
            }

            if (toolArgs.Cache == null || toolArgs.Cache == string.Empty)
            {
                Console.Error.WriteLine("Error: Cache name not specified.");
                return false;
            }
            return true;
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: javithalion/NCache
 private static CacheInitParams GetInitParams(ref ToolArgs toolArgs)
 {
     CacheInitParams initParams = new CacheInitParams();
     string ip = "";
     if (string.IsNullOrEmpty(toolArgs.Server))
     { return initParams; }
     else
     {
         int port = toolArgs.Port != 0 ? toolArgs.Port : 9800;
         CacheServerInfo[] cacheServerInfos = new CacheServerInfo[1];
         cacheServerInfos[0] = new CacheServerInfo(ip, port);
         initParams.ServerList = cacheServerInfos;
         return initParams;
     }
 }