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


C# Assembly.GetName方法代码示例

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


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

示例1: ModuleInfo

        public ModuleInfo(Assembly _asm)
        {
            _name = _asm.GetName().Name;
            _version = DepVersion.VersionParse (_asm.GetName().Version.ToString ());

            ModuleDependencyAttribute _depAttr = ((ModuleDependencyAttribute)(_asm.GetCustomAttributes (typeof (ModuleDependencyAttribute), false)[0]));

            if (_depAttr != null) {
                DepLexer _lexer = new DepLexer (new StringReader (_depAttr.DepString));
                DepParser _parser = new DepParser (_lexer);

                // woot...lets do this!
                _dependencies = new DepNode ();

                _parser.expr (_dependencies);
            } else
                _dependencies = null;

            ModuleRoleAttribute _roleAttr = ((ModuleRoleAttribute)(_asm.GetCustomAttributes (typeof (ModuleRoleAttribute), false)[0]));

            if (_roleAttr != null) {
                _roles = _roleAttr.Roles;
            } else
                throw new ModuleInfoException (string.Format ("The module {0} has no defined roles, and is not a valid NModule module.", _asm.GetName ().Name));

            _owner = _asm;
        }
开发者ID:BackupTheBerlios,项目名称:nmodule-svn,代码行数:27,代码来源:ModuleInfo.cs

示例2: GetAssemblyDump

        public static ObjectDump GetAssemblyDump(Assembly assembly)
        {
            var dump = new ObjectDump();

            dump.Headers.Add("Name");
            dump.Headers.Add("Product");
            dump.Headers.Add("Version");
            dump.Headers.Add("File Version");
            dump.Headers.Add("Informational Version");
            dump.Headers.Add("Configuration");
            dump.Headers.Add("CLR");

            AssemblyProductAttribute productAttribute = null;
            try
            {
                productAttribute = (AssemblyProductAttribute)Attribute.GetCustomAttribute(assembly, typeof(AssemblyProductAttribute));
            }
            catch (Exception e)
            {
                Log.ErrorException("Failed to enumerate AssemblyProductAttribute", e);
            }

            var configAttribute = (AssemblyConfigurationAttribute)Attribute.GetCustomAttribute(assembly, typeof(AssemblyConfigurationAttribute));

            dump.Data.Add(assembly.GetName().Name);
            dump.Data.Add(productAttribute == null ? string.Empty : productAttribute.Product);
            dump.Data.Add(assembly.GetName().Version.ToString());
            dump.Data.Add(FileVersionInfo.GetVersionInfo(assembly.Location).FileVersion);
            dump.Data.Add(FileVersionInfo.GetVersionInfo(assembly.Location).ProductVersion);
            dump.Data.Add(configAttribute == null ? string.Empty : configAttribute.Configuration);
            dump.Data.Add(assembly.ImageRuntimeVersion);

            return dump;
        }
开发者ID:neutmute,项目名称:AssemblyChecker,代码行数:34,代码来源:Program.cs

示例3: CsCodeWriter

 public CsCodeWriter(TextWriter writer) : base(writer, "{", "}")
 {
     _generator = Assembly.GetCallingAssembly();
     _generator = _generator ?? GetType().Assembly;
     _generateName = _generator.GetName().Name;
     _generatorVersion = _generator.GetName().Version.ToString(2);
 }
开发者ID:modulexcite,项目名称:NClassify,代码行数:7,代码来源:CsCodeWriter.cs

示例4: AssemblyInfoString

        public static string AssemblyInfoString(Assembly a)
        {
            object helper;
            if (a == null) a = GetParentAssembly();

            var sb = new StringBuilder();

            try { helper = a.CodeBase; }
            catch (Exception e) { helper = e; }
            sb.Append(string.Format("Assembly Codebase: {0}", helper));
            sb.Append(Environment.NewLine);

            try { helper = a.FullName; }
            catch (Exception e) { helper = e; }
            sb.Append(string.Format("Assembly Full Name: {0}", helper));
            sb.Append(Environment.NewLine);

            try { helper = a.GetName().Version.ToString(); }
            catch (Exception e) { helper = e; }
            sb.Append(string.Format("Assembly Version: {0}", helper));
            sb.Append(Environment.NewLine);

            try { helper = a.GetName().Version.ToString(); }
            catch (Exception e) { helper = e; }
            sb.Append(string.Format("Assembly Version: {0}", helper));
            sb.Append(Environment.NewLine);

            sb.Append(string.Format("Assembly Build Date: {0}", GetAssemblyBuildDate(a, false)));
            sb.Append(Environment.NewLine);

            return sb.ToString();
        }
