System.Attribute.GetCustomAttribute C# (CSharp) Method

GetCustomAttribute() public static method

public static GetCustomAttribute ( Module element, Type attributeType, bool inherit ) : Attribute
element Module
attributeType Type
inherit bool
return Attribute
        public static Attribute GetCustomAttribute(Module element, Type attributeType, bool inherit)
        {
            // Returns an Attribute of base class/inteface attributeType on the Module or null if none exists.
            // throws an AmbiguousMatchException if there are more than one defined.
            Attribute[] attrib = GetCustomAttributes(element,attributeType,inherit);

            if (attrib == null || attrib.Length == 0)
                return null;

            if (attrib.Length == 1)
                return attrib[0];

            throw new AmbiguousMatchException(Environment.GetResourceString("RFLCT.AmbigCust"));
        }

Same methods

Attribute::GetCustomAttribute ( Assembly element, Type attributeType ) : Attribute
Attribute::GetCustomAttribute ( Assembly element, Type attributeType, bool inherit ) : Attribute
Attribute::GetCustomAttribute ( MemberInfo element, Type attributeType ) : Attribute
Attribute::GetCustomAttribute ( MemberInfo element, Type attributeType, bool inherit ) : Attribute
Attribute::GetCustomAttribute ( Module element, Type attributeType ) : Attribute
Attribute::GetCustomAttribute ( ParameterInfo element, Type attributeType ) : Attribute
Attribute::GetCustomAttribute ( ParameterInfo element, Type attributeType, bool inherit ) : Attribute

Usage Example

Beispiel #1
0
        /// <summary>
        ///  This method is called by Inventor when it loads the addin.
        ///  The AddInSiteObject provides access to the Inventor Application object.
        ///  The FirstTime flag indicates if the addin is loaded for the first time.
        /// </summary>
        /// <param name="addInSiteObject"></param>
        /// <param name="firstTime"></param>
        public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            try
            {
                InventorApplication = addInSiteObject.Application;

                //retrieve the GUID for this class and assign it to the string member variable
                //intended to hold it
                GuidAttribute addInClsid = (GuidAttribute)Attribute.GetCustomAttribute
                                               (typeof(StandardAddInServer), typeof(GuidAttribute));
                string addInClsidString = "{" + addInClsid.Value + "}";
                AddInServerId = addInClsidString;

                //Set a reference to the user interface manager to determine the interface style
                UserInterfaceManager userInterfaceManager = InventorApplication.UserInterfaceManager;
                InterfaceStyleEnum   interfaceStyle       = userInterfaceManager.InterfaceStyle;

                RectangleDependencyManager = new RectangleToolsDependencyMapper();

                if (interfaceStyle == InterfaceStyleEnum.kRibbonInterface)
                {
                    if (firstTime == true)
                    {
                        RectangleDependencyManager.InitializeUserInterface();
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
All Usage Examples Of System.Attribute::GetCustomAttribute