Example #1
0
 public AboutViewModel()
 {
     // Get the application information.
     var app = Assembly.GetExecutingAssembly();
     _copyright = (AssemblyCopyrightAttribute)Attribute.GetCustomAttribute(app, typeof(AssemblyCopyrightAttribute));
     _version = (AssemblyFileVersionAttribute)Attribute.GetCustomAttribute(app, typeof(AssemblyFileVersionAttribute));
 }
Example #2
0
        /// <summary>
        /// 어셈블리의 저작권 정보를 구합니다.
        /// </summary>
        /// <param name="assembly">구하려는 어셈블리</param>
        /// <returns>어셈블리의 저작권 정보를 반환합니다.</returns>
        public static string GetAssemblyCopyright(this Assembly assembly)
        {
            AssemblyCopyrightAttribute assemblyGetCustomAttributes = assembly.GetCustomAttributes <AssemblyCopyrightAttribute>().FirstOrDefault();

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

            return(string.Empty);
        }
Example #3
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];
 }
		public AssemblyCopyrightAttributeTest ()
		{
			//create a dynamic assembly with the required attribute
			//and check for the validity

			dynAsmName.Name = "TestAssembly";

			dynAssembly = Thread.GetDomain().DefineDynamicAssembly (
				dynAsmName,AssemblyBuilderAccess.Run
				);

			// Set the required Attribute of the assembly.
			Type attribute = typeof (AssemblyCopyrightAttribute);
			ConstructorInfo ctrInfo = attribute.GetConstructor (
				new Type []{ typeof (string) }
				);
			CustomAttributeBuilder attrBuilder =
				new CustomAttributeBuilder (ctrInfo, new object [1] {"Ximian"} );
			dynAssembly.SetCustomAttribute(attrBuilder);
			object [] attributes = dynAssembly.GetCustomAttributes (true);
			attr = attributes [0] as AssemblyCopyrightAttribute;
		}
Example #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)
         {
             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);
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandLine.Text.CopyrightInfo"/> class
 /// with an assembly attribute, this overrides all formatting.
 /// </summary>
 /// <param name="attribute">The attribute which text to use.</param>
 private CopyrightInfo(AssemblyCopyrightAttribute attribute)
 {
     _attribute = attribute;
 }
Example #7
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 { }
            }
Example #8
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));
 }
 public CodeAttributeDeclaration Convert(AssemblyCopyrightAttribute attribute)
 {
     return new CodeAttributeDeclaration(new CodeTypeReference(attribute.GetType()), new CodeAttributeArgument(new CodePrimitiveExpression(attribute.Copyright)));
 }
Example #10
0
 public string ProgramCopyrightNotice()
 {
     System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
     System.Reflection.AssemblyCopyrightAttribute copyrightAttr = assembly.GetCustomAttributes(typeof(System.Reflection.AssemblyCopyrightAttribute), false)[0] as System.Reflection.AssemblyCopyrightAttribute;
     return(copyrightAttr?.Copyright);
 }