Official Everybody Edits Forums

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.

#1 2017-12-31 08:35:34

SirJosh3917
Formerly ninjasupeatsninja
From: USA
Joined: 2015-04-05
Posts: 2,095

[Release/Beta] C# EEApi Wrapper

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.

code

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

Wooted by: (3)

#2 2017-12-31 08:51:15, last edited by Gosha (2017-12-31 10:01:13)

Gosha
Member
From: Russia
Joined: 2015-03-15
Posts: 6,211

Re: [Release/Beta] C# EEApi Wrapper

ninjasupeatsninja wrote:

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

#3 2017-12-31 15:09:11

Zumza
Member
From: root
Joined: 2015-02-17
Posts: 4,656

Re: [Release/Beta] C# EEApi Wrapper

goto.png


Everybody edits, but some edit more than others

Offline

Wooted by: (2)

#4 2017-12-31 15:35:17, last edited by Latif (2017-12-31 15:35:50)

Latif
Member
From: The Netherlands
Joined: 2015-03-13
Posts: 1,206

Re: [Release/Beta] C# EEApi Wrapper

There's actually nothing wrong with using goto but I prefer using a while loop with a boolean if it should break. //forums.everybodyedits.com/img/smilies/tongue
Or a for loop, so I can show an error message after x times.

Offline

#5 2017-12-31 15:43:05

Gosha
Member
From: Russia
Joined: 2015-03-15
Posts: 6,211

Re: [Release/Beta] C# EEApi Wrapper

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

Wooted by: (2)

#6 2017-12-31 15:51:04

Tomahawk
Forum Mod
From: UK
Joined: 2015-02-18
Posts: 2,847

Re: [Release/Beta] C# EEApi Wrapper

^ 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

Wooted by:

#7 2017-12-31 16:03:26, last edited by SirJosh3917 (2017-12-31 18:39:33)

SirJosh3917
Formerly ninjasupeatsninja
From: USA
Joined: 2015-04-05
Posts: 2,095

Re: [Release/Beta] C# EEApi Wrapper

Gosha wrote:
ninjasupeatsninja wrote:

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();
		}
	}
}

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:

fixed

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

#8 2017-12-31 16:12:57

Gosha
Member
From: Russia
Joined: 2015-03-15
Posts: 6,211

Re: [Release/Beta] C# EEApi Wrapper

gotFriends is no-no

while(true)
if(error) {
//cod
}
else {
//cod
break;
}

Offline

#9 2017-12-31 16:37:30, last edited by capasha (2017-12-31 16:39:15)

capasha
Member
Joined: 2015-02-21
Posts: 4,066

Re: [Release/Beta] C# EEApi Wrapper

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

#10 2017-12-31 18:37:57

SirJosh3917
Formerly ninjasupeatsninja
From: USA
Joined: 2015-04-05
Posts: 2,095

Re: [Release/Beta] C# EEApi Wrapper

capasha wrote:

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.

capasha wrote:

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.

capasha wrote:

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.

___________________________________________

Gosha wrote:

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

#11 2017-12-31 23:08:58

John
Member
Joined: 2019-01-11
Posts: 2,011

Re: [Release/Beta] C# EEApi Wrapper

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!


PW?scale=2

Offline

Wooted by:

#12 2017-12-31 23:13:55, last edited by Gosha (2017-12-31 23:14:21)

Gosha
Member
From: Russia
Joined: 2015-03-15
Posts: 6,211

Re: [Release/Beta] C# EEApi Wrapper

Emalton wrote:

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

#13 2017-12-31 23:16:47

John
Member
Joined: 2019-01-11
Posts: 2,011

Re: [Release/Beta] C# EEApi Wrapper

Gosha wrote:

bad code should be fixed

He isn't doing it anymore though.


PW?scale=2

Offline

#14 2017-12-31 23:28:50, last edited by hummerz5 (2017-12-31 23:29:44)

hummerz5
Member
From: wait I'm not a secret mod huh
Joined: 2015-08-10
Posts: 5,853

Re: [Release/Beta] C# EEApi Wrapper

Emalton wrote:
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

#15 2018-01-01 14:55:27, last edited by capasha (2018-01-01 14:59:36)

capasha
Member
Joined: 2015-02-21
Posts: 4,066

Re: [Release/Beta] C# EEApi Wrapper

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

capasha1514814927689487

Board footer

Powered by FluxBB

[ Started around 1732684753.0762 - Generated in 0.148 seconds, 10 queries executed - Memory usage: 1.67 MiB (Peak: 1.89 MiB) ]