Beispiel #1
0
        //-------------------------------------------------------------------------
        private static object find_attribute(Attribute_id atid_)
        {
            string att_name = "Assembly" + atid_.ToString() + "Attribute";

            foreach (object att in assembly_info.attributes)
            {
                if (att.GetType().Name.StartsWith(att_name))
                {
                    return(att);
                }
            }
            return(null);                     // NOT found
        }
Beispiel #2
0
        //-------------------------------------------------------------------------
        public static string attribute_value(Attribute_id atid_, string property_name)
        {
            lock (assembly_info.locker_)
            {
                object the_att = assembly_info.find_attribute(atid_);

                if (the_att == null)
                {
                    return(string.Empty);
                }

                System.Reflection.PropertyInfo pi_ = the_att.GetType().GetProperty(property_name);

                if (pi_ != null)
                {
                    return((string)pi_.GetValue(the_att, null));
                }

                return(string.Empty);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Simpler to use. We always want same properties from same assembly attributes
        /// </summary>
        public static string attribute_value(Attribute_id atid_)
        {
            lock (assembly_info.locker_)
            {
                object the_att = assembly_info.find_attribute(atid_);

                if (the_att == null)
#if DEBUG
                { return("Attribute " + atid_.ToString() + " NOT found on executing assembly"); }
#else
                { throw new System.ApplicationException("Attribute " + atid_.ToString() + " NOT found on executing assembly"); }
#endif

                System.Reflection.PropertyInfo pi_ = null;
                string prop_name = string.Empty;

                switch (atid_)
                {
                case Attribute_id.Title:
                    prop_name = ("Title");
                    break;

                case Attribute_id.Description:
                    prop_name = ("Description");
                    break;

                case Attribute_id.Configuration:
                    prop_name = ("Configuration");
                    break;

                case Attribute_id.Company:
                    prop_name = ("Company");
                    break;

                case Attribute_id.Product:
                    prop_name = ("Product");
                    break;

                case Attribute_id.Copyright:
                    prop_name = ("Copyright");
                    break;

                case Attribute_id.Trademark:
                    prop_name = ("Trademark");
                    break;

                case Attribute_id.Culture:
                    prop_name = ("Culture");
                    break;

                case Attribute_id.Version:
                    prop_name = ("Version");
                    break;

                case Attribute_id.DelaySign:
                    prop_name = ("DelaySign");
                    break;

                case Attribute_id.KeyFile:
                    prop_name = ("KeyFile");
                    break;

                case Attribute_id.KeyName:
                    prop_name = ("KeyName");
                    break;
                }

                pi_ = the_att.GetType().GetProperty(prop_name);
                if (pi_ != null)
                {
                    return((string)pi_.GetValue(the_att, null));
                }
#if DEBUG
                return("Property by name: " + prop_name + ", NOT found on attribute " + the_att.GetType().Name);
#else
                throw new System.ApplicationException("Property by name: " + prop_name + ", NOT found on attribute " + the_att.GetType().Name);
#endif
            }
        }