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


C# Application.GetType方法代码示例

本文整理汇总了C#中System.Windows.Application.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Application.GetType方法的具体用法?C# Application.GetType怎么用?C# Application.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Application的用法示例。


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

示例1: ParseTypeName

        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);
            }
        }
开发者ID:nikhilk,项目名称:silverlightfx,代码行数:14,代码来源:TypeTypeConverter.cs

示例2: ConfigureControllers

		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;
				}
			}
		}
开发者ID:sergiosilvajr,项目名称:mpos,代码行数:37,代码来源:MposFramework.cs

示例3: WindowsApplicationSettings

 // ----------------------------------------------------------------------
 public WindowsApplicationSettings(Application application) :
     this(application, application.GetType())
 {
 } // WindowsApplicationSettings
开发者ID:llenroc,项目名称:Inflexion2,代码行数:5,代码来源:WindowsApplicationSettings.cs

示例4: InjectObjects

		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!");
						}
					}
				}
			}
		}
开发者ID:sergiosilvajr,项目名称:mpos,代码行数:49,代码来源:MposFramework.cs

示例5: Run

        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();
        }
开发者ID:WaffleSquirrel,项目名称:More,代码行数:44,代码来源:Host.cs

示例6: CreateTestPage

		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;
		}
开发者ID:snorp,项目名称:moon,代码行数:26,代码来源:Testing.cs

示例7: Configure

        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!");
            }
        }
开发者ID:tapanila,项目名称:HockeySDK-Windows,代码行数:48,代码来源:CrashHandler.cs


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