This file contains hidden or 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
/// Use most of the time | |
public static string GetExecutingDirectoryName() | |
{ | |
var location = new Uri(Assembly.GetEntryAssembly().GetName().CodeBase); | |
return new FileInfo(location.AbsolutePath).Directory.FullName; | |
} | |
/// In case of tests or when we know what we're doing | |
/// This works in ASP.NET Web API | |
public static string GetExecutingDirectoryNameForTests() |
This file contains hidden or 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
/// <summary> | |
/// Reads text that is embedded into an assembly | |
/// </summary> | |
/// <remarks> | |
/// fullyQualifiedFileName is fully qualified, e.g. if the file abc.config was in assembly with namespace MyCompany.MyLib inside a | |
/// folder Config then fullyQualifiedFileName should read MyCompany.MyLib.abc.config | |
/// </remarks> | |
private static string GetTextFromEmbededResource(string fullyQualifiedFileName) | |
{ | |
var assembly = Assembly.GetExecutingAssembly(); |
This file contains hidden or 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
SET ANSI_NULLS ON | |
GO | |
SET QUOTED_IDENTIFIER ON | |
GO | |
CREATE PROC [dbo].[pr_ins_test] | |
@CompanyID INT | |
AS | |
SET NOCOUNT ON |
This file contains hidden or 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
/// <summary> | |
/// Gets the IIS version from registry. | |
/// </summary> | |
/// <remarks> | |
/// From SO: http://stackoverflow.com/a/1699947/190476 | |
/// </remarks> | |
public Version GetIisVersion() | |
{ | |
using (RegistryKey componentsKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\InetStp", false)) | |
{ |
This file contains hidden or 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 idea: http://stackoverflow.com/questions/9565889/get-the-ip-address-of-the-remote-host | |
using System.Net.Http; | |
using System.ServiceModel.Channels; | |
using System.Web; | |
namespace CrowSoftware.Api | |
{ | |
public static class HttpRequestMessageHelper | |
{ |
This file contains hidden or 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
void Main() | |
{ | |
var fileName = @"C:\OfficeDocs\somfile.js"; | |
var hash = GetFileHash(fileName); | |
hash.Dump("Hash"); | |
} | |
// Define other methods and classes here | |
public static string GetFileHash(string filePath) | |
{ |
This file contains hidden or 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
/// <summary> | |
/// Gets the first header value or default. | |
/// </summary> | |
/// <typeparam name="T"></typeparam> | |
/// <param name="requestMessage">The <see cref="HttpRequestMessage"/> message.</param> | |
/// <param name="headerKey">The header key i.e. the header to read.</param> | |
/// <param name="defaultValueSelector">The <see cref="Func{T, TResult}"/> default value selector.</param> | |
/// <param name="valueTransform">The <see cref="Func{T, TResult}"/> value transform.</param> | |
/// <returns></returns> | |
private T GetFirstHeaderValueOrDefault<T>( |
This file contains hidden or 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
# Initialize repo | |
git init | |
# add everything (except ignored files) | |
git add . | |
# add a remote origin | |
git remote add origin https://{url} | |
# push to remote repo - push to the master |
This file contains hidden or 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
<?xml version="1.0" encoding="utf-8"?> | |
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> | |
<CodeSnippet Format="1.0.0"> | |
<Header> | |
<Title>Add NLog Logger</Title> | |
<Shortcut>adlog</Shortcut> | |
<Description>Code snippet for adding NLog Logger</Description> | |
<Author>Sudhanshu Mishra</Author> | |
<SnippetTypes> | |
<SnippetType>Expansion</SnippetType> |
This file contains hidden or 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
// METHOD 1 No receive endpoint (this is meant for Publish in a pub-sub scenario) | |
public IBusControl CreateBusControl() | |
{ | |
var bus = Bus.Factory.CreateUsingRabbitMq(configurator => | |
{ | |
IRabbitMqHost rabbitMqHost = configurator.Host(new Uri("rabbitmq://localhost/test"), hostConfigurator => | |
{ | |
hostConfigurator.Username("guest"); | |
hostConfigurator.Password("guest"); | |
}); |
OlderNewer