using System.ComponentModel.Design;
using System.Security.Permissions;
-#if NET_2_0
using System.Collections.Generic;
-#endif
namespace System.ComponentModel
{
private static Hashtable typeTable = new Hashtable ();
private static Hashtable editors;
-#if NET_2_0
static object typeDescriptionProvidersLock = new object ();
static Dictionary <Type, LinkedList <TypeDescriptionProvider>> typeDescriptionProviders;
typeDescriptionProviders = new Dictionary <Type, LinkedList <TypeDescriptionProvider>> ();
componentDescriptionProviders = new Dictionary <WeakObjectWrapper, LinkedList <TypeDescriptionProvider>> (new WeakObjectWrapperComparer ());
}
-#endif
+
private TypeDescriptor ()
{
}
-#if NET_2_0
[MonoNotSupported ("Mono does not support COM")]
[EditorBrowsable (EditorBrowsableState.Advanced)]
public static Type ComObjectType {
get { throw new NotImplementedException (); }
}
+#if NET_4_0
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ public static Type InterfaceType {
+ get {
+ return typeof (TypeDescriptorInterface);
+ }
+ }
+#endif
+
[EditorBrowsable (EditorBrowsableState.Advanced)]
public static TypeDescriptionProvider AddAttributes (object instance, params Attribute [] attributes)
{
}
}
+#if NET_4_0
+ [MonoLimitation ("Security not applied.")]
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ public static void AddProviderTransparent (TypeDescriptionProvider provider, object instance)
+ {
+ AddProvider (provider, instance);
+ }
+
+ [MonoLimitation ("Security not applied.")]
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ public static void AddProviderTransparent (TypeDescriptionProvider provider, Type type)
+ {
+ AddProvider (provider, type);
+ }
+#endif
+
[MonoTODO]
public static object CreateInstance (IServiceProvider provider, Type objectType, Type [] argTypes, object [] args)
{
return instance;
}
-#endif
-#if NET_2_0
[EditorBrowsable (EditorBrowsableState.Advanced)]
-#endif
#if !NET_2_1
public
#else
return GetAttributes (component, false);
}
-#if NET_2_0
[EditorBrowsable (EditorBrowsableState.Advanced)]
-#endif
public static AttributeCollection GetAttributes (object component, bool noCustomTypeDesc)
{
if (component == null)
return GetClassName (component, false);
}
-#if NET_2_0
[EditorBrowsable (EditorBrowsableState.Advanced)]
-#endif
public static string GetClassName (object component, bool noCustomTypeDesc)
{
if (component == null)
return GetComponentName (component, false);
}
-#if NET_2_0
[EditorBrowsable (EditorBrowsableState.Advanced)]
-#endif
public static string GetComponentName (object component, bool noCustomTypeDesc)
{
if (component == null)
IComponent c = component as IComponent;
if (c != null && c.Site != null)
return c.Site.Name;
-#if NET_2_0
return null;
-#else
- return component.GetType().Name;
-#endif
}
}
-#if NET_2_0
[MonoNotSupported("")]
public static string GetFullComponentName (object component)
{
{
throw new NotImplementedException ();
}
-#endif
public static TypeConverter GetConverter (object component)
{
return GetConverter (component, false);
}
-#if NET_2_0
[EditorBrowsable (EditorBrowsableState.Advanced)]
-#endif
public static TypeConverter GetConverter (object component, bool noCustomTypeDesc)
{
if (component == null)
{
Type converterType = null;
if (type != null) {
-#if NET_2_0
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>))
return typeof(NullableConverter);
-#endif
// Is there a default converter
foreach (DictionaryEntry entry in DefaultConverters) {
if ((Type)entry.Key == type)
return GetDefaultEvent (component, false);
}
-#if NET_2_0
[EditorBrowsable (EditorBrowsableState.Advanced)]
-#endif
public static EventDescriptor GetDefaultEvent (object component, bool noCustomTypeDesc)
{
if (!noCustomTypeDesc && (component is ICustomTypeDescriptor))
return GetDefaultProperty (component, false);
}
-#if NET_2_0
[EditorBrowsable (EditorBrowsableState.Advanced)]
-#endif
public static PropertyDescriptor GetDefaultProperty (object component, bool noCustomTypeDesc)
{
if (!noCustomTypeDesc && (component is ICustomTypeDescriptor))
return GetEditor (component, editorBaseType, false);
}
-#if NET_2_0
[EditorBrowsable (EditorBrowsableState.Advanced)]
-#endif
public static object GetEditor (object component, Type editorBaseType, bool noCustomTypeDesc)
{
if (component == null)
return GetEvents (component, attributes, false);
}
-#if NET_2_0
[EditorBrowsable (EditorBrowsableState.Advanced)]
-#endif
public static EventDescriptorCollection GetEvents (object component, bool noCustomTypeDesc)
{
if (!noCustomTypeDesc && (component is ICustomTypeDescriptor))
return GetTypeInfo (componentType).GetEvents (attributes);
}
-#if NET_2_0
[EditorBrowsable (EditorBrowsableState.Advanced)]
-#endif
public static EventDescriptorCollection GetEvents (object component, Attribute [] attributes, bool noCustomTypeDesc)
{
if (!noCustomTypeDesc && (component is ICustomTypeDescriptor))
}
}
-#if NET_2_0
[EditorBrowsable (EditorBrowsableState.Advanced)]
-#endif
public static PropertyDescriptorCollection GetProperties (object component, bool noCustomTypeDesc)
{
if (component == null)
return GetTypeInfo (componentType).GetProperties (attributes);
}
-#if NET_2_0
[EditorBrowsable (EditorBrowsableState.Advanced)]
public static TypeDescriptionProvider GetProvider (object instance)
{
refreshed (new RefreshEventArgs (type));
}
+#if NET_4_0
+ [MonoLimitation ("Security not applied.")]
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ public static void RemoveProviderTransparent (TypeDescriptionProvider provider, object instance)
+ {
+ RemoveProvider (provider, instance);
+ }
+
+ [MonoLimitation ("Security not applied.")]
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ public static void RemoveProviderTransparent (TypeDescriptionProvider provider, Type type)
+ {
+ RemoveProvider (provider, type);
+ }
+#endif
+
static void RemoveProvider (TypeDescriptionProvider provider, LinkedList <TypeDescriptionProvider> plist)
{
LinkedListNode <TypeDescriptionProvider> node = plist.Last;
} while (true);
}
-#endif
public static void SortDescriptorArray (IList infos)
{
infos.Add (ob);
}
-#if NET_2_0
// well, ComObjectType is not implemented, but we don't support COM anyways ...
[Obsolete ("Use ComObjectType")]
-#endif
public static IComNativeDescriptorHandler ComNativeDescriptorHandler {
[PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
get { return descriptorHandler; }
return type;
}
-#if NET_2_0
sealed class AttributeProvider : TypeDescriptionProvider
{
Attribute[] attributes;
return new DefaultTypeDescriptor (this, objectType, instance);
}
}
-#endif
}
internal abstract class Info
else {
EventDescriptorCollection events = GetEvents ();
_defaultEvent = events [attr.Name];
-#if !NET_2_0
- // In our test case (TypeDescriptorTest.TestGetDefaultEvent), we have
- // a scenario where a custom filter adds the DefaultEventAttribute,
- // but its FilterEvents method removes the event the
- // DefaultEventAttribute applied to. .NET 1.x accepts this and returns
- // the *other* event defined in the class.
- //
- // Consequently, we know we have a DefaultEvent, but we need to check
- // and ensure that the requested event is unfiltered. If it is, just
- // grab the first element in the collection.
- if (_defaultEvent == null && events.Count > 0)
- _defaultEvent = events [0];
-#endif
}
_gotDefaultEvent = true;
return _defaultEvent;
return _properties;
}
}
+
+#if NET_4_0
+ // In .net this class seems to be a dummy and empty class
+ // used to represent internally any extender provider associated with
+ // all the interfaces.
+ sealed class TypeDescriptorInterface
+ {
+ }
+#endif
}