Example #1
0
        private void LoadAssemblies(string asmName)
        {
            checkSumComboBox.SelectedIndex = 0;
            Assembly asm = Assembly.LoadFrom(asmName);
            AssemblyConfigurationAttribute atrDescr = (AssemblyConfigurationAttribute)AssemblyConfigurationAttribute.GetCustomAttribute(asm, typeof(AssemblyConfigurationAttribute));

            string[] config = atrDescr.Configuration.Split(' ');
            try
            {
                for (int i = 0; i < config.Length; i++)
                {
                    string[] configParametrs = config[i].Split('/');

                    if (configParametrs[1] == "C")
                    {
                        checkSumComboBox.Items.Add(configParametrs[0]);
                    }
                    else
                    {
                        fileNameTextEdit.Text = configParametrs[0];
                    }
                }
            }
            catch (IndexOutOfRangeException ex)
            {
            }
        }
Example #2
0
        /// <summary>
        /// Ctor
        /// </summary>
        public About(Assembly assembly)
        {
            AssemblyName name = assembly.GetName();

            this.FullName = assembly.FullName;
            this.Version  = name.Version;
            this.Name     = name.Name;

            AssemblyCopyrightAttribute copyright = Attribute.GetCustomAttribute(assembly, typeof(AssemblyCopyrightAttribute)) as AssemblyCopyrightAttribute;

            this.Copyright = (copyright != null) ? copyright.Copyright : String.Empty;

            AssemblyDescriptionAttribute description = Attribute.GetCustomAttribute(assembly, typeof(AssemblyDescriptionAttribute)) as AssemblyDescriptionAttribute;

            this.Description = (description != null) ? description.Description : String.Empty;

            AssemblyTitleAttribute title = Attribute.GetCustomAttribute(assembly, typeof(AssemblyTitleAttribute)) as AssemblyTitleAttribute;

            this.Title = (title != null) ? title.Title : String.Empty;

            AssemblyCompanyAttribute company = Attribute.GetCustomAttribute(assembly, typeof(AssemblyCompanyAttribute)) as AssemblyCompanyAttribute;

            this.Company = (company != null) ? company.Company : String.Empty;

            AssemblyConfigurationAttribute config = Attribute.GetCustomAttribute(assembly, typeof(AssemblyConfigurationAttribute)) as AssemblyConfigurationAttribute;

            this.Configuration = (config != null) ? config.Configuration : String.Empty;
        }
Example #3
0
        public AssemblyConfigurationAttributeTest()
        {
            //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(AssemblyConfigurationAttribute);
            ConstructorInfo ctrInfo   = attribute.GetConstructor(
                new Type [] { typeof(string) }
                );
            CustomAttributeBuilder attrBuilder =
                new CustomAttributeBuilder(ctrInfo, new object [1] {
                "Config"
            });

            dynAssembly.SetCustomAttribute(attrBuilder);
            object [] attributes = dynAssembly.GetCustomAttributes(true);
            attr = attributes [0] as AssemblyConfigurationAttribute;
        }
Example #4
0
        private static string GetConfigurationString()
        {
            object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyConfigurationAttribute), false);
            AssemblyConfigurationAttribute aca = (AssemblyConfigurationAttribute)attributes[0];

            return(aca.Configuration);
        }
Example #5
0
        private static string GetAppConfig()
        {
            object[] attributes = typeof(PdnInfo).Assembly.GetCustomAttributes(typeof(AssemblyConfigurationAttribute), false);
            AssemblyConfigurationAttribute aca = (AssemblyConfigurationAttribute)attributes[0];

            return(aca.Configuration);
        }
