Hiding the public members of a class without modifying the CLASS

Discussion in 'ASP .Net' started by Brahmam, Jan 3, 2006.

  1. Brahmam

    Brahmam Guest

    HI,

    Suppose i have the requirement that i want to hide the pubilc members
    of a class without modifying the code inside the class

    Example :
    class A
    {
    public foo1();
    public foo2();
    public foo3();
    public foo4();
    public foo5();
    public foo6();
    public foo7();
    public foo8();
    public foo9();
    public foo10();
    }

    I made this class as a DLL and i have given this DLL to the user. Now the
    requirement is, For the user only 7 public methods has to be exposed and the
    remaining 3 has not , for that what to do , I am not allowed to change the
    code inside the class (But , i can implement this class), can anyone give me
    the solution for this.

    Thanks in advance,
    BR.
    Brahmam, Jan 3, 2006
    #1
    1. Advertising

  2. Hi,

    Once you declare the methods identifier as PUBLIC they will accessible to
    everywhere.

    I think what you are trying to do is not possible by this implementation.
    you can achieve this by explosing another class if it can be inherited by
    that DLL. In this class make methods public you want to explose and make
    other methods private that you don't want to explose to user and then give
    that DLL to user.

    Regards,
    Sachin Saki
    ..NET Developer, Capgemini - INDIA

    "Brahmam" ने लिखा:

    > HI,
    >
    > Suppose i have the requirement that i want to hide the pubilc members
    > of a class without modifying the code inside the class
    >
    > Example :
    > class A
    > {
    > public foo1();
    > public foo2();
    > public foo3();
    > public foo4();
    > public foo5();
    > public foo6();
    > public foo7();
    > public foo8();
    > public foo9();
    > public foo10();
    > }
    >
    > I made this class as a DLL and i have given this DLL to the user. Now the
    > requirement is, For the user only 7 public methods has to be exposed and the
    > remaining 3 has not , for that what to do , I am not allowed to change the
    > code inside the class (But , i can implement this class), can anyone give me
    > the solution for this.
    >
    > Thanks in advance,
    > BR.
    >
    >
    >
    >
    >
    =?Utf-8?B?U2FjaGluIFNha2k=?=, Jan 6, 2006
    #2
    1. Advertising

  3. Brahmam

    Brahmam Guest

    Hi sachin thanks for ur reply,

    But if I create the instance of the base class I can use all the 10 methods
    it has to be restricted .If I have created the instance of this base class
    or any sub classes derived from this dllclass it will not allow u to use all
    the methods

    If u have any idea plz get back to my mail

    Thanks in advance

    BR




    "Sachin Saki" <> wrote in message
    news:...
    > Hi,
    >
    > Once you declare the methods identifier as PUBLIC they will accessible to
    > everywhere.
    >
    > I think what you are trying to do is not possible by this implementation.
    > you can achieve this by explosing another class if it can be inherited by
    > that DLL. In this class make methods public you want to explose and make
    > other methods private that you don't want to explose to user and then give
    > that DLL to user.
    >
    > Regards,
    > Sachin Saki
    > .NET Developer, Capgemini - INDIA
    >
    > "Brahmam" ?? ????:
    >
    >> HI,
    >>
    >> Suppose i have the requirement that i want to hide the pubilc
    >> members
    >> of a class without modifying the code inside the class
    >>
    >> Example :
    >> class A
    >> {
    >> public foo1();
    >> public foo2();
    >> public foo3();
    >> public foo4();
    >> public foo5();
    >> public foo6();
    >> public foo7();
    >> public foo8();
    >> public foo9();
    >> public foo10();
    >> }
    >>
    >> I made this class as a DLL and i have given this DLL to the user. Now the
    >> requirement is, For the user only 7 public methods has to be exposed and
    >> the
    >> remaining 3 has not , for that what to do , I am not allowed to change
    >> the
    >> code inside the class (But , i can implement this class), can anyone give
    >> me
    >> the solution for this.
    >>
    >> Thanks in advance,
    >> BR.
    >>
    >>
    >>
    >>
    >>
    Brahmam, Jan 10, 2006
    #3
  4. Hi,

    you can use encapsulation :

    class A_User
    {
    private A a = new A();
    public foo1() { a.foo1(); }
    public foo2() { a.foo2(); }
    public foo3() { a.foo3(); }
    public foo4() { a.foo4(); }
    public foo5() { a.foo5(); }
    public foo6() { a.foo6(); }
    public foo7() { a.foo7(); }
    }

    The user will use A_User and he will be able to call method foo 1 ot 7.

    --
    Francois Beaussier

    "Brahmam" <> a écrit dans le message de news:
    ...
    > Hi sachin thanks for ur reply,
    >
    > But if I create the instance of the base class I can use all the 10
    > methods it has to be restricted .If I have created the instance of this
    > base class or any sub classes derived from this dllclass it will not allow
    > u to use all the methods
    >
    > If u have any idea plz get back to my mail
    >
    > Thanks in advance
    >
    > BR
    >
    >
    >
    >
    > "Sachin Saki" <> wrote in message
    > news:...
    >> Hi,
    >>
    >> Once you declare the methods identifier as PUBLIC they will accessible to
    >> everywhere.
    >>
    >> I think what you are trying to do is not possible by this implementation.
    >> you can achieve this by explosing another class if it can be inherited by
    >> that DLL. In this class make methods public you want to explose and make
    >> other methods private that you don't want to explose to user and then
    >> give
    >> that DLL to user.
    >>
    >> Regards,
    >> Sachin Saki
    >> .NET Developer, Capgemini - INDIA
    >>
    >> "Brahmam" ?? ????:
    >>
    >>> HI,
    >>>
    >>> Suppose i have the requirement that i want to hide the pubilc
    >>> members
    >>> of a class without modifying the code inside the class
    >>>
    >>> Example :
    >>> class A
    >>> {
    >>> public foo1();
    >>> public foo2();
    >>> public foo3();
    >>> public foo4();
    >>> public foo5();
    >>> public foo6();
    >>> public foo7();
    >>> public foo8();
    >>> public foo9();
    >>> public foo10();
    >>> }
    >>>
    >>> I made this class as a DLL and i have given this DLL to the user. Now
    >>> the
    >>> requirement is, For the user only 7 public methods has to be exposed and
    >>> the
    >>> remaining 3 has not , for that what to do , I am not allowed to change
    >>> the
    >>> code inside the class (But , i can implement this class), can anyone
    >>> give me
    >>> the solution for this.
    >>>
    >>> Thanks in advance,
    >>> BR.
    >>>
    >>>
    >>>
    >>>
    >>>

    >
    >
    Francois Beaussier, Jan 11, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Charles A. Lackman
    Replies:
    1
    Views:
    1,325
    smith
    Dec 8, 2004
  2. SpamProof
    Replies:
    0
    Views:
    531
    SpamProof
    Oct 21, 2003
  3. CoolPint
    Replies:
    8
    Views:
    957
    Jeff Schwab
    Dec 14, 2003
  4. DaveLessnau
    Replies:
    3
    Views:
    414
    Howard
    May 16, 2005
  5. Ombra

    Hiding public members of a base class

    Ombra, Jun 4, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    112
    Mythran
    Jun 4, 2004
Loading...

Share This Page