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


C# Assembly.GetAssemblyName方法代码示例

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


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

示例1: GetResourceNames

        private static IReadOnlyList<string> GetResourceNames( Assembly assembly, string resourceName )
        {
            Contract.Requires( assembly != null );
            Contract.Requires( !string.IsNullOrEmpty( resourceName ) );
            Contract.Ensures( Contract.Result<IReadOnlyList<string>>() != null );
            Contract.Ensures( Contract.ForAll( Contract.Result<IReadOnlyList<string>>(), name => !string.IsNullOrEmpty( name ) ) );

            // XAML resources are stored in the *.g.resources element
            var manifestKey = XamlResourcesFormat.FormatInvariant( assembly.GetAssemblyName() );
            IReadOnlyList<string> resourceNames;

            // look up cached resource names
            if ( xamlResources.TryGetValue( manifestKey, out resourceNames ) )
                return resourceNames;

            // no resources
            if ( !assembly.GetManifestResourceNames().Contains( manifestKey, StringComparer.Ordinal ) )
                throw new IOException( ExceptionMessage.MissingResourceException.FormatDefault( resourceName ) );

            // prevent cache from group exponentially
            if ( xamlResources.Count > 100 )
                xamlResources.Clear();

            using ( var stream = assembly.GetManifestResourceStream( manifestKey ) )
            {
                var reader = new System.Resources.ResourceReader( stream );
                resourceNames = new List<string>( reader.Cast<System.Collections.DictionaryEntry>().Select( entry => (string) entry.Key ) );
            }

            // cache resource names so the manifest doesn't have to be reloaded
            xamlResources[manifestKey] = resourceNames;

            return resourceNames;
        }
开发者ID:WaffleSquirrel,项目名称:More,代码行数:34,代码来源:TypeExtensions.cs

示例2: ResourceUri

        public static Uri ResourceUri(string resource, string subfolder = "Icons", Assembly assembly = null)
        {
            assembly = assembly ?? typeof(ResourceHelper).Assembly;

            return new Uri(string.Format(
                "pack://application:,,,/{0};component/{1}/{2}",
                assembly.GetAssemblyName(),
                subfolder,
                resource));
        }
开发者ID:Geminior,项目名称:DeepConfig,代码行数:10,代码来源:ResourceHelper.cs

示例3: GetVersionFromAssembly

        private string GetVersionFromAssembly(Assembly assembly) {
            if (assembly == null)
                return null;

            string version = assembly.GetInformationalVersion();
            if (String.IsNullOrEmpty(version) || String.Equals(version, "0.0.0.0"))
                version = assembly.GetFileVersion();

            if (String.IsNullOrEmpty(version) || String.Equals(version, "0.0.0.0"))
                version = assembly.GetVersion();
            
            if (String.IsNullOrEmpty(version) || String.Equals(version, "0.0.0.0")) {
                var assemblyName = assembly.GetAssemblyName();
                version = assemblyName != null ? assemblyName.Version.ToString() : null;
            }

            return !String.IsNullOrEmpty(version) && !String.Equals(version, "0.0.0.0") ? version : null;
        }
开发者ID:arpitgold,项目名称:Exceptionless,代码行数:18,代码来源:VersionEnrichment.cs

示例4: WithIcon

        public StandardMenuItem WithIcon(Assembly source, string path)
        {
            var manager = IoC.Get<IResourceService>();
            var iconSource = manager.GetBitmap(path, source.GetAssemblyName());

            if (source != null)
                Icon = new Image
                {
                    Source = iconSource,
                    Width = 16,
                    Height = 16
                };

            return this;
        }
开发者ID:blueskywyf,项目名称:ShowMaker,代码行数:15,代码来源:StandardMenuItem.cs

示例5: ToComponentUri

 /// <summary>Converts the path to a resource into a fully qualified component URI (eg "/assembly;component/Images/MyImage.png").</summary>
 /// <param name="resourcePath">
 ///    The path to the resource from the root of the project.<BR/>
 ///    This may, or may not, contain a leading '/' character.<BR/>
 ///    For example: "Images/MyImage.png"<BR/>
 /// </param>
 /// <param name="assembly">The assembly the resource is within.</param>
 /// <returns>A fully qualified URI.</returns>
 public static Uri ToComponentUri(this string resourcePath, Assembly assembly)
 {
     resourcePath = resourcePath.TrimStart("/".ToCharArray());
     var url = string.Format("/{0};component/{1}", assembly.GetAssemblyName(), resourcePath);
     return new Uri(url, UriKind.Relative);
 }
开发者ID:philcockfield,项目名称:Open.TestHarness.SL,代码行数:14,代码来源:StringExtensions.silverlight.cs

示例6: ResolveResourceName

        private static string ResolveResourceName( Assembly assembly, string resourceName )
        {
            Contract.Requires( assembly != null );
            Contract.Requires( !string.IsNullOrEmpty( resourceName ) );
            Contract.Ensures( !string.IsNullOrEmpty( Contract.Result<string>() ) );

            var manifestResources = GetResourceNames( assembly, resourceName );
            var resourceNames = MatchResourceNames( manifestResources, resourceName );

            // must be exactly one resource
            // NOTE: WPF and Silverlight throw different exceptions for missing resources; match the behavior
            if ( !resourceNames.Any() )
                throw new IOException( ExceptionMessage.MissingResourceException.FormatDefault( resourceName ) );
            else if ( resourceNames.Count > 1 )
                throw new IOException( ExceptionMessage.AmbiguousResourceException.FormatDefault( resourceName, assembly.GetAssemblyName(), resourceNames.Count ) );

            return resourceNames[0];
        }
开发者ID:WaffleSquirrel,项目名称:More,代码行数:18,代码来源:TypeExtensions.cs

示例7: WithIcon

        public StandardToolBarItem WithIcon(Assembly source, string path)
        {
            var manager = IoC.Get<IResourceManager>();
            Icon = manager.GetBitmap(path, source.GetAssemblyName());

            return this;
        }
开发者ID:KingKnecht,项目名称:gemini,代码行数:7,代码来源:StandardToolBarItem.cs

示例8: WithIcon

		public StandardMenuItem WithIcon(Assembly source, string path)
		{
			var manager = IoC.Get<IResourceManager>();
			var iconSource = manager.GetBitmap(path, source.GetAssemblyName());
            //IconSource = new Uri(path, UriKind.Relative);
		    IconSource = new Uri("pack://application:,,,/"+source.GetAssemblyName() + ";component/" + path, UriKind.RelativeOrAbsolute);

			if (source != null)
				Icon = new Image
				{
					Source = iconSource,
					Width = 16,
					Height = 16
				};

			return this;
		}
开发者ID:CedarLogic,项目名称:CShell,代码行数:17,代码来源:StandardMenuItem.cs


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