Example #6
0
        public static string GetAssemblyConfiguration(
            Assembly assembly
            )
        {
            if (assembly != null)
            {
                try
                {
                    if (assembly.IsDefined(
                            typeof(AssemblyConfigurationAttribute), false))
                    {
                        AssemblyConfigurationAttribute configuration =
                            (AssemblyConfigurationAttribute)
                            assembly.GetCustomAttributes(
                                typeof(AssemblyConfigurationAttribute),
                                false)[0];

                        return(configuration.Configuration);
                    }
                }
                catch
                {
                    // do nothing.
                }
            }

            return(null);
        }
        private static bool AssemblyConfigurationEquals(string configuration)
        {
            AssemblyConfigurationAttribute assemblyConfigurationAttribute = typeof(string).Assembly.GetCustomAttribute <AssemblyConfigurationAttribute>();

            return(assemblyConfigurationAttribute != null &&
                   string.Equals(assemblyConfigurationAttribute.Configuration, configuration, StringComparison.InvariantCulture));
        }
Example #8
0
        static void Main(string[] args)
        {
            if (args.Length > 0 && args[0] == "/buildString")
            {
                Assembly assembly   = Assembly.GetExecutingAssembly();
                object[] attributes = assembly.GetCustomAttributes(true);
                object   configRaw  = attributes.FirstOrDefault(a => a.GetType() == typeof(AssemblyConfigurationAttribute));
                if (configRaw != null)
                {
                    String _ApplicationVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
                    _ApplicationVersion = _ApplicationVersion.Substring(0, _ApplicationVersion.LastIndexOf('.'));
                    _ApplicationVersion = _ApplicationVersion.Substring(0, _ApplicationVersion.LastIndexOf('.'));

                    AssemblyConfigurationAttribute config = (AssemblyConfigurationAttribute)configRaw;
                    string configuration;
#if _WIN64
                    configuration = "_x64";
#else
                    configuration = "_x86";
#endif
                    Console.WriteLine(_ApplicationVersion + "_" + config.Configuration + configuration);
                    return;
                }

                Console.WriteLine("");
                return;
            }
        }
Example #9
0
        private static bool IsCheckedRuntime()
        {
            Assembly assembly = typeof(string).Assembly;
            AssemblyConfigurationAttribute assemblyConfigurationAttribute = assembly.GetCustomAttribute <AssemblyConfigurationAttribute>();

            return(assemblyConfigurationAttribute != null &&
                   string.Equals(assemblyConfigurationAttribute.Configuration, "Checked", StringComparison.InvariantCulture));
        }
