Aurora.Addon.HyperGrid.HypergridLinker.RunHGCommand C# (CSharp) Метод

RunHGCommand() приватный Метод

private RunHGCommand ( string command, string cmdparams ) : void
command string
cmdparams string
Результат void
        private void RunHGCommand(string command, string[] cmdparams)
        {
            if (command.Equals ("link-mapping"))
            {
                if (cmdparams.Length == 2)
                {
                    try
                    {
                        m_autoMappingX = Convert.ToUInt32 (cmdparams[0]);
                        m_autoMappingY = Convert.ToUInt32 (cmdparams[1]);
                        m_enableAutoMapping = true;
                    }
                    catch (Exception)
                    {
                        m_autoMappingX = 0;
                        m_autoMappingY = 0;
                        m_enableAutoMapping = false;
                    }
                }
            }
            else if (command.Equals ("link-region"))
            {
                if (cmdparams.Length < 3)
                {
                    if ((cmdparams.Length == 1) || (cmdparams.Length == 2))
                    {
                        LoadXmlLinkFile (cmdparams);
                    }
                    else
                    {
                        LinkRegionCmdUsage ();
                    }
                    return;
                }

                //this should be the prefererred way of setting up hg links now
                if (cmdparams[2].StartsWith ("http"))
                {
                    RunLinkRegionCommand (cmdparams);
                }
                else if (cmdparams[2].Contains (":"))
                {
                    // New format
                    string[] parts = cmdparams[2].Split (':');
                    if (parts.Length > 2)
                    {
                        // Insert remote region name
                        ArrayList parameters = new ArrayList (cmdparams);
                        parameters.Insert (3, parts[2]);
                        cmdparams = (string[])parameters.ToArray (typeof (string));
                    }
                    cmdparams[2] = "http://" + parts[0] + ':' + parts[1];

                    RunLinkRegionCommand (cmdparams);
                }
                else
                {
                    // old format
                    GridRegion regInfo;
                    int xloc, yloc;
                    uint externalPort;
                    string externalHostName;
                    try
                    {
                        xloc = Convert.ToInt32 (cmdparams[0]);
                        yloc = Convert.ToInt32 (cmdparams[1]);
                        externalPort = Convert.ToUInt32 (cmdparams[3]);
                        externalHostName = cmdparams[2];
                        //internalPort = Convert.ToUInt32(cmdparams[4]);
                        //remotingPort = Convert.ToUInt32(cmdparams[5]);
                    }
                    catch (Exception e)
                    {
                        MainConsole.Instance.Output ("[HGrid] Wrong format for link-region command: " + e.Message);
                        LinkRegionCmdUsage ();
                        return;
                    }

                    // Convert cell coordinates given by the user to meters
                    xloc = xloc * (int)Constants.RegionSize;
                    yloc = yloc * (int)Constants.RegionSize;
                    string reason = string.Empty;
                    if (TryCreateLink (UUID.Zero, xloc, yloc, string.Empty, externalPort, externalHostName, UUID.Zero, out regInfo, out reason))
                    {
                        // What is this? The GridRegion instance will be discarded anyway,
                        // which effectively ignores any local name given with the command.
                        //if (cmdparams.Length >= 5)
                        //{
                        //    regInfo.RegionName = "";
                        //    for (int i = 4; i < cmdparams.Length; i++)
                        //        regInfo.RegionName += cmdparams[i] + " ";
                        //}
                    }
                }
                return;
            }
            else if (command.Equals ("unlink-region"))
            {
                if (cmdparams.Length < 1)
                {
                    UnlinkRegionCmdUsage ();
                    return;
                }
                string region = string.Join (" ", cmdparams);
                if (TryUnlinkRegion (region))
                    MainConsole.Instance.Output ("Successfully unlinked " + region);
                else
                    MainConsole.Instance.Output ("Unable to unlink " + region + ", region not found.");
            }
        }