-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for AJAX requests for XMLHTTPRequests and partly for fe…
…tch requests (#23) * working on front end side of things. regular development * regular dev * regular dev. major roadblock * Added ajax support for XMLHTTPRequests and partly for fetch requests
- Loading branch information
Showing
35 changed files
with
6,824 additions
and
130 deletions.
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
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
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
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
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
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
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
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; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Serialization; | ||
|
||
namespace NToastNotify.Helpers | ||
{ | ||
public static class JsonSerialization | ||
{ | ||
public static JsonSerializerSettings JsonSerializerSettings => new JsonSerializerSettings() | ||
{ | ||
ContractResolver = new CamelCasePropertyNamesContractResolver(), | ||
NullValueHandling = NullValueHandling.Ignore | ||
}; | ||
|
||
public static string ToJson(this object obj) | ||
{ | ||
return JsonConvert.SerializeObject(obj, JsonSerializerSettings); | ||
} | ||
} | ||
} |
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,29 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace NToastNotify.Helpers | ||
{ | ||
public static class RequestHelpers | ||
{ | ||
public static bool IsAjaxRequest(this HttpRequest request) | ||
{ | ||
if (request == null) | ||
{ | ||
throw new ArgumentNullException(nameof(request)); | ||
} | ||
|
||
if (!string.IsNullOrWhiteSpace(request.Headers[Constants.RequestHeaderKey])) | ||
{ | ||
return true; | ||
}; | ||
if (!string.IsNullOrWhiteSpace(request.Headers[Constants.RequestHeaderKey.ToLower()])) | ||
{ | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
} |
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,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace NToastNotify | ||
{ | ||
public interface IMessageContainer | ||
{ | ||
void Add(ToastMessage message); | ||
void RemoveAll(); | ||
IList<ToastMessage> GetAll(); | ||
IList<ToastMessage> ReadAll(); | ||
} | ||
} |
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,11 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace NToastNotify | ||
{ | ||
public interface IMessageContainerFactory | ||
{ | ||
IMessageContainer Create(); | ||
} | ||
} |
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
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
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,36 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace NToastNotify | ||
{ | ||
public class InMemoryMessageContainer : IMessageContainer | ||
{ | ||
private IList<ToastMessage> Messages { get; } | ||
|
||
public InMemoryMessageContainer() | ||
{ | ||
Messages = new List<ToastMessage>(); | ||
} | ||
public void Add(ToastMessage message) | ||
{ | ||
Messages.Add(message); | ||
} | ||
|
||
public void RemoveAll() | ||
{ | ||
Messages.Clear(); | ||
} | ||
|
||
public IList<ToastMessage> GetAll() | ||
{ | ||
return Messages; | ||
} | ||
|
||
public IList<ToastMessage> ReadAll() | ||
{ | ||
var messages = new List<ToastMessage>(Messages); | ||
Messages.Clear(); | ||
return messages; | ||
} | ||
} | ||
} |
Oops, something went wrong.