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 static void EntityRelationshipMap<T, K>(this ICollection<T> startingCollection, ICollection<T> newCollection, | |
Func<T, K> selector ) | |
{ | |
var newItemCompareValues = newCollection.Select(selector); | |
var existingItemCompareValues = startingCollection.Select(selector); | |
var alternativeTitlesToRemove = startingCollection.Where(at => !newItemCompareValues.Contains(selector(at))); | |
var alternativeTitlesToAdd = newCollection.Where(at => !existingItemCompareValues.Contains(selector(at))); | |
foreach (var alternativeTitleToRemove in alternativeTitlesToRemove) |
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
/// <summary> | |
/// This class uploads files to Azure. | |
/// </summary> | |
public class SimpleAzureUploader | |
{ | |
private readonly CloudMediaContext _context; | |
/// <summary> | |
/// Initializes a new instance of the <see cref="SimpleAzureUploader"/> class. |
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
var requestParameters = new Dictionary | |
{ | |
{"param1", "value1"}, | |
{"param2", "value2"}, | |
}; | |
var webClient = new SilverlightWebClient(); | |
string response = webClient.UploadValues(new Uri("[uri to post to]"), requestParameters); | |
var webClient2 = new SilverlightWebClient(); |
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 static Mock<DbSet<T>> AsMockDbSet<T>(this IEnumerable<T> data) where T : class | |
{ | |
var mockSet = new Mock<DbSet<T>>(); | |
var queryable = data.AsQueryable(); | |
mockSet.As<IQueryable<T>>().Setup(m => m.Provider).Returns(() => queryable.Provider); | |
mockSet.As<IQueryable<T>>().Setup(m => m.Expression).Returns(() => queryable.Expression); | |
mockSet.As<IQueryable<T>>().Setup(m => m.ElementType).Returns(() => queryable.ElementType); | |
mockSet.As<IQueryable<T>>().Setup(m => m.GetEnumerator()).Returns(() => queryable.GetEnumerator()); |
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
private static void SetupLogging() | |
{ | |
var logFolder = GetSetting("LogFolder", @"c:\logs"); | |
var logFile = GetSetting("LogFile", @"c:\logs\MyLog.txt"); | |
if (!Directory.Exists(logFolder)) | |
{ | |
Directory.CreateDirectory(logFolder); | |
} | |
var hierarchy = (Hierarchy) LogManager.GetRepository(); | |
hierarchy.Root.RemoveAllAppenders(); /*Remove any other appenders*/ |
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.IO; | |
using System.Linq; | |
using LibGit2Sharp; | |
namespace GitDeploy | |
{ | |
public class GitRepositoryManager | |
{ | |
private readonly string _repoSource; |
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 directive asks the user for a Yes/No confirmation, and then requires the user to type a value to confirm the action. | |
* | |
* Usage: | |
<button confirm-by-typing confirm-action="deleteSite(site)" confirm-value="{{site.Path}}" alert-message="Are you sure you want to delete '{{site.Name}}'?" modal-title="Are you sure you want to delete '{{site.Name}}'?" modal-message="Enter the site path <strong>'{{site.Path}}'</strong> below to confirm."> | |
Delete | |
</button> | |
*/ | |
adminApp.directive("confirmByTyping", ["$modal", function ($modal) { | |
var getConfirmTypingModalTemplate = function (title, 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
using System; | |
using System.Diagnostics; | |
using System.Net; | |
namespace EventLogListener | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ |
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
/// <summary> | |
/// Class for doing IP Address and network calculations | |
/// </summary> | |
public class IpRangeCalculator | |
{ | |
public readonly Dictionary<string, string> CidrSuffixesForMask = new Dictionary<string, string> | |
{ | |
{ "255.255.255.255", "32" }, | |
{ "255.255.255.254", "31" }, | |
{ "255.255.255.252", "30" }, |
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
/// <reference path="../app.js" /> | |
'use strict'; | |
app.factory('authService', ['$http', '$q', '$log', 'apiBaseUrl', 'localStorageService', function ($http, $q, $log, apiBaseUrl, localStorageService) { | |
var setupHttp = function() { | |
$http.defaults.headers.common["Content-Type"] = "application/x-www-form-urlencoded"; | |
$http.defaults.headers.common['Authorization'] = "Bearer " + authentication.access_token; | |
} | |
var authServiceFactory = {}; |
OlderNewer