Example #1
0
        /// <summary>
        /// Registers all http request handlers to be served by the web interface. Override to register
        /// own handlers (via <see cref="Resolver.Add"/>) or pages (via <see cref="RegisterPage"/>),
        /// but remember to call the base method to register some shared handlers.
        /// </summary>
        public virtual void RegisterHandlers(FileSystemOptions fsOptions)
        {
            if (fsOptions == null)
            {
                throw new ArgumentException("FileSystemOptions can't be null");
            }

            var fileHandler = new FileSystemHandler(PathUtil.AppPathCombine("Static"), fsOptions);

            Resolver.Add(new UrlMapping(fileHandler.Handle, path: "/Static"));
        }
Example #2
0
    public object Soma(Type T, params object[] valores)
    {
        Resolver r = new Resolver(T);

        foreach (object o in valores)
        {
            r.Add(o);
        }

        return(r.Value);
    }
Example #3
0
        public void Acceptance()
        {
            Resolver.Clear();
            Resolver.Add <int>(() => 1);
            Resolver.Add <Uri>(() => new Uri("http://localhost:8080"));

            var i   = Resolver.Get <int>();
            var uri = Resolver.Get <Uri>();

            Assert.AreEqual("http://localhost:8080/", uri.AbsoluteUri);

            Assert.Throws <ApplicationException>(() => Resolver.Get <double>());
        }
Example #4
0
        public static void Main(string[] args)
        {
            var endpoint = new Uri(args[0]);

            var config = new Config();

            Resolver.Add <RequestHandler>(() => new RequestHandler(config));
            var trigger = new Trigger(endpoint);

            Resolver.Add <Trigger>(() => trigger);

            using (trigger) {
                Server.Run(endpoint);
            }
        }
Example #5
0
        public void Acceptance()
        {
            Environment.CurrentDirectory = TestContext.CurrentContext.TestDirectory;
            var config = new Config("acceptance/urlcron_local_acceptance.config");

            Resolver.Add <RequestHandler>(() => new RequestHandler(config));

            using (var sh = new ServiceHost()) {
                sh.Start(new Uri("http://localhost:8080"));
                Console.WriteLine("Started server...");

                var wc     = new WebClient();
                var result = wc.UploadString("http://localhost:8080/runAllDue", "POST", "");
                Console.WriteLine(result);
            }
        }
Example #6
0
        public Uri AddSchema(string jsonSchema, bool makeCurrent = false)
        {
            JSchema jschema = JSchema.Parse(jsonSchema, Resolver);

            Context.GetTracer().Info($"WhamEngine adding schema {jschema.Title}");
            if (!string.IsNullOrEmpty(jschema.Title))
            {
                if (ClassNameFilters.IsValidTypeName.IsMatch(jschema.Title))
                {
                    if (makeCurrent)
                    {
                        CurrentSchema = jschema;
                    }

                    var uri = new Uri("http://wham.org/" + jschema.Title);
                    Resolver.Add(uri, jsonSchema);

                    if (Context != null)
                    {
                        Context["currentSchema"] = new JSchemaDrop(CurrentSchema);
                        var schemas = Context["schemas"] as List <JSchemaDrop> ?? new List <JSchemaDrop>();
                        schemas.Add(new JSchemaDrop(jschema));
                        Context["schemas"] = schemas;
                    }

                    return(uri);
                }
                else
                {
                    throw new WhamException("[FIAIQIWEHRH] Invalid schema title, it needs to be in namespace.class format");
                }
            }
            else
            {
                throw new WhamException("[FAUHQRJKWRTO] Schema needs Title");
            }
        }
Example #7
0
 /// <summary>
 /// Registers a <see cref="SpinneretPage"/> to be accessible through the web interface.
 /// </summary>
 /// <param name="baseUrl">The URL on which the page will be accessible. If the path ends with "/",
 /// the subpaths will not be handled; otherwise the path and all subpaths will use the page.</param>
 /// <param name="pageMaker">A function taking a request and returning a new page instance for
 /// that request.</param>
 public void RegisterPage(string baseUrl, Func <HttpRequest, SpinneretPage> pageMaker)
 {
     Resolver.Add(new UrlMapping(path: baseUrl, specificPath: baseUrl.EndsWith("/"),
                                 handler: request => handler_Page(request, pageMaker)));
 }
Example #8
0
 public void Add(ContentType type) {
    list.Add(type);
 }