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 Authentication | |
private List<string> getGroupNames(string userName) | |
{ | |
using (var pc = new PrincipalContext(ContextType.Domain, _domainUri)) | |
{ | |
var identity = UserPrincipal.FindByIdentity(pc, userName); | |
if (identity == null) | |
return new List<string>(); | |
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 DisposableStopwatch: IDisposable { | |
private readonly Stopwatch sw; | |
private readonly Action<TimeSpan> f; | |
public DisposableStopwatch(Action<TimeSpan> f) { | |
this.f = f; | |
sw = Stopwatch.StartNew(); | |
} | |
public void Dispose() { |
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
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var sqlConfig = MsSqlConfiguration.MsSql2008.ConnectionString(@"Server=.\SQLEXPRESS;Database=testdb3;Trusted_Connection=True;"); | |
var config = PostgreSQLConfiguration.PostgreSQL82.ConnectionString(c => | |
c.Database("testdb3") | |
.Host("localhost") | |
.Port(5432) |
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
<configSections> | |
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /> | |
</configSections> | |
<log4net> | |
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender"> | |
<file value="log.txt" /> | |
<appendToFile value="true" /> | |
<rollingStyle value="Size" /> | |
<maxSizeRollBackups value="5" /> | |
<maximumFileSize value="1000KB" /> |
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
(function(NS, $, undefined) { | |
//idea gleaned from https://gist.github.com/661855 | |
var o = $({}); | |
NS.Events = {}; | |
NS.Events.subscribe = function () { | |
console.log('Subscribing to ' + arguments[0]); | |
o.on.apply(o, arguments); | |
}; | |
NS.Events.unsubscribe = function () { | |
console.log('UnSubscribing from ' + arguments[0]); |
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 ModuleBootstrapper | |
{ | |
public static string GetModuleTitle(IViewModel instance) | |
{ | |
var title = from a in instance.GetType().GetCustomAttributes(typeof(PublishedViewAttribute), false) | |
let pva = a as PublishedViewAttribute | |
select pva.Title; | |
return title.FirstOrDefault(); | |
} | |
public static Uri GetCurrentUICultureSource(string resourceName, Type containingModule) |
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 ViewSelector : DataTemplateSelector | |
{ | |
public override DataTemplate SelectTemplate(object item, DependencyObject container) | |
{ | |
/* | |
<Window.Resources> | |
<Selectors:ViewSelector x:Key="ViewSelector"> | |
</Selectors:ViewSelector> | |
</Window.Resources> | |
<DockPanel Name="pnlDockMain" > |
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
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var ctx = new Testctx(); | |
var usr = new User() {username = "bob"}; | |
ctx.Users.Add(usr); | |
ctx.SaveChanges(); |
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 RSAClass | |
{ | |
private static UnicodeEncoding _encoder = new UnicodeEncoding(); | |
public static string Decrypt(string data, string xmlPrivateKey) | |
{ | |
var rsa = new RSACryptoServiceProvider(); | |
var dataArray = data.Split(new char[] { ',' }); | |
var dataByte = new byte[dataArray.Length]; | |
for (int i = 0; i < dataArray.Length; i++) |