开发者ID:TroutZhang,项目名称:unreal-debugger,代码行数:32,代码来源:ExceptionMessageBox.cs

示例5: AssemblyInformation

		internal AssemblyInformation(Assembly assembly)
		{
			_assembly = assembly;

			this.InformationalVersion = string.Empty;
			this.ProductVersion = string.Empty;
			this.Major = string.Empty;
			this.Minor = string.Empty;
			this.Revision = string.Empty;
			this.Build = string.Empty;
			this.FullName = string.Empty;

			try
			{
				AssemblyInformationalVersionAttribute attribute = (AssemblyInformationalVersionAttribute)_assembly.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false).FirstOrDefault();

				if (attribute != null)
				{
					this.InformationalVersion = attribute.InformationalVersion;
				}
			}
			catch { }

			try
			{
				this.ProductVersion = FileVersionInfo.GetVersionInfo(_assembly.Location).ProductVersion;
			}
			catch { }

			try
			{
				this.FullName = _assembly.FullName;
			}
			catch { }

			try
			{
				this.Major = _assembly.GetName().Version.Major.ToString();
			}
			catch { }

			try
			{
				this.Minor = _assembly.GetName().Version.Minor.ToString();
			}
			catch { }

			try
			{
				this.Revision = _assembly.GetName().Version.Revision.ToString();
			}
			catch { }

			try
			{
				this.Build = _assembly.GetName().Version.Build.ToString();
			}
			catch { }
		}
开发者ID:SaggioTechnologies,项目名称:AssemblyInfo,代码行数:59,代码来源:AssemblyInformation.cs

示例6: AssemblyDetail

        public AssemblyDetail(Assembly assembly)
        {
            _name = "";
            _location = assembly.Location;

            _children.Add(new TraitDetail(this, "FullName", assembly.FullName));
            _children.Add(new TraitDetail(this, "Version", assembly.GetName().Version.ToString()));
            _children.Add(new TraitDetail(this, "RuntimeVersion", assembly.ImageRuntimeVersion));
            _children.Add(new TraitDetail(this, "PublicKeyToken", GenericUtility.GetHashText(assembly.GetName().GetPublicKeyToken())));
            _children.Add(new TraitDetail(this, "Flags", assembly.GetName().Flags.ToString()));

            AttributesDetail attributes = new AttributesDetail(this);
            _children.Add(attributes);
            foreach (CustomAttributeData cad in CustomAttributeData.GetCustomAttributes(assembly))
            {
                AttributeDetail ad = new AttributeDetail(attributes, cad);
                ad.Visibility = Visibility.Exported;
                attributes.Children.Add(ad);
            }

            ResourcesDetail resources = new ResourcesDetail(this);
            _children.Add(resources);
            foreach (string resource in assembly.GetManifestResourceNames())
            {
                resources.Children.Add(new ResourceDetail(resources, resource, GenericUtility.ReadStream(assembly, resource)));
            }

            ReferencesDetail references = new ReferencesDetail(this);
            _children.Add(references);
            foreach (AssemblyName an in assembly.GetReferencedAssemblies())
            {
                references.Children.Add(new ReferenceDetail(references, an));
            }

            Type[] types = assembly.GetTypes();

            foreach (Type type in types)
            {
                if (!type.IsNested)
                {
                    NamespaceDetail ns = FindOrCreateNamespace(type.Namespace);

                    if (type.IsEnum)
                    {
                        ns.Children.Add(new EnumDetail(ns, type));
                    }
                    else if (type.IsInterface)
                    {
                        ns.Children.Add(new InterfaceDetail(ns, type));
                    }
                    else if (type.IsClass)
                    {
                        ns.Children.Add(new ClassDetail(ns, type));
                    }
                }
            }
        }
