コード例 #1
0
ファイル: Program.cs プロジェクト: solorzanof2/Consolas
        public override void Configure(Container container)
        {
            container.Register <IConsole, SystemConsole>();
            container.Register <IThreadService, ThreadService>();

            ViewEngines.Add <RazorViewEngine>();
        }
コード例 #2
0
        public void Setup()
        {
            var types = new TypePool();
            types.AddAssembly(GetType().Assembly);

            _runner = new ViewEngines();
        }
コード例 #3
0
        public override void Configure(Container container)
        {
            container.Register <IConsole, SystemConsole>();


            ViewEngines.Add <MustacheViewEngine>();
        }
コード例 #4
0
        public void Setup()
        {
            var types = new TypePool();

            types.AddAssembly(GetType().Assembly);

            _runner = new ViewEngines();
        }
コード例 #5
0
        public override void Configure(Container container)
        {
            // We need to add all types in test project as potential arguments
            // as most don't follow the naming convention by ending with 'Args'
            foreach (var type in GetType().Assembly.GetTypes())
            {
                Arguments.Add(type);
            }

            ViewEngines.Clear();
        }
コード例 #6
0
ファイル: Jess.cs プロジェクト: jackingod/jessica
        private static void RegisterViewEngines(IEnumerable <Type> engines)
        {
            engines.ForEach(engine =>
            {
                var instance = Factory.CreateInstance(engine) as IViewEngine;

                if (instance != null)
                {
                    ViewEngines.Add(instance);
                }
            });
        }
