Exemplo n.º 1
0
        /// <summary>
        /// 어셈블리의 회사 이름에 대한 정보를 가져옵니다.
        /// </summary>
        /// <param name="assembly">구하려는 어셈블리</param>
        /// <returns>어셈블리의 회사 이름에 대한 정보를 반환합니다.</returns>
        public static string GetAssemblyCompany(this Assembly assembly)
        {
            AssemblyCompanyAttribute assemblyGetCustomAttributes = assembly.GetCustomAttributes <AssemblyCompanyAttribute>().FirstOrDefault();

            if (assemblyGetCustomAttributes != null)
            {
                return(assemblyGetCustomAttributes.Company);
            }

            return(string.Empty);
        }
Exemplo n.º 2
0
 public AssemblyPropertyHelper(Assembly asm)
 {
     var attributes = asm.GetCustomAttributes(typeof (AssemblyProductAttribute), false);
     if (attributes.Length > 0)
         _product = (AssemblyProductAttribute) attributes[0];
     attributes = asm.GetCustomAttributes(typeof (AssemblyCompanyAttribute), false);
     if (attributes.Length > 0)
         _company = (AssemblyCompanyAttribute) attributes[0];
     attributes = asm.GetCustomAttributes(typeof (AssemblyCopyrightAttribute), false);
     if (attributes.Length > 0)
         _copyright = (AssemblyCopyrightAttribute) attributes[0];
     attributes = asm.GetCustomAttributes(typeof (AssemblyDescriptionAttribute), false);
     if (attributes.Length > 0)
         _description = (AssemblyDescriptionAttribute) attributes[0];
 }
Exemplo n.º 3
0
        public static string getPath()
        {
            if (m_path == null)
            {
                System.Reflection.Assembly assemblyObj = System.Reflection.Assembly.GetExecutingAssembly();

                System.Reflection.AssemblyCompanyAttribute companyAttr = System.Reflection.AssemblyCompanyAttribute.GetCustomAttribute(assemblyObj, typeof(System.Reflection.AssemblyCompanyAttribute)) as System.Reflection.AssemblyCompanyAttribute;
                string companyName = companyAttr.Company;

                System.Reflection.AssemblyTitleAttribute titleAttr = System.Reflection.AssemblyTitleAttribute.GetCustomAttribute(assemblyObj, typeof(System.Reflection.AssemblyTitleAttribute)) as System.Reflection.AssemblyTitleAttribute;
                string programTitle = titleAttr.Title;

                // ... AppData/Local/Solace Inc./Facebook Message Analyzer/
                m_path = Microsoft.Win32.Registry.GetValue(
                    Microsoft.Win32.Registry.CurrentUser.Name + "\\SOFTWARE\\Facebook Message Analyzer",
                    "data path",
                    Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\" + companyName + "\\" + programTitle + "\\"
                    ) as string;
            }

            return(m_path);
        }
Exemplo n.º 4
0
 static ApplicationAttributes()
 {
     try
     {
         Title = string.Empty;
         CompanyName = string.Empty;
         Copyright = string.Empty;
         ProductName = string.Empty;
         Version = string.Empty;
         Assembly = Assembly.GetEntryAssembly();
         if (Assembly != null)
         {
             var customAttributes = Assembly.GetCustomAttributes(false);
             var array = customAttributes;
             foreach (var obj in array)
             {
                 var type = obj.GetType();
                 if (type == typeof (AssemblyTitleAttribute))
                 {
                     _Title = (AssemblyTitleAttribute) obj;
                 }
                 if (type == typeof (AssemblyCompanyAttribute))
                 {
                     _Company = (AssemblyCompanyAttribute) obj;
                 }
                 if (type == typeof (AssemblyCopyrightAttribute))
                 {
                     _Copyright = (AssemblyCopyrightAttribute) obj;
                 }
                 if (type == typeof (AssemblyProductAttribute))
                 {
                     _Product = (AssemblyProductAttribute) obj;
                 }
             }
             _Version = Assembly.GetName().Version;
         }
         if (_Title != null)
         {
             Title = _Title.Title;
         }
         if (_Company != null)
         {
             CompanyName = _Company.Company;
         }
         if (_Copyright != null)
         {
             Copyright = _Copyright.Copyright;
         }
         if (_Product != null)
         {
             ProductName = _Product.Product;
         }
         if (_Version != null)
         {
             Version = _Version.ToString();
         }
     }
     catch (Exception ex)
     {
         var msg = new ErrorMessage("RecentFileList.ApplicationAttributes", ex, MessageType.Error);
         Messenger.Default.Send<IMessage>(msg);
     }
 }
