Fixed space indents to tabs to adhere to Mono coding guidelines.
[mono.git] / mcs / class / System / System.ComponentModel / Component.cs
index e370a6aa6834ae328c4237904f1ffb104f5e3012..5c61d72eef89da05deee4e4ade0717818f8d4853 100644 (file)
 
 using System;
 using System.ComponentModel;
+using System.Runtime.InteropServices;
 
 namespace System.ComponentModel {
 
        [DesignerCategory ("Component")]
+       [ComVisible (true)]
+       [ClassInterface (ClassInterfaceType.AutoDispatch)]
        public class Component : MarshalByRefObject, IComponent, IDisposable
        {
 
@@ -48,6 +51,17 @@ namespace System.ComponentModel {
                        event_handlers = null;
                }
 
+               protected virtual bool CanRaiseEvents {
+                       get { return false; }
+               }
+
+               [Browsable (false), DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+               public virtual ISite Site
+               {
+                       get { return mySite; }
+                       set { mySite = value; }
+               }
+
                [Browsable (false), DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
                public IContainer Container {
                        get {
@@ -81,22 +95,23 @@ namespace System.ComponentModel {
                        }
                }
 
-               [Browsable (false), DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
-               public virtual ISite Site {
-                       get { return mySite; }
-                       set { mySite = value; }
-               }
-
                ~Component()
                {
                        Dispose (false);
                }
 
+#if TARGET_JVM
+               public virtual void Dispose ()
+               {
+                       Dispose (true);
+               }
+#else
                public void Dispose ()
                {
                        Dispose (true);
                        GC.SuppressFinalize (this);
                }
+#endif
 
                // <summary>
                //   Controls disposal of resources used by this.
@@ -112,11 +127,12 @@ namespace System.ComponentModel {
                protected virtual void Dispose (bool release_all)
                {
                        if (release_all) {
+                               if (mySite != null && mySite.Container != null)
+                                       mySite.Container.Remove (this);
                                EventHandler eh = (EventHandler) Events [disposedEvent];
                                if (eh != null)
                                        eh (this, EventArgs.Empty);
                        }
-                       mySite = null;
                }
 
                protected virtual object GetService (Type service)