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 class HtmlHelperExtension | |
{ | |
public static string ActiveCss<T>(this HtmlHelper helper, T pageId, string activeClass = "active") | |
{ | |
var displayContext = helper.ViewData.DisplayContext<T>(); | |
if (EqualityComparer<T>.Default.Equals(displayContext, pageId)) | |
{ | |
return activeClass; | |
} | |
return string.Empty; |
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 class ViewDataExtension | |
{ | |
public static void DisplayContext<T>(this ViewDataDictionary viewData, T instance, string key = null) | |
{ | |
var keyValue = (string.IsNullOrEmpty(key)) ? typeof(T).FullName : typeof(T).FullName + "." + key; | |
viewData[keyValue] = instance; | |
} | |
public static T DisplayContext<T>(this ViewDataDictionary viewData, string key = null) | |
{ |
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.Linq; | |
using System.Reflection; | |
using System.Reflection.Emit; | |
using System.ServiceModel; | |
namespace DisposableChannelFactory | |
{ | |
public class ClientGenerator |
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.Concurrent; | |
using System.Dynamic; | |
using System.Linq; | |
using System.Reflection; | |
public class GenericExpando : DynamicObject | |
{ | |
private readonly object instance; | |
private readonly Type staticType; |
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.Concurrent; | |
using System.Globalization; | |
using System.Linq; | |
using System.Linq.Expressions; | |
using System.Reflection; | |
public static class TryParser | |
{ | |
private delegate bool TryParseDelegate<T>(string stringValue, out T instance) where T : struct; |
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 LoadFileData.Constants; | |
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling; | |
public static class ExceptionHandler | |
{ | |
public static void Dispose(this IDisposable disposable, string policyName = PolicyName.Disposable) | |
{ | |
if (disposable == null) | |
{ |
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.Linq; | |
using System.Reflection; | |
public static class AssemblyHelper | |
{ | |
public static IEnumerable<Type> LoadableTypesOf(Type loadableType) | |
{ |
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
function Create-Xdt( | |
[string] $prodConfig, | |
[string] $devConfig, | |
[string] $xdtFile, | |
[string[]] $keepNodes = @(), | |
[hashtable] $findReplace = @{}, | |
[string[]] $keyAttributes = @("name", "key", "path", "contract") | |
) | |
{ | |
if([System.String]::IsNullOrEmpty($prodConfig) -or |
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
function XmlDocTransform($xml, $xdt, $output) | |
{ | |
if (!$xml -or !(Test-Path -path $xml -PathType Leaf)) { | |
throw "File not found. $xml"; | |
} | |
if (!$xdt -or !(Test-Path -path $xdt -PathType Leaf)) { | |
throw "File not found. $xdt"; | |
} | |
$transformDll = "" |
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
Function Invoke-ElevatedCommand { | |
<# | |
.DESCRIPTION | |
Invokes the provided script block in a new elevated (Administrator) powershell process, | |
while retaining access to the pipeline (pipe in and out). Please note, "Write-Host" output | |
will be LOST - only the object pipeline and errors are handled. In general, prefer | |
"Write-Output" over "Write-Host" unless UI output is the only possible use of the information. | |
Also see Community Extensions "Invoke-Elevated"/"su" | |
.EXAMPLE |
OlderNewer