当前位置: 首页>>代码示例>>C#>>正文


C# ApplicationContext类代码示例

本文整理汇总了C#中ApplicationContext的典型用法代码示例。如果您正苦于以下问题:C# ApplicationContext类的具体用法?C# ApplicationContext怎么用?C# ApplicationContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ApplicationContext类属于命名空间,在下文中一共展示了ApplicationContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ApplicationStarted

 protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
 {
     MemberService.Saved += MemberService_Saved;
     MemberService.Created += MemberService_Created;
     
     MemberService.Deleting += MemberService_Deleting;
 }
开发者ID:Interon,项目名称:uMaster,代码行数:7,代码来源:Events.cs

示例2: WindowsServiceRunner

        /// <summary>
        /// Executes the provided IWindowsServices and supports automatic installation using the command line params -install / -uninstall
        /// </summary>
        /// <param name="args"></param>
        /// <param name="createServices">Function which provides a WindowsServiceCollection of services to execute</param>
        /// <param name="configureContext">Optional application context configuration</param>
        /// <param name="installationSettings">Optional installer configuration with semi-sensible defaults</param>
        /// <param name="registerContainer">Optionally register an IoC container</param>
        /// <param name="agentSettingsManager">Optionally provide agent settings </param>
        public WindowsServiceRunner(string[] args,
            Func<IWindowsService[]> createServices,
            Action<ApplicationContext> configureContext = null,
            Action<System.ServiceProcess.ServiceInstaller,
            ServiceProcessInstaller> installationSettings = null,
            Func<IIocContainer> registerContainer = null,
            IAgentSettingsManager agentSettingsManager = null,
            Action<ApplicationContext,string> notify=null)
        {
            _notify = notify ?? ((ctx,message) => { });
            var log = LogManager.GetLogger(typeof (WindowsServiceRunner));
            _args = args;
            _context = new ApplicationContext();
            _createServices = createServices;
            _agentSettingsManager = agentSettingsManager;
            _logger = log;
            _configureContext = configureContext ?? (ctx => {  });
            _context.ConfigureInstall = installationSettings ?? ((serviceInstaller, serviceProcessInstaller) => { });
            _context.Container = registerContainer;

            if (registerContainer==null)
            {
                throw new ArgumentException("Binding container is null");
            }
            if (registerContainer != null)
            {
                _logger.DebugFormat("container is " + registerContainer.ToString());
            }
        }
开发者ID:andrewmyhre,项目名称:DeployD,代码行数:38,代码来源:WindowsServiceRunner.cs

示例3: OnReceive

        public void OnReceive(Message message)
        {
            // Mark the sender on the incoming message
            message.Sender = this;

            if (_protocolManager.IsProtocolNegotiation(message))
            {
                _protocolManager.Negotiate(message);
            }
            else
            {
                ApplicationContext applicationContext;
                if (!_contexts.TryGetValue(message.ContextId, out applicationContext))
                {
                    Logger.TraceInformation("[ConnectionContext]: Creating new application context for {0}", message.ContextId);

                    applicationContext = new ApplicationContext(_services,
                                                                _protocolManager,
                                                                new CompilationEngineFactory(_cache),
                                                                message.ContextId);

                    _contexts.Add(message.ContextId, applicationContext);
                }

                applicationContext.OnReceive(message);
            }
        }
开发者ID:henghu-bai,项目名称:dnx,代码行数:27,代码来源:ConnectionContext.cs

示例4: ConfigurationLoader

        /// <summary>
        /// Creates a new configuration loader for the given application context.
        /// </summary>
        /// <param name="ctx">The application context</param>
        public ConfigurationLoader(ApplicationContext ctx)
        {
            _ctx = ctx;
            ConfigurationProcessors.Add(new ComponentScanProvider());
            ConfigurationProcessors.Add(new ComponentBindingProvider());

        }
开发者ID:ElderByte-,项目名称:Archimedes.Framework,代码行数:11,代码来源:ConfigurationLoader.cs

