public TemplateServiceConfiguration()
        {
            Activator = new DefaultActivator();
            CompilerServiceFactory = new DefaultCompilerServiceFactory();
            EncodedStringFactory = new HtmlEncodedStringFactory();
            
#if !RAZOR4
#pragma warning disable 0618 // Backwards Compat.
            CodeInspectors = new List<ICodeInspector>();
#pragma warning restore 0618 // Backwards Compat.
#endif

            ReferenceResolver = new UseCurrentAssembliesReferenceResolver();
            CachingProvider = new DefaultCachingProvider();
            TemplateManager =
                new DelegateTemplateManager();

            Namespaces = new HashSet<string>
                             {
                                 "System", 
                                 "System.Collections.Generic", 
                                 "System.Linq"
                             };
            
            var config = RazorEngineConfigurationSection.GetConfiguration();
            Language = (config == null)
                           ? Language.CSharp
                           : config.DefaultLanguage;
        }
Exemple #2
0
        public TemplateServiceConfiguration()
        {
            Activator = new DefaultActivator();
            CompilerServiceFactory =
#if RAZOR4
                new Roslyn.RoslynCompilerServiceFactory();
#else
                new DefaultCompilerServiceFactory();
#endif
            EncodedStringFactory = new HtmlEncodedStringFactory();

#if !RAZOR4
#pragma warning disable 0618 // Backwards Compat.
            CodeInspectors = new List <ICodeInspector>();
#pragma warning restore 0618 // Backwards Compat.
#endif

            ReferenceResolver = new UseCurrentAssembliesReferenceResolver();
            CachingProvider   = new DefaultCachingProvider();
            TemplateManager   =
                new DelegateTemplateManager();

            Namespaces = new HashSet <string>
            {
                "System",
                "System.Collections.Generic",
                "System.Linq"
            };

            var config = RazorEngineConfigurationSection.GetConfiguration();
            Language = (config == null)
                           ? Language.CSharp
                           : config.DefaultLanguage;
        }
Exemple #3
0
        public void Compiler_Template_IsAssignable_From_TemplatePage()
        {
            var expectedType = typeof(TemplatePage);

            CompilationResult compilerResult = TestCompilation();
            var actualType = new DefaultActivator().CreateInstance(compilerResult.CompiledType);

            Assert.IsAssignableFrom(expectedType, actualType);
        }
Exemple #4
0
        public static void Main()
        {
            var activator = new DefaultActivator();

            activator.Register <ICommand <PingPongCommand>, PingPongCommandHandler>();
            activator.Register <ICommand <InitiateHandshakeMessage>, InitiateHandshakeMessageHandler>();
            Configure.With(activator)
            .Transport(t => t.UseTcpTransport())
            .Start(new ReWorkServerRole(IPAddress.Any, 13000));
        }
Exemple #5
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            initializeLogging();

            // Workflow

            // 1. read configuration
            var config = new ConfigurationReader().Read();

            // 2. check whether there is a new version or not
            var updatesProvider  = new UpdatesProviderFactory(config).Create();
            var namingConvention = new DefaultNamingConvention();

            try
            {
                var lastVersionFilename = updatesProvider.GetLastVersionFilename(namingConvention);
                var lastVersion         = namingConvention.GetVersionFromFilename(lastVersionFilename);
                var currentVersion      = new CurrentVersionProvider(config).GetCurrentVersion();

                if (lastVersion > currentVersion)
                {
                    log.InfoFormat("Current version: {0}", currentVersion);
                    log.InfoFormat("Last version available: {0}", lastVersion);

                    // 3. if there is a new version, download it
                    var downloadProgressNotificator = new DownloadProgressForm();
                    var localFilename = updatesProvider.Download(lastVersionFilename,
                                                                 downloadProgressNotificator);

                    // 4. then activate it
                    var activator = new DefaultActivator(config, null);
                    activator.Activate(localFilename);
                }
            }
            catch (UpdatesProviderInaccessibleException ex)
            {
                // ignore errors when updates provider is inaccessible
            }
            catch (Exception ex)
            {
                log.Error("Error updating", ex);
            }

            try
            {
                Process.Start(config.ApplicationExe);
            }
            catch (Exception ex)
            {
                log.Fatal("Cannot start application", ex);
            }
        }
        /// <summary>
        /// Initialises a new instance of <see cref="DefaultTemplateServiceConfiguration"/>.
        /// </summary>
        public DefaultTemplateServiceConfiguration()
        {
            Activator = new DefaultActivator();
            CompilerServiceFactory = new DefaultCompilerServiceFactory();
            EncodedStringFactory = new HtmlEncodedStringFactory();

            Namespaces = new HashSet<string>
                             {
                                 "System",
                                 "System.Collections.Generic",
                                 "System.Linq"
                             };

            var config = RazorEngineConfigurationSection.GetConfiguration();
            Language = (config == null)
                           ? Language.CSharp
                           : config.DefaultLanguage;
        }
