This project is read-only.

Can't seem to get it working

May 2, 2014 at 1:32 PM
Hello,

I've installed the NuGet package successfully, references have been added to my project and I can use "GW2DotNET.V1" in my class. Issue is, there doesn't seem to be any DataManager. I saw in another discussion someone talk about instantiating a WorldManager, but that doesn't seem to exist either. All in all, I don't have any manager classes.

Ideas ?

Thanks
May 2, 2014 at 1:54 PM
Hello and welcome

All of the documentation on the project page corresponds to a previous release of the library. We don't have a dedicated technical writer keeping the docs in sync.

Anyway, I'll whip up a little tutorial right here and now.

Step 1: create an instance of the service manager
var service = new ServiceManager();
Previously known as the DataManager, the ServiceManager class is the entry point for all of the supported service endpoints. It's actually a facade class that delegates method calls to objects that know how to handle each specific service method call.

Step 2: do stuff

The simplest use case is retrieving the current build number:
var build = service.GetBuild();

Console.WriteLine("The current build number is: {0}", build.BuildId);
For the most part, you'll have to rely on IntelliSense. Again due to lack of documentation.

Step 3: ask questions

If at this point, there is still something you don't know how to do, feel free to ask. Especially if you're trying to do advanced stuff.
May 4, 2014 at 8:08 PM
Copied what's been said here to the wiki: https://gw2dotnet.codeplex.com/wikipage?title=ServiceManager
May 21, 2014 at 11:30 AM
Hello,
I have a problem with obtaining the item detail. For example, I would like to receive weight of armor. Could you please write an example of how to do this?
Thanks.
May 21, 2014 at 11:55 AM
Edited May 21, 2014 at 2:08 PM
Hello!

In order to get type-specific item details, you can cast the item object to the target type.
var weight = ((Armor)item).Details.Weight;
May 21, 2014 at 1:04 PM
Yes ! it works perfectly, thank you very much.
May 28, 2014 at 9:44 PM
I'm realy sorry, i'm lost again. :(
Now i have problem with recipes, i need crafting disciplines.

var disciplines = recipe.CraftingDisciplines;

but, how can i get strings of Disciplines ? Ideally as List<string> or array ?

Thanks for Your help.
May 28, 2014 at 10:11 PM
Edited May 28, 2014 at 10:40 PM
I understand the confusion. A recipe's crafting disciplines are stored as a combination of bit flags. This is a design choice that I made, because a bit flag enum uses only 4 bytes in memory, while a List<string> uses 1 byte per character.

Possibly the easiest way to build such a list is by using the HasFlag() method to check whether a specific discipline is set, then adding its name to a list.
using GW2DotNET.V1.Recipes.Details.Contracts;
var disciplines = new List<string>();

foreach (var discipline in Enum.GetValues(typeof(CraftingDisciplines)).Cast<Enum>())
{
    if (recipe.CraftingDisciplines.HasFlag(discipline))
    {
        disciplines.Add(discipline.ToString());
    }
}
This can be rewritten as a LINQ query to get the same result:
var disciplines = (from discipline in Enum.GetValues(typeof(CraftingDisciplines)).Cast<Enum>()
                   where recipe.CraftingDisciplines.HasFlag(discipline)
                   select discipline.ToString()).ToList();
A third, shorter way is to just split the output of recipe.CraftingDisciplines.ToString() by commas and spaces. I don't recommend using this method though.
var disciplines = recipe.CraftingDisciplines.ToString().Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
--

If you have any suggestions on how to make this easier or more intuitive, make sure to let me know.
May 29, 2014 at 8:24 AM
Edited May 29, 2014 at 8:59 AM
You're one of the last of programmers who still care about memory requirements. Your way I like it. Finally, I dont used the "List <string.>" but data saved directly to db. Thank you for the quick reply. I have one more question for threads? I want to import all Items and recipes, but I fear that it will be considered a DDOS attack. Do you have experience with what has arena.net opinion on this?
May 29, 2014 at 9:02 AM
I've written and used code that bombards the item details API with hundreds of requests at the same time. So far, I haven't heard anyone complain. I doubt that this is an issue.
May 29, 2014 at 9:17 AM
Good to hear, that api is so robust, but i received System.Net.WebException {"The operation has timed out"} after 9500 items. Maybe it is my internet connection, but how can i handle these exceptions ? Is any way to increase timeout ?
May 29, 2014 at 1:02 PM
Can I see the code that's causing timeouts? I've never seen timeouts happen myself.
May 29, 2014 at 1:17 PM
It was my bad internet connection i think. Now its working, but something strange happend. This was thrown while importing items :

An exception of type 'Newtonsoft.Json.JsonSerializationException' occurred in Newtonsoft.Json.dll but was not handled in user code

Additional information: Error converting value "Choking" to type 'GW2DotNET.V1.Items.Details.Contracts.ItemTypes.Weapons.WeaponDamageType'. Path 'damage_type', line 6, position 90.
May 29, 2014 at 1:27 PM
Edited May 29, 2014 at 1:43 PM
That's because of item with item ID 6: https://api.guildwars2.com/v1/item_details.json?item_id=6

This is the only known item with damage type "Choking". It didn't exist back when we released the current version of the library. I have implemented support for this item in the latest version of the source code, but we haven't done an official release yet.

If you absolutely need support for this item, you can download the source code (branch: GW2.NET-Http) and use that instead. Do note that the latest version of the code comes with a number of breaking changes.
May 29, 2014 at 9:26 PM
I'll see that I get a small hotfix out on NuGet the next day(s).
May 30, 2014 at 1:06 PM
You all are doing a great job. Thanks for all your help.
Jun 3, 2014 at 10:39 AM
Can we do hotfixes using TFS? How would that work? First check out an earlier revision, then make the changes, and then what? Sorry, I'm still not used to this way of working.
Jun 6, 2014 at 9:36 AM
I really don't know. I will look into it, but I doubt TFS has something like Subversions "Patch" feature, although I am sure there is a feature which works in a similar way.
Jun 6, 2014 at 9:46 AM
OR... I'll tidy up what I'm working on now and prepare the base library for a new version release (0.9.3?). I've done quite a bit of bug fixing and refactoring since the previous release. Still working on EF6 integration though.
Jun 6, 2014 at 12:55 PM
I'll merge the GW2.NET core library from the http branch into the main branch you could do another branch for the EF6 integration, so we could move forward with the main branch if needed