Ejemplo n.º 1
0
        private void BuildUserAgent() //build the user agent string for playing urls
        {
            string agent = "";

            object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
            if (attributes.Length > 0)
            {
                AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];
                if (titleAttribute.Title != "")
                {
                    agent += titleAttribute.Title + " ";
                }
            }

            agent += Assembly.GetExecutingAssembly().GetName().Version.ToString() + " ";

            attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
            if (attributes.Length > 0)
            {
                agent += ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
            }

            agent        = agent.Replace("©", "");
            userAgentPtr = Marshal.StringToHGlobalAnsi(agent); //can't use StringToHGlobalUni for user agent :(

            Bass.BASS_SetConfigPtr(BASSConfig.BASS_CONFIG_NET_AGENT, userAgentPtr);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Set the title of the window itself
        /// </summary>
        void SetTitle()
        {
            Assembly assembly = Assembly.GetExecutingAssembly();
            AssemblyTitleAttribute assemblyTitle = assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false)[0] as AssemblyTitleAttribute;

            Window.Title = assemblyTitle.Title + ": " + RouteData.RouteName;
        }
Ejemplo n.º 3
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;
        }
Ejemplo n.º 4
0
        private void Itm_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string   path        = e.Item.Tag.ToString();
            Assembly DllAssembly = Assembly.LoadFrom(path);
            AssemblyFileVersionAttribute VersionInfo     = DllAssembly.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false)[0] as AssemblyFileVersionAttribute;
            AssemblyCompanyAttribute     CompanyInfo     = DllAssembly.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false)[0] as AssemblyCompanyAttribute;
            AssemblyProductAttribute     ProductInfo     = DllAssembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false)[0] as AssemblyProductAttribute;
            AssemblyTitleAttribute       TitleInfo       = DllAssembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false)[0] as AssemblyTitleAttribute;
            AssemblyCopyrightAttribute   CopyrightInfo   = DllAssembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)[0] as AssemblyCopyrightAttribute;
            AssemblyDescriptionAttribute DescriptionInfo = DllAssembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false)[0] as AssemblyDescriptionAttribute;

            Type[] type_list = DllAssembly.GetExportedTypes();
            foreach (Type outerForm in type_list)
            {
                //Type outerForm = DllAssembly.GetTypes()[3];
                if (outerForm.BaseType.Name == "XtraUserControl")
                {
                    var obj = (Activator.CreateInstance(outerForm) as XtraUserControl);
                    obj.Dock = DockStyle.Fill;
                    this.panelControl1.Controls.Clear();
                    this.panelControl1.Controls.Add(obj);
                    break;
                }
                else if (outerForm.BaseType.Name == "ToolbarForm")
                {
                    var obj = (Activator.CreateInstance(outerForm) as ToolbarForm);
                    obj.ShowDialog();
                    break;
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Get the name of the plugin.
        /// </summary>
        /// <param name="pluginassembly">The plugin assembly</param>
        /// <returns>The name of the plugin</returns>
        public static string GetPluginName(Assembly pluginassembly)
        {
            string pluginname = Strings.T("unknown");

            object[] atttitle = pluginassembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
            if (atttitle.Length > 0)
            {
                AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)atttitle[0];
                if (titleAttribute.Title != string.Empty)
                {
                    if (titleAttribute.Title.Length > 200)
                    {
                        pluginname = titleAttribute.Title.Substring(0, 200);
                    }
                    else
                    {
                        pluginname = titleAttribute.Title;
                    }
                }
                else
                {
                    Log.Write(LogType.exception, "Plugin " + pluginassembly.Location + " has no name.");
                }
            }

            return(pluginname);
        }
Ejemplo n.º 6
0
        ///////////////////////////////////////////////////////////////////////

        public static string GetAssemblyTitle(
            Assembly assembly
            )
        {
            if (assembly != null)
            {
                try
                {
                    if (assembly.IsDefined(
                            typeof(AssemblyTitleAttribute), false))
                    {
                        AssemblyTitleAttribute title =
                            (AssemblyTitleAttribute)
                            assembly.GetCustomAttributes(
                                typeof(AssemblyTitleAttribute), false)[0];

                        return(title.Title);
                    }
                }
                catch
                {
                    // do nothing.
                }
            }

            return(null);
        }
Ejemplo n.º 7
0
        private static bool HasAemManagerRegistrySettings()
        {
            Assembly assembly = Assembly.GetEntryAssembly();
            AssemblyCompanyAttribute attrCompany = (AssemblyCompanyAttribute)assembly.GetCustomAttributes(typeof(AssemblyCompanyAttribute), true)[0];
            AssemblyTitleAttribute   attrTitle   = (AssemblyTitleAttribute)assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), true)[0];

            RegistryKey keyUser     = Registry.CurrentUser;
            RegistryKey keySoftware = keyUser.OpenSubKey("Software", false);
            RegistryKey keyCompany  = keySoftware.OpenSubKey(attrCompany.Company, false);

            if (keyCompany == null)
            {
                return(false);
            }
            RegistryKey keyApplication = keyCompany.OpenSubKey(attrTitle.Title, false);

            if (keyApplication == null)
            {
                return(false);
            }

            RegistryKey keyInstances = keyApplication.OpenSubKey("Instances", false);

            return(keyInstances != null);
        }
