Skip to content

Instantly share code, notes, and snippets.

View DinkDev's full-sized avatar

Dale Thompson DinkDev

View GitHub Profile
@DinkDev
DinkDev / AppBootstrapper.cs
Created November 18, 2019 15:50
Autofac wire up for Caliburn.Micro Boostrapper.
namespace Vastec.Ocr.Evaluator.Wpf
{
using System;
using System.Collections.Generic;
using Autofac;
using Caliburn.Micro;
using Properties;
using ViewModels;
/// <remarks>
@DinkDev
DinkDev / Exceptions.Data access
Created November 14, 2019 16:34
A gist of an extension method to help simplify accessing the Exception's Data property.
/// <summary>
/// Exception Helper extension methods for using Data dictionary.
/// </summary>
public static class ExceptionExtensions
{
public static bool HasData(this Exception ex, Func<object, bool> keyFilter)
{
keyFilter = keyFilter ?? (o => true);
return ex.Data.Cast<DictionaryEntry>().Any(datum => keyFilter(datum.Key));
@DinkDev
DinkDev / LockedFileHelper.cs
Created November 8, 2019 18:10
Utility class to check if a file is locked.
public static class LockedFileHelper
{
public static bool IsFileLocked(string fileName)
{
return IsFileLocked(new FileInfo(fileName));
}
public static bool IsFileLocked(FileInfo file)
{
FileStream stream = null;
@DinkDev
DinkDev / DynamicXml.cs
Created July 16, 2019 19:35
Converting an XDocument to ExpandoObject for dyanmic element access.
namespace DynamicLinqToXml
{
using System.Dynamic;
using System.Text;
using System.Xml;
using System.Xml.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
[TestClass]