Medal Class not working?

Developer
Oct 30, 2010 at 11:52 AM

Hello I know you are very busy with your own stuff but the only thing that's cracking me up here is the Medal class. Everytime a declare a variable of type Medal, I can't access it's content (ID,Description, ImageName, etc.). Even when I try looking through the debugger in the response var when I reach AllMedalsbyId, the "Medal" part of the KeyValuePair cannot be interpreted. I don't know if this is a good way to answer this question, but what could be causing this? I really need the medals to finish one important phase of my app. (WP7 BTW!) Thanks for your help.

Coordinator
Oct 30, 2010 at 6:57 PM
Can you post some code so I can see how your trying to accomplish this?

You can't just create a new medal instance and expect it to have any information, you'll want to use the gamemetadata class to get the medal information and cache it. Then the other services will just reference a medal id.

Jacob
Developer
Oct 31, 2010 at 5:59 AM

Hi Jacob, Thanks of the quick reply. Yes I understand that but a simple operation like the one below:

If you look at it closely, Medal should have a .Description, .Id, .Name and .ImageName. Non of those attributes are accessible. If I look through the repsonse, the debugger says the array thats supposed to have this information (Medal Class) cannot be evaluated. Now if I create an Enemy instance for example, this attributes are available. Right now the Medal has Equals, GetHashCode, GetType, ToString on available in Intellisense. I tried it in the console test app in the new version of your wrapper and I get the same result. Desc, Id, Name and ImageName are missing. I only did this Function to present a scenario. What I do right now (planning on checking impact on phone) is dump the dictionary containing the AllMedalsbyId to a local dictionary so I can use it outside the GotResult response from GetGameMetadata(). The only thing is that the medal part of <int, medal> dictionary cannot be evaluated according to the debugger. the key which is int is correctly evaluated. Can please try this? Pass the dictionary of AllMedalsbyId to a local one and see if you can access the Medals array (value) part of the KVP.

 

void ResolveMedal()

{

 

Medal m = new Medal ();

m.Equals;

m.GetHashCode;

m.GetType;

m.ToString();

}

 

 

Coordinator
Oct 31, 2010 at 9:14 PM

Ok, I think I found the problem.  The Medal class didn't have the public modifier on it's properties.  There were also some other classes that didn't have the public modifiers.  When I added the public modifier to the properties the dictionary parses correctly.  You can download the latest responses.cs class from the source tab, or replace the following section in the responses.cs file (HaloReachApi/Services/Responses.cs)

 

    /// <summary>
    /// Map info
    /// </summary>
    public class Map
    {
        public uint Id { get; set; }
        public string ImageName { get; set; }
        public string MapType { get; set; }
        public string Name { get; set; }
    }

    /// <summary>
    /// Medal Info
    /// </summary>
    public class Medal
    {
        public int Id { get; set; }
        public string Description { get; set; }
        public string ImageName { get; set; }
        public string Name { get; set; }
    }

    /// <summary>
    /// Weapon info
    /// </summary>
    public class Weapon
    {
        public string Description { get; set; }
        public int Id { get; set; }
        public string Name { get; set; }
    }

Hope that helps.  Sorry for the bug, but thanks for finding it.

Jacob

Developer
Nov 1, 2010 at 3:22 AM

Thanks Jacob, I don't know how I missed that. I thought it was something with the Web Service. Thanks, I will try it tonight.

Developer
Nov 2, 2010 at 5:25 AM

Hi I Jacob I don't know if you have time to get into this but, if I wanted to add the new GetChallenges, what files do I need to "Copy and Paste"? I know a  Service type class should be created like the other ones and of course in Response I would have to add what's incoming from the svc. Is there any other place were I should add code? Thanks for the help. If I get it running I'll send you the code so you can add it to the latest release.

Developer
Nov 2, 2010 at 6:01 AM

I managed to get it working in no time :). You're a pretty good teacher. I uploaded the bits for your approval. thanks

Coordinator
Nov 2, 2010 at 6:58 PM

Thanks for submitting your code.  There is actually a better way to submit patches where you only have to submit the diff file; see this article by Scott Hanselman http://www.hanselman.com/blog/ExampleHowToContributeAPatchToAnOpenSourceProjectLikeDasBlog.aspx

I'll go ahead and do the diff for your files and apply it.  But it would probably be a good exercise for you to see if you can put together a subversion patch and submit it.

At any rate, thanks again for the code.  If you have any more, let me know.

Jacob

Coordinator
Nov 2, 2010 at 7:16 PM

I've applied your patch and committed to the latest source.  I'll try and get a new release version out this weekend with your changes included.

Developer
Nov 2, 2010 at 9:25 PM

Ok cool glad I could help! I'll check out that post it looks interesting, since this is the first time I've contributed to an Open project. I'm very much into my project because of this so if the API is updated again (which it will) you can count on me to help add the fuctionality.