private static string IntegrationService(IRuntimeSettings runtimeSettings) { ApplicationEnvironment environment = runtimeSettings.Environment; return(string.Concat("Integration Service", environment != null ? $" [{environment}]" : string.Empty)); }
public void GetEnvironmentProperties(ApplicationEnvironment applicationEnvironment) { TestUtilities.ConsoleWriteJson(new { Environment.CommandLine, Environment.CurrentDirectory, Environment.CurrentManagedThreadId, Environment.ExitCode, Environment.HasShutdownStarted, Environment.Is64BitOperatingSystem, Environment.Is64BitProcess, Environment.MachineName, Environment.NewLine, Environment.OSVersion, Environment.ProcessorCount, Environment.SystemDirectory, Environment.TickCount, Environment.SystemPageSize, Environment.UserDomainName, Environment.UserName, Environment.Version, Environment.UserInteractive, Environment.WorkingSet, Environment.SpecialFolder.Desktop, Environment.SpecialFolder.UserProfile, LogicalDrives = Environment.GetLogicalDrives(), EnvironmentVariables = Environment.GetEnvironmentVariables() }); }
public ApplicationEnvironment Create(long applicationId, long environmentId) { if (!ApplicationExists(applicationId)) { throw new EntityValidationException("Application does not exist!"); } if (!EnvironmentExists(environmentId)) { throw new EntityValidationException("Environment does not exist!"); } if ( _db.ApplicationEnvironments.Active() .Any(ae => ae.ApplicationId == applicationId && ae.EnvironmentId == environmentId)) { throw new EntityValidationException("This environment is already added to this application."); } var env = new ApplicationEnvironment() { ApplicationId = applicationId, EnvironmentId = environmentId, Active = true }; _db.ApplicationEnvironments.Add(env); _db.SaveChanges(); return(Get(env.ApplicationEnvironmentId)); }
public bool RedirectApplicationLaunchIfNeeded(IApplicationPackage package, ApplicationEnvironment environment) { bool shouldRedirect = false; var manifest = package.Manifest; if (manifest.SingleInstance || !string.IsNullOrEmpty(manifest.ProcessGroup)) { var mutexName = string.Format("{0}:{1}:{2}", (string.IsNullOrEmpty(manifest.ProcessGroup) ? manifest.Id : manifest.ProcessGroup), environment, System.Environment.UserName); string channelName = mutexName + ":LaunchRedirectorService"; bool createdNew = false; var mutex = new Mutex(true, mutexName, out createdNew); shouldRedirect = !createdNew; if (shouldRedirect) { RedirectAplicationLaunch(channelName); mutex.Close(); } else { _mutex = mutex; if (!_pendingSingleInstanceAppLaunches.Contains(manifest.Id)) { _pendingSingleInstanceAppLaunches.Add(manifest.Id); } StartApplicationLaunchRedirectionService(channelName); } } return(shouldRedirect); }
public MetricsAppEnvironment(ApplicationEnvironment applicationEnvironment) { ApplicationName = applicationEnvironment.ApplicationName; ApplicationVersion = applicationEnvironment.ApplicationVersion; RuntimeFramework = applicationEnvironment.RuntimeFramework.Identifier; RuntimeFrameworkVersion = applicationEnvironment.RuntimeFramework.Version.ToString(); }
private SortedList <string, string> _sources; // property name -> where it came from private ApplicationContext(ApplicationEnvironment environment) { try { _environment = environment; // The applicationPropertyPath may be null, eg. when running unit tests. _applicationPropertyPath = ConfigurationManager.AppSettings[APPLICATION_PROPERTY_PATH]; // EP 10/09/08: DO NOT REMOVE this call to configure log4net. It's required to prevent // NHibernate from logging too much stuff, which is OK on a dev machine, but drastically // slows down the unit tests on the build server. XmlConfigurator.Configure(); Configure(); } catch (Exception e) { var eventLog = new EventLog { Source = "Application" }; eventLog.WriteEntry("Unable to configure application:" + System.Environment.NewLine + MiscUtils.GetExceptionMessageTree(e), EventLogEntryType.Error); throw; } }
public Startup(IHostingEnvironment env) { // Setup configuration sources. var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("version.json") .AddJsonFile("config.json") .AddJsonFile($"config.{env.EnvironmentName}.json", optional: true) .AddEnvironmentVariables(); if (env.IsDevelopment()) { // This reads the configuration keys from the secret store. // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709 builder.AddUserSecrets(); // This will push telemetry data through Application Insights pipeline faster, allowing you to view results immediately. //builder.AddApplicationInsightsSettings(developerMode: true); builder.AddApplicationInsightsSettings(developerMode: false); } else if (env.IsStaging() || env.IsProduction()) { // This will push telemetry data through Application Insights pipeline faster, allowing you to view results immediately. builder.AddApplicationInsightsSettings(developerMode: false); } Configuration = builder.Build(); Configuration["version"] = new ApplicationEnvironment().ApplicationVersion; // version in project.json }
static void Main(string[] args) { var env = new ApplicationEnvironment(); var bootupConfigurationProvider = new BootupConfigurationProvider(env); Autofac.ContainerBuilder cb = new Autofac.ContainerBuilder(); cb.RegisterInstance <IEnvironment>(env); cb.RegisterInstance(bootupConfigurationProvider).As <IBootupConfigurationProvider>(); cb.RegisterModule <Teleware.Foundation.Core.Module>(); cb.RegisterModule <Teleware.Foundation.Configuration.Module>(); cb.RegisterModule <Teleware.Foundation.Diagnostics.Loggers.NLog.Module>(); cb.RegisterModule <Teleware.Foundation.Data.Memory.Module>(); //cb.RegisterModule<Teleware.Foundation.Data.EntityFramework.Module>(); //cb.RegisterModule<Teleware.Foundation.Data.EntityFramework.Oracle.Module>(); var container = cb.Build(); using (var lt = container.BeginLifetimeScope()) { while (true) { var db = lt.Resolve <IOptions <DatabaseOptions> >(); Console.WriteLine(db.Value.ConnectionStrings.First().ToString()); Thread.Sleep(1000); } } }
private async Task <int> ExecuteCommandWithServices(IServiceProvider services, Project project, string[] args) { var environment = new ApplicationEnvironment(project, _targetFramework.Value, _configuration.Value); var applicationHost = new ApplicationHost.Program( (IAssemblyLoaderContainer)_hostServices.GetService(typeof(IAssemblyLoaderContainer)), environment, services); try { return(await applicationHost.Main(args)); } catch (Exception ex) { Trace.TraceError("[ApplicationContext]: ExecutCommandWithServices" + Environment.NewLine + ex.ToString()); OnTransmit(new Message() { ContextId = Id, MessageType = "Error", Payload = JToken.FromObject(new ErrorMessage() { Message = ex.ToString(), }), }); throw; }; }
/// <summary> /// Constructor /// </summary> /// <param name="env">ApplicationEnvironment</param> public ScriptEditor(ApplicationEnvironment env) { m_env = env; CodeEditorSyntaxLoader.SetSyntax(codeEditorControl, SyntaxLanguage.Python); DMESaveButton.Enabled = true; DMESaveAsButton.Enabled = true; }
public void LoadAssembliesIntoAppDomain(IEnumerable<AssemblyData> assembliesAndSymbols, ApplicationEnvironment environment) { var resolver = new AssemblyResolver(); resolver.Attach(); // Store files locally, because only pure IL assemblies can be loaded directly from memory var path = Path.Combine( environment.GetLocalResourcePath("AssembliesTemp"), Guid.NewGuid().ToString("N")); if (Directory.Exists(path)) { Directory.Delete(path, true); } Directory.CreateDirectory(path); foreach (var assembly in assembliesAndSymbols) { File.WriteAllBytes(Path.Combine(path, assembly.Name), assembly.Bytes); } var assemblies = Directory.EnumerateFiles(path, "*.dll").Concat(Directory.EnumerateFiles(path, "*.exe")); foreach (var assembly in assemblies) { Assembly.LoadFile(assembly); } }
public static void ChangeEnvironment(ApplicationEnvironment newEnvironment) { if (_currentEnvironment != newEnvironment) { _currentEnvironment = newEnvironment; } }
public static List <TestSuiteMethod> GetTestRunOptions(ApplicationEnvironment applicationEnvironment) { List <TestSuiteMethod> testRunOptions = new List <TestSuiteMethod>(); List <string> testSuiteClasses = AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypes()) .Where(x => typeof(ITestSuite).IsAssignableFrom(x) && !x.IsInterface && !x.IsAbstract) .Select(x => x.FullName).ToList(); int methodOrder = 1; foreach (string testSuiteClassName in testSuiteClasses) { Type testSuiteType = Type.GetType(testSuiteClassName); ConstructorInfo constructor = testSuiteType.GetConstructor(Type.EmptyTypes); object magicClassObject = constructor.Invoke(new object[] { }); List <MethodInfo> methodInfos = testSuiteType.GetMethods(BindingFlags.Public | BindingFlags.Instance) .Where(m => m.DeclaringType != typeof(object)).ToList(); foreach (MethodInfo methodInfo in methodInfos) { TestSuiteMethod testSuiteMethod = new TestSuiteMethod(); testSuiteMethod.Title = $"{testSuiteType.Name} => {methodInfo.Name}"; testSuiteMethod.Order = methodOrder; testSuiteMethod.TaskToRun = delegate { object[] parameters = { applicationEnvironment }; methodInfo.Invoke(magicClassObject, parameters); }; testRunOptions.Add(testSuiteMethod); methodOrder++; } } return(testRunOptions); }
public void Initialize(string registrySettingsPath, IContentEditorLogger logger, IContentTarget contentTarget, ISettingsProvider settingsProvider) { try { GlobalEditorOptions.Init(contentTarget, settingsProvider); HtmlEditorControl.AllowCachedEditor(); Assembly assembly = Assembly.GetExecutingAssembly(); ApplicationEnvironment.Initialize(assembly, Path.GetDirectoryName(assembly.Location), registrySettingsPath, contentTarget.ProductName); ContentSourceManager.Initialize(false); Trace.Listeners.Clear(); if (logger != null) { _logger = new RedirectionLogger(logger); Trace.Listeners.Add(_logger); } #if DEBUG Trace.Listeners.Add(new DefaultTraceListener()); #endif } catch (Exception e) { Trace.Fail("Failed to initialize Shared Canvas: " + e); Trace.Flush(); throw; } }
//private static string _timeout = ParseTimeout(); //private static int _candidateTimeOut; //private static readonly string TimeoutSuffix = "Connection Timeout=" + _timeout + ";"; //private static readonly string InternetConnStrTesting = ConfigurationManager.ConnectionStrings[ConnectionStringKeys.INTERNET_TEST].ConnectionString + TimeoutSuffix; //private static readonly string FTDataConnStrTesting = ConfigurationManager.ConnectionStrings[ConnectionStringKeys.FTDATA_TEST].ConnectionString + TimeoutSuffix; public string GetConnectionString(ApplicationEnvironment environment, ApplicationDatabase context) { //string connectionString; if (environment == ApplicationEnvironment.Production) { throw new NotImplementedException(); } return("UNIDATA"); //else //{ // switch (context) // { // case ApplicationDatabase.FTData: // throw new NotImplementedException(); // connectionString = FTDataConnStrTesting; // break; // case ApplicationDatabase.Internet: // connectionString = InternetConnStrTesting; // break; // default: // throw new NotImplementedException(); // } //} //return connectionString; }
public static void UseEnvironmentEndpoint(this IApplicationBuilder app, bool includeEnvVars = true) { app.Use(async(context, next) => { if (context.Request.Path.Value.Equals("/env")) { // Perform IP access check if (MicroserviceConfiguration.AllowedIpAddresses != null && context.Request.HttpContext.Connection.RemoteIpAddress != null && !MicroserviceConfiguration.AllowedIpAddresses.Contains( context.Request.HttpContext.Connection.RemoteIpAddress)) { context.Response.StatusCode = 403; await next(); } // Get current application environment ApplicationEnvironment env = ApplicationEnvironment.GetApplicationEnvironment(includeEnvVars); context.Response.Headers["Content-Type"] = "application/json"; await context.Response.WriteAsync(JsonConvert.SerializeObject(env, Formatting.Indented, new JsonSerializerSettings() { StringEscapeHandling = StringEscapeHandling.EscapeNonAscii })); } else { await next(); } }); }
private void SendTo(MonitorTarget target, MonitorWorkItem workItem, ILog log, string subjectPrefix) { MonitorEntry[] entries = workItem.GetEntries(target); if (entries.Length != 0) { if (target.Recipients == null || target.Recipients.Length == 0) { log.Warning(Target.Service, "No recipients found for target '{0}'.", new object[] { target }); return; } log.Message("Sending {0} entries to {1}.", new object[] { (int)entries.Length, target }); StringBuilder stringBuilder = new StringBuilder(); ApplicationEnvironment environment = this._runtimeSettings.Environment; if (environment != null) { stringBuilder.AppendFormat("[{0}] ", environment); } if (!string.IsNullOrWhiteSpace(subjectPrefix)) { stringBuilder.AppendFormat("{0}: ", subjectPrefix); } stringBuilder.AppendFormat("Monitoring ({0})", workItem.CheckRange); this._emailService.Send(new MonitorEmailTemplate(stringBuilder.ToString(), entries, target), target.Recipients); } }
private void SendTo(MonitorTarget target, ITaskExecutionContext <MonitorWorkItem> context) { MonitorEntry[] entries = context.WorkItem.GetEntries(target); if (entries.Length > 0) { if (target.Recipients == null || target.Recipients.Length == 0) { context.Log.Warning(Target.Service, "No recipients found for target '{0}'.", target); return; } context.Log.Message("Sending {0} entries to {1}.", entries.Length, target); var subject = new StringBuilder(); ApplicationEnvironment environment = _runtimeSettings.Environment; if (environment != null) { subject.AppendFormat("[{0}] ", environment); } if (!string.IsNullOrWhiteSpace(context.WorkItem.Configuration.SubjectPrefix)) { subject.AppendFormat("{0}: ", context.WorkItem.Configuration.SubjectPrefix); } subject.AppendFormat("Monitoring ({0})", context.WorkItem.CheckRange); _emailService.Send(new MonitorEmailTemplate(subject.ToString(), entries, target), target.Recipients); } }
protected virtual string GetReportBody() { var body = new StringBuilder(); body.AppendLine(ExceptionString); body.AppendLine(); body.AppendLine(new string('-', 80)); if (!string.IsNullOrWhiteSpace(TxtErrorComment.Text)) { body.AppendLine("<補足>:" + TxtErrorComment.Text); body.AppendLine(new string('-', 80)); } body.AppendLine($"バージョン: Inazuma Search {ApplicationEnvironment.GetVersion().ToString()}" + (ApplicationEnvironment.GetPlatform() == "x86" ? " (32ビットバージョン)" : "")); body.AppendLine($"発生日時: {RaisedTime.ToString("yyyy-MM-dd HH:mm:ss")}"); if (UserSetting.LastLoadedUserUuid != null) { body.AppendLine($"UUID: {UserSetting.LastLoadedUserUuid}"); } body.AppendLine(); body.AppendLine($"[OS]"); var bitCaption = (OSIs64Bit == null ? "ビット数不明" : OSIs64Bit.Value ? "64ビット" : "32ビット"); body.AppendLine($"{OSCaption ?? "不明"} {bitCaption}"); body.AppendLine($"[メモリ使用量]"); body.AppendLine($"物理RAM : {FormatMemorySize(ProcessWorkingSet)} (ピーク: {FormatMemorySize(ProcessPeakWorkingSet)})"); body.AppendLine($"ページングファイル : {FormatMemorySize(ProcessPagedMemorySize)} (ピーク: {FormatMemorySize(ProcessPeakPagedMemorySize)})"); return(body.ToString()); }
public static string GetRuntimeVersion() { ApplicationEnvironment app = PlatformServices.Default.Application; var split = app.ApplicationVersion.Split('.'); return(string.Join('.', split.Take(3))); }
public void AskException(ApplicationEnvironment applicationEnvironment) { ActorSystem actorSystem = ActorSystem.Create("app"); IActorRef userActor = actorSystem.ActorOf <UserActor>(); IActorRef registerActor = actorSystem.ActorOf <RegisterActor>(); UserAction userAction = new UserAction(UserActionTypes.GenerateRandom); userAction.ExceptionToThrow = new Exception("Cannot make SQL connection"); Task <TestUser> testUser = userActor.Ask <TestUser>(userAction); testUser.Wait(); Task <object> registerTask = registerActor.Ask(userAction); try { registerTask.Wait(); } catch (Exception exception) { TestUtilities.ConsoleWriteJson(new { exception }); } userAction.ExceptionToThrow = null; registerTask = registerActor.Ask(userAction); registerTask.Wait(); }
public static string ToString(ApplicationEnvironment type) { string urlPrefix = ""; string urlDomain = "volotea.com/"; switch (type) { case ApplicationEnvironment.Prod: urlPrefix = UrlPrefix.Prod; break; case ApplicationEnvironment.CI: urlPrefix = UrlPrefix.CI; break; case ApplicationEnvironment.Pre1: urlPrefix = UrlPrefix.Pre1; break; case ApplicationEnvironment.Pre2: urlPrefix = UrlPrefix.Pre2; break; case ApplicationEnvironment.Pre3: urlPrefix = UrlPrefix.Pre3; break; case ApplicationEnvironment.Pre4: urlPrefix = UrlPrefix.Pre4; break; case ApplicationEnvironment.Pre5: urlPrefix = UrlPrefix.Pre5; break; case ApplicationEnvironment.Pre6: urlPrefix = UrlPrefix.Pre6; break; default: throw new Exception("AppEnv2URLConverter. Cannot convert given ApplicationEnvironment: " + type.ToString() + " to string"); } return(urlPrefix + urlDomain); }
public void BackoffSupervisorOnFailure(ApplicationEnvironment applicationEnvironment) { ActorSystem actorSystem = ActorSystem.Create("app"); // This class represents a configuration object used in creating an // ActorBase actor Props childProps = Props.Create <EchoActor>(); // TimeSpan minBackoff = TimeSpan.FromSeconds(3); TimeSpan maxBackoff = TimeSpan.FromSeconds(30); double randomFactor = 0.2; int maxNrOfRetries = 2; // Builds back-off options for creating a back-off supervisor. BackoffOptions backoffOptions = Backoff.OnFailure(childProps, "myEcho", minBackoff, maxBackoff, randomFactor, maxNrOfRetries); Props supervisor = BackoffSupervisor.Props(backoffOptions); IActorRef supervisorActor = actorSystem.ActorOf(supervisor, "echoSupervisor"); supervisorActor.Tell("EchoMessage1"); supervisorActor.Tell(new Exception("File not found exception")); TestUtilities.ThreadSleepSeconds(5); supervisorActor.Tell("EchoMessage2"); TestUtilities.ThreadSleepSeconds(5); supervisorActor.Tell("EchoMessage3"); TestUtilities.MethodEnds(); }
public void GetConfig() { var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); ApplicationEnvironment env = PlatformServices.Default.Application; IConfiguration Configuration = builder.Build(); var a = ConfigOptions.AppSettings.SqlHelperNonQueryCommandTimeout; }
public void GetSetDataPersistDataWithinASingleApplicationEnvironmentInstance() { var appEnv = new ApplicationEnvironment(null, null, null, null); var obj = new object(); var key = "testGetSet:" + Guid.NewGuid().ToString("N"); appEnv.SetData(key, obj); Assert.Same(obj, appEnv.GetData(key)); }
/// <summary> /// Constructor /// </summary> public EcellWebBrowser(ApplicationEnvironment env, List<KeyValuePair<string, string>> recentFiles) { m_env = env; InitializeComponent(); webBrowser.ObjectForScripting = new AutomationStub(this); m_recentFiles = recentFiles; m_startupPage = FindStartPage(); }
public ApplicationHostPlatformServices(PlatformServices previous, ApplicationEnvironment applicationEnvironment, RuntimeLibraryManager runtimeLibraryManager) { _previous = previous; LibraryManager = runtimeLibraryManager; Application = applicationEnvironment; }
private void BrowserForm_Load(object sender, EventArgs e) { if (App.DebugMode) { Text = $"Inazuma Search {ApplicationEnvironment.GetVersionCaption()} [Debug Mode]"; } App.Crawler.AlwaysCrawlProgress.ProgressChanged += AlwaysCrawlProgress_ProgressChanged; }
public void DoInstallation(ApplicationEnvironment environment) { container.Register(Configuration(environment)); container.AddFacility<StartableFacility>(); container.Install(FromAssembly.This()); container.Install(FromAssembly.Containing<installer>()); container.Install(FromAssembly.Containing<filedalInstaller>()); }
public void SetUp() { _env = new ApplicationEnvironment(); string group = "Group"; ReportManager rm = _env.ReportManager; _unitUnderTest = rm.GetReportingSession(group); }
public static string GetApplicationEnvironmentName(ApplicationEnvironment environment) { if (!Enum.IsDefined(typeof(ApplicationEnvironment), environment)) { throw new ArgumentException("The specified environment is not a valid ApplicationEnvironment value.", "environment"); } return(EnvironmentNames[(int)environment]); }
/// <summary> /// Constructor with the initial parameters. /// </summary> /// <param name="env">The ApplicationEnvironment.</param> /// <param name="dmDir">The path of dm directory.</param> /// <param name="node">The current selected node.</param> /// <param name="menu">The context menu.</param> public CreateDMDialog(ApplicationEnvironment env, string dmDir, TreeNode node, ContextMenuStrip menu) { m_env = env; InitializeComponent(); m_dir = dmDir; m_node = node; m_menu = menu; }
public ApplicationHostPlatformServices(PlatformServices previous, ApplicationEnvironment applicationEnvironment, RuntimeLibraryManager runtimeLibraryManager) { _previous = previous; LibraryManager = runtimeLibraryManager; Application = applicationEnvironment; }
public DocumentationFiles(ApplicationEnvironment applicationEnvironment) { if (applicationEnvironment == null) { throw new ArgumentNullException(nameof(applicationEnvironment)); } _applicationEnvironment = applicationEnvironment; }
public IProvider QueryInterface(Type refType, Version queryVer) { if (ApplicationEnvironment.InterfaceGuidCompare(ApplicationEnvironment.GetInterfaceGuid(refType), base.GetType()) && ApplicationEnvironment.InterfaceVersionCompare(ApplicationEnvironment.GetInterfaceVersion(refType), queryVer)) { return(this); } return(null); }
public Startup(ApplicationEnvironment appEnv) { var builder = new ConfigurationBuilder() .SetBasePath(appEnv.ApplicationBasePath) .AddJsonFile("config.json") .AddEnvironmentVariables(); Configuration = builder.Build(); }
public void GetSetDataPersistDataWithinEachApplicationEnvironment() { var appEnv1 = new ApplicationEnvironment(null, null, null, null); var appEnv2 = new ApplicationEnvironment(null, null, null, null); var key = "testGetSetDifferent:" + Guid.NewGuid().ToString("N"); appEnv1.SetData(key, new object()); appEnv2.SetData(key, new object()); Assert.NotSame(appEnv1.GetData(key), appEnv2.GetData(key)); }
protected string GetDistFolderPath() { ApplicationEnvironment appEnvironment = new ApplicationEnvironment(); // This works locally, but what about when it's deployed to Azure var tempFolderPath = appEnvironment.ApplicationBasePath.Substring(0, appEnvironment.ApplicationBasePath.LastIndexOf(appEnvironment.ApplicationName, StringComparison.Ordinal) + appEnvironment.ApplicationName.Length); tempFolderPath += @"\wwwroot\dist"; return(tempFolderPath); }
public GetConfigurationHandler(ApplicationEnvironment applicationEnvironment) { if (applicationEnvironment == null) { throw new ArgumentNullException(nameof(applicationEnvironment)); } _applicationEnvironment = applicationEnvironment; }
/// <summary> /// Constructor. /// </summary> public Splash(ApplicationEnvironment env) { m_env = env; InitializeComponent(); Assembly executingAssembly = Assembly.GetExecutingAssembly(); VersionNumber.Text = ((AssemblyProductAttribute)executingAssembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false)[0]).Product; CopyrightNotice.Text = "Copyright\r\n" + ((AssemblyCopyrightAttribute)executingAssembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)[0]).Copyright; m_ehandler = new Ecell.Logging.LogEntryAppendedEventHandler(LogManager_LogEntryAppended); env.LogManager.LogEntryAppended += m_ehandler; }
public void GetSetDataPersistDataGloballyAcrossAppDomainInDesktopClr() { var appEnv1 = new ApplicationEnvironment(null, null, null, null); var appEnv2 = new ApplicationEnvironment(null, null, null, null); var obj = new object(); var key = "testGetSetGlobal:" + Guid.NewGuid().ToString("N"); appEnv1.SetData(key, obj); Assert.Same(obj, appEnv2.GetData(key)); Assert.Same(obj, AppDomain.CurrentDomain.GetData(key)); }
/// <summary> /// /// </summary> /// <param name="env"></param> public SelectPlotDataDialog(ApplicationEnvironment env) { InitializeComponent(); IList<string> resList = env.DataManager.GetLoggerList(); foreach (String data in resList) { XplotComboBox.Items.Add(data); YPlotComboBox.Items.Add(data); } }
/// <summary> /// /// </summary> public LayoutPane(ApplicationEnvironment env) { InitializeComponent(); _env = env; foreach (ILayoutPanel panel in _env.PluginManager.GetLayoutPanels()) { SetPanel((LayoutPanel)panel); } if(tabControl.TabPages.Count > 0) SetAlgorithm(tabControl.TabPages[0]); }
static void Main(string[] args) { string[] fileList = parseArguments(args); Util.InitialLanguage(); ApplicationEnvironment env = new ApplicationEnvironment(); Splash frmSplash = new Splash(env); if (!s_noSplash) frmSplash.Show(); MainWindow.MainWindow window = null; EventHandler onIdle = null; onIdle = delegate(object sender, EventArgs ev) { Application.Idle -= onIdle; IEcellPlugin mainWnd = env.PluginManager.RegisterPlugin( typeof(Ecell.IDE.MainWindow.MainWindow)); window = (MainWindow.MainWindow)mainWnd; env.PluginManager.ChangeStatus(ProjectStatus.Uninitialized); ((Form)mainWnd).Show(); // Load default window settings. window.LoadDefaultWindowSetting(); window.SetStartUpWindow(); if (!s_noSplash) frmSplash.Close(); foreach (string fPath in fileList) { if (fPath.EndsWith(Constants.FileExtEML) || fPath.EndsWith(Constants.fileProjectXML)) { env.DataManager.LoadProject(fPath); } else { //window.LoadUserActionFile(fPath); } } }; try { Application.Idle += onIdle; Application.Run(window); } catch (Exception e) { Trace.WriteLine(e.ToString()); } }
public void GetSetDataSharesWithHostEnvironmentIfProvided() { var appEnv1 = new ApplicationEnvironment(null, null, null, null); var appEnv2 = new ApplicationEnvironment(null, null, null, appEnv1); var key1 = "testGetSetShared:" + Guid.NewGuid().ToString("N"); var key2 = "testGetSetShared2:" + Guid.NewGuid().ToString("N"); var obj1 = new object(); var obj2 = new object(); appEnv1.SetData(key1, obj1); appEnv2.SetData(key2, obj2); Assert.Same(obj1, appEnv2.GetData(key1)); Assert.Same(obj2, appEnv1.GetData(key2)); }
public Task<int> Main(string[] args) { if (args.Length < 1) { Console.WriteLine("{app} [arguments]"); return Task.FromResult(-1); } var name = args[0]; var programArgs = args.Skip(1).ToArray(); var assembly = Assembly.Load(new AssemblyName(name)); if (assembly == null) { return Task.FromResult(-1); } #if NET45 // REVIEW: Need a way to set the application base on mono string applicationBaseDirectory = PlatformHelper.IsMono ? Directory.GetCurrentDirectory() : AppDomain.CurrentDomain.SetupInformation.ApplicationBase; #else string applicationBaseDirectory = ApplicationContext.BaseDirectory; #endif var framework = Environment.GetEnvironmentVariable("TARGET_FRAMEWORK") ?? Environment.GetEnvironmentVariable("KRE_FRAMEWORK"); var configuration = Environment.GetEnvironmentVariable("TARGET_CONFIGURATION") ?? Environment.GetEnvironmentVariable("KRE_CONFIGURATION") ?? "Debug"; var targetFramework = FrameworkNameUtility.ParseFrameworkName(framework ?? (PlatformHelper.IsMono ? "net45" : "net451")); var applicationEnvironment = new ApplicationEnvironment(applicationBaseDirectory, targetFramework, configuration, assembly: assembly); CallContextServiceLocator.Locator = new ServiceProviderLocator(); var serviceProvider = new ServiceProvider(); serviceProvider.Add(typeof(IAssemblyLoaderContainer), _container); serviceProvider.Add(typeof(IAssemblyLoaderEngine), _loaderEngine); serviceProvider.Add(typeof(IApplicationEnvironment), applicationEnvironment); CallContextServiceLocator.Locator.ServiceProvider = serviceProvider; return EntryPointExecutor.Execute(assembly, programArgs, serviceProvider); }
public void SetUp() { _env = new ApplicationEnvironment(); _unitUnderTest = _env.ActionManager; // Load plugins foreach (string pluginDir in Util.GetPluginDirs()) { string[] files = Directory.GetFiles( pluginDir, Constants.delimiterWildcard + Constants.FileExtPlugin); foreach (string fileName in files) { _env.PluginManager.LoadPlugin(fileName); } } }
/// <summary> /// Method to create the primary key. /// </summary> /// <param name="applicationEnvironment">The application environment.</param> /// <returns>Returns primary key value.</returns> public static string GetPrimaryKey(ApplicationEnvironment applicationEnvironment) { string primaryKey; try { primaryKey = string.Format("{0}{1}{2}", applicationEnvironment.ToString(), RepositoryUtil.GetFormattedLongDateTime("yyyyMMddHHmmssffffff"), RepositoryUtil.GetCryptographicRandomCharacterGenerator(8)); } catch (Exception exception) { Logger.Error("Error at GetPrimaryKey", exception); throw; } return primaryKey; }
public static void Initialize(IntPtr context, IntPtr exception) { try { DebugMessage("CoreCLREmbedding::Initialize (CLR) - Starting"); RuntimeEnvironment = new EdgeRuntimeEnvironment(Marshal.PtrToStructure<EdgeBootstrapperContext>(context)); Project project; Project.TryGetProject(RuntimeEnvironment.ApplicationDirectory, out project); ApplicationHostContext = new ApplicationHostContext { ProjectDirectory = RuntimeEnvironment.ApplicationDirectory, TargetFramework = TargetFrameworkName, Project = project }; ApplicationEnvironment = new ApplicationEnvironment(ApplicationHostContext.Project, TargetFrameworkName, "Release", null); LoadContextAccessor = new EdgeAssemblyLoadContextAccessor(); EdgeServiceProvider serviceProvider = new EdgeServiceProvider(); serviceProvider.Add(typeof(IRuntimeEnvironment), RuntimeEnvironment); serviceProvider.Add(typeof(IApplicationEnvironment), ApplicationEnvironment); serviceProvider.Add(typeof(IAssemblyLoadContextAccessor), LoadContextAccessor); CallContextServiceLocator.Locator = new EdgeServiceProviderLocator { ServiceProvider = serviceProvider }; PlatformServices.SetDefault(PlatformServices.Create(null, ApplicationEnvironment, RuntimeEnvironment, null, LoadContextAccessor, null)); DebugMessage("CoreCLREmbedding::Initialize (CLR) - Complete"); } catch (Exception e) { DebugMessage("CoreCLREmbedding::Initialize (CLR) - Exception was thrown: {0}", e.Message); V8Type v8Type; Marshal.WriteIntPtr(exception, MarshalCLRToV8(e, out v8Type)); } }
private PlatformServices() { Application = new ApplicationEnvironment(); }
public CommonFactoryImpl(ApplicationEnvironment applicationEnvironment) { this.applicationEnvironment = applicationEnvironment; }
public void TearDown() { _env = null; _unitUnderTest = null; }
/// <summary> /// Constructor for ActionManager. /// </summary> public ActionManager(ApplicationEnvironment env) { m_env = env; m_list = new List<UserAction>(); }
public void SetUp() { _env = new ApplicationEnvironment(); _unitUnderTest = new JobManager(_env); }
public void SetUp() { _env = new ApplicationEnvironment(); _env.DataManager.LoadProject(TestConstant.Model_Drosophila); _unitUnderTest = new ProcessConverter(); }
/// <summary> /// Constructor /// </summary> /// <param name="env">the application environment.</param> public LoggerManager(ApplicationEnvironment env) { m_env = env; m_count = 0; }
private static BasedOnDescriptor Configuration(ApplicationEnvironment environment) { return AllTypes.FromThisAssembly().Pick().If(t => t.Namespace != null && t.Namespace.EndsWith(".Configuration") && t.Name == environment.ToString()).Configure(c => c.LifeStyle.Singleton).WithService.AllInterfaces(); }
/// <summary> /// Initializes a new instance of the <see cref="CaseFactoryImpl"/> class. /// </summary> /// <param name="applicationEnvironment">The application environment.</param> public CaseSpecificFactoryImpl(ApplicationEnvironment applicationEnvironment) { this.applicationEnvironment = applicationEnvironment; }
/// <summary> /// Initializes a new instance of the <see cref="AuditFactoryImpl"/> class. /// </summary> /// <param name="applicationEnvironment">The application environment.</param> public AuditFactoryImpl(ApplicationEnvironment applicationEnvironment) { this.applicationEnvironment = applicationEnvironment; }
public Task<int> RunAsync(List<string> args, IRuntimeEnvironment env, FrameworkName targetFramework) { var accessor = LoadContextAccessor.Instance; var container = new LoaderContainer(); LoadContext.InitializeDefaultContext(new DefaultLoadContext(container)); var disposable = container.AddLoader(new PathBasedAssemblyLoader(accessor, _searchPaths)); try { var name = args[0]; var programArgs = new string[args.Count - 1]; args.CopyTo(1, programArgs, 0, programArgs.Length); var assembly = accessor.Default.Load(name); if (assembly == null) { return Task.FromResult(-1); } #if DNX451 string applicationBaseDirectory = Environment.GetEnvironmentVariable(EnvironmentNames.AppBase); if (string.IsNullOrEmpty(applicationBaseDirectory)) { applicationBaseDirectory = Directory.GetCurrentDirectory(); } #else string applicationBaseDirectory = AppContext.BaseDirectory; #endif var configuration = Environment.GetEnvironmentVariable("TARGET_CONFIGURATION") ?? Environment.GetEnvironmentVariable(EnvironmentNames.Configuration) ?? "Debug"; Logger.TraceInformation($"[{nameof(Bootstrapper)}] Runtime Framework: {targetFramework}"); var applicationEnvironment = new ApplicationEnvironment(applicationBaseDirectory, targetFramework, configuration, assembly); CallContextServiceLocator.Locator = new ServiceProviderLocator(); var serviceProvider = new ServiceProvider(); serviceProvider.Add(typeof(IAssemblyLoaderContainer), container); serviceProvider.Add(typeof(IAssemblyLoadContextAccessor), accessor); serviceProvider.Add(typeof(IApplicationEnvironment), applicationEnvironment); serviceProvider.Add(typeof(IRuntimeEnvironment), env); CallContextServiceLocator.Locator.ServiceProvider = serviceProvider; #if DNX451 if (RuntimeEnvironmentHelper.IsMono) { // Setting this value because of a Execution Context bug in older versions of Mono AppDomain.CurrentDomain.SetData("DNX_SERVICEPROVIDER", serviceProvider); } #endif var task = EntryPointExecutor.Execute(assembly, programArgs, serviceProvider); return task.ContinueWith(async (t, state) => { // Dispose the host ((IDisposable)state).Dispose(); return await t; }, disposable).Unwrap(); } catch { disposable.Dispose(); throw; } }