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
namespace UWPBackgroundTaskDemo | |
{ | |
using System; | |
using System.Collections.Generic; | |
using System.Threading.Tasks; | |
using Windows.ApplicationModel.Background; | |
using System.Linq; | |
///Helper class for regsitering multiple background task | |
public static class BackgroundTaskRegistrationHelper |
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
//No third party library required for this code. | |
using System.Net; | |
using System.Net.Http; | |
using System.Threading.Tasks; | |
internal static class Stripe | |
{ | |
internal static async Task<string> DoesTLS12Support() | |
{ |
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
using System.Runtime.Serialization.Json; | |
using System.Text; | |
using System.Xml.Linq; | |
internal static string JsonToXmlResponse(this Type type) | |
{ | |
if (type == null) return string.Empty; | |
var json = new ObjectGenerator().GenerateObject(type).Serialize(); | |
var xml = XDocument.Load(JsonReaderWriterFactory.CreateJsonReader(Encoding.ASCII.GetBytes(json), new XmlDictionaryReaderQuotas())); | |
return xml.ToString(); |
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
public class UriQueryStringBuilder : UriBuilder | |
{ | |
private readonly IDictionary<string, string> _queryParameters; | |
public UriQueryStringBuilder(string schemeName, string hostName, string path) : this(schemeName, hostName, path, null) { } | |
public UriQueryStringBuilder(string schemeName, string hostName, string path, IEnumerable<KeyValuePair<string, string>> queryParameters) : this(schemeName, hostName,path,null) | |
{ | |
if (queryParameters == null) return; |
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
try | |
{ | |
var httpWebRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create("API URL HERE"); | |
httpWebRequest.Headers.Add("Authorization", string.Format("Bearer {0}", "REPLACE YOUR TOKEN")); | |
httpWebRequest.ContentType = "application/json"; //for xml response change to application/xml | |
httpWebRequest.Method = "GET"; | |
httpWebRequest.Accept = "application/json"; | |
var httpResponse = (System.Net.HttpWebResponse)httpWebRequest.GetResponse(); |
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
class C | |
{ | |
public event EventHandler<EventArgs> ItemDiscarded; | |
public void Add(int value) | |
{ | |
OnItemDiscarded(value);//trigger event handler | |
} | |
void OnItemDiscarded(int value) |
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
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
public class DictionaryParameter | |
{ | |
private readonly Dictionary<string, object> _parameters = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase); | |
public DictionaryParameters(object param) | |
{ |
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
ExpressionBodied Methods => public string SomeMethod => "Hello world"; | |
ConditionalAccessOperator - Elvis Operator ?. SomeMethod?.Property | |
AutoPropertyIntializers public List<string> Roles {get;set;} = new[] {"FFF","FF"}; | |
Primary Constructor | |
class C(string a, string b) | |
{ |
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
public struct PropertyBag<T1, T2> | |
{ | |
public PropertyBag(T1 t1, T2 t2) | |
{ | |
Item1 = t1; | |
Item2 = t2; | |
} | |
public T1 Item1; | |
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
internal class FtpClient | |
{ | |
const string BaseUrl = "ftp://[IPADDRESS]/[FOLDER_PATH/"; | |
private FtpWebRequest CreateRequest(string url) | |
{ | |
var request = FtpWebRequest.Create(url) as FtpWebRequest; | |
request.Credentials = new NetworkCredential("[USERNAME]", "[PASSWORD]"); | |
request.UsePassive = true; | |
request.UseBinary = true; |
OlderNewer