Skip to content

Instantly share code, notes, and snippets.

View petarvucetin's full-sized avatar

Petar Vučetin petarvucetin

  • Clear Lines
  • Los Angeles
View GitHub Profile
@petarvucetin
petarvucetin / Control.XAML
Created January 18, 2013 03:02
Wire up VM via service locator pattern
<Window.DataContext>
<Binding Path="Main" Source="{StaticResource Locator}"/>
</Window.DataContext>
@petarvucetin
petarvucetin / IRepository<T>.cs
Last active December 11, 2015 07:29
YARP - yet another repository pattern
public interface IRepository<T> where T : IAggregateRoot
{
IQueryable<T> Find();
void Add(T instance);
void Update(T instance);
void DeleteById(object id);
}
public class DisposableClass :
IDisposable
{
bool _disposed;
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
# --- settings ---
$feedUrlBase = "http://go.microsoft.com/fwlink/?LinkID=206669"
# the rest will be params when converting to funclet
$latest = $true
$overwrite = $false
$top = 500 #use $top = $null to grab all
$destinationDirectory = join-path ([Environment]::GetFolderPath("MyDocuments")) "NuGetLocal"
# --- locals ---
$webClient = New-Object System.Net.WebClient
public interface IRepository<T, in K> : IDisposable where T:class
{
IQueryable<T> All { get; }
IQueryable<T> AllAndExpand(params Expression<Func<T, object>>[] entity);
T Find(K id);
void InsertOrUpdate(T item);
void Delete(K id);
void Save();
}
#r @"C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp\3.0\Runtime\v4.0\Type Providers\FSharp.Data.TypeProviders.dll"
#r @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.Services.Client.dll"
#r @"C:\Program Files (x86)\Microsoft WCF Data Services\5.0\bin\.NETFramework\Microsoft.Data.OData.dll"
open Microsoft.FSharp.Data.TypeProviders
open System.Data.Services.Client
open System.Net
open System.IO
let apiUrl = "http://packages.nuget.org/api/v1/package/"
@petarvucetin
petarvucetin / BindableObject.cs
Created October 15, 2013 16:45
Exposes classes as BindableObjects
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Reflection;
namespace ClearLines.iFX.WPF
{
/// <summary>
@petarvucetin
petarvucetin / VisibilityConverter.cs
Created October 15, 2013 16:47
WPF/XAML VisibilityConverter
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Data;
namespace ClearLines.iFX.WPF
{
@petarvucetin
petarvucetin / SelectionItem<T>.cs
Created October 15, 2013 16:49
SelectionItem<T> and SelectionList<T> for WPF
using System;
using System.ComponentModel;
namespace ClearLines.iFX.WPF
{
public class SelectionItem<T> : INotifyPropertyChanged
{
#region Fields
@petarvucetin
petarvucetin / EnumExtensions.cs
Last active January 4, 2016 05:19
Missing enum BCL extensions
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
namespace iFX.Core
{
public static class EnumExtensions
{
public static T FromString<T>(this Enum e, string value)