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
private string GetManufacturer(string MacAddress) | |
{ | |
using (ISession session = Global._DatabaseConn.OpenSession()) | |
{ | |
using (ITransaction transaction = session.BeginTransaction()) | |
{ | |
string strManuFacturer = "N/A"; | |
var OID = session.Query<normutils.data.Entities.MACIdentifier>(); | |
var Type = (from t in OID | |
where t.ID == MacAddress.Substring(0,8) |
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 TResult Send<TResult>(IRequest<TResult> message) | |
{ | |
var context = Container.GetInstance<MyContext>(); | |
var mediator = Container.GetInstance<IMediator>(); | |
DbContextTransaction txn = null; | |
TResult result; | |
try | |
{ | |
txn = context.Database.BeginTransaction(); |
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 DbConnectionBindings : NinjectModule | |
{ | |
public override void Load() | |
{ | |
Bind<MySpesificDatabaseConnection>() | |
.ToSelf() | |
.InRequestScope() | |
.WithConstructorArgument("connectionString", ConfigurationManager.ConnectionStrings["MyConnectionStringInConfig"].ConnectionString) | |
.OnDeactivation(con => con.Close()) | |
.OnActivation(con => con.Open()); |
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 void Txn(Action<MyContext> action) | |
{ | |
var dbContext = new MyContext(); | |
DbContextTransaction txn = null; | |
try | |
{ | |
txn = dbContext.Database.BeginTransaction(); | |
action(dbContext); | |
dbContext.SaveChanges(); | |
txn.Commit(); |
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
// A generic base repository which other repositories (if needed) can inherit from | |
public class BaseRepository<TEntity> : IEntityRepository<TEntity> where TEntity : class | |
{ | |
internal DataContext context; | |
internal DbSet<TEntity> dbSet; | |
public BaseRepository(DataContext context) | |
{ | |
this.context = context; |
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
using System; | |
using System.Collections.Generic; | |
using System.Data.Entity; | |
namespace DAL.Models | |
{ | |
public static class IDbSetExtensions | |
{ | |
/// <summary> | |
/// When using IDbSet Interface the SQLQuery method is hidden this extension method will allow us to expose the method |
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
using System; | |
using System.Diagnostics; | |
using System.Security.Cryptography; | |
using System.Text; | |
namespace Crtypto | |
{ | |
class Program | |
{ | |
static void Main(string[] args) |
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
// load primary key data from PEM file with BouncyCastle lib | |
var privrsa = new RSACryptoServiceProvider(); | |
using (StreamReader sr = new StreamReader("../../rsakeys.pem")) | |
{ | |
var pass = new Password("gDpfk2Em".ToCharArray()); | |
var pr = new PemReader(sr, pass); | |
var p = (AsymmetricCipherKeyPair)pr.ReadObject(); | |
var o = (RsaPrivateCrtKeyParameters)p.Private; | |
var rsaParams = new RSAParameters | |
{ |
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
using System; | |
using System.IO; | |
using System.Security; | |
using System.Security.Cryptography; | |
using System.Globalization; | |
using System.Text; | |
namespace Core.Util | |
{ |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Security.Cryptography; | |
using System.IO; | |
namespace RSASample | |
{ | |
class Program |