示例5: ApplicationStarted

 protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
 {
     global::Umbraco.Web.UI.JavaScript.ServerVariablesParser.Parsing += (sender, dictionary) =>
         {
             dictionary["SubscribersList"] = "/umbraco/api/Subscribers/";
         };
 }
开发者ID:AzarinSergey,项目名称:UmbracoE-commerceBadPractic_1,代码行数:7,代码来源:SubscribersController.cs

示例6: Install

        protected override async Task<Result> Install(ApplicationContext context)
        {
            try
            {
                var user = new ApplicationUser();
                user.Email = "[email protected]";
                user.UserName = "[email protected]";

                var userManager = (UserManager<ApplicationUser>)ApplicationServices.GetService(typeof(UserManager<ApplicationUser>));
                var result = await userManager.CreateAsync(user, "!QAZxsw2#");

                if(!result.Succeeded)
                {
                    return Result.Failure(String.Join(",", result.Errors.Select(e => e.Description)));
                }

                result = await userManager.AddToRoleAsync(user, "Administrator");
                if(!result.Succeeded)
                {
                    return Result.Failure(String.Join(",", result.Errors.Select(e => e.Description)));
                }
                return Result.Success();
            }
            catch(Exception ex)
            {
                return Result.Failure("Błąd w czasie dodawanie administratora", Request, ex);
            }
       }
开发者ID:GasiorowskiPiotr,项目名称:EvilDuck.Cms,代码行数:28,代码来源:SecurityInstaller.cs

示例7: UsersController

 public UsersController(UserManager<ApplicationUser> userManager, ApplicationContext context, ILog log)
 {
     _context = context;
     _userManager = userManager;
     _logger = log;
     _logger.Init(GetType().ToString());
 }
开发者ID:GasiorowskiPiotr,项目名称:EvilDuck.Cms,代码行数:7,代码来源:UsersController.cs

示例8: ApplicationStarted

 protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
 {
     try { ((LuceneIndexer)ExamineManager.Instance.IndexProviderCollection["MotoIndexer"]).IfNotNull(x => x.DocumentWriting += MotosIndexerExternalFields); } catch (Exception) { }
     ContentService.Saving += DocumentAfterSaving;
     ContentService.Published += CacheAfterPublishNode;
     ContentService.UnPublished += CacheAfterUnPublishNode;
 }
开发者ID:AzarinSergey,项目名称:motoCache,代码行数:7,代码来源:RegisterEvents.cs

示例9: PerformAnyRequestedInstallations

        public static void PerformAnyRequestedInstallations(string[] args, ApplicationContext context, string assemblyLocation = null)
        {
            if(assemblyLocation == null)
            {
                assemblyLocation = Assembly.GetEntryAssembly().Location;
            }

            var parameter = string.Concat(args);
            _configureAction = x => x.ConfigureServiceInstall(context);

            switch (parameter)
            {
                case "-install":
                case "/install":
                case "-i":
                case "/i":
                    InstallAssemblyAsService(assemblyLocation);
                    break;
                case "-uninstall":
                case "/uninstall":
                case "-u":
                case "/u":
                    UninstallService(assemblyLocation);
                    break;
                case "-tryinstall":
                case "/tryinstall":
                case "-ti":
                case "/ti":
                    TryInstallAsService(assemblyLocation);
                    break;
            }
        }
开发者ID:repne,项目名称:DeployD,代码行数:32,代码来源:ServiceInstaller.cs