Ejemplo n.º 8
0
        private string GetEULA(string eula)
        {
            Stream       resStream = Application.GetResourceStream(new Uri("pack://application:,,,/DavuxLib2;component/EULAs/" + eula + ".txt")).Stream;
            StreamReader sr        = new StreamReader(resStream);
            string       ret       = sr.ReadToEnd();

            Assembly assembly = Assembly.GetEntryAssembly();

            AssemblyTitleAttribute       assemblyTitle       = assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false)[0] as AssemblyTitleAttribute;
            AssemblyDescriptionAttribute assemblyDescription = assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false)[0] as AssemblyDescriptionAttribute;
            AssemblyCompanyAttribute     assemblyCompany     = assembly.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false)[0] as AssemblyCompanyAttribute;
            AssemblyCopyrightAttribute   assemblyCopyright   = assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)[0] as AssemblyCopyrightAttribute;
            AssemblyProductAttribute     assemblyProduct     = assembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false)[0] as AssemblyProductAttribute;

            string company = assemblyCompany.Company;


            if (company == "Dave Amenta")
            {
                company = "Dave Amenta Software, LLC";
            }
            //ret = ret.Replace("[SOFTWARE TITLE]", assemblyTitle.Title);
            ret = ret.Replace("[COMPANY_NAME]", company);
            //ret = ret.Replace("[YOUR COUNTRY]", "USA");


            return(ret);
        }
Ejemplo n.º 9
0
        private static string ConstructPath(System.Environment.SpecialFolder baseFolder)
        {
            string companyPart = string.Empty;
            string appNamePart = string.Empty;

            Assembly entryAssembly = Assembly.GetEntryAssembly();

            if (entryAssembly != null)//for unit tests entryAssembly == null
            {
                AssemblyCompanyAttribute companyAttribute = (AssemblyCompanyAttribute)Attribute.GetCustomAttribute(entryAssembly, typeof(AssemblyCompanyAttribute));
                if (!string.IsNullOrEmpty(companyAttribute.Company))
                {
                    companyPart = string.Format("{0}\\", companyAttribute.Company);
                }
                AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)Attribute.GetCustomAttribute(entryAssembly, typeof(AssemblyTitleAttribute));
                if (!string.IsNullOrEmpty(titleAttribute.Title))
                {
                    appNamePart = string.Format("{0}\\", titleAttribute.Title);
                }
            }

            string backingFilePath = Path.Combine(
                Environment.GetFolderPath(baseFolder),
                string.Format(@"{0}{1}tracked_settings.xml", companyPart, appNamePart)
                );

            return(backingFilePath);
        }
        /// <summary>Obtains the title of the specified assembly.</summary>
        /// <remarks>
        /// <para>
        /// We try to obtain the title by firstly examining a
        /// <see cref="System.Reflection.AssemblyTitleAttribute"/>
        /// if it exists; otherwise, by returning a name based on
        /// the assembly file name.
        /// </para>
        /// <para>
        /// If <paramref name="appendAssemblyCulture"/> is set to
        /// <c>true</c> and the assembly culture is not the invariant
        /// culture (<see cref="GetCulture"/>) then its code is appended
        /// at the end of the title string.
        /// </para>
        /// </remarks>
        /// <param name="assembly">The assembly.</param>
        /// <param name="appendAssemblyCulture">
        /// if set to <c>true</c> append the assembly culture (if it is not the invariant culture).
        /// </param>
        /// <returns>The assembly title as a string.</returns>
        public static string GetTitle(this Assembly assembly, bool appendAssemblyCulture)
        {
            if (assembly.IsDynamic)
            {
                return(assembly.GetName().Name);
            }

            var title = string.Empty;

            object[] attributes = assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
            if (attributes.Length > 0)
            {
                AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];
                if (!string.IsNullOrEmpty(titleAttribute.Title))
                {
                    title = titleAttribute.Title;
                }
            }
            else
            {
                title = Path.GetFileNameWithoutExtension(assembly.CodeBase);
            }

            var ci = assembly.GetCulture();

            if (ci != CultureInfo.InvariantCulture)
            {
                title = string.Format("{0} ({1})", title, ci);
            }
            return(title);
        }
