Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Sid.WebServices.WebService"/> class.
        /// </summary>
        /// <param name="sidModuleAssemblies">Names of assemblies to scan for SidModules.</param>
        /// <param name="successHandler">SuccessHandler; this is a delegate that, if set, 
        /// executes as the last thing before the response hits the wire.  It allows users to
        /// set response headers.</param>
        /// <param name="prefixes">The set of prefixes for the HttpListener class that Sid 
        /// wraps.</param>
        public WebService(IEnumerable<Assembly> sidModuleAssemblies, 
            System.Func<IRequest, Uri, bool> IsValidOriginHandler, params string[] prefixes)
        {
            SetupJsonDefaults();

            if (!HttpListener.IsSupported) {
                throw new NotSupportedException("Not supported on this");
            }

            threadPool = new SmartThreadPool();

            if (prefixes == null || prefixes.Length == 0) {
                throw new ArgumentException("prefixes");
            }

            foreach (var s in prefixes) {
                listener.Prefixes.Add(s);
            }

            methodDispatcher = new RestfulMethodDispatcher(sidModuleAssemblies) {
                IsValidOrigin = IsValidOriginHandler,
            };

            listener.Start();
        }
Ejemplo n.º 2
0
 public Browser(IEnumerable<Assembly> sidModuleAssemblies)
 {
     MethodDispatcher = new RestfulMethodDispatcher(sidModuleAssemblies) {
         IsValidOrigin = (req, uri) => true,
     };
 }