What fields can a nested class access of the class it's nested in?

后端 未结 3 1804
一个人的身影
一个人的身影 2021-01-25 22:58

I have a web service in C# and would like to have a nested inner class, that abstracts away the session collection, something like this:


public class Service          


        
3条回答
  •  借酒劲吻你
    2021-01-26 00:03

    I can think of a couple things.

    First, you might try using getContext() instead of just accessing Context. If that works, you're done.

    If not, you could pass the Service in as an initializer to your SessionPool. Add a WebService handle to SessionPool that you initialize via a call to setService() before calling getSession() from Foo().

    Although, at that point, why not just pass in the Context as an argument to getSession()?

提交回复
热议问题