Ejemplo n.º 11
0
        private void FillInInfo()
        {
            Assembly app = Assembly.GetExecutingAssembly();

            AssemblyTitleAttribute       title       = (AssemblyTitleAttribute)app.GetCustomAttributes(typeof(AssemblyTitleAttribute), false)[0];
            AssemblyProductAttribute     product     = (AssemblyProductAttribute)app.GetCustomAttributes(typeof(AssemblyProductAttribute), false)[0];
            AssemblyCopyrightAttribute   copyright   = (AssemblyCopyrightAttribute)app.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)[0];
            AssemblyCompanyAttribute     company     = (AssemblyCompanyAttribute)app.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false)[0];
            AssemblyDescriptionAttribute description = (AssemblyDescriptionAttribute)app.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false)[0];

            System.Version version = app.GetName().Version;

            if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
            {
                version = System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion;
            }

            SetCurrentValue(TitleProperty, System.String.Format("About {0}", title.Title));
            lblName.SetCurrentValue(TextBlock.TextProperty, title.Title);
            lblDescription.SetCurrentValue(TextBlock.TextProperty, description.Description);
            lblVersion.SetCurrentValue(TextBlock.TextProperty, System.String.Format("Version {0}", version.ToString()));
            lblCopyright.SetCurrentValue(TextBlock.TextProperty, copyright.Copyright.ToString());
            lblCompany.SetCurrentValue(TextBlock.TextProperty, company.Company);
            lblDisclaimer.SetCurrentValue(TextBlock.TextProperty, "All rights reserved.");
        }
