Link to home
Start Free TrialLog in
Avatar of Corey_819
Corey_819

asked on

Interface Get Property Values

Hello and I am sure I am missing something. I have implemented an interface from third party assembly and I want to know the Interface property values before I either change them or do anything else I just want to know their values. I implemented the interface and did a get on one of the properties but all the values are blank. Am I missing something, do I need reflections to do something like this? Thanks

C
Avatar of w00te
w00te
Flag of United States of America image

You should be able to access the property values defined in the interface assuming the class instance the interface referrs to is initialized and actually has those values set.
Can you paste some code in so we can work with it? :)
Thanks,
-w00te
Avatar of Corey_819
Corey_819

ASKER

I thought so as well okay here you go I really must be missing something.
 class Program : IComUserIdentity
    {
        static void Main(string[] args)
        {
           
                IComUserIdentity SCMUser = new Program();
               
                System.Console.WriteLine("User Name: " + SCMUser.Context);
         }

}

 private String m_Context;
        private int m_DirType;
       
        String IComUserIdentity.Context
        {
            get { return m_Context; }
            set { m_Context = value; }

        }


        int IComUserIdentity.DirType
        {
            get { return m_DirType; }
            set { m_DirType = value; }
        }

Open in new window

have you set a debug.breakpoint on each of the properties, and added a watch for each of the properties, so that you can see their default values at run time?

based purely on the datatypes the
String IComUserIdentity.Context should default to null or string.Empty and the
int IComUserIdentity.DirType should default to 0

Tarigpahmed and yeah based on the dataTypes this is excatly what keeps returning as values.
so, I am assuming that these values are not being set during the Third Party Class or app. I will put on the breakpoints and watch the values during runtime and find out if these values are event being populated.
ASKER CERTIFIED SOLUTION
Avatar of tariqpahmed
tariqpahmed

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Implementing the IComUserIdentity does nothing with the properties values. The typical usage would be to pass an instance of the class Program to someone that know how to handle IComUserIdentity.

Your class just create two variables (m_Context and m_DirType) and never assign a value to them so you will always get Nothing and 0.

As I said, implementing IComUserIdentity will never put a value on those variables (how would it be?)

Feel free to ask more if you need.
Thank you this makes sense.