internal static Type ParseTypeName(Application app, string typeName) { if (typeName.IndexOf(",") > 0) { return Type.GetType(typeName, /* throwOnError */ false, /* ignoreCase */ false); } else { Type appType = app.GetType(); if (typeName.IndexOf(".") < 0) { typeName = appType.Namespace + "." + typeName; } return appType.Assembly.GetType(typeName, /* throwOnError */ false); } }
private static void SetDeployment(Deployment deployment) { Application app = Application.Current; if (app != null) { Type appType = app.GetType(); #if NETSTANDARD deployment.SetValue(EntryPointAssemblyProperty, appType.Assembly.GetName().Name); #elif BRIDGE deployment.SetValue(EntryPointAssemblyProperty, string.Concat(appType.Assembly.FullName.TakeWhile(c => c != ','))); #endif deployment.SetValue(EntryPointTypeProperty, appType.FullName); _current = deployment; } }
private void ConfigureControllers(Application application) { Type localClass = application.GetType(); deviceController = new DeviceController(); Debug.WriteLine("## AppName: " + deviceController.AppName); Debug.WriteLine("## Version: " + deviceController.Version); foreach (object attribute in localClass.GetCustomAttributes(true)) { if (attribute is MposConfig) { MposConfig appConfig = (MposConfig)attribute; Debug.WriteLine(appConfig); if (appConfig.DeviceDetails) { deviceController.CollectDeviceConfig(); } if (appConfig.LocationCollect) { deviceController.CollectLocation(); } if (appConfig.EndpointSecondary == null && !appConfig.DiscoveryCloudlet) { throw new NetworkException("You must define an internet server IP or allow the service discovery!"); } profileController = new ProfileController(appConfig.Profile); endpointController = new EndpointController(appConfig.EndpointSecondary, appConfig.DecisionMakerActive, appConfig.DiscoveryCloudlet); break; } } }
// ---------------------------------------------------------------------- public WindowsApplicationSettings(Application application) : this(application, application.GetType()) { } // WindowsApplicationSettings
private void InjectObjects(Application app, IProxy proxy) { Type localClass = app.GetType(); BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly; foreach (FieldInfo field in localClass.GetFields(flags)) { foreach (object injectAttribute in field.GetCustomAttributes(true)) { if (injectAttribute is Inject) { if (field.FieldType.IsInterface) { Inject inject = injectAttribute as Inject; Debug.WriteLine(">> Interface: '" + field.FieldType.Name + "' request a injecting class: " + inject.Type.Name); bool remoteSupport = false; foreach (MethodInfo method in field.FieldType.GetMethods()) { foreach (object remotableAttribute in method.GetCustomAttributes(true)) { if (remotableAttribute is Remotable) { remoteSupport = true; goto FoundSupport; } } } FoundSupport: if (remoteSupport) { field.SetValue(app, ProxyHandler.NewInstance(proxy, inject.Type, field.FieldType)); } else { throw new InstantiationException("The injection required a interface with remotable annotation!"); } } else { throw new InstantiationException("The injection annotation required a object interface, not a concrete class or primitive type!"); } } } } }
public virtual void Run( Application application, IEnumerable<Assembly> hostedAssemblies ) { Arg.NotNull( application, nameof( application ) ); Arg.NotNull( hostedAssemblies, nameof( hostedAssemblies ) ); // HACK: WPF doesn't set the Application.Current property until an application object has been created. This can cause composition issues. // Require this method to accept an application object to ensure it's set. This also simplifies startup code. // add hosted assemblies and guard against double registration (which can occur via Configure or using WithAppDomain) var applicationAssembly = application.GetType().Assembly; var assemblies = new HashSet<Assembly>( hostedAssemblies ) { applicationAssembly }.Where( a => !Configuration.IsRegistered( a ) ).ToArray(); Configuration.WithAssemblies( assemblies ); // set current service provider if unset if ( ServiceProvider.Current == ServiceProvider.Default ) ServiceProvider.SetCurrent( this ); try { // build up and execute the startup activities foreach ( var activity in Activities.Where( a => a.CanExecute( this ) ) ) activity.Execute( this ); } catch ( HostException ex ) { if ( application.MainWindow != null ) MessageBox.Show( application.MainWindow, ex.Message, SR.ActivityFailedCaption, MessageBoxButton.OK ); else MessageBox.Show( ex.Message, SR.ActivityFailedCaption, MessageBoxButton.OK ); return; } // set the default unit of work if unset if ( UnitOfWork.Provider == UnitOfWork.DefaultProvider ) UnitOfWork.Provider = new UnitOfWorkFactoryProvider( Container.GetExports<IUnitOfWorkFactory> ); // run the application if ( application.MainWindow != null ) application.Run( application.MainWindow ); else application.Run(); }
public static UIElement CreateTestPage (Application app) { settings = new UnitTestSettings (); app.UnhandledException += Application_UnhandledException; moonlog = new MoonLogProvider (); harness = new Microsoft.Silverlight.Testing.UnitTesting.Harness.UnitTestHarness (); settings.TestHarness = harness; settings.TestAssemblies.Add (app.GetType ().Assembly); UnitTestSystem.PrepareCustomLogProviders (settings); settings.LogProviders.Add (moonlog); settings.RuntimeVersion = Int32.Parse (Deployment.Current.RuntimeVersion.Split('.')[0]); // Silverlight thinks HtmlPage.Document.DocumentUri.Query is empty // so lets just manually parse instead. This allows tagging to work on SL. if (HtmlPage.Document.DocumentUri.OriginalString.IndexOf ('?') > 0) { settings.TagExpression = HtmlPage.Document.DocumentUri.OriginalString.Substring (HtmlPage.Document.DocumentUri.OriginalString.IndexOf ('?') + 1); if (settings.TagExpression.IndexOf ('#') > 0) settings.TagExpression = settings.TagExpression.Remove (settings.TagExpression.IndexOf ('#')); } test_page = UnitTestSystem.CreateTestPage (settings); settings.TestHarness.TestHarnessCompleted += new EventHandler<TestHarnessCompletedEventArgs> (Harness_Completed); return test_page; }
public void Configure(Application application, string identifier, Frame rootFrame = null, Func<Exception,string> descriptionLoader = null, string apiBase = null, string userId = null, string contactInformation = null) { if (this._application == null) { this._crashLogInfo = new CrashLogInformation() { PackageName = application.GetType().Namespace, ProductID = ManifestHelper.GetProductID(), Version = ManifestHelper.GetAppVersion(), WindowsPhone = Environment.OSVersion.Version.ToString(), Manufacturer = GetDeviceManufacturer(), Model = GetDeviceModel() }; this._application = application; this._application.UnhandledException += OnUnhandledException; HockeyClient.ConfigureInternal(identifier, ManifestHelper.GetAppVersion(), userID: userId, apiBase: apiBase, contactInformation: contactInformation, userAgentName: Constants.UserAgentString, sdkName: Constants.SdkName, sdkVersion: Constants.SdkVersion, descriptionLoader: descriptionLoader, os: Environment.OSVersion.Platform.ToString(), osVersion: Environment.OSVersion.Version.ToString(), device: GetDeviceModel(), oem: GetDeviceManufacturer()); if (rootFrame != null) { //Idea based on http://www.markermetro.com/2013/01/technical/handling-unhandled-exceptions-with-asyncawait-on-windows-8-and-windows-phone-8/ AsyncSynchronizationContext.RegisterForFrame(rootFrame, this); } } else { throw new InvalidOperationException("CrashHandler was already configured!"); } }