Ejemplo n.º 12
0
        public bool HasUpdate()
        {
            string filepath = Application.ExecutablePath;

            using (UpdateCheckSoapClient client = new UpdateCheckSoapClient())
            {
                if (File.Exists(filepath))
                {
                    Assembly assembly   = Assembly.LoadFrom(filepath);
                    object[] attributes = assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
                    if (attributes.Length > 0)
                    {
                        // 请选择第一个属性
                        AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];
                        // 如果该属性为非空字符串,则将其返回
                        if (titleAttribute.Title != "")
                        {
                            updateEntity = client.Check(titleAttribute.Title);
                            if (updateEntity != null)
                            {
                                Version ver = new Version(updateEntity.version);
                                return(ver > assembly.GetName().Version);
                            }
                        }
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 13
0
        public frmMain()
        {
            InitializeComponent();

            #region Version Info
            object[] attribute = this.GetType().Assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
            AssemblyDescriptionAttribute desc = (AssemblyDescriptionAttribute)(attribute[0]);
            attribute = this.GetType().Assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
            AssemblyTitleAttribute title = (AssemblyTitleAttribute)(attribute[0]);
            this.Text = $"[{ title.Title } - {Process.GetCurrentProcess().Id}]  {desc.Description}  V{Application.ProductVersion}";
            #endregion

            #region Form Layout
            VS2003Theme t = new VS2003Theme();
            dockPanel1.Theme = t;
            //Utility.SubscribeForm.Show(dockPanel1, WeifenLuo.WinFormsUI.Docking.DockState.DockRight);
            //Utility.RequestForm.Show(Utility.SubscribeForm.Pane, Utility.SubscribeForm);
            //Utility.SDataForm.Show(dockPanel1);
            //Utility.RDataForm.Show(dockPanel1);
            Utility.SubDockForm.Show(dockPanel1);
            //Utility.ReqDockForm.Show(dockPanel1);
            Utility.SettingForm.Show(dockPanel1, DockState.DockRight);
            Utility.MsgForm.Show(dockPanel1, DockState.DockBottomAutoHide);
            #endregion

            Utility.PUB = new Pub(ConnectType.Bind, Utility.Load <int>("ZMQ", "PUBPORT"));
            Utility.REP = new Rep(ConnectType.Bind, Utility.Load <int>("ZMQ", "REPPORT"));
            Utility.REP.OnREQReceived += new Rep.OnREQReceivedDelegate(OnREQReceived);
            Utility.REP.Start();

            //Utility.LoadConfig(tsPublish);
            tsPublish.Checked = Utility.Load <bool>("REDIS", "PUBLISH");
            m_Channel         = Utility.Load <string>("REDIS", "CHANNEL");
        }
        public static void EXC_Init_LOGfile(string version)
        {
            try
            {
                if (!Directory.Exists(LogFolderPath))
                {
                    Directory.CreateDirectory(LogFolderPath);
                }

                if (File.Exists(LogFilePath))
                {
                    FileInfo fInfo = new FileInfo(LogFilePath);
                    {
                        if ((fInfo.Length / 1024f) / 1024f > 5.0)
                        {
                            fInfo.MoveTo(LogFolderPath + "\\" + "Log_" + DateTime.Now.ToString("ddMMMMyyyy hhmmss") + ".eng");
                        }
                    }
                }

                if (!File.Exists(LogFilePath))
                {
                    //LOG_fileStream = new FileStream(Global.ApplicationFilePath + "\\LOG.eng", FileMode.Create);
                    LOG_fileStream  = new FileStream(LogFilePath, FileMode.Create);
                    LOGstreamWriter = new StreamWriter(LOG_fileStream);
                    object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
                    AssemblyTitleAttribute titleAttribute = null;
                    if (attributes.Length > 0)
                    {
                        titleAttribute = (AssemblyTitleAttribute)attributes[0];
                    }

                    string title = "-----------------------------------------------" + System.Environment.NewLine + "VMS";
                    if (!string.IsNullOrEmpty(titleAttribute.Title))
                    {
                        title = titleAttribute.Title;
                    }

                    //title += " " + Global.MACHINE_MODE.ToString() + " ";
                    title += " Multimedia Radio Station ";
                    string s = "--------------------------------------------------------------------" + System.Environment.NewLine +
                               title + version +
                               " Session Started  " + DateTime.Now.ToString() + System.Environment.NewLine +
                               "--------------------------------------------------------------------" + System.Environment.NewLine;

                    LOGstreamWriter.WriteLine(s);
                    LOGstreamWriter.Close();
                    LOG_fileStream.Close();
                }
                else
                {
                    EXC_WriteIn_LOGfile(" Session Started ");
                }
            }
            catch (Exception excp)
            {
                MessageBox.Show(excp.Source + System.Environment.NewLine +
                                excp.Message + System.Environment.NewLine + excp.StackTrace);
            }
        }
Ejemplo n.º 15
0
        private string FormatDescription(Assembly asm)
        {
            string s = "";

            object[] attributes = asm.GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
            if (attributes.Length > 0)
            {
                AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];
                if (titleAttribute.Title != "")
                {
                    s += titleAttribute.Title;
                }
            }
            else
            {
                s += System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
            }

            s += " " + asm.GetName().Version + Environment.NewLine;


            attributes = asm.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
            if (attributes.Length != 0)
            {
                if (!string.IsNullOrEmpty(((AssemblyDescriptionAttribute)attributes[0]).Description))
                {
                    s += ((AssemblyDescriptionAttribute)attributes[0]).Description + Environment.NewLine;
                }
            }

            attributes = null;
            return(s + Environment.NewLine);
        }
Ejemplo n.º 16
0
        private HeadingInfo CreateHeadingInfo()
        {
            try
            {
                Assembly executingAssembly = Assembly.GetEntryAssembly() ?? Assembly.GetExecutingAssembly();
                string   name                = executingAssembly.GetName().Name;
                string   version             = executingAssembly.GetName().Version.ToString();
                AssemblyTitleAttribute title = executingAssembly.GetCustomAttribute <AssemblyTitleAttribute>();
                if (title != null)
                {
                    name = title.Title;
                }

                AssemblyInformationalVersionAttribute informationalVersion = executingAssembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>();
                if (informationalVersion != null)
                {
                    version = $"{informationalVersion.InformationalVersion} ({version})";
                }

                return(new HeadingInfo(name, version));
            }
            catch (Exception e)
            {
                executionContext.WriteError($"Exception while creating the heading:{Environment.NewLine}{e}", false);
            }

            return(HeadingInfo.Empty);
        }
Ejemplo n.º 17
0
        public Login()
        {
            try
            {
                InitializeComponent();
                //string connString = ModuleClass.Connect();
                //DataAccess.RedaV1Entities db = ModuleClass.GetConnection();//= new DataAccess.RedaV1Entities(ModuleClass.Connect());
                db = ModuleClass.GetConnection();
                DevExpress.UserSkins.BonusSkins.Register();

                Assembly executingAssembly                   = Assembly.GetExecutingAssembly();
                AssemblyTitleAttribute       assembly        = executingAssembly.GetCustomAttribute <AssemblyTitleAttribute>();
                AssemblyFileVersionAttribute assemblyVersion = executingAssembly.GetCustomAttribute <AssemblyFileVersionAttribute>();
                this.Text = assembly.Title + " " + assemblyVersion.Version;// +" ( " + UserData.Default.UserName + " ) ";// +branch.BranchName;

                SkinContainerCollection skins = SkinManager.Default.Skins;
                for (int i = 0; i < skins.Count; i++)
                {
                    cmbTheme.Properties.Items.Add(skins[i].SkinName);
                }

                LoadData();
            }
            catch (Exception ex)
            {
                ModuleClass.ShowExceptionMessage(this, ex, "خطأ", null);
            }
        }
Ejemplo n.º 18
0
        public Game()
        {
            Game._instance             = this;
            this.LaunchParameters      = new LaunchParameters();
            this._services             = new GameServiceContainer();
            this._components           = new GameComponentCollection();
            this.Content               = new ContentManager((IServiceProvider)this._services);
            this.Platform              = GamePlatform.Create(this);
            this.Platform.Activated   += new EventHandler <EventArgs>(this.OnActivated);
            this.Platform.Deactivated += new EventHandler <EventArgs>(this.OnDeactivated);
            this._services.AddService(typeof(GamePlatform), (object)this.Platform);
            string   str           = string.Empty;
            Assembly entryAssembly = Assembly.GetEntryAssembly();
            AssemblyTitleAttribute assemblyTitleAttribute = (AssemblyTitleAttribute)System.Attribute.GetCustomAttribute(entryAssembly, typeof(AssemblyTitleAttribute));

            if (assemblyTitleAttribute != null)
            {
                str = assemblyTitleAttribute.Title;
            }
            if (string.IsNullOrEmpty(str))
            {
                str = entryAssembly.GetName().Name;
            }
            this.Window.Title = str;
        }
Ejemplo n.º 19
0
        public AboutBox()
        {
            InitializeComponent();

            foreach (Assembly s in AppDomain.CurrentDomain.GetAssemblies())
            {
                string[] lvsi = new string[3];
                lvsi[0] = s.GetName().Name;
                lvsi[1] = s.GetName().FullName;
                lvsi[2] = s.GetName().Version.ToString();
                ListViewItem lvi = new ListViewItem(lvsi, 0);
                this.ListOfAssemblies.Items.Add(lvi);
            }

            AssemblyCopyrightAttribute   objCopyright   = AssemblyCopyrightAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyCopyrightAttribute)) as AssemblyCopyrightAttribute;
            AssemblyDescriptionAttribute objDescription = AssemblyDescriptionAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyDescriptionAttribute)) as AssemblyDescriptionAttribute;
            AssemblyCompanyAttribute     objCompany     = AssemblyCompanyAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyCompanyAttribute)) as AssemblyCompanyAttribute;
            AssemblyTrademarkAttribute   objTrademark   = AssemblyTrademarkAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyTrademarkAttribute)) as AssemblyTrademarkAttribute;
            AssemblyProductAttribute     objProduct     = AssemblyProductAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyProductAttribute)) as AssemblyProductAttribute;
            AssemblyTitleAttribute       objTitle       = AssemblyTitleAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyTitleAttribute)) as AssemblyTitleAttribute;
            GuidAttribute         objGuid         = GuidAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(GuidAttribute)) as GuidAttribute;
            DebuggableAttribute   objDebuggable   = DebuggableAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(DebuggableAttribute)) as DebuggableAttribute;
            CLSCompliantAttribute objCLSCompliant = CLSCompliantAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(CLSCompliantAttribute)) as CLSCompliantAttribute;

            AppName.Text        = objProduct.Product;
            BigTitle.Text       = objTitle.Title;
            ProdVer.Text        = QuestDesignerMain.Version;
            AppDesc.Text        = objDescription.Description;
            CopyrightLabel.Text = objCopyright.Copyright;
            SerialNo.Text       = objGuid.Value;
            Company.Text        = objCompany.Company;
        }
