コード例 #1
0
ファイル: Program.cs プロジェクト: kf6kjg/halcyon
        static void Main(string[] args)
        {
            // Template generators are used to render templates 
            // (convert code + html to pure html).
            TemplateManager mgr = new TemplateManager();
            mgr.Add("haml", new HamlGenerator());

            // The httpserver is quite dumb and will only serve http, nothing else.
            HttpServer server  = new HttpServer();

            // a controller mode implements a MVC pattern
            // You'll add all controllers to the same module.
            ControllerModule mod = new ControllerModule();
            mod.Add(new UserController(mgr));
            server.Add(mod);

            // file module will be handling files
            FileModule fh = new FileModule("/", Environment.CurrentDirectory);
            fh.AddDefaultMimeTypes();
            server.Add(fh);

            // Let's start pure HTTP, we can also start a HTTPS listener.
            server.Start(IPAddress.Any, 8081);

            Console.ReadLine();
        }
コード例 #2
0
ファイル: Tutorial5.cs プロジェクト: kf6kjg/halcyon
        public void StartTutorial()
        {
            // load language from a YAML file.
            new YamlWatcher(_language, "..\\..\\tutorial5\\language.yaml"); // "..\\..\\" since we run the tutorial in vstudio
            Validator.Language = _language.GetChild("Validator") ?? LanguageNode.Empty;
            
            // since we do not use files on disk, we'll just add the resource template loader.
            ResourceTemplateLoader templateLoader = new ResourceTemplateLoader();
            templateLoader.LoadTemplates("/", Assembly.GetExecutingAssembly(), "Tutorial.Tutorial5.views");
            TemplateManager templateManager = new TemplateManager(templateLoader);
            templateManager.AddType(typeof (WebHelper));
            templateManager.Add("haml", new HamlGenerator());
            

            // we've just one controller. Add it.
            ControllerModule controllerModule = new ControllerModule();
            controllerModule.Add(new UserController(templateManager, _language));
            _server.Add(controllerModule);

            // add file module, to be able to handle files
            ResourceFileModule fileModule = new ResourceFileModule();
            fileModule.AddResources("/", Assembly.GetExecutingAssembly(), "Tutorial.Tutorial5.public");
            _server.Add(fileModule);

            // ok. We should be done. Start the server.
            _server.Start(IPAddress.Any, 8081);

            Console.WriteLine("Tutorial 5 is running. Go to http://localhost:8081/user/");
            Console.WriteLine("Try to add '?lcid=1053' and '?lcid=1033' to address to switch language (i.e: http://localhost:8081/user/?lcid=1053).");
        }
コード例 #3
0
        /// <summary>
        /// Create a new <see cref="ViewController"/>.
        /// </summary>
        protected ApplicationController(TemplateManager mgr, ILanguageNode language) : base(mgr)
        {
            Language = language.GetChild(char.ToUpper(ControllerName[0]) + ControllerName.Substring(1)) ?? language;

            // fetch validation language.
            ILanguageNode node = language;
            while (node.ParentNode != null)
                node = language.ParentNode;
            _validationLanguage = node.GetChild("Validation");
        }
コード例 #4
0
ファイル: ViewController.cs プロジェクト: kow/Aurora-Sim
 /// <summary>
 /// Create a new <see cref="ViewController"/>.
 /// </summary>
 /// <param name="controller">prototype to copy information from.</param>
 protected ViewController(ViewController controller)
     : base(controller)
 {
     _templateMgr = controller._templateMgr;
 }
コード例 #5
0
ファイル: ViewController.cs プロジェクト: kow/Aurora-Sim
 /// <summary>
 /// Create a new <see cref="ViewController"/>.
 /// </summary>
 protected ViewController(TemplateManager mgr)
 {
     _templateMgr = mgr;
 }
コード例 #6
0
ファイル: UserController.cs プロジェクト: kf6kjg/halcyon
 /// <summary>
 /// This constructor is never called by the framework, only by you when creating the prototype.
 /// that's why we can set the LanguageNode as static.
 /// </summary>
 public UserController(TemplateManager mgr, LanguageNode modelLanguage) : base(mgr, modelLanguage)
 {
     DefaultMethod = "Main";
 }
コード例 #7
0
ファイル: UserController.cs プロジェクト: kow/Aurora-Sim
 public UserController(UserController controller) : base(controller)
 {
     _templateMgr = controller._templateMgr;
 }
コード例 #8
0
ファイル: UserController.cs プロジェクト: kow/Aurora-Sim
 public UserController(TemplateManager mgr)
 {
     _templateMgr = mgr;
     DefaultMethod = "World";
 }
コード例 #9
0
 public DefaultController(TemplateManager manager, HttpServant parent)
     : base(manager)
 {
     this.Servant = parent;
 }