Skip to content

Instantly share code, notes, and snippets.

@mika76
mika76 / IniSerializer.cs
Last active January 16, 2024 20:45
INI Serializer for .NET Core in C# - Pretty basic with some validations and Serialize and Deserialize methods. There are lot's of variations for ini files though so it will probably not support every scenario. Feel free to adapt to your use-case.
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace tools
{
/// <summary>
/// Serializer class for ini files.
@mikanyg
mikanyg / ResourceNotFoundAttribute.cs
Last active May 2, 2017 22:37
WebApi ActionFilter used in conjunction with Service Fabric reverse proxy or ServiceFabric.AutoRest to indicate a RESTfull 404 response.
using System;
using System.Net;
using System.Web.Http.Filters;
namespace ServiceFabric.WebApi.Filters
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
public class ResourceNotFoundAttribute : ActionFilterAttribute
{
public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
@kadet1090
kadet1090 / prompt.ps1
Created March 21, 2016 17:33
PowerLine like prompt for PowerShell
$script:bg = [Console]::BackgroundColor;
$script:first = $true;
$script:last = 0;
function Write-PromptFancyEnd {
Write-Host  -NoNewline -ForegroundColor $script:bg
$script:bg = [System.ConsoleColor]::Black
}
[AttributeUsage(AttributeTargets.Method)]
public class ValidationActionFilterAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(HttpActionContext actionContext)
{
InnerOnActionExecuting(actionContext);
var modelState = actionContext.ModelState;
if (modelState.IsValid)
# This script will clone the settings from one project to another via an exported YAML
$apiUrl = 'https://ci.appveyor.com/api'
$token = '[your token]'
$headers = @{
"Authorization" = "Bearer $token"
"Content-type" = "application/json"
}
$accountName = '[account name]'
$projectSlug = '[project slug]'
@bsommardahl
bsommardahl / AppVeyorArtifact
Last active August 29, 2015 14:04
AppVeyor Build Report Structure
public class AppVeyorArtifact
{
public string FileName { get; set; }
public string Name { get; set; }
public string Type { get; set; }
public int Size { get; set; }
public string Url { get; set; }
}
@krunalm
krunalm / appveyor deplyment name with version
Created June 5, 2014 10:12
appveyor deplyment name with version
function ZipFiles($zipfilename, $sourcedir)
{
[Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem")
$compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal
[System.IO.Compression.ZipFile]::CreateFromDirectory($sourcedir, $zipfilename, $compressionLevel, $false)
}
# Step 1 - Sign all output assemblies
# TODO
@quexy
quexy / SpecFlow.CollectionVerifier.cs
Last active August 29, 2015 14:01
Collection verifier for SpecFlow
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
namespace TechTalk.SpecFlow.ObjectVerification
{
public static class CollectionVerifierExtensions
{
/// <summary>
@derjabkin
derjabkin / gist:6549465
Created September 13, 2013 11:24
XAF ASP.NET Shortcut for an action
public class ActionContainerHolderEx : ActionContainerHolder
{
protected override DevExpress.ExpressApp.Web.Templates.ActionContainers.Menu.MenuActionItemBase CreateSimpleActionItem(DevExpress.ExpressApp.Actions.SimpleAction simpleAction)
{
SimpleActionMenuActionItem item = base.CreateSimpleActionItem(simpleAction) as SimpleActionMenuActionItem;
if (item != null)
{
ModificationsController controller = item.Action.Controller as ModificationsController;
using System.Configuration;
using System.Data.Common;
using System.Data.SqlClient;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;