Ejemplo n.º 20
0
        public static void PrintHeader(Assembly a)
        {
            // Retrieves name and description that are stored as assembly
            // attributes in the specified assembly (usually the calling one)
            //
            // These attributes are defined as following:
            //  [assembly: AssemblyTitle ("beagrep-foo")]
            //  [assembly: AsssemblyDescription ("This is the program that does foo")]

            AssemblyTitleAttribute       title     = (AssemblyTitleAttribute)Attribute.GetCustomAttribute(a, typeof(AssemblyTitleAttribute));
            AssemblyDescriptionAttribute desc      = (AssemblyDescriptionAttribute)Attribute.GetCustomAttribute(a, typeof(AssemblyDescriptionAttribute));
            AssemblyCopyrightAttribute   copyright = (AssemblyCopyrightAttribute)Attribute.GetCustomAttribute(a, typeof(AssemblyCopyrightAttribute));

            StringBuilder text = new StringBuilder();

            if (title != null && desc != null)
            {
                text.AppendFormat("{0}: {1}.\n", title.Title, desc.Description);
            }

            text.Append("Web page: http://www.beagrep-project.org/\n");
            text.Append(copyright == null ? DefaultCopyright : copyright.Copyright);

            Console.WriteLine(text);
        }
        public AssemblyTitleAttributeTest()
        {
            //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(AssemblyTitleAttribute);
            ConstructorInfo ctrInfo   = attribute.GetConstructor(
                new Type [] { typeof(string) }
                );
            CustomAttributeBuilder attrBuilder =
                new CustomAttributeBuilder(ctrInfo, new object [1] {
                "The Assembly"
            });

            dynAssembly.SetCustomAttribute(attrBuilder);
            object [] attributes = dynAssembly.GetCustomAttributes(true);
            attr = attributes [0] as AssemblyTitleAttribute;
        }
        private static string GetAssemblyTitle()
        {
            Assembly assembly = Assembly.GetEntryAssembly();
            AssemblyTitleAttribute assemblyTitleAttribute = assembly.GetCustomAttribute <AssemblyTitleAttribute>();

            return(assemblyTitleAttribute?.Title);
        }
