Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?
You are not logged in.
Pages: 1
C# EEApi Wrapper
A C# Wrapper for Lrussell's EEApi
EEApi is a C# wrapper for Lrussell's EEApi
EEApi is a simple and easy to use interface for interaction between you and Lrussell's EEApi.
It's very easy and elegant to use. By using a static approach, EEApi avoids making you have to create any instances of it and gets the job done without much hassle.
Here's a sample application using EEApi.
If you need any documentation or help, please take a look at Github Wiki. I've been up for a few hours since 12:00 AM and it's now ~2:30 AM, so the wiki is considerably broken. If you see any grammar errors or mislinks/misdirects, please submit an issue about it.
I'm trying to practice better at this whole releasing thing, so if you see any imperfections or dislike a portion of the code, or dislike how something appears to have been rushed, or have tips in general about releasing schedules, please PM me about your constructive criticism and I'll be sure to look into it.
Offline
if (i.IsOnline == true)
omg
EDIT:
wait, let me fix it
using System;
using System.Collections.Generic;
using System.Text;
namespace EEApiTester {
class Program {
static void Main(string[] args) {
start:
try {
var findBotFriends = EEApi.Get.Friends();
foreach (var i in findBotFriends.Friends) {
if (i.IsOnline == true) {
Console.WriteLine(string.Format("{0} is in world '{1}' ( {2} )", i.Name, i.WorldName, i.WorldId));
}
}}
catch(Exception er) {
goto start;
}
Console.ReadLine();
}
}
}
Offline
Everybody edits, but some edit more than others
Offline
There's actually nothing wrong with using goto but I prefer using a while loop with a boolean if it should break.
Or a for loop, so I can show an error message after x times.
Offline
goto is okay to use when you need multiple breaks.
for(var l=0;l<a;l++)
for(var y=0;y<b;y++)
for(var x=0;x<c;x++) {
if(array[l][x][y].id == 1234) {
GlobalThing=true;
goto end;
}
end:
Offline
^ Well AKCHUALLY, you'd be better off putting that into a function and then using return as a way to break out of multiple statements.
~You won't be better off in any meaningful way, but you can feel good about yourself for avoiding having to use goto.
One bot to rule them all, one bot to find them. One bot to bring them all... and with this cliché blind them.
Offline
ninjasupeatsninja wrote:if (i.IsOnline == true)
omg
EDIT:
wait, let me fix itusing System; using System.Collections.Generic; using System.Text; namespace EEApiTester { class Program { static void Main(string[] args) { start: try { var findBotFriends = EEApi.Get.Friends(); foreach (var i in findBotFriends.Friends) { if (i.IsOnline == true) { Console.WriteLine(string.Format("{0} is in world '{1}' ( {2} )", i.Name, i.WorldName, i.WorldId)); } }} catch(Exception er) { goto start; } Console.ReadLine(); } } }
Actually, this isn't the preferred method of checking if there is an error.
Popular advice is to ditch the try{}catch{} and use a while loop instead, and allow me to assist you be using the API's built in error catchers to ( hopefully ) guide you on the right path.
Here's some code to try on for size:
With your concerns about the i.IsOnline == true, if you checked the wiki, you'd see that the boolean is actually a nullable - it wouldn't compile if you just left in a boolean statement! This is because the API will return "null" frequently if it doesn't have any data. ( A sample example is to look at a profile that is private )
______________________________________________
Also noted, if there's a goto, can anybody show me it? I'll fix it when I get back.
Offline
gotFriends is no-no
while(true)
if(error) {
//cod
}
else {
//cod
break;
}
Offline
Why is there stackoverflow in the code?
Another note, have you switched from try catches now? You have always used them in all your bots.
Anyway I guess it's can be used for people that don't know how to parse Json from lrussels site.
Offline
Why is there stackoverflow in the code?
It's to ensure that proper credit is given to stackoverflow for their code. I could change the name of the class it if you dislike it.
Another note, have you switched from try catches now? You have always used them in all your bots.
The only try catch in the code is at the HTTPGet.cs class of the code, where it checks if there was an error, and checks if there is valid Json.
If you have any suggestions on how to remove them, I'm all ears.
Lrussell's API doesn't return a '200' upon an error, and it will output a Json error.
Anyway I guess it's can be used for people that don't know how to parse Json from lrussels site.
I do hope it is used, as it can be installed from nuget and should be quick to jump into using.
___________________________________________
gotFriends is no-no
while(true)
if(error) {
//cod
}
else {
//cod
break;
}
Ah, I see what you mean. Thanks for that tip - I'll be to take note of that!
Offline
I don't get why people are still making fun of ninjasupeatsninja because of his old try catch obsession. It's at the point of being off topic.
Nice API my guy!
Offline
I don't get why people are still making fun of ninjasupeatsninja because of his old try catch obsession
Because bad code should be fixed, not appreciated
Offline
bad code should be fixed
He isn't doing it anymore though.
Offline
Gosha wrote:bad code should be fixed
He isn't doing it anymore though.
well this, and (correct me if I'm wrong) isn't it quite often just better to throw the exception? I'd think that easier than checking numerous booleans and potentially null data. But I digress. It looks nice
edit: maybe we're toeing the distinction between a library communicating errors to the utilizing programmer as opposed to the programmer catching logical mistakes better handled with applied thought
Offline
I coded a bit with newtonsoft JSON parser. My code may look like **** because I coded this fast.
Code: https://pastebin.com/qLeu9D7J
Like someone said I was attacking ninja, I didn't. I just remember his old coding style.
Offline
Pages: 1
[ Started around 1732369292.4767 - Generated in 0.168 seconds, 12 queries executed - Memory usage: 1.68 MiB (Peak: 1.9 MiB) ]