System.ComponentModel.DebugTypeDescriptor.GetComponentName C# (CSharp) Method

GetComponentName() public static method

public static GetComponentName ( object component, bool noCustomTypeDesc ) : string
component object
noCustomTypeDesc bool
return string
        public static string GetComponentName(object component, bool noCustomTypeDesc) {

            if (component == null) {
                throw new ArgumentNullException("component");
            }

            if (System.Runtime.InteropServices.Marshal.IsComObject(component)) {
            
                // Do not rip this varible -- it is here to make the get to 
                // this static variable thread-safe.
                //
#pragma warning disable 618
                IComNativeDescriptorHandler handler = comNativeDescriptorHandler;
#pragma warning restore 618
                
                if (handler != null) {
                    return handler.GetName(component);
                }
            }

            if (!noCustomTypeDesc && component is ICustomTypeDescriptor) {
                string str = ((ICustomTypeDescriptor)component).GetComponentName();
                if (str != null) {
                    return str;
                }
            }

            if (component is IComponent) {
                ISite site = ((IComponent)component).Site;
                if (site != null) {
                    return site.Name;
                }
            }
            return component.GetType().Name;
        }

Same methods

DebugTypeDescriptor::GetComponentName ( object component ) : string