Ejemplo n.º 23
0
        //=====================================================================

        /// <summary>
        /// Set the version and assembly info on load
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void AboutDlg_Load(object sender, EventArgs e)
        {
            // Get assembly information not available from the application object
            Assembly asm = Assembly.GetEntryAssembly();
            AssemblyTitleAttribute title = (AssemblyTitleAttribute)
                                           AssemblyTitleAttribute.GetCustomAttribute(asm, typeof(AssemblyTitleAttribute));
            AssemblyCopyrightAttribute copyright = (AssemblyCopyrightAttribute)
                                                   AssemblyCopyrightAttribute.GetCustomAttribute(asm, typeof(AssemblyCopyrightAttribute));
            AssemblyDescriptionAttribute desc = (AssemblyDescriptionAttribute)
                                                AssemblyDescriptionAttribute.GetCustomAttribute(asm, typeof(AssemblyDescriptionAttribute));

            // Set the labels
            lblName.Text        = title.Title;
            lblDescription.Text = desc.Description;
            lblVersion.Text     = "Version: " + Application.ProductVersion;
            lblCopyright.Text   = copyright.Copyright;

            // Display components used by this assembly sorted by name
            foreach (AssemblyName an in asm.GetReferencedAssemblies())
            {
                ListViewItem lvi = lvComponents.Items.Add(an.Name);
                lvi.SubItems.Add(an.Version.ToString());
            }

            lvComponents.Sorting = SortOrder.Ascending;
            lvComponents.Sort();

            // Set e-mail link
            lnkHelp.Links[0].LinkData = "mailto:" + lnkHelp.Text + "?Subject=EWSoftware CalendarBrowser Demo";
        }