开发者ID:redoz,项目名称:bitdiffer,代码行数:57,代码来源:AssemblyDetail.cs

示例7: GetDriversInAssemblyInternal

 private DCDriverInfo[] GetDriversInAssemblyInternal(Assembly assem)
 {
     string name = assem.GetName().Name;
     string pkToken = DCDriverLoader.GetPublicKeyToken(assem.GetName());
     return (from t in assem.GetExportedTypes()
         where !t.IsAbstract && typeof(DataContextDriver).IsAssignableFrom(t)
         let driver = InstantiateDCDriver(t)
         let loader = new DCDriverLoader(name, pkToken, t.FullName)
         select new DCDriverInfo { Loader = loader, Name = driver.Name, Author = driver.Author, Version = driver.Version.ToString(), IsAuto = driver is DynamicDataContextDriver }).ToArray<DCDriverInfo>();
 }
开发者ID:CuneytKukrer,项目名称:TestProject,代码行数:10,代码来源:ThirdPartyDriverProber.cs

示例8: AsmDiagram

        public AsmDiagram(Assembly asm, bool withNamespaceSubGraphs = false)
        {
            if (asm == null)
                throw new ArgumentNullException(nameof(asm));

            _targetedNs = asm.GetName().Name;

            _withNsSubgraphs = withNamespaceSubGraphs;
            _asmName = NfTypeName.SafeDotNetIdentifier(asm.GetName().Name);
            foreach (
                var asmType in
                    asm.NfGetExportedTypes()
                        .Where(x => !string.IsNullOrWhiteSpace(x.Namespace) && x.Namespace.StartsWith(_targetedNs)))
            {
                var item1 = new FlattenedItem(asmType) {FlName = asmType.Name};
                if (item1.IsTerminalNode || NfTypeName.IsEnumType(asmType))
                    continue;

                foreach (
                    var p in
                        asmType.GetProperties(NfConfig.DefaultFlags)
                            .Where(
                                x =>
                                    !string.IsNullOrWhiteSpace(x.PropertyType.Namespace) &&
                                    x.PropertyType.Namespace.StartsWith(_targetedNs))
                    )
                {
                    if (NfTypeName.IsEnumType(p.PropertyType))
                        continue;
                    var item2 = new FlattenedItem(p.PropertyType) {FlName = p.Name};
                    if (item2.IsTerminalNode)
                        continue;
                    var tupleOfItems = new Tuple<FlattenedItem, FlattenedItem>(item1, item2);
                    var itemEv = new AsmDiagramEdge(tupleOfItems);
                    if (Edges.Any(x => x.AreSame(itemEv)))
                        continue;
                    Edges.Add(itemEv);
                }
            }

            Edges = RemoveDuplicates(Edges);

            var names = Edges.SelectMany(x => x.NodeName).ToList();
            var uqNames = names.Distinct().OrderBy(x => x).ToList();
            _nodes = uqNames.Select(x => new AsmDiagramNode(x, GetCountOfEdgesOn(x))).ToList();

            if (_withNsSubgraphs)
            {
                var uqNamespaces = _nodes.Select(x => x.NodeNamespace).Distinct().ToList();
                foreach (var ns in uqNamespaces)
                {
                    _nsSubGraphs.Add(new AsmDiagramSubGraph(ns, _nodes));
                }
            }
        }
开发者ID:nofuture-git,项目名称:31g,代码行数:55,代码来源:AsmDiagram.cs

示例9: BuildAssemplyInfo

		public String BuildAssemplyInfo(Assembly assembly)
		{
			if (assembly.GetName().CodeBase.EndsWith("/system.dll"))
			{
				return String.Empty;
			}
			
			return String.Format("<tr><td class=\"tableCell\">{0}</td><td class=\"tableCell\">{1}</td><td class=\"tableCell\">{2}</td></tr>",
				assembly.GetName().Name, assembly.GetName().Version,
				assembly.GetName().CodeBase);
		}
开发者ID:qwinner,项目名称:NetBPM,代码行数:11,代码来源:InfoHelper.cs

