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
public static class Sequential | |
{ | |
public static void Invoke(params System.Action[] actions) | |
{ | |
foreach (var a in actions) | |
a.Invoke(); | |
} | |
} |
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
# | |
# push.ps1 | |
# | |
# Push all Nuget packages to Artifactory if the package version has been updated. Checks to make sure that there was not a | |
# previous push of the same version using Git tags. | |
##### USER PARAMETERS | |
param ( | |
[string[]]$csproj_list = $(gci *.csproj), | |
[string]$source = "artifactory-vt", |
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
public static class MarshalExt | |
{ | |
// Only needed for .NET 4.5 and earlier | |
public static T PtrToStructure<T>(IntPtr ptr) | |
{ | |
return (T)Marshal.PtrToStructure(ptr, typeof(T)); | |
} | |
public static T[] PtrToStructureArray<T>(IntPtr ptr, int count) | |
{ |
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> | |
/// Reserve the URL we'll be using for this session for a given user on a given domain | |
/// Source: http://stackoverflow.com/questions/14962334/httplistenerexception-access-denied-for-non-admins on Oct 09, 2014 | |
/// </summary> | |
/// <param name="address">URL (something like http://<ip_address>:<port>/)</param> | |
/// <param name="domain">Domain name (the current one is from Environment.UserDomainName)</param> | |
/// <param name="user">User name (the current one is from Environment.UserName)</param> | |
public static void AddAddress(this HttpListener listener, string address, string domain, string user) | |
{ | |
string args = string.Format(@"http add urlacl url={0}", address) + " user=\"" + domain + "\\" + user + "\""; |
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> | |
/// Finds sections of the given IEnumerable<bool> that are continuously true | |
/// </summary> | |
/// <param name="src">Any IEnumerable<bool></param> | |
/// <returns>An IEnumerable<Tuple<int, int> where each pair represents the start and end index that is continuously true</returns> | |
private IEnumerable<Tuple<int, int>> FindContinuousTrue(IEnumerable<bool> src) | |
{ | |
var res = new Collection<Tuple<int, int>>(); | |
var srclist = src.ToList(); |
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
# | |
# push.ps1 | |
# | |
# A simple script to package and push a Nuget package from a Visual Studio C# project. | |
# `nuget.exe` must be on the path or otherwise available to the script (Package Manager Console) | |
Set-Location -Path $PSScriptRoot | |
# project parameters | |
$projname = "MyProject" |
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
# | |
# push_replace.ps1 | |
# | |
# This script is designed to produce customized release and debug nupkgs from a Visual Studio C# project. This is especially useful | |
# for nupkgs that include native DLLs that are different depending upon debug or release mode. | |
# | |
# How to use: | |
# In your .nuspec file in the <files> section, add the following line: | |
# <file src="$filelist$" target="lib\native" /> | |
# That line is set to go to lib\native because this script was made for handling native DLLs, but that target can be anything. |
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
public class AssemblyResources | |
{ | |
public static bool ResourceExists(string resourceName) | |
{ | |
return Assembly.GetExecutingAssembly().GetManifestResourceNames().Contains(GetResourcePath(resourceName)); | |
} | |
public static string GetResourcePath(string resourceName) => $"{Assembly.GetExecutingAssembly().GetName().Name}.Resources.{resourceName}"; | |
public static Stream GetStream(string resourceName) |
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
// C# 6.0 and up: | |
public class PropertyChangedBase : INotifyPropertyChanged | |
{ | |
public event PropertyChangedEventHandler PropertyChanged = delegate { }; | |
protected void NotifyOfPropertyChange(string name) | |
{ | |
PropertyChanged(this, new PropertyChangedEventArgs(name)); | |
} | |
} |
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
#region INotifyPropertyChanged Boilerplate | |
public event PropertyChangedEventHandler PropertyChanged; | |
private void RaisePropertyChanged(string propname) | |
{ | |
PropertyChangedEventHandler handler = PropertyChanged; | |
if (handler != null) handler(this, new PropertyChangedEventArgs(propname)); | |
} |