Exemplo n.º 1
0
        private static Gateway DetermineGateway(XProperty gateway, XProperty serverUri, XProperty serverPort)
        {
            Gateway[] gateways = new Gateway[] { Gateway.Asia, Gateway.Europe, Gateway.USEast, Gateway.USWest };

            if (gateway == null)
            {
                string server = serverUri.Value;
                int port = serverUri.AsInt32();
                var realGateway = gateways.Where(g => g.ServerHost.Equals(server, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                if (realGateway != null)
                {
                    return realGateway;
                }
                else
                {
                    return new Gateway(server, "", "", server, port);
                }
            }
            else
            {
                XElement element = gateway.AsElement;
                if (element.HasElements)
                {
                    return new Gateway(
                        element.Property("Name").Value,
                        element.Property("OldClientSuffix").Value,
                        element.Property("Warcraft3ClientSuffix").Value,
                        element.Property("ServerHost").Value,
                        element.Property("ServerPort").AsInt32()
                        );
                }
                else
                {
                    var realGateway = gateways.Where(g => g.Name.Equals(gateway.Value, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                    if (realGateway != null)
                        return realGateway;

                    return new Gateway(gateway.Value, "", "", gateway.Value, 6112);
                }
            }
        }
Exemplo n.º 2
0
 private static object GetGatewayValue(ClientProfile cp)
 {
     Gateway g = cp.Gateway;
     Gateway[] predefined = new Gateway[] { Gateway.USEast, Gateway.USWest, Gateway.Asia, Gateway.Europe };
     Gateway match = predefined.Where(gw => gw.Name.Equals(g.Name, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
     if (match != null)
     {
         return match.Name;
     }
     else
     {
         return (new XElement[] { new XElement("Name", g.Name), new XElement("OldClientSuffix", g.OldClientSuffix), new XElement("Warcraft3ClientSuffix", g.Warcraft3ClientSuffix), new XElement("ServerHost", g.ServerHost), new XElement("ServerPort", g.ServerPort) }).AsEnumerable();
     }
 }