Remove Console.WriteLine.
[mono.git] / mcs / class / System.Design / System.ComponentModel.Design / DesignModeSite.cs
index 331115439839735a3a3ffe29a3044c476af7db1a..e94440d7c10de4f954dfc9315ae67d72c2031eca 100644 (file)
@@ -55,15 +55,6 @@ namespace System.ComponentModel.Design
 
                public DesignModeSite (IComponent component, string name, IContainer container, IServiceProvider serviceProvider)
                {
-                       if (serviceProvider == null)
-                               throw new ArgumentNullException ("serviceProvider");
-                       if (component == null)
-                               throw new ArgumentNullException ("component");
-                       if (container == null)
-                               throw new ArgumentNullException ("container");
-                       if (name == null)
-                               throw new ArgumentNullException ("name");
-
                        _component = component;
                        _container = container;
                        _componentName = name;
@@ -93,20 +84,13 @@ namespace System.ComponentModel.Design
                        }
                        set {
                                if (value != _componentName && value != null && value.Trim().Length > 0) {
-
                                        INameCreationService nameService = this.GetService (typeof (INameCreationService)) as INameCreationService;
+                                       IComponent component = _container.Components[value]; // get the component with that name
 
-                                       // Get the component with that name, if any
-                                       //
-                                       IComponent component = _container.Components[value];
-
-                                       // check for duplicated name
-                                       //
-                                       if (component == null && nameService != null && !nameService.IsValidName (value)) { // no duplicate name
-                                               value = _componentName;
+                                       if (component == null &&
+                                           (nameService == null || (nameService != null && nameService.IsValidName (value)))) {
                                                string oldName = _componentName;
                                                _componentName = value;
-
                                                ((DesignerHost)this.GetService (typeof (IDesignerHost))).OnComponentRename (_component, oldName, _componentName);
                                        }
                                }
@@ -213,7 +197,9 @@ namespace System.ComponentModel.Design
                                serviceInstance = _nestedContainer;
                        }
 
-                       if (serviceInstance == null && _siteSpecificServices != null)
+                       // Avoid returning the site specific IServiceContainer
+                       if (serviceInstance == null && service != typeof (IServiceContainer) &&
+                           _siteSpecificServices != null)
                                serviceInstance = _siteSpecificServices.GetService (service);
 
                        if (serviceInstance == null)