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


C# Assembly.GetShortAssemblyName方法代码示例

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


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

示例1: Assembly

 /// <summary>
 /// Returns a string that can be used for representing a <see cref="System.Reflection.Assembly"/> in log entries.
 /// </summary>
 /// <param name="asm"></param>
 /// <returns></returns>
 public static string Assembly(Assembly asm)
 {
     if (asm == null) return "null";
     string shortName = asm.GetShortAssemblyName();
     try
     {
         Version version = asm.GetName().Version;
         return string.Format("{0} {1}", shortName, version);
     }
     catch (Exception)
     {
         return string.Format("{0} {1}", shortName, "[Error retrieving Version]");
     }
 }
开发者ID:SirePi,项目名称:duality,代码行数:19,代码来源:Log.cs

示例2: Assembly

		/// <summary>
		/// Returns a string that can be used for representing a <see cref="System.Reflection.Assembly"/> in log entries.
		/// </summary>
		/// <param name="asm"></param>
		/// <returns></returns>
		public static string Assembly(Assembly asm)
		{
			return asm.GetShortAssemblyName();
		}
开发者ID:KETMGaming,项目名称:duality,代码行数:9,代码来源:Log.cs

示例3: RemovePlugin

		private static void RemovePlugin(Assembly pluginAssembly)
		{
			CorePlugin plugin;
			if (plugins.TryGetValue(pluginAssembly.GetShortAssemblyName(), out plugin))
			{
				RemovePlugin(plugin);
			}
		}
开发者ID:undue,项目名称:duality,代码行数:8,代码来源:DualityApp.cs

示例4: LoadPlugin

		/// <summary>
		/// Adds an already loaded plugin Assembly to the internal Duality CorePlugin registry.
		/// You shouldn't need to call this method in general, since Duality manages its plugins
		/// automatically. 
		/// </summary>
		/// <remarks>
		/// This method can be useful in certain cases when it is necessary to treat an Assembly as a
		/// Duality plugin, even though it isn't located in the Plugins folder, or is not available
		/// as a file at all. A typical case for this is Unit Testing where the testing Assembly may
		/// specify additional Duality types such as Components, Resources, etc.
		/// </remarks>
		/// <param name="pluginAssembly"></param>
		/// <param name="pluginFilePath"></param>
		/// <returns></returns>
		public static CorePlugin LoadPlugin(Assembly pluginAssembly, string pluginFilePath)
		{
			disposedPlugins.Remove(pluginAssembly);

			string asmName = pluginAssembly.GetShortAssemblyName();
			CorePlugin plugin = plugins.Values.FirstOrDefault(p => p.AssemblyName == asmName);
			if (plugin != null) return plugin;

			Type pluginType = pluginAssembly.GetExportedTypes().FirstOrDefault(t => typeof(CorePlugin).IsAssignableFrom(t));
			if (pluginType == null)
			{
				Log.Core.WriteWarning("Can't find CorePlugin class. Discarding plugin...");
				disposedPlugins.Add(pluginAssembly);
			}
			else
			{
				try
				{
					plugin = (CorePlugin)pluginType.CreateInstanceOf();
					plugin.FilePath = pluginFilePath;
					plugin.LoadPlugin();
					plugins.Add(plugin.AssemblyName, plugin);
				}
				catch (Exception e)
				{
					Log.Core.WriteError("Error loading plugin: {0}", Log.Exception(e));
					disposedPlugins.Add(pluginAssembly);
					plugin = null;
				}
			}

			return plugin;
		}
开发者ID:undue,项目名称:duality,代码行数:47,代码来源:DualityApp.cs

示例5: CleanInputSources

		private static void CleanInputSources(Assembly invalidAssembly)
		{
			string warningText = string.Format(
				"Found leaked input source '{1}' defined in invalid Assembly '{0}'. " +
				"This is a common problem when registering input sources from within a CorePlugin " +
				"without properly unregistering them later. Please make sure that all sources are " +
				"unregistered in CorePlugin::OnDisposePlugin().",
				invalidAssembly.GetShortAssemblyName(),
				"{0}");

			if (mouse.Source != null && mouse.Source.GetType().Assembly == invalidAssembly)
			{
				mouse.Source = null;
				Log.Core.WriteWarning(warningText, Log.Type(mouse.Source.GetType()));
			}
			if (keyboard.Source != null && keyboard.Source.GetType().Assembly == invalidAssembly)
			{
				keyboard.Source = null;
				Log.Core.WriteWarning(warningText, Log.Type(keyboard.Source.GetType()));
			}
			foreach (JoystickInput joystick in joysticks.ToArray())
			{
				if (joystick.Source != null && joystick.Source.GetType().Assembly == invalidAssembly)
				{
					joysticks.RemoveSource(joystick.Source);
					Log.Core.WriteWarning(warningText, Log.Type(joystick.Source.GetType()));
				}
			}
			foreach (GamepadInput gamepad in gamepads.ToArray())
			{
				if (gamepad.Source != null && gamepad.Source.GetType().Assembly == invalidAssembly)
				{
					gamepads.RemoveSource(gamepad.Source);
					Log.Core.WriteWarning(warningText, Log.Type(gamepad.Source.GetType()));
				}
			}
		}