示例10: Use

        public void Use(Assembly assembly)
        {
            if (hasAssemblyByName(assembly.GetName().Name))
            {
                _diagnostics.LogDuplicateAssembly(_currentPackage, assembly.GetName().FullName);
                return;
            }

            _diagnostics.LogAssembly(_currentPackage, assembly, DIRECTLY_REGISTERED_MESSAGE);
            _assemblies.Add(assembly);
        }
开发者ID:NTCoding,项目名称:FubuRaven.NTCoding.com,代码行数:11,代码来源:AssemblyRegistration.cs

示例11:

 void IAssemblyRegistration.Use(Assembly assembly)
 {
     if (hasAssemblyByName(assembly.GetName().Name))
     {
         _diagnostics.LogDuplicateAssembly(_currentPackage, assembly.GetName().FullName);
     }
     else
     {
         _diagnostics.LogAssembly(_currentPackage, assembly, DIRECTLY_REGISTERED_MESSAGE);
         _assemblies.Add(assembly);
     }
 }
开发者ID:rytutis,项目名称:bottles,代码行数:12,代码来源:AssemblyLoader.cs

示例12: AssemblyLoader

 public AssemblyLoader(Assembly assembly, IAbsoluteFilePath locationOverride = null,
     IAbsoluteDirectoryPath netEntryPath = null) {
     if (assembly == null)
         throw new Exception("Entry Assembly is null!");
     _entryAssembly = assembly;
     var asName = _entryAssembly.GetName().Name;
     var netEntryFilePath = GetNetEntryFilePath(netEntryPath, asName);
     _netEntryPath = netEntryFilePath.ParentDirectoryPath;
     _entryLocation = locationOverride ?? netEntryFilePath;
     _entryPath = _entryLocation.ParentDirectoryPath;
     _entryVersion = _entryAssembly.GetName().Version;
     _entryAssemblyName = asName;
 }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:13,代码来源:AssemblyLoader.cs

示例13: GetPTXStreamFromAssembly

        public static Stream GetPTXStreamFromAssembly(Assembly assembly, string resourceName, string resourceDir = "ptx")
        {
            try

            {
                return assembly.GetManifestResourceStream(assembly.GetName().Name + "." + resourceDir + "." + PathToResourceName(resourceName) + ".ptx");
            }
            catch (Exception e)
            {
                MyLog.ERROR.WriteLine("PTX resource '" + resourceName + "' load failed from assembly " + assembly.GetName().Name + ".");
                return null;
            }
        }
开发者ID:Jlaird,项目名称:BrainSimulator,代码行数:13,代码来源:MyResources.cs

示例14: Create

        public Endpoint Create(Assembly modelsAssembly)
        {
            var endpoint = new Endpoint();
            endpoint.Name = modelsAssembly.GetName().Name;
            endpoint.AssemblyGuid = Guid.Parse(modelsAssembly.GetCustomAttribute<GuidAttribute>().Value);
            endpoint.AssemblyVersion = modelsAssembly.GetName().Version.ToString();

            BuildEndpointRoutes(endpoint);

            // models must be built after routes
            BuildEndpointModels(endpoint, modelsAssembly);

            return endpoint;
        }
开发者ID:tjb042,项目名称:Archipelago,代码行数:14,代码来源:EndpointFactory.cs

示例15: RegisterArea

        protected override void RegisterArea(AreaRegistrationContext context, Assembly assembly, SparkViewFactory sparkViewFactory)
        {
            context.Routes.Add(new Route("assets/default/{*resource}",
                new RouteValueDictionary(),
                new RouteValueDictionary(),
                new EmbeddedContentRouteHandler(assembly, assembly.GetName().Name + ".Mvc.DefaultTemplate.Assets")));

            context.Routes.Add(new Route("services/templates/bbcode", new BBCodeRouteHandler()));

            var viewFolder = new EmbeddedViewFolder(assembly, assembly.GetName().Name + ".Mvc.DefaultTemplate.Views");

            sparkViewFactory.ViewFolder = sparkViewFactory.ViewFolder
                .Append(viewFolder);
        }
开发者ID:dpawatts,项目名称:zeus,代码行数:14,代码来源:TemplatesAreaRegistration.cs


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