[Mono-bugs] [Bug 665345] Services: Some suggestions to improve the API and .netify it

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Feb 1 12:43:58 EST 2011


https://bugzilla.novell.com/show_bug.cgi?id=665345

https://bugzilla.novell.com/show_bug.cgi?id=665345#c2


--- Comment #2 from Jonathan Dick <jondick at gmail.com> 2011-02-01 17:43:57 UTC ---
Here's the implementation one has to repeat for each type of service they want
to bind.  I guess my definition of way more verbose is perhaps a bit radical,
but I know other coders that would think this looks pretty ugly, compared to
adding a nice generic helper class... Point is, by adding a helper class, that
doesn't mean you can't still do it this way as well... It's just there if it
can make your life a bit easier and you desire to use it...



        public class TweetServiceBinder : Binder
        {
            public TweetServiceBinder(BindingTweetService service)
            {
                this.ServiceInstance = service;
            }

            public BindingTweetService ServiceInstance
            {
                get;
                private set;
            }
        }

        public class TweetServiceConnection : Java.Lang.Object,
IServiceConnection
        {
            public event Action<BindingTweetService> Connected;

            public event Action Disconnected;

            public void OnServiceConnected(ComponentName className, IBinder   
serviceBinder)
            {
                if (this.Connected != null)
                    this.Connected((serviceBinder as
TweetServiceBinder).ServiceInstance);
            }

            public void OnServiceDisconnected(ComponentName className)
            {
                if (this.Disconnected != null)
                    this.Disconnected();
            }
        }

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list