Exemple #7
0
        /// <summary>
        /// Initialises a new instance of <see cref="TemplateServiceConfiguration"/>.
        /// </summary>
        public TemplateServiceConfiguration()
        {
            Activator = new DefaultActivator();
            CompilerServiceFactory = new DefaultCompilerServiceFactory();
            EncodedStringFactory   = new HtmlEncodedStringFactory();
            CodeInspectors         = new List <ICodeInspector>();

            Namespaces = new HashSet <string>
            {
                "System",
                "System.Collections.Generic",
                "System.Linq"
            };

            var config = RazorEngineConfigurationSection.GetConfiguration();

            Language = (config == null)
                           ? Language.CSharp
                           : config.DefaultLanguage;
        }
        public TemplateServiceConfiguration()
        {
            Activator = new DefaultActivator();
            CompilerServiceFactory =
                new Roslyn.RoslynCompilerServiceFactory();

            EncodedStringFactory = new HtmlEncodedStringFactory();



            ReferenceResolver = new UseCurrentAssembliesReferenceResolver();
            CachingProvider   = new DefaultCachingProvider();
            TemplateManager   =
                new DelegateTemplateManager();

            Namespaces = new HashSet <string>
            {
                "System",
                "System.Collections.Generic",
                "System.Linq"
            };
            Language = Language.CSharp;
        }
Exemple #9
0
        static void Connect(String server, String message)
        {
            try
            {
                Thread.Sleep(1000);

                var activator = new DefaultActivator();
                activator.Register <ICommand <PingPongCommand>, PingPongCommandHandler>();
                activator.Register <ICommand <CompleteHandshakeMessage>, CompleteHandshakeMessageHandler>();
                activator.Register <ICommand <ReceivedMessage>, MessageReceivedCommandHandler>();
                activator.Register <ICommand <HandledMessage>, MessageHandledCommandHandler>();
                var connection = Configure
                                 .With(activator)
                                 .Transport(t => t.UseTcpTransport())
                                 .Start(new ReWorkClientRole("127.0.0.1", 13000));

                while (true)
                {
                    connection.Send(new PingPongCommand()
                    {
                        Message = "Ping!"
                    }, true, true).Wait();
                    Console.ReadLine();
                }
            }
            catch (ArgumentNullException e)
            {
                Console.WriteLine("ArgumentNullException: {0}", e);
            }
            catch (SocketException e)
            {
                Console.WriteLine("SocketException: {0}", e);
            }

            Console.WriteLine("\n Press Enter to continue...");
            Console.Read();
        }
 public Service(DefaultActivator activator, Type type)
 {
     _activator = activator;
     _type      = type;
 }
Exemple #11
0
 public CompactContainer()
 {
     DefaultActivator   = new DefaultActivator(this);
     DependencyResolver = new CompositeDependencyResolver(this);
     DefaultLifestyle   = LifestyleType.Singleton;
 }
Exemple #12
0
        public TStoreType CreateStore <TStoreType>() where TStoreType : IStore <TState>
        {
            if (m_activatorTypeRequest == null)
            {
                throw new MissingActivatorException();
            }

            List <IReducer <TState> > reducers    = new List <IReducer <TState> >();
            List <IMiddleware>        middlewares = new List <IMiddleware>();
            List <IParameter>         parameters  = new List <IParameter>();

            // Create activator
            IActivator activator = DefaultActivator.Get <IActivator>(m_activatorTypeRequest);

            parameters.Add(ConstantParameter.Create <IActivator>(nameof(activator), activator));

            // Logging
            ILog logger = activator.Get <ILog>(m_loggerTypeRequest);

            parameters.Add(new ConstantParameter("log", logger, typeof(ILog)));

            foreach (ITypeRequest singletonRequest in m_singletonTypeRequests)
            {
                object instance = activator.Get(singletonRequest, parameters);

                IParameter parameter = new ConstantParameter("", instance, singletonRequest.Type);

                parameters.Add(parameter);
            }

            foreach (ITypeRequest reducerTypeRequest in m_reducers)
            {
                IReducer <TState> reducer = activator.Get <IReducer <TState> >(reducerTypeRequest, parameters);
                reducers.Add(reducer);
            }

            ReducerMiddleware <TState> rootDispatcher = new ReducerMiddleware <TState>(reducers);

            ActionDispatchDelegate next = rootDispatcher.InvokeAsync;

            foreach (ITypeRequest middlewareTypeRequest in m_middleware)
            {
                IParameter          nextParameter      = ConstantParameter.Create <ActionDispatchDelegate>("next", next);
                IAbstractMiddleware abstractMiddleware = activator.Get <IAbstractMiddleware>(middlewareTypeRequest, parameters.Clone(nextParameter));
                switch (abstractMiddleware)
                {
                case IMiddleware middleware:
                    next = (p) => middleware.InvokeAsync(p);
                    break;

                case IMiddleware <TState> typedMiddleware:
                    next = (p) => typedMiddleware.InvokeAsync((ActionContext <TState>)p);
                    break;

                default:
                    throw new InvalidMiddlewareException(abstractMiddleware.GetType());
                }
            }

            IList <IParameter> storeParameters = parameters.Clone(
                ConstantParameter.Create <TState>("state", m_initialState),
                ConstantParameter.Create <ActionDispatchDelegate>("dispatch", next)
                );

            TypeRequest storeRequest = new TypeRequest(typeof(TStoreType));

            TStoreType store = DefaultActivator.Get <TStoreType>(storeRequest, storeParameters);

            return(store);
        }
Exemple #13
0
 public void Setup()
 {
     _sut = new DefaultActivator();
 }