Ejemplo n.º 24
0
        // *******************************************************************

        /// <summary>
        /// Reads the value of the <see cref="AssemblyTitleAttribute"/>
        /// attribute for the given assembly.
        /// </summary>
        /// <param name="assembly">The assembly to read from.</param>
        /// <returns>The value of the given assembly's title attribute.</returns>
        public static string ReadTitle(this Assembly assembly)
        {
            // Attempt to read the assembly's title attribute.
            object[] attributes = assembly.GetCustomAttributes(
                typeof(AssemblyTitleAttribute),
                true
                );

            // Did we fail?
            if (attributes.Length == 0)
            {
                return(string.Empty);
            }

            // Attempt to recover a reference to the attribute.
            AssemblyTitleAttribute attr =
                attributes[0] as AssemblyTitleAttribute;

            // Did we fail?
            if (attr == null || attr.Title.Length == 0)
            {
                return(string.Empty);
            }

            // Return the text for the attribute.
            return(attr.Title);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CommandLineManagerAttribute"/> class.
        /// </summary>
        public CommandLineManagerAttribute()
        {
            Assembly     assembly = Assembly.GetEntryAssembly();
            AssemblyName name     = assembly.GetName();

            Version = name.Version.ToString();

            foreach (object objAttribute in assembly.GetCustomAttributes(false))
            {
                AssemblyCopyrightAttribute copyrightAttribute = objAttribute as AssemblyCopyrightAttribute;
                if (copyrightAttribute != null)
                {
                    Copyright = copyrightAttribute.Copyright;
                    continue;
                }

                AssemblyTitleAttribute titleAttribute = objAttribute as AssemblyTitleAttribute;
                if (titleAttribute != null)
                {
                    ApplicationName = titleAttribute.Title;
                    continue;
                }

                AssemblyDescriptionAttribute descriptionAttribute = objAttribute as AssemblyDescriptionAttribute;
                if (descriptionAttribute != null)
                {
                    Description = descriptionAttribute.Description;
                    continue;
                }
            }
        }
Ejemplo n.º 26
0
        public static void AddInitialLog(this ILog log, string[] args)
        {
            if (log == null)
            {
                throw new ArgumentNullException(nameof(log));
            }

            try
            {
                Assembly executingAssembly = Assembly.GetEntryAssembly() ?? Assembly.GetExecutingAssembly();
                string   name                = executingAssembly.GetName().Name;
                string   version             = executingAssembly.GetName().Version.ToString();
                AssemblyTitleAttribute title = executingAssembly.GetCustomAttribute <AssemblyTitleAttribute>();
                if (title != null)
                {
                    name = title.Title;
                }

                AssemblyInformationalVersionAttribute informationalVersion =
                    executingAssembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>();
                if (informationalVersion != null)
                {
                    version = $"{informationalVersion.InformationalVersion} ({version})";
                }
                log.LogInformation($"{name}: {version}");
            }
            catch (Exception e)
            {
                log.LogError($"Could not create application infos:{Environment.NewLine}{e}");
            }
            log.LogInformation($"Arguments: {string.Join(" ", args)}");
            log.LogInformation($"Execution context: {Directory.GetCurrentDirectory()}");
            log.LogInformation($"Process id: {Process.GetCurrentProcess().Id}");
        }
        public string ReadAssemblyTitle()
        {
            Type t = typeof(Program);
            AssemblyTitleAttribute productAttr = t.Assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), true)[0] as AssemblyTitleAttribute;

            return(productAttr.Title);
        }
