Skip to content

Instantly share code, notes, and snippets.

View ArnisL's full-sized avatar
🦊

Arnis Lapsa ArnisL

🦊
View GitHub Profile
using Map=BudgetPerPartnersMap;
//you all going to die down here!
public static class BudgetPerPartnersReader{
public static void Read(IExcelReader r,ApplicationForm f){
r.ChangeSheet(SheetMap.BudgetPerPartners);
var b=f.BudgetPerPartners;
var fillCostsType=new Action<CostsType,string[,]>(
(costsType,map)=>{
costsType.AllPartnersTotal=r.Get(Map.AllPartnersTotal[0]);
for(var i=0;i<map.GetUpperBound(0);i++)
namespace Interreg.Infra.Forms{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using Microsoft.Office.Interop.Excel;
public interface IExcelReader:IDisposable{
void Open(string path);
string Get(string key);
void ChangeSheet(string key);
@ArnisL
ArnisL / gist:634186
Created October 19, 2010 13:27
userSession.cs
public class UserSession:IUserSession{
private readonly IAuthenticationService _authenticationService;
private readonly ICryptographer _crypto;
private readonly IUserRepository _repository;
public UserSession(IUserRepository repository,IAuthenticationService authenticationService,ICryptographer crypto){
Guard.AgainstNull(repository);
Guard.AgainstNull(authenticationService);
Guard.AgainstNull(crypto);
_repository=repository;
_crypto=crypto;
@ArnisL
ArnisL / gist:634190
Created October 19, 2010 13:30
globalasax.cs
namespace Interreg.Web{
using System;
using System.Security.Principal;
using System.Web.Security;
using MvcExtensions.StructureMap;
public class MvcApplication:StructureMapMvcApplication{
//ignore this bullshit code...
protected void Application_AuthenticateRequest(Object sender,EventArgs e){
var authCookie=Context.Request.Cookies[FormsAuthentication.FormsCookieName];
if(authCookie==null||authCookie.Value=="") return;
@ArnisL
ArnisL / gist:742040
Created December 15, 2010 14:59
temp_directory.cs
using System;
using System.IO;
public class TempDirectory:IDisposable{
private readonly string _path;
public TempDirectory(){
var path=Path.Combine(Path.GetTempPath(),Path.GetRandomFileName());
Directory.CreateDirectory(path);
_path=path;
}
public void Dispose(){
@ArnisL
ArnisL / gist:742085
Created December 15, 2010 15:27
word_interop.cs
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Linq;
public class WordTemplateFiller{
private readonly Zipper _zipper=new Zipper();
private const string _pathToCustomPropXml="docprops\\custom.xml";
/// <returns>path to filled docx</returns>
public FileInfo FillTemplate(string templatePath,Dictionary<string,string> props){
var docPath=Path.GetTempFileName();
@ArnisL
ArnisL / after.cs
Created October 19, 2011 22:02
refactoring == joy
namespace Interreg.App.Audit.Application{
using Domain.Model.Applications;
public class ApplicationAudit:Audit{
public override void AttachHandlers(){
On<AttachmentAdded>(e=>e.Source.LogEvent(
"Attachment named '{0}' added".With(e.Attachment.Name)));
On<AttachmentRemoved>(e=>e.Source.LogEvent(
"Attachment named '{0}' removed".With(e.Attachment.Name)));
public class Show{
public Show(DateTime startsOn, DateTime endsOn, string location, ShowType showType){
StartsOn = startsOn;
EndsOn = endsOn;
Location = location;
ShowType = showType;
Speakers = new List<Speaker>();
Attendees = new List<Attendee>();
AssociatedCampaigns = new List<Campaign>();
}
//view
@model StateIneligibilityModel
@Html.Js("ineligibilities/state")
@using (Html.BeginForm("State", "Ineligibilities", FormMethod.Post)){
<fieldset class="state-ineligibility">
<legend>State ineligibility:</legend>
@Html.HiddenFor(x=>x.Project)
<table>
<tr>
<td>@Html.LabelFor(x=>x.IneligibleCosts)</td>
@ArnisL
ArnisL / ApplicationsFacts.cs
Created January 3, 2012 17:18
Asp.net mvc route testing
namespace Interreg.Integration.Web.Routing{
using Extensions;
using Interreg.Web.Controllers;
using Xunit;
public class ApplicationsFacts:Base{
[Fact]
public void Application(){
"~/Applications/1"
.ShouldMapTo<ApplicationsController>(c=>c.Application(null,null));
}