Example #10
0
        private void DropPanel_DragDrop(object sender, DragEventArgs e)
        {
            string[]   fnames = (string[])e.Data.GetData(DataFormats.FileDrop, false);
            Assembly[] fileAs = new Assembly[fnames.Length];
            for (int i = 0; i < fileAs.Length; i++)
            {
                fileAs[i] = Assembly.LoadFrom(fnames[i]);
            }
            foreach (Assembly file in fileAs)
            {
                object[] version = file.GetCustomAttributes(
                    typeof(AssemblyFileVersionAttribute), false),
                company = file.GetCustomAttributes(
                    typeof(AssemblyCompanyAttribute), false),
                buildCof = file.GetCustomAttributes(
                    typeof(AssemblyConfigurationAttribute), false),
                Copyright = file.GetCustomAttributes(
                    typeof(AssemblyCopyrightAttribute), false),
                Desc = file.GetCustomAttributes(
                    typeof(AssemblyDescriptionAttribute), false);
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("このファイルの名前:" + file.FullName);
                sb.AppendLine("ファイルバージョン:");
                foreach (object v in version)
                {
                    AssemblyFileVersionAttribute ver =
                        (AssemblyFileVersionAttribute)v;
                    sb.AppendLine(ver.Version);
                }
                sb.AppendLine("著作権表示:");
                foreach (object c in Copyright)
                {
                    AssemblyCopyrightAttribute co = (AssemblyCopyrightAttribute)c;
                    sb.AppendLine(co.Copyright);
                }
                sb.AppendLine("ビルド構成:");
                foreach (object b in buildCof)
                {
                    AssemblyConfigurationAttribute ac = (AssemblyConfigurationAttribute)b;
                    sb.AppendLine(ac.Configuration);
                }
                sb.AppendLine("作成元:");
                foreach (object cp in company)
                {
                    AssemblyCompanyAttribute aca = (AssemblyCompanyAttribute)cp;
                    sb.AppendLine(aca.Company);
                }
                sb.AppendLine("説明:");
                foreach (object desc in Desc)
                {
                    AssemblyDescriptionAttribute ad = (AssemblyDescriptionAttribute)desc;
                    sb.AppendLine(ad.Description);
                }

                MessageBox.Show(sb.ToString(), "情報", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
        }
Example #11
0
        public static void AssemblyConfigurationAttributeTests()
        {
            var attr1 = new AssemblyConfigurationAttribute(null);

            Assert.Null(attr1.Configuration);

            var attr2 = new AssemblyConfigurationAttribute("My Configuration");

            Assert.Equal("My Configuration", attr2.Configuration);
        }
Example #12
0
 private static string GetConfigName(Assembly assembly)
 {
     object[] attr = assembly.GetCustomAttributes(typeof(AssemblyConfigurationAttribute), false);
     if (attr.Length > 0)
     {
         AssemblyConfigurationAttribute aca = (AssemblyConfigurationAttribute)attr[0];
         return(aca.Configuration);
     }
     return("");
 }
Example #13
0
        public static IHostBuilder UseEnvironment(this IHostBuilder hostBuilder, Assembly assembly)
        {
            AssemblyConfigurationAttribute configuration = assembly.GetCustomAttribute <AssemblyConfigurationAttribute>();

            string environment = configuration.Configuration switch
            {
                "Debug" => Environments.Development,
                "Release" => Environments.Production,
                _ => Environments.Staging,
            };

            return(hostBuilder.UseEnvironment(environment));
        }
Example #14
0
        /// <summary>
        /// Static initialization of build information, read from assembly information
        /// </summary>
        static Program()
        {
            AssemblyConfigurationAttribute attribute
                = typeof(Program)
                  .Assembly
                  .GetCustomAttributes(typeof(System.Reflection.AssemblyConfigurationAttribute), false)
                  .FirstOrDefault() as AssemblyConfigurationAttribute;

            if (attribute != null)
            {
                BuildInfo = attribute.Configuration;
            }
        }
Example #15
0
        private static string GetConfiguration(Assembly appAssembly)
        {
            Type type = typeof(AssemblyConfigurationAttribute);
            AssemblyConfigurationAttribute conf = AssemblyConfigurationAttribute.GetCustomAttribute(appAssembly, type)
                                                  as AssemblyConfigurationAttribute;

            if (conf != null)
            {
                return(conf.Configuration);
            }
            else
            {
                return("");
            }
        }
Example #16
0
        private string GetConfigurationInfo()
        {
            Assembly assemblyInfo = Assembly.GetExecutingAssembly();

            object[] objects = assemblyInfo.GetCustomAttributes(false);

            foreach (object obj in objects)
            {
                if (obj.GetType() == typeof(System.Reflection.AssemblyConfigurationAttribute))
                {
                    AssemblyConfigurationAttribute configuration = (AssemblyConfigurationAttribute)obj;
                    return(configuration.Configuration);
                }
            }

            return(string.Empty);
        }
Example #17
0
    private void WriteCopyright()
    {
        Assembly executingAssembly = Assembly.GetExecutingAssembly();

#if NUNITLITE
        string title = "NUnitLite";
#else
        string title = "NUNit Framework";
#endif
        System.Version version   = executingAssembly.GetName().Version;
        string         copyright = "Copyright (C) 2012, Charlie Poole";
        string         build     = "";

#if !NETCF_1_0
        object[] attrs = executingAssembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
        if (attrs.Length > 0)
        {
            AssemblyTitleAttribute titleAttr = (AssemblyTitleAttribute)attrs[0];
            title = titleAttr.Title;
        }

        attrs = executingAssembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
        if (attrs.Length > 0)
        {
            AssemblyCopyrightAttribute copyrightAttr = (AssemblyCopyrightAttribute)attrs[0];
            copyright = copyrightAttr.Copyright;
        }

        attrs = executingAssembly.GetCustomAttributes(typeof(AssemblyConfigurationAttribute), false);
        if (attrs.Length > 0)
        {
            AssemblyConfigurationAttribute configAttr = (AssemblyConfigurationAttribute)attrs[0];
            build = string.Format("({0})", configAttr.Configuration);
        }
#endif

        writer.WriteLine(String.Format("{0} {1} {2}", title, version.ToString(3), build));
        writer.WriteLine(copyright);
        writer.WriteLine();

        string clrPlatform = Type.GetType("Mono.Runtime", false) == null ? ".NET" : "Mono";
        writer.WriteLine("Runtime Environment -");
        writer.WriteLine("    OS Version: {0}", Environment.OSVersion);
        writer.WriteLine("  {0} Version: {1}", clrPlatform, Environment.Version);
        writer.WriteLine();
    }
Example #18
0
    public static void GetCompiledExtensions(ArrayList assemblies)
    {
        string s = Path.Combine(HttpContext.Current.Server.MapPath("~/"), "bin");

        string[] fileEntries = Directory.GetFiles(s);
        foreach (string fileName in fileEntries)
        {
            if (fileName.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
            {
                Assembly asm  = Assembly.LoadFrom(fileName);
                object[] attr = asm.GetCustomAttributes(typeof(AssemblyConfigurationAttribute), false);
                if (attr.Length > 0)
                {
                    AssemblyConfigurationAttribute aca = (AssemblyConfigurationAttribute)attr[0];
                }
            }
        }
    }
Example #19
0
        public void ConfigureEnvironmentFromAssemblyConfiguration()
        {
            IHostBuilder hostBuilder = new HostBuilder();

            Assembly assembly = typeof(HostBuilderExtensionsTests).Assembly;

            Assert.Same(hostBuilder, hostBuilder.UseEnvironment(assembly));

            IHost host = hostBuilder.Build();

            AssemblyConfigurationAttribute configuration = assembly.GetCustomAttribute <AssemblyConfigurationAttribute>();

            Assert.True(configuration.Configuration == "Debug" || configuration.Configuration == "Release");

            IHostEnvironment environment     = host.Services.GetRequiredService <IHostEnvironment>();
            string           environmentName = configuration.Configuration == "Debug" ? Environments.Development : Environments.Production;

            Assert.Equal(environmentName, environment.EnvironmentName);
        }
Example #20
0
        protected void PrintVersion(string appDomainVersionString)
        {
            Assembly assembly = Assembly.GetEntryAssembly();

            if (assembly != null)
            {
                Version   version    = assembly.GetName().Version;
                object [] attributes = assembly.GetCustomAttributes(typeof(AssemblyConfigurationAttribute),
                                                                    false);
                if (attributes.Length > 0)
                {
                    AssemblyConfigurationAttribute configAttr = (AssemblyConfigurationAttribute)attributes[0];
                    attributes = assembly.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute),
                                                              false);
                    AssemblyInformationalVersionAttribute versionAttr =
                        (AssemblyInformationalVersionAttribute)attributes[0];
                    if (OutputEnum != RCOutput.Test)
                    {
                        Console.Out.WriteLine("Robocube Language {0} ({1}/{2})",
                                              version.ToString(),
                                              configAttr.Configuration,
                                              versionAttr.InformationalVersion);
                    }
                    else
                    {
                        Console.Out.WriteLine("Robocube Language {0}", version.ToString());
                    }
                }
                else
                {
                    Console.Out.WriteLine("Robocube Language {0}", version.ToString());
                }
            }
            else if (appDomainVersionString != null && appDomainVersionString != "")
            {
                Console.Out.WriteLine("Robocube Language {0} (isolated)", appDomainVersionString);
            }
            else
            {
                Console.Out.WriteLine("Robocube Language (isolated)");
            }
        }
Example #21
0
        /// <summary>
        /// Write the standard header information to a TextWriter.
        /// </summary>
        /// <param name="writer">The TextWriter to use</param>
        public static void WriteHeader(TextWriter writer)
        {
            Assembly executingAssembly = Assembly.GetExecutingAssembly();

                        #if NUNITLITE
            string title = "NUnitLite";
                        #else
            string title = "NUNit Framework";
                        #endif
            AssemblyName   assemblyName = AssemblyHelper.GetAssemblyName(executingAssembly);
            System.Version version      = assemblyName.Version;
            string         copyright    = "Copyright (C) 2012, Charlie Poole";
            string         build        = "";

            object[] attrs = executingAssembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
            if (attrs.Length > 0)
            {
                AssemblyTitleAttribute titleAttr = (AssemblyTitleAttribute)attrs[0];
                title = titleAttr.Title;
            }

            attrs = executingAssembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
            if (attrs.Length > 0)
            {
                AssemblyCopyrightAttribute copyrightAttr = (AssemblyCopyrightAttribute)attrs[0];
                copyright = copyrightAttr.Copyright;
            }

            attrs = executingAssembly.GetCustomAttributes(typeof(AssemblyConfigurationAttribute), false);
            if (attrs.Length > 0)
            {
                AssemblyConfigurationAttribute configAttr = (AssemblyConfigurationAttribute)attrs[0];
                if (configAttr.Configuration.Length > 0)
                {
                    build = string.Format("({0})", configAttr.Configuration);
                }
            }

            writer.WriteLine(String.Format("{0} {1} {2}", title, version.ToString(3), build));
            writer.WriteLine(copyright);
            writer.WriteLine();
        }
Example #22
0
        public void ConfigureFromAssemblyInfo()
        {
            IHostBuilder hostBuilder = new HostBuilder();

            Assert.Same(hostBuilder, hostBuilder.UseAssemblyAttributes());

            Assembly         assembly    = Assembly.GetEntryAssembly();
            IHost            host        = hostBuilder.Build();
            IHostEnvironment environment = host.Services.GetRequiredService <IHostEnvironment>();

            AssemblyConfigurationAttribute configuration = assembly.GetCustomAttribute <AssemblyConfigurationAttribute>();

            Assert.Equal("", configuration.Configuration);
            Assert.Equal(Environments.Staging, environment.EnvironmentName);

            AssemblyProductAttribute product = assembly.GetCustomAttribute <AssemblyProductAttribute>();

            Assert.Contains("Test", product.Product);
            Assert.Equal(product.Product, environment.ApplicationName);
        }
Example #23
0
        /// <summary>
        /// Gets the informational version of the given assembly.
        /// </summary>
        /// <param name="asm"></param>
        /// <returns></returns>
        public static string InformationalVersion(Assembly asm)
        {
            object[] attrs  = asm.GetCustomAttributes(typeof(AssemblyConfigurationAttribute), false);
            string   config = null;

            if (attrs.Length > 0)
            {
                AssemblyConfigurationAttribute attr = attrs[0] as AssemblyConfigurationAttribute;
                config = attr.Configuration;
            }
            string version = asm.GetName().Version.ToString();

            if (string.IsNullOrEmpty(config))
            {
                return(version);
            }
            else
            {
                return(string.Format("{0} ({1})", version, config));
            }
        }
 public bool PosTest3()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest3:Initialize the AssemblyConfigurationAttribute 3");
     try
     {
         string configuration = string.Empty;
         AssemblyConfigurationAttribute assemConfigAttr = new AssemblyConfigurationAttribute(configuration);
         if (assemConfigAttr == null || assemConfigAttr.Configuration != "")
         {
             TestLibrary.TestFramework.LogError("005", "the ExpectResult is not the ActualResult");
             retVal = false;
         }
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("006", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
 public bool PosTest1()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest1:Initialize the AssemblyConfigurationAttribute 1");
     try
     {
         string configuration = TestLibrary.Generator.GetString(-55, false, c_MIN_STR_LENGTH, c_MAX_STR_LENGTH);
         AssemblyConfigurationAttribute assemConfigAttr = new AssemblyConfigurationAttribute(configuration);
         if (assemConfigAttr == null || assemConfigAttr.Configuration != configuration)
         {
             TestLibrary.TestFramework.LogError("001", "the ExpectResult is not the ActualResult");
             retVal = false;
         }
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("002", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
 public bool PosTest2()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest2:Return the configuration info from initialized the AssemblyConfigurationAttribute 2");
     try
     {
         string configuration = null;
         AssemblyConfigurationAttribute assemConfigAttr = new AssemblyConfigurationAttribute(configuration);
         if (assemConfigAttr.Configuration != null)
         {
             TestLibrary.TestFramework.LogError("003", "the ExpectResult is not the ActualResult");
             retVal = false;
         }
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
Example #27
0
        private void WriteHeader()
        {
            Assembly executingAssembly = Assembly.GetExecutingAssembly();

                        #if NUNITLITE
            string title = "NUnitLite";
                        #else
            string title = "NUNit Framework";
                        #endif
            System.Version version   = executingAssembly.GetName().Version;
            string         copyright = "Copyright (C) 2012, Charlie Poole";
            string         build     = "";

                        #if !NETCF_1_0
            object[] attrs = executingAssembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
            if (attrs.Length > 0)
            {
                AssemblyTitleAttribute titleAttr = (AssemblyTitleAttribute)attrs[0];
                title = titleAttr.Title;
            }

            attrs = executingAssembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
            if (attrs.Length > 0)
            {
                AssemblyCopyrightAttribute copyrightAttr = (AssemblyCopyrightAttribute)attrs[0];
                copyright = copyrightAttr.Copyright;
            }

            attrs = executingAssembly.GetCustomAttributes(typeof(AssemblyConfigurationAttribute), false);
            if (attrs.Length > 0)
            {
                AssemblyConfigurationAttribute configAttr = (AssemblyConfigurationAttribute)attrs[0];
                build = string.Format("({0})", configAttr.Configuration);
            }
                        #endif

            writer.WriteLine(String.Format("{0} {1} {2}", title, version.ToString(3), build));
            writer.WriteLine(copyright);
            writer.WriteLine();
        }
Example #28
0
    public bool PosTest3()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest3:Return the configuration info from initialized the AssemblyConfigurationAttribute 3");
        try
        {
            string configuration = string.Empty;
            AssemblyConfigurationAttribute assemConfigAttr = new AssemblyConfigurationAttribute(configuration);
            if (assemConfigAttr.Configuration != "")
            {
                TestLibrary.TestFramework.LogError("005", "the ExpectResult is not the ActualResult");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("006", "Unexpect exception:" + e);
            retVal = false;
        }
        return(retVal);
    }
Example #29
0
    public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest1:Return the configuration info from initialized the AssemblyConfigurationAttribute 1");
        try
        {
            string configuration = TestLibrary.Generator.GetString(-55, false, c_MIN_STR_LENGTH, c_MAX_STR_LENGTH);
            AssemblyConfigurationAttribute assemConfigAttr = new AssemblyConfigurationAttribute(configuration);
            if (assemConfigAttr.Configuration != configuration)
            {
                TestLibrary.TestFramework.LogError("001", "the ExpectResult is not the ActualResult");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpect exception:" + e);
            retVal = false;
        }
        return(retVal);
    }
Example #30
0
    public bool PosTest2()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest2:Initialize the AssemblyConfigurationAttribute 2");
        try
        {
            string configuration = null;
            AssemblyConfigurationAttribute assemConfigAttr = new AssemblyConfigurationAttribute(configuration);
            if (assemConfigAttr == null || assemConfigAttr.Configuration != null)
            {
                TestLibrary.TestFramework.LogError("003", "the ExpectResult is not the ActualResult");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e);
            retVal = false;
        }
        return(retVal);
    }
        /// <summary>
        /// Help toolbar button event handler
        /// </summary>
        /// <param name="Ctrl"></param>
        /// <param name="CancelDefault"></param>
        void m_HelpButton_Click(Microsoft.Office.Core.CommandBarButton Ctrl, ref bool CancelDefault)
        {
            if (m_helpUrl == null)
            {
                StringBuilder helpUrl = new StringBuilder(Properties.Resources.HelpURL);
                Assembly      asm     = Assembly.GetExecutingAssembly();
                Version       version = asm.GetName().Version;
                string        edition = "Community";
                object[]      attr    = asm.GetCustomAttributes(typeof(AssemblyConfigurationAttribute), false);
                if (attr.Length > 0)
                {
                    AssemblyConfigurationAttribute aca = (AssemblyConfigurationAttribute)attr[0];
                    edition = aca.Configuration;
                }
                helpUrl.Replace("{major}", version.Major.ToString());
                helpUrl.Replace("{minor}", version.Minor.ToString());
                helpUrl.Replace("{edition}", edition);

                m_helpUrl = helpUrl.ToString();
            }
            System.Diagnostics.Process.Start(m_helpUrl);
        }
Example #32
0
    public About(Assembly assembly)
    {
        AssemblyName name = assembly.GetName();

        FullName = assembly.FullName;
        Version  = name.Version;
        Name     = name.Name;
        AssemblyCopyrightAttribute assemblyCopyrightAttribute = Attribute.GetCustomAttribute(assembly, typeof(AssemblyCopyrightAttribute)) as AssemblyCopyrightAttribute;

        Copyright = ((assemblyCopyrightAttribute == null) ? string.Empty : assemblyCopyrightAttribute.Copyright);
        AssemblyDescriptionAttribute assemblyDescriptionAttribute = Attribute.GetCustomAttribute(assembly, typeof(AssemblyDescriptionAttribute)) as AssemblyDescriptionAttribute;

        Description = ((assemblyDescriptionAttribute == null) ? string.Empty : assemblyDescriptionAttribute.Description);
        AssemblyTitleAttribute assemblyTitleAttribute = Attribute.GetCustomAttribute(assembly, typeof(AssemblyTitleAttribute)) as AssemblyTitleAttribute;

        Title = ((assemblyTitleAttribute == null) ? string.Empty : assemblyTitleAttribute.Title);
        AssemblyCompanyAttribute assemblyCompanyAttribute = Attribute.GetCustomAttribute(assembly, typeof(AssemblyCompanyAttribute)) as AssemblyCompanyAttribute;

        Company = ((assemblyCompanyAttribute == null) ? string.Empty : assemblyCompanyAttribute.Company);
        AssemblyConfigurationAttribute assemblyConfigurationAttribute = Attribute.GetCustomAttribute(assembly, typeof(AssemblyConfigurationAttribute)) as AssemblyConfigurationAttribute;

        Configuration = ((assemblyConfigurationAttribute == null) ? string.Empty : assemblyConfigurationAttribute.Configuration);
    }
Example #33
0
        private void WriteCopyright()
        {
            Assembly executingAssembly = Assembly.GetExecutingAssembly();
            string   arg     = "NUNit Framework";
            Version  version = executingAssembly.GetName().Version;
            string   value   = "Copyright (C) 2012, Charlie Poole";
            string   arg2    = "";

            object[] customAttributes = executingAssembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), inherit: false);
            if (customAttributes.Length > 0)
            {
                AssemblyTitleAttribute assemblyTitleAttribute = (AssemblyTitleAttribute)customAttributes[0];
                arg = assemblyTitleAttribute.Title;
            }
            customAttributes = executingAssembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), inherit: false);
            if (customAttributes.Length > 0)
            {
                AssemblyCopyrightAttribute assemblyCopyrightAttribute = (AssemblyCopyrightAttribute)customAttributes[0];
                value = assemblyCopyrightAttribute.Copyright;
            }
            customAttributes = executingAssembly.GetCustomAttributes(typeof(AssemblyConfigurationAttribute), inherit: false);
            if (customAttributes.Length > 0)
            {
                AssemblyConfigurationAttribute assemblyConfigurationAttribute = (AssemblyConfigurationAttribute)customAttributes[0];
                arg2 = $"({assemblyConfigurationAttribute.Configuration})";
            }
            writer.WriteLine($"{arg} {version.ToString(3)} {arg2}");
            writer.WriteLine(value);
            writer.WriteLine();
            string arg3 = ((Type.GetType("Mono.Runtime", throwOnError: false) == null) ? ".NET" : "Mono");

            writer.WriteLine("Runtime Environment -");
            writer.WriteLine("    OS Version: {0}", Environment.OSVersion);
            writer.WriteLine("  {0} Version: {1}", arg3, Environment.Version);
            writer.WriteLine();
        }