-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.net core compatible version #1
Open
navaei
wants to merge
1
commit into
kavenegar:master
Choose a base branch
from
navaei:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Kavenegar.Models.Enums; | ||
|
||
namespace Kavenegar.Exceptions | ||
{ | ||
public class ApiException : KavenegarException | ||
{ | ||
readonly MetaCode _result; | ||
public ApiException(string message, int code) | ||
: base(message) | ||
{ | ||
_result = (MetaCode)code; | ||
} | ||
|
||
public MetaCode Code | ||
{ | ||
get { return _result; } | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace Kavenegar.Exceptions | ||
{ | ||
public class KavenegarException : System.Exception | ||
{ | ||
public KavenegarException(string message) | ||
: base(message) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace Kavenegar.Exceptions | ||
{ | ||
public class HttpException : KavenegarException | ||
{ | ||
private readonly int _code; | ||
public HttpException(string message, int code) | ||
: base(message) | ||
{ | ||
_code = code; | ||
} | ||
|
||
public int Code | ||
{ | ||
get { return _code; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Kavenegar.Json | ||
{ | ||
|
||
public class JsonArray : JsonObject | ||
{ | ||
public List<JsonObject> Array { get; set; } | ||
private List<JsonObject>.Enumerator _e; | ||
|
||
public JsonArray() | ||
{ | ||
Array = new List<JsonObject>(); | ||
} | ||
|
||
public void AddElementToArray(JsonObject arrayElement) | ||
{ | ||
Array.Add(arrayElement); | ||
} | ||
|
||
public JsonObject UpCast() | ||
{ | ||
JsonObject objectJ = this; | ||
return objectJ; | ||
} | ||
|
||
public void AddList(List<JsonObject> lista) | ||
{ | ||
Array = lista; | ||
} | ||
|
||
public Boolean NextObject(out JsonObject o) | ||
{ | ||
|
||
JsonObject outObject; | ||
_e = Array.GetEnumerator(); | ||
|
||
if (_e.MoveNext()) | ||
{ | ||
outObject = _e.Current; | ||
o = outObject; | ||
return true; | ||
} | ||
outObject = new JsonObject(); | ||
o = outObject; | ||
return false; | ||
} | ||
|
||
public int Count | ||
{ | ||
get { return Array.Count; } | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
|
||
namespace Kavenegar.Json | ||
{ | ||
|
||
public class JsonBoolean : JsonObject | ||
{ | ||
public Boolean BooleanValue { get; set; } | ||
|
||
public JsonBoolean(Boolean booleanValue) | ||
{ | ||
BooleanValue = booleanValue; | ||
} | ||
|
||
public JsonObject UpCast() | ||
{ | ||
JsonObject objectJ = this; | ||
return objectJ; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
|
||
namespace Kavenegar.Json | ||
{ | ||
public class JsonNullable : JsonObject | ||
{ | ||
public String Nullable { get; set; } | ||
|
||
public JsonNullable() | ||
{ | ||
Nullable = "Null"; | ||
} | ||
|
||
public JsonObject UpCast() | ||
{ | ||
JsonObject objectJ = this; | ||
return objectJ; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace Kavenegar.Json | ||
{ | ||
public class JsonNumber : JsonObject | ||
{ | ||
public float Number { get; set; } | ||
|
||
public JsonNumber(float number) | ||
{ | ||
Number = number; | ||
} | ||
|
||
public JsonObject UpCast() | ||
{ | ||
JsonObject objectJ = this; | ||
return objectJ; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Kavenegar.Json | ||
{ | ||
/// <summary> | ||
/// JsonObject is the base class. | ||
/// JsonString,JsonNumber,JsonBoolean,JsonNullable and JsonArray inherits from JsonObject. | ||
/// A JsonArray object may contain objects of the base class | ||
/// </summary> | ||
|
||
public class JsonObject | ||
{ | ||
public Dictionary<String, JsonObject> Values; | ||
|
||
public JsonObject() | ||
{ | ||
Values = new Dictionary<String, JsonObject>(); | ||
} | ||
|
||
public void AddJsonValue(String textTag, JsonObject newObject) | ||
{ | ||
if (!Values.ContainsKey(textTag)) | ||
{ | ||
Values.Add(textTag, newObject); | ||
} | ||
} | ||
|
||
public JsonObject GetObject(String key) | ||
{ | ||
JsonObject current = Values[key]; | ||
return current; | ||
} | ||
|
||
public int ElementsOfDictionary() | ||
{ | ||
return Values.Count; | ||
} | ||
|
||
|
||
public Boolean IsJsonString() | ||
{ | ||
if (this is JsonString) | ||
{ | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public Boolean IsJsonNumber() | ||
{ | ||
if (this is JsonNumber) | ||
{ | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public Boolean IsJsonBoolean() | ||
{ | ||
if (this is JsonBoolean) | ||
{ | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public Boolean IsJsonNullable() | ||
{ | ||
if (this is JsonNullable) | ||
{ | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public Boolean IsJsonArray() | ||
{ | ||
if (this is JsonArray) | ||
{ | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public JsonString GetAsString() | ||
{ | ||
return (JsonString)this; | ||
} | ||
public JsonNumber GetAsNumber() | ||
{ | ||
return (JsonNumber)this; | ||
} | ||
public JsonArray GetAsArray() | ||
{ | ||
return (JsonArray)this; | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
|
||
namespace Kavenegar.Json | ||
{ | ||
public class JsonString : JsonObject | ||
{ | ||
public String Text { get; set; } | ||
|
||
public JsonString(String text) | ||
{ | ||
Text = text; | ||
} | ||
|
||
public JsonObject UpCast() | ||
{ | ||
JsonObject objectJ = this; | ||
return objectJ; | ||
} | ||
|
||
|
||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, Formatting.