Exemplo n.º 5
0
            static ApplicationAttributes()
            {
                try
                {
                    Title = String.Empty;
                    CompanyName = String.Empty;
                    Copyright = String.Empty;
                    ProductName = String.Empty;
                    Version = String.Empty;

                    _Assembly = Assembly.GetEntryAssembly();

                    if (_Assembly != null)
                    {
                        object[] attributes = _Assembly.GetCustomAttributes(false);

                        foreach (object attribute in attributes)
                        {
                            Type type = attribute.GetType();

                            if (type == typeof(AssemblyTitleAttribute)) _Title = (AssemblyTitleAttribute)attribute;
                            if (type == typeof(AssemblyCompanyAttribute)) _Company = (AssemblyCompanyAttribute)attribute;
                            if (type == typeof(AssemblyCopyrightAttribute)) _Copyright = (AssemblyCopyrightAttribute)attribute;
                            if (type == typeof(AssemblyProductAttribute)) _Product = (AssemblyProductAttribute)attribute;
                        }

                        _Version = _Assembly.GetName().Version;
                    }

                    if (_Title != null) Title = _Title.Title;
                    if (_Company != null) CompanyName = _Company.Company;
                    if (_Copyright != null) Copyright = _Copyright.Copyright;
                    if (_Product != null) ProductName = _Product.Product;
                    if (_Version != null) Version = _Version.ToString();
                }
                catch { }
            }
Exemplo n.º 6
0
 private string GetAssembly(Type type)
 {
     if (type.ToString() == "System.Reflection.AssemblyVersionAttribute")
     {//程序集版本号,要用这个方法获取,无法用下边的方法获取,原因不知
         return(System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
     }
     object[] attributes = System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttributes(type, false);
     if (attributes.Length > 0)
     {
         if (type.ToString() == "System.Reflection.AssemblyCompanyAttribute")
         {
             #region//公司
             System.Reflection.AssemblyCompanyAttribute company = (System.Reflection.AssemblyCompanyAttribute)attributes[0];
             if (company.Company != "")
             {
                 return(company.Company);
             }
             #endregion
         }
         else if (type.ToString() == "System.Reflection.AssemblyCopyrightAttribute")
         {
             #region//版权
             System.Reflection.AssemblyCopyrightAttribute company = (System.Reflection.AssemblyCopyrightAttribute)attributes[0];
             if (company.Copyright != "")
             {
                 return(company.Copyright);
             }
             #endregion
         }
         else if (type.ToString() == "System.Reflection.AssemblyTitleAttribute")
         {
             #region//标题
             System.Reflection.AssemblyTitleAttribute company = (System.Reflection.AssemblyTitleAttribute)attributes[0];
             if (company.Title != "")
             {
                 return(company.Title);
             }
             #endregion
         }
         else if (type.ToString() == "System.Reflection.AssemblyDescriptionAttribute")
         {
             #region//备注
             System.Reflection.AssemblyDescriptionAttribute company = (System.Reflection.AssemblyDescriptionAttribute)attributes[0];
             if (company.Description != "")
             {
                 return(company.Description);
             }
             #endregion
         }
         else if (type.ToString() == "System.Reflection.AssemblyProductAttribute")
         {
             #region//产品名称
             System.Reflection.AssemblyProductAttribute company = (System.Reflection.AssemblyProductAttribute)attributes[0];
             if (company.Product != "")
             {
                 return(company.Product);
             }
             #endregion
         }
         else if (type.ToString() == "System.Reflection.AssemblyTrademarkAttribute")
         {
             #region//商标
             System.Reflection.AssemblyTrademarkAttribute company = (System.Reflection.AssemblyTrademarkAttribute)attributes[0];
             if (company.Trademark != "")
             {
                 return(company.Trademark);
             }
             #endregion
         }
         else if (type.ToString() == "System.Reflection.AssemblyConfigurationAttribute")
         {
             #region//获取程序集配置信息,具体什么内容,不清楚
             System.Reflection.AssemblyConfigurationAttribute company = (System.Reflection.AssemblyConfigurationAttribute)attributes[0];
             if (company.Configuration != "")
             {
                 return(company.Configuration);
             }
             #endregion
         }
         else if (type.ToString() == "System.Reflection.AssemblyCultureAttribute")
         {
             #region//获取属性化程序集支持的区域性,具体什么内容,不清楚
             System.Reflection.AssemblyCultureAttribute company = (System.Reflection.AssemblyCultureAttribute)attributes[0];
             if (company.Culture != "")
             {
                 return(company.Culture);
             }
             #endregion
         }
         else if (type.ToString() == "System.Reflection.AssemblyVersionAttribute")
         {
             #region//程序集版本号
             System.Reflection.AssemblyVersionAttribute company = (System.Reflection.AssemblyVersionAttribute)attributes[0];
             if (company.Version != "")
             {
                 return(company.Version);
             }
             #endregion
         }
         else if (type.ToString() == "System.Reflection.AssemblyFileVersionAttribute")
         {
             #region//文件版本号
             System.Reflection.AssemblyFileVersionAttribute company = (System.Reflection.AssemblyFileVersionAttribute)attributes[0];
             if (company.Version != "")
             {
                 return(company.Version);
             }
             #endregion
         }
         else if (type.ToString() == "System.Reflection.AssemblyInformationalVersionAttribute")
         {
             #region//产品版本号
             System.Reflection.AssemblyInformationalVersionAttribute company = (System.Reflection.AssemblyInformationalVersionAttribute)attributes[0];
             if (company.InformationalVersion != "")
             {
                 return(company.InformationalVersion);
             }
             #endregion
         }
     }
     //如果没有  属性,或者  属性为一个空字符串,则返回 .exe 的名称
     return(System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().CodeBase));
 }
