/// <summary> /// Default ctor. /// </summary> public Com2Properties(object obj, Com2PropertyDescriptor[] props, int defaultIndex) { #if DEBUG ComNativeDescriptor cnd = new ComNativeDescriptor(); dbgObjName = cnd.GetName(obj); if (dbgObjName == null) { dbgObjName = "(null)"; } dbgObjClass = cnd.GetClassName(obj); if (dbgObjClass == null) { dbgObjClass = "(null)"; } if (DbgCom2PropertiesSwitch.TraceVerbose) { Debug.WriteLine("Creating Com2Properties for object " + dbgObjName + ", class=" + dbgObjClass); } #endif // set up our variables SetProps(props); weakObjRef = new WeakReference(obj); this.defaultIndex = defaultIndex; typeInfoVersions = GetTypeInfoVersions(obj); touchedTime = DateTime.Now.Ticks; }
/// <summary> /// Converts the given object to another type. The most common types to convert /// are to and from a string object. The default implementation will make a call /// to ToString on the object if the object is valid and if the destination /// type is string. If this cannot convert to the destination type, this will /// throw a NotSupportedException. /// </summary> public override object?ConvertTo(ITypeDescriptorContext?context, CultureInfo?culture, object?value, Type destinationType) { if (destinationType == typeof(string)) { if (value is null) { return(s_none); } string text = ComNativeDescriptor.GetName(value); if (text is null || text.Length == 0) { text = ComNativeDescriptor.GetClassName(value); } if (text is null) { return("(Object)"); } return(text); } return(base.ConvertTo(context, culture, value, destinationType)); }
/// <include file='doc\COM2Properties.uex' path='docs/doc[@for="Com2Properties.Com2Properties"]/*' /> /// <devdoc> /// Default ctor. /// </devdoc> public Com2Properties(object obj, Com2PropertyDescriptor[] props, int defaultIndex) { #if DEBUG ComNativeDescriptor cnd = new ComNativeDescriptor(); this.dbgObjName = cnd.GetName(obj); if (this.dbgObjName == null) { this.dbgObjName = "(null)"; } this.dbgObjClass = cnd.GetClassName(obj); if (this.dbgObjClass == null) { this.dbgObjClass = "(null)"; } if (DbgCom2PropertiesSwitch.TraceVerbose) { Debug.WriteLine("Creating Com2Properties for object " + dbgObjName + ", class=" + dbgObjClass); } #endif // set up our variables SetProps(props); weakObjRef = new WeakReference(obj); hashCode = obj.GetHashCode(); this.defaultIndex = defaultIndex; // get the type infos count if (obj is NativeMethods.IProvideMultipleClassInfo) { int infos = 0; if (NativeMethods.Succeeded(((NativeMethods.IProvideMultipleClassInfo)obj).GetMultiTypeInfoCount(ref infos))) { this.nTypeInfos = infos; } } }
/// <summary> /// ICustomTypeDescriptor implementation. /// </summary> string ICustomTypeDescriptor.GetComponentName() { return(_handler.GetName(_instance)); }
/// <include file='doc\COM2Properties.uex' path='docs/doc[@for="Com2Properties.Com2Properties"]/*' /> /// <devdoc> /// Default ctor. /// </devdoc> public Com2Properties(object obj, Com2PropertyDescriptor[] props, int defaultIndex) { #if DEBUG ComNativeDescriptor cnd = new ComNativeDescriptor(); this.dbgObjName = cnd.GetName(obj); if (this.dbgObjName == null) { this.dbgObjName = "(null)"; } this.dbgObjClass = cnd.GetClassName(obj); if (this.dbgObjClass == null) { this.dbgObjClass = "(null)"; } if (DbgCom2PropertiesSwitch.TraceVerbose) Debug.WriteLine("Creating Com2Properties for object " + dbgObjName + ", class=" + dbgObjClass); #endif // set up our variables SetProps(props); weakObjRef = new WeakReference(obj); this.defaultIndex = defaultIndex; typeInfoVersions = GetTypeInfoVersions(obj); touchedTime = DateTime.Now.Ticks; }