コード例 #7
0
        public static void Execute(this IController controller, string action)
        {
            var request = RequestBuilder.CreateRequest(controller.GetType().Name, action, null);

            controller.Execute(
                new ControllerContext(
                    controller,
                    request.BuildRequest(),
                    ViewEngines.CreateDefaults(),
                    ModelBinders.CreateDefaults(),
                    () => { }
                    ));
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: mrpastewart/EmailProcessor
        public override void Configure(Container container)
        {
            Logger log;

            /* Ugly I know, but trying to keep this as low level as possible. If the config
             * doesn't load just log errors. Won't use the actual config service.
             */
            try
            {
                Config config = LoadSettingsFromFile();

                if (config.Debug)
                {
                    log = new LoggerConfiguration()
                          .MinimumLevel.Debug()
                          .WriteTo.Console()
                          .CreateLogger();
                }
                else
                {
                    log = new LoggerConfiguration()
                          .MinimumLevel.Error()
                          .WriteTo.Console()
                          .CreateLogger();
                }
            }
            catch (Exception ex)
            {
                log = new LoggerConfiguration()
                      .MinimumLevel.Error()
                      .WriteTo.Console()
                      .CreateLogger();
            }


            container.Register <IConsole, SystemConsole>();
            container.Register <IThreadService, ThreadService>();

            container.Register <Logger>(() => log, Lifestyle.Singleton);
            container.Register <IConfigService, ConfigService>();
            container.Register <IFileService, FileService>();
            container.Register <INetworkService, NetworkService>();
            container.Register <IEmailService, EmailService>();
            container.Register <IImportService, ImportService>();
            container.Register <IMontiorService, MonitorService>();
            container.Register <IDataService, DataService>();
            container.Register <ICallsService, CallsService>();

            ViewEngines.Add <StubbleViewEngine>();
        }
コード例 #9
0
        protected ViewEngineResult FindViewForController(string controllerName, string viewName, object viewParameters)
        {
            var controllerType      = Project.Assembly.GetType(controllerName, true);
            var controllerShortName = Path.GetExtension(controllerName.Replace("Controller", "")).Substring(1);

            var context = new ControllerContext(Activator.CreateInstance(controllerType) as IController,
                                                new ResolvedNavigationRequest(
                                                    new Uri("magellan://foobar"),
                                                    "foobar",
                                                    true,
                                                    new Mock <INavigator>().Object,
                                                    new Mock <IRoute>().Object,
                                                    new RouteValueDictionary(new{ controller = controllerShortName, action = "x" }),
                                                    new List <INavigationProgressListener>()
                                                    ),
                                                ViewEngines.CreateDefaults());
            var viewEngine = _viewEngineCreator();

            return(viewEngine.FindView(context, new ViewResultOptions(viewParameters), viewName));
        }
コード例 #10
0
ファイル: Jess.cs プロジェクト: jackingod/jessica
        public static void Initialise(JessicaSettings settings = null)
        {
            Settings = settings ?? ConfigurationManager.GetSection("jessica") as JessicaSettings;

            RouteTable.Routes.Clear();
            ViewEngines.Clear();

            var modules = new List <Type>();
            var engines = new List <Type>();

            LoadJessicaAssemblies();

            AppDomain.CurrentDomain.GetAssemblies().ForEach(asm =>
            {
                modules.AddRange(asm.GetTypes().Where(type => type.BaseType == typeof(JessModule)));
                engines.AddRange(asm.GetTypes().Where(type => typeof(IViewEngine).IsAssignableFrom(type)).Where(type => !type.IsInterface));
            });

            RegisterRoutes(modules);
            RegisterViewEngines(engines);
        }
コード例 #11
0
ファイル: WebAppConfig.cs プロジェクト: ArthurYiL/mvc
        public static void Init()
        {
            lock (_initLock)
            {
                if (_initialized)
                {
                    return;
                }

                _initialized = true;

                Regex.CacheSize = 100;

                _version = Assembly.GetExecutingAssembly().GetName().Version.ToString();

                string applicationClassName = null;

                foreach (string configKey in ConfigurationManager.AppSettings.Keys)
                {
                    string configValue = ConfigurationManager.AppSettings[configKey];

                    switch (configKey.ToLower())
                    {
                    case "promesh.defaultlayout":
                    case "mvc.defaultlayout":
                        DefaultLayout = configValue;
                        break;

                    case "promesh.templatepath":
                    case "mvc.templatepath":
                        TemplatePath = configValue;
                        break;

                    case "promesh.uselanguagepath":
                    case "mvc.uselanguagepath":
                        UseLanguagePath = (configValue.ToLower() == "true");
                        break;

                    case "promesh.defaultlanguage":
                    case "mvc.defaultlanguage":
                        DefaultLanguage = configValue;
                        break;

                    case "promesh.applicationclass":
                    case "mvc.applicationclass":
                        applicationClassName = configValue;
                        break;
                    }

                    if (configKey.ToLower().StartsWith("mvc.viewengine"))
                    {
                        IViewEngine viewEngine = (IViewEngine)Activator.CreateInstance(Type.GetType(configValue));

                        string ext = configKey.Length > 15 ? configKey.Substring(14) : null;

                        ViewEngines.Add(viewEngine, ext);
                    }
                }

                if (applicationClassName == null)
                {
                    throw new Exception("No Mvc.ApplicationClass defined in web.config");
                }

                Type appType = Type.GetType(applicationClassName, false);

                if (appType == null)
                {
                    throw new Exception("Application class {" + applicationClassName + "} could not be loaded");
                }

                MethodInfo initMethod = appType.GetMethod("Init", new Type[0]);

                if (initMethod == null || !initMethod.IsStatic)
                {
                    throw new Exception("No \"public static void Init()\" method defined for class " + appType.Name);
                }

                RegisterAssembly(appType.Assembly);
                RegisterAssembly(Assembly.GetExecutingAssembly());

                initMethod.Invoke(null, null);

                ViewEngines.Add(new ViciViewEngine(), "htm");

                LoadControllerClasses();

                StringConverter.RegisterStringConverter(_objectBinder);
            }
        }
コード例 #12
0
 public PageActivationExpression(ViewEngines parent, Func <IViewToken, bool> filter)
 {
     _parent = parent;
     _filter = filter;
 }
コード例 #13
0
 public ControllerContext BuildControllerContext(IController controllerInstance)
 {
     return(new ControllerContext(controllerInstance, BuildRequest(), ViewEngines.CreateDefaults(), ModelBinders.CreateDefaults(), () => { }));
 }
コード例 #14
0
 /// <summary>
 /// Registers a view engine at this <see cref="ViewEngineConfig"/>
 /// </summary>
 /// <typeparam name="TViewEngine">The type of the view engine.</typeparam>
 /// <param name="xhtmlRendering"><c>true</c> if the view engine generates XHTML;
 /// otherwise, <c>false</c>.</param>
 /// <returns>
 ///  A reference to this <see cref="ViewEngineConfig"/> for method chaining.
 /// </returns>
 /// <remarks>
 /// This method is a shortcut for
 /// <code>
 /// ViewEngines.Add(new ViewEngineInfo(typeof(TViewEngine), xhtmlRendering));
 /// </code>
 /// <para/>
 /// <typeparamref name="TViewEngine"/> must be a type that implements <see cref="IViewEngine"/>
 /// </remarks>
 public ViewEngineConfig AddViewEngine <TViewEngine>(bool xhtmlRendering)
     where TViewEngine : IViewEngine
 {
     ViewEngines.Add(new ViewEngineInfo(typeof(TViewEngine), xhtmlRendering));
     return(this);
 }
コード例 #15
0
        public void Setup()
        {
            var types = new TypePool(null);

            _runner = new ViewEngines();
        }
コード例 #16
0
 public override void Configure(Container container)
 {
     ViewEngines.Add <RazorViewEngine>();
 }
コード例 #17
0
 public override void Configure(Container container)
 {
     ViewEngines.Add <StubbleViewEngine>();
 }
コード例 #18
0
 public override void Configure(Container container)
 {
     ViewEngines.Add <MustacheViewEngine>();
 }