Ejemplo n.º 28
0
        public string Copyleft()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(LINEBREAK);

            AssemblyTitleAttribute titleAttrib = (AssemblyTitleAttribute)GetAttribute(typeof(AssemblyTitleAttribute));

            sb.Append(titleAttrib.Title + LINEBREAK + LINEBREAK);

            AssemblyFileVersionAttribute versionAttrib = (AssemblyFileVersionAttribute)GetAttribute(typeof(AssemblyFileVersionAttribute));

            if (versionAttrib != null)
            {
                sb.Append("Version: " + versionAttrib.Version.ToString() + LINEBREAK);
            }

            AssemblyCompanyAttribute companyAttrib = (AssemblyCompanyAttribute)GetAttribute(typeof(AssemblyCompanyAttribute));

            sb.Append(companyAttrib.Company + LINEBREAK);
            AssemblyCopyrightAttribute copyrightAttrib = (AssemblyCopyrightAttribute)GetAttribute(typeof(AssemblyCopyrightAttribute));

            sb.Append(copyrightAttrib.Copyright + LINEBREAK);

            return(sb.ToString());
        }
Ejemplo n.º 29
0
        private void Dashboard_Load(object sender, EventArgs e)
        {
            try
            {
                BranchID = Convert.ToInt32(UserData.Default.BranchID);
                branchBindingSource.DataSource = db.Branches.ToList();
                var      branch                              = db.Branches.Where(s => s.ID == BranchID).SingleOrDefault();
                Assembly executingAssembly                   = Assembly.GetExecutingAssembly();
                AssemblyTitleAttribute       assembly        = executingAssembly.GetCustomAttribute <AssemblyTitleAttribute>();
                AssemblyFileVersionAttribute assemblyVersion = executingAssembly.GetCustomAttribute <AssemblyFileVersionAttribute>();


                this.Text = assembly.Title + " " + assemblyVersion.Version + " ( " + UserData.Default.UserName + " ) - " + branch.BranchName;

                var users = from s in db.Users where s.IsEnable == true select s;
                userBindingSource.DataSource = users.ToList();
                cmbUsers.EditValue           = 1;

                cmbSaleInvoiceDateFrom.DateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);
                // cmbSaleInvoiceDateTo.DateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);
                new SaleInvoiceForm(new DataAccess.SaleInvoice(), true, SaleInvoiceType.Sale).Show();
            }
            catch (Exception ex)
            {
                ModuleClass.ShowExceptionMessage(this, ex, "خطأ", null);
            }
        }
Ejemplo n.º 30
0
        public static RegistryKey GetRootKey(ref string ErrorMessage)
        {
            RegistryKey currentUser = Registry.CurrentUser;

            try
            {
                Assembly entryAssembly              = Assembly.GetEntryAssembly();
                AssemblyCompanyAttribute attribute  = (AssemblyCompanyAttribute)GetAttribute(entryAssembly, typeof(AssemblyCompanyAttribute));
                AssemblyTitleAttribute   attribute2 = (AssemblyTitleAttribute)GetAttribute(entryAssembly, typeof(AssemblyTitleAttribute));
                string      str  = (attribute2 != null) ? attribute2.Title : entryAssembly.GetName().Name;
                string      str2 = (attribute != null) ? attribute.Company : "";
                string      name = $"Software\\{str2}\\{str}";
                RegistryKey key2 = currentUser.OpenSubKey(name, true);
                if (key2 == null)
                {
                    return(currentUser.CreateSubKey(name));
                }
                currentUser = key2;
            }
            catch (Exception exception)
            {
                ErrorMessage = exception.Message;
            }
            return(currentUser);
        }
Ejemplo n.º 31
0
 public bool PosTest2()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest2:Return the Title info from initialized AssemblyTitleAttribute 2");
     try
     {
         string title = null;
         AssemblyTitleAttribute assemTitleAttr = new AssemblyTitleAttribute(title);
         if (assemTitleAttr.Title != 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;
 }
 public bool PosTest3()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest3:Initialize the AssemblyTitleAttribute 3");
     try
     {
         string title = string.Empty;
         AssemblyTitleAttribute assemTitleAttr = new AssemblyTitleAttribute(title);
         if (assemTitleAttr == null || assemTitleAttr.Title != "")
         {
             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;
 }
Ejemplo n.º 33
0
 public bool PosTest1()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest1:Return the Title info from initialized AssemblyTitleAttribute 1");
     try
     {
         string title = TestLibrary.Generator.GetString(-55, false, c_MIN_STR_LENGTH, c_MAX_STR_LENGTH);
         AssemblyTitleAttribute assemTitleAttr = new AssemblyTitleAttribute(title);
         if (assemTitleAttr.Title != title)
         {
             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;
 }