开发者ID:undue,项目名称:duality,代码行数:37,代码来源:DualityApp.cs

示例6: CleanEventBindings

		private static void CleanEventBindings(Assembly invalidAssembly)
		{
			// Note that this method is only a countermeasure against common mistakes. It doesn't guarantee
			// full error safety in all cases. Event bindings inbetween different plugins aren't checked,
			// for example.

			string warningText = string.Format(
				"Found leaked event bindings to invalid Assembly '{0}' from {1}. " +
				"This is a common problem when registering global events from within a CorePlugin " +
				"without properly unregistering them later. Please make sure that all events are " +
				"unregistered in CorePlugin::OnDisposePlugin().",
				invalidAssembly.GetShortAssemblyName(),
				"{0}");

			if (ReflectionHelper.CleanEventBindings(typeof(DualityApp),			invalidAssembly))	Log.Core.WriteWarning(warningText, Log.Type(typeof(DualityApp)));
			if (ReflectionHelper.CleanEventBindings(typeof(Scene),				invalidAssembly))	Log.Core.WriteWarning(warningText, Log.Type(typeof(Scene)));
			if (ReflectionHelper.CleanEventBindings(typeof(Resource),			invalidAssembly))	Log.Core.WriteWarning(warningText, Log.Type(typeof(Resource)));
			if (ReflectionHelper.CleanEventBindings(typeof(ContentProvider),	invalidAssembly))	Log.Core.WriteWarning(warningText, Log.Type(typeof(ContentProvider)));
			if (ReflectionHelper.CleanEventBindings(Log.LogData,				invalidAssembly))	Log.Core.WriteWarning(warningText, Log.Type(typeof(Log)) + ".LogData");
			if (ReflectionHelper.CleanEventBindings(keyboard,					invalidAssembly))	Log.Core.WriteWarning(warningText, Log.Type(typeof(DualityApp)) + ".Keyboard");
			if (ReflectionHelper.CleanEventBindings(mouse,						invalidAssembly))	Log.Core.WriteWarning(warningText, Log.Type(typeof(DualityApp)) + ".Mouse");
			foreach (JoystickInput joystick in joysticks)
			{
				if (ReflectionHelper.CleanEventBindings(joystick,				invalidAssembly))	Log.Core.WriteWarning(warningText, Log.Type(typeof(DualityApp)) + ".Joysticks");
			}
			foreach (GamepadInput gamepad in gamepads)
			{
				if (ReflectionHelper.CleanEventBindings(gamepad,				invalidAssembly))	Log.Core.WriteWarning(warningText, Log.Type(typeof(DualityApp)) + ".Gamepads");
			}
		}
开发者ID:undue,项目名称:duality,代码行数:30,代码来源:DualityApp.cs

示例7: AddPlugin

		/// <summary>
		/// Adds an already loaded plugin Assembly to the internal Duality CorePlugin registry.
		/// You shouldn't need to call this method in general, since Duality manages its plugins
		/// automatically. 
		/// </summary>
		/// <remarks>
		/// This method can be useful in certain cases when it is necessary to treat an Assembly as a
		/// Duality plugin, even though it isn't located in the Plugins folder, or is not available
		/// as a file at all. A typical case for this is Unit Testing where the testing Assembly may
		/// specify additional Duality types such as Components, Resources, etc.
		/// </remarks>
		/// <param name="pluginAssembly"></param>
		/// <param name="pluginFilePath"></param>
		/// <returns></returns>
		public static CorePlugin AddPlugin(Assembly pluginAssembly, string pluginFilePath)
		{
			if (disposedPlugins.Contains(pluginAssembly)) return null;

			string asmName = pluginAssembly.GetShortAssemblyName();
			CorePlugin plugin = plugins.Values.FirstOrDefault(p => p.AssemblyName == asmName);
			if (plugin != null) return plugin;

			Type pluginType = pluginAssembly.GetExportedTypes().FirstOrDefault(t => typeof(CorePlugin).IsAssignableFrom(t));
			if (pluginType == null)
			{
				disposedPlugins.Add(pluginAssembly);
			}
			else
			{
				plugin = (CorePlugin)pluginType.CreateInstanceOf();
				plugin.FilePath = pluginFilePath;
				plugins.Add(plugin.AssemblyName, plugin);
			}

			return plugin;
		}
开发者ID:KETMGaming,项目名称:duality,代码行数:36,代码来源:DualityApp.cs


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