/// <summary> /// Extends GetEditor so that methods that return a specific type object given a Type parameter can be /// used as generic method and casting is not required. /// <example> /// icomnativedescriptorhandler.GetEditor<int>(component); /// </example> /// </summary> public static T GetEditor <T>(this IComNativeDescriptorHandler icomnativedescriptorhandler, Object component) { if (icomnativedescriptorhandler == null) { throw new ArgumentNullException("icomnativedescriptorhandler"); } return((T)icomnativedescriptorhandler.GetEditor(component, typeof(T))); }
#pragma warning disable CS0618 // 'IComNativeDescriptorHandler' is obsolete: 'This interface has been deprecated. Add a TypeDescriptionProvider to handle type TypeDescriptor.ComObjectType instead. http://go.microsoft.com/fwlink/?linkid=14202' /// <summary> /// Extends GetEditor so that methods that return a specific type object given a Type parameter can be /// used as generic method and casting is not required. /// <example> /// icomnativedescriptorhandler.GetEditor<int>(component); /// </example> /// </summary> public static T GetEditor <T>(this IComNativeDescriptorHandler icomnativedescriptorhandler, Object component) #pragma warning restore CS0618 // 'IComNativeDescriptorHandler' is obsolete: 'This interface has been deprecated. Add a TypeDescriptionProvider to handle type TypeDescriptor.ComObjectType instead. http://go.microsoft.com/fwlink/?linkid=14202' { if (icomnativedescriptorhandler == null) { throw new ArgumentNullException("icomnativedescriptorhandler"); } return((T)icomnativedescriptorhandler.GetEditor(component, typeof(T))); }
private static string GetCatID(object component) { // 1 : handle intrinsic extensions string catID = null; if (Marshal.IsComObject(component)) { bool success = false; Type descriptorType = Type.GetType("System.Windows.Forms.ComponentModel.Com2Interop.ComNativeDescriptor, " + AssemblyRef.SystemWindowsForms); Debug.Assert(descriptorType != null, "No comnative descriptor; we can't get native property values"); if (descriptorType != null) { PropertyInfo info = descriptorType.GetProperty("Instance"); Debug.Assert(info != null, "Property Instance does not exist on com native descriptor"); if (info != null) { IComNativeDescriptorHandler handler = (IComNativeDescriptorHandler)info.GetValue(null, null); catID = (string)handler.GetPropertyValue(component, extenderPropName, ref success); } } } else { PropertyInfo propCatID = component.GetType().GetProperty(extenderPropName); if (propCatID != null) { object[] tempIndex = null; catID = (string)propCatID.GetValue(component, tempIndex); } } if (catID != null && catID.Length > 0) { try { // is this a vaild catID string? Guid g = new Guid(catID); } catch (Exception) { Debug.Fail("'" + catID + "' is not a valid CatID (GUID) string"); catID = null; } } else { catID = null; } return(catID); }
/// <devdoc> /// Creates a new ComNativeTypeDescriptor. /// </devdoc> internal ComNativeTypeDescriptor(IComNativeDescriptorHandler handler, object instance) { _handler = handler; _instance = instance; }
internal ComNativeDescriptionProvider(IComNativeDescriptorHandler handler) { _handler = handler; }