本文整理汇总了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;
}
示例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());
}
}
示例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);
}
}
示例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());
}
示例5: ApplicationStarted
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
global::Umbraco.Web.UI.JavaScript.ServerVariablesParser.Parsing += (sender, dictionary) =>
{
dictionary["SubscribersList"] = "/umbraco/api/Subscribers/";
};
}
示例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);
}
}
示例7: UsersController
public UsersController(UserManager<ApplicationUser> userManager, ApplicationContext context, ILog log)
{
_context = context;
_userManager = userManager;
_logger = log;
_logger.Init(GetType().ToString());
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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;
}
}
示例15: OnApplicationStarted
public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
if (ShouldExecute(applicationContext))
{
ApplicationStarted(umbracoApplication, applicationContext);
}
}