Skip to content

Instantly share code, notes, and snippets.

View thdotnet's full-sized avatar

Thiago Custodio thdotnet

  • Microsoft
  • Texas, USA
View GitHub Profile
@thdotnet
thdotnet / gist:d5c0b2320e6b90700b85bd0b4876dc64
Created January 11, 2017 03:43
c# code to read and update session values persisted into Sql Server
private static void ReadShortSessionItem(SqlBytes SessionItemShort)
{
using (MemoryStream ms = new MemoryStream(SessionItemShort.Buffer))
{
using (BinaryReader br = new BinaryReader(ms))
{
var sessionTimeout = br.ReadInt32();
bool sessionDataExists = br.ReadBoolean();
bool containsStaticObjects = br.ReadBoolean();
@thdotnet
thdotnet / Distinct By
Created November 24, 2016 11:17
Linq Distinct By implementation
using System;
using System.Collections.Generic;
using System.Linq;
namespace Testes
{
class Program
{
static void Main(string[] args)
{
@thdotnet
thdotnet / gist:dbb3afdd831582721b3096247ca5193b
Last active November 2, 2016 09:00
Webapi Route Prefix
public class ApiVersion1RoutePrefixAttribute : RoutePrefixAttribute
{
private const string RouteBase = "api/{apiVersion:apiVersionConstraint(v1)}";
private const string PrefixRouteBase = RouteBase + "/";
public ApiVersion1RoutePrefixAttribute(string routePrefix)
: base(string.IsNullOrWhiteSpace(routePrefix) ? RouteBase : PrefixRouteBase + routePrefix)
{
}
}
@thdotnet
thdotnet / gist:0a94e688dd3e6a14b4d75edd54474c55
Last active October 29, 2016 10:48
Packages to Secure Web App with Azure AD
Install-Package Microsoft.IdentityModel.Protocol.Extensions
Install-Package System.IdentityModel.Tokens.Jwt
Install-Package Microsoft.Owin.Security.OpenIdConnect
Install-Package Microsoft.Owin.Security.Cookies
Install-Package Microsoft.Owin.Host.SystemWeb
@thdotnet
thdotnet / gist:b389ad252552368f5171
Created June 10, 2015 14:03
Could not load file or assembly Microsoft.Data.OData Version=5.2.0.0 error in Azure
Today I've faced a problem with Microsoft.WindowsAzure.Storage nuget package. Running the application I've got the following runtime exception:
"Could not load file or assembly Microsoft.Data.OData Version=5.2.0.0..."
I've found some blog posts that says to use binding redirect to Version 5.6.4.0. However, only configuring the binding redirect of this version will not fix the error, When I've published my application to Azure, I've saw a message on the output window:
1>------ Build started: Project: XXX, Configuration: Release Any CPU ------
1> Consider app.config remapping of assembly "Microsoft.Data.Edm, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "5.6.2.0" [] to Version "5.6.4.0" [C:\Users\br.thiago.custodio\documents\visual studio 2013\Projects\XXX\packages\Microsoft.Data.Edm.5.6.4\lib\net40\Microsoft.Data.Edm.dll] to solve conflict and get rid of warning.
1> Consider app.config remapping of assembly "Microsoft.Data.Services.Client, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
@thdotnet
thdotnet / gist:7252193
Created October 31, 2013 15:59
Based on @tucaz's project "https://github.com/tucaz/XmlToObjectParser", I decided to do the oposite, ExpandoObject to XML. Enjoy http://twitter.com/thdotnet
using System;
using System.Dynamic;
using System.Xml.Linq;
namespace ConsoleApplication5
{
internal class ToXml
{
public string GetXml(ExpandoObject obj, XElement rootElement)
{