[Mono-devel-list] patch for System.ComponentModel.Design.ServiceContainer
Alexander Pigolkin
pigolkine at gmx.de
Sun Aug 31 18:14:13 EDT 2003
Hello,
I implemented few functions for ServiceContainer class.
Could someone please review the patch.
Alexandre Pigolkine
-------------- next part --------------
? CompModDesign.diff
Index: ServiceContainer.cs
===================================================================
RCS file: /cvs/public/mcs/class/System/System.ComponentModel.Design/ServiceContainer.cs,v
retrieving revision 1.3
diff -u -r1.3 ServiceContainer.cs
--- ServiceContainer.cs 2 Jul 2003 14:56:55 -0000 1.3
+++ ServiceContainer.cs 31 Aug 2003 22:12:59 -0000
@@ -49,8 +49,10 @@
if (promote)
if (parentProvider != null)
((IServiceContainer)parentProvider.GetService(typeof(IServiceContainer))).AddService (serviceType, serviceInstance, promote);
- // Add real implementation
- throw new NotImplementedException();
+ if (services.Contains (serviceType)) {
+ throw new ArgumentException (string.Format ("The service {0} already exists in the service container.", serviceType.ToString()));
+ }
+ services.Add (serviceType, serviceInstance);
}
[MonoTODO]
@@ -63,8 +65,10 @@
if (promote)
if (parentProvider != null)
((IServiceContainer)parentProvider.GetService(typeof(IServiceContainer))).AddService (serviceType, callback, promote);
- // Add real implementation
- throw new NotImplementedException();
+ if (services.Contains (serviceType)) {
+ throw new ArgumentException (string.Format ("The service {0} already exists in the service container.", serviceType.ToString()));
+ }
+ services.Add (serviceType, callback);
}
public void RemoveService (Type serviceType)
@@ -86,7 +90,19 @@
[MonoTODO]
public object GetService (Type serviceType)
{
- throw new NotImplementedException();
+ object result = services[serviceType];
+ if (result == null && parentProvider != null){
+ result = parentProvider.GetService (serviceType);
+ }
+ if (result != null) {
+ ServiceCreatorCallback cb = result as ServiceCreatorCallback;
+ if (cb != null) {
+ result = cb (this, serviceType);
+ services[serviceType] = result;
+ }
+
+ }
+ return result;
}
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ServiceContainerTest.cs
Type: application/x-cs
Size: 2479 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20030901/91fa1767/attachment.bin
More information about the Mono-devel-list
mailing list