示例10: SelectUserRolesViewModel

        // Enable initialization with an instance of ApplicationUser:
        public SelectUserRolesViewModel(ApplicationUser user)
            : this()
        {
            var db = new ApplicationContext();

            // Add all available roles to the list of EditorViewModels:
            var findUser = db.Users.First(u=>u.Email == user.Email);
            if (findUser != null)
            {
                Id = findUser.Id;
                Email = findUser.Email;
                FirstName = findUser.FirstName;
                UserName = findUser.UserName;
                LastName = findUser.LastName;
                Address = findUser.Address;
                City = findUser.City;
                Province = findUser.Province;
            }
            var allRoles = db.Roles;
            foreach (var role in allRoles)
            {
                // An EditorViewModel will be used by Editor Template:
                var rvm = new SelectRoleEditorViewModel(role);
                Roles.Add(rvm);
            }

            // Set the Selected property to true for those roles for
            // which the current user is a member:
            foreach (var userRole in user.Roles)
            {
                var checkUserRole =
                    Roles.Find(r => r.RoleName == userRole.Role.Name);
                checkUserRole.Selected = true;
            }
        }
开发者ID:khoaht,项目名称:AngularJSDemo,代码行数:36,代码来源:SelectUserRolesViewModel.cs

示例11: OnReceive

        public void OnReceive(Message message)
        {
            // Mark the sender on the incoming message
            message.Sender = this;

            if (_protocolManager.IsProtocolNegotiation(message))
            {
                _protocolManager.Negotiate(message);
            }
            else
            {
                ApplicationContext applicationContext;
                if (!_contexts.TryGetValue(message.ContextId, out applicationContext))
                {
                    Logger.TraceInformation("[ConnectionContext]: Creating new application context for {0}", message.ContextId);

                    applicationContext = new ApplicationContext(_services,
                                                                _applicationEnvironment,
                                                                _runtimeEnvironment,
                                                                _loadContextAccessor,
                                                                _protocolManager,
                                                                _compilationEngine,
                                                                _frameworkResolver,
                                                                message.ContextId);

                    _contexts.Add(message.ContextId, applicationContext);
                }

                applicationContext.OnReceive(message);
            }
        }
开发者ID:adwardliu,项目名称:dnx,代码行数:31,代码来源:ConnectionContext.cs

示例12: RolesController

 public RolesController(RoleManager<IdentityRole> roleManager, ApplicationContext context, ILog logging)
 {
     this._rolesManager = roleManager;
     this._context = context;
     this._logging = logging;
     this._logging.Init(typeof(RolesController).FullName);
 }
开发者ID:GasiorowskiPiotr,项目名称:EvilDuck.Cms,代码行数:7,代码来源:RolesController.cs

示例13: GetLocalizedText

 private static string GetLocalizedText(string virtualPath, string textName)
 {
     var appContext = new ApplicationContext();
     var list = ViewTextLocaleList.GetCachedViewTextLocaleList(
         appContext.CurrentTenant.Id, appContext.CurrentLocaleId, virtualPath);
     return list.GetLocalizedText(textName);
 }
开发者ID:NightOwl888,项目名称:ComplexCommerce,代码行数:7,代码来源:WebPageExecutingBaseExtensions.cs

示例14: PerformAnyRequestedInstallations

        public static void PerformAnyRequestedInstallations(string[] args, ApplicationContext context, string assemblyLocation = null)
        {
            if(assemblyLocation == null)
            {
                assemblyLocation = Assembly.GetEntryAssembly().Location;
            }

            var behavior = GetInstallBehavior(args);

            var parameter = string.Concat(args);
            _configureAction = x => x.ConfigureServiceInstall(context);

            switch (behavior)
            {
                case InstallBehavior.Install:
                    EnsureElevated(args);
                    InstallAssemblyAsService(assemblyLocation);
                    break;
                case InstallBehavior.Uninstall:
                    EnsureElevated(args);
                    UninstallService(assemblyLocation);
                    break;
                case InstallBehavior.TryInstall:
                    EnsureElevated(args);
                    TryInstallAsService(assemblyLocation);
                    break;
            }
        }
开发者ID:davidwhitney,项目名称:SimpleServices,代码行数:28,代码来源:SimpleServiceApplication.cs

示例15: OnApplicationStarted

 public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
 {
     if (ShouldExecute(applicationContext))
     {
         ApplicationStarted(umbracoApplication, applicationContext);
     }
 }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:7,代码来源:ApplicationEventHandler.cs


注:本文中的ApplicationContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。