Skip to content

Instantly share code, notes, and snippets.

View runceel's full-sized avatar

Kazuki Ota runceel

View GitHub Profile
@runceel
runceel / gist:2427098
Created April 20, 2012 08:21
INotifyPropertyChanged Implementation
using System;
using System.Data.Common;
using System.Linq;
using System.Linq.Expressions;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Validation;
using System.ComponentModel;
using Microsoft.Practices.Unity.InterceptionExtension;
using System.Collections.Generic;
@runceel
runceel / gist:2437074
Created April 21, 2012 13:26
WinRT IObservableVector<T> implementation
namespace Okazuki.WinRT.Common
{
using System.Collections.Generic;
using System.Linq;
using Windows.Foundation.Collections;
class ObservableVector<T> : IObservableVector<T>
{
private List<T> inner;
@runceel
runceel / gist:2437116
Created April 21, 2012 13:38
WinRT ICommand implementation
using System;
using System.Collections.Generic;
using System.Windows.Input;
namespace Application3.Common
{
class DelegateCommand : ICommand
{
private static readonly Action EmptyExecute = () => { };
private static readonly Func<bool> EmptyCanExecute = () => true;
@runceel
runceel / gist:2622484
Created May 6, 2012 14:15
明日のBlog記事ネタ
*[WinRT][MEF]WinRTのMEFでServiceLocator実装してみた
WinRTのMEFってCompositionContainerクラスがいなくなってCompositionServiceクラスでSatisfyImportsOnceメソッド使って対象クラスに何かをImportするということしかできないっぽいです。なのでMVVM Light 4のDIコンテナにMEF使ってやろうと思ったらいきなり挫折してしまいましたorz
それじゃぁ悔しいので、無理やりCompositionServiceクラスを使った状態でIServiceLocatorインターフェースを実装してみました。ちなみにMVVM Light 4に添付されてるMicrosoft.Practices.ServiceLocation.dllを使います。
**実装
ということでさくっと実装してみました。SatisfyImportsOnceメソッドにRegistrationBuilderのインスタンスを渡せば実行時にImportの挙動とかをいじれるみたいなので、それを使ってごにょごにょっとしてます。
>|cs|
namespace SampleImplementation
{
@runceel
runceel / gist:2632442
Created May 8, 2012 03:59
MEF2 Code sample
void Main()
{
var catalog = new AssemblyCatalog(typeof(A<>).Assembly);
var container = new CompositionContainer(catalog);
var a = container.GetExportedValue<A<string>>();
a.Dump();
container.ComposeParts(this);
var export = this.AProperty.CreateExport();
var value = export.Value;
@runceel
runceel / gist:2651233
Created May 10, 2012 05:30
WCF RIA ServicesのCompletedイベントのお試し
using System.ServiceModel.DomainServices.Client;
using System.Windows;
using System.Windows.Controls;
using SilverlightApplication1.Web;
namespace SilverlightApplication1
{
/// <summary>
/// Button2つとDataGridを1つ適当に置いた画面のコードビハインド
/// </summary>
@runceel
runceel / gist:2658124
Created May 11, 2012 07:27
非同期処理を順次実行
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.ServiceModel.DomainServices.Client;
using System.Windows;
using System.Windows.Controls;
using SilverlightApplication1.Web;
@runceel
runceel / MainWindow.xaml
Created May 15, 2012 14:10
コードビハインド
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<ItemsControl ItemsSource="{Binding Items}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBox Text="{Binding Text}" />
@runceel
runceel / gist:3698649
Created September 11, 2012 13:52
BackgroundWorker interface sample
template<typename TProgress>
class BackgroundWorker
{
private:
TProgress progress_;
bool reportChanged_;
public:
BackgroundWorker(bool reportChanged = false) :
progress_(TProgress()),
reportChanged_(reportChanged)
@runceel
runceel / gist:3878023
Last active April 18, 2023 12:42
プライバシーポリシー/Privacy policy

アプリケーションのプライバシーポリシー

このアプリケーションは、個人情報を収集したり公開しません。


Application privacy policy

This application does not collect or publish any personal information.