Exemplo n.º 7
0
 public ExportHelper()
 {
     Assembly assembly = Assembly.GetExecutingAssembly();
     _companyAttribute = (AssemblyCompanyAttribute)Attribute.GetCustomAttribute(assembly, typeof(AssemblyCompanyAttribute));
     _productAttribute = (AssemblyProductAttribute)Attribute.GetCustomAttribute(assembly, typeof(AssemblyProductAttribute));
 }
 public CodeAttributeDeclaration Convert(AssemblyCompanyAttribute attribute)
 {
     return new CodeAttributeDeclaration(new CodeTypeReference(attribute.GetType()), new CodeAttributeArgument(new CodePrimitiveExpression(attribute.Company)));
 }
Exemplo n.º 9
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Sets the configuration files.
		/// </summary>
		/// <returns>File mapping for configuration files</returns>
		/// ------------------------------------------------------------------------------------
		private ExeConfigurationFileMap SetConfigFiles()
		{
			ExeConfigurationFileMap configMap = new ExeConfigurationFileMap();
			Assembly assembly = Assembly.GetCallingAssembly();
			object[] attributes = assembly.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
			AssemblyCompanyAttribute company;
			if (attributes.Length > 0)
				company = (AssemblyCompanyAttribute)attributes[0];
			else
				company = new AssemblyCompanyAttribute("Company");
			attributes = assembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false);
			AssemblyProductAttribute product;
			if (attributes.Length > 0)
				product = (AssemblyProductAttribute)attributes[0];
			else
				product = new AssemblyProductAttribute("Product");
			string configFilename = Path.Combine(company.Company, Path.Combine(product.Product, "user.config"));
			configMap.LocalUserConfigFilename = Path.Combine(
				Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
				configFilename);
			configMap.RoamingUserConfigFilename = Path.Combine(
				Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), configFilename);
			configMap.ExeConfigFilename = Path.Combine(Path.GetDirectoryName(assembly.Location), product.Product + ".config");
			return configMap;
		}