Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Static interface to dynamic implementation (duck casting). That and more using the DLR.
C# Visual Basic F#
Failed to load latest commit information.
.nuget Upgrade projects for VS12
ImpromptuInterface.FSharp.Silverlight Upgrade projects for VS12
ImpromptuInterface.FSharp.Silverlight5 Up'd version number
ImpromptuInterface.FSharp Added Alias Member support, decoupled type spec notification
ImpromptuInterface.MVVM.Silverlight Fixed line endings and added git ingore
ImpromptuInterface.MVVM.Silverlight5 Fixed line endings and added git ingore
ImpromptuInterface.MVVM Added Alias Member support, decoupled type spec notification
ImpromptuInterface.Silverlight Added Alias Member support, decoupled type spec notification
ImpromptuInterface.Silverlight5 Added Alias Member support, decoupled type spec notification
ImpromptuInterface Added Alias Member support, decoupled type spec notification
NuGetBuild Added Alias Member support, decoupled type spec notification
Tests Added Alias Member support, decoupled type spec notification
docs Moved files around, removed mecurial files
graphics fixed name
nuget Up'd version number
tools Fixed line endings and added git ingore
.gitattributes Fixed line endings and added git ingore
.gitignore Up'd version number
ImpromptuInterface.DotNetOnly.sln Upgrade projects for VS12
ImpromptuInterface.DotNetOnly.sln.DotSettings Upgrade projects for VS12
ImpromptuInterface.sln Up'd version number
ImpromptuInterface.sln.DotSettings Upgrade projects for VS12
License.txt Moved files around, removed mecurial files
Readme.md Update Readme.md

Readme.md

C# 4.0 (.net & silverlight) framework to allow you to wrap any object (static or dynamic) with a static interface even though it didn't inherit from it. It does this by emitting cached dynamic binding code inside a proxy. By expanding on the DLR plumbing used to implement this library, it has grown to support more general dynamic implementations.

See Wiki for full examples of all features. Other features include Really Late Binding, Inline Syntaxes, Currying, some dynamic extensions for FSharp, and unsealed Dynamic Objects including a fully dynamic MVVM ViewModel

Roadmap:

  • 6.5
  • 7.0
    • Strip out Obsolete Code
    • Full PCL port of Interface Wrapping
    • Tool to pregenerate proxies for WinRT

Quick Usage:

    using ImpromptuInterface;
    using ImpromptuInterface.Dynamic;

    public interface IMyInterface{

       string Prop1 { get;  }

        long Prop2 { get; }

        Guid Prop3 { get; }

        bool Meth1(int x);
   }
   //Anonymous Class
    var anon = new {
             Prop1 = "Test",
             Prop2 = 42L,
             Prop3 = Guid.NewGuid(),
             Meth1 = Return<bool>.Arguments<int>(it => it > 5)
    }

    var myInterface = anon.ActLike<IMyInterface>();

OR

   //Dynamic Expando object
    dynamic expando = Build<ExpandoObject>.NewObject(
             Prop1: "Test",
             Prop2: 42L,
             Prop3: Guid.NewGuid(),
             Meth1: Return<bool>.Arguments<int>(it => it > 5)
    );

    IMyInterface myInterface = Impromptu.ActLike(expando);

ALSO

    //In F#
    let expando:obj = !?Build<ExpandoObject>.NewObject (
                dynArg("Test")         ? Prop1,
                dynArg(42L)            ? Prop2,
                dynArg(Guid.NewGuid()) ? Prop3,
                dynArg(Return<bool>.Arguments<int>(fun x -> x > 5))
                                                       ? Meth1
                )

    let myInterface = expando.ActLike<IMyInterface>()

Get The Code

Project can be checked out from git repository, works with .net 4.0, Silverlight 4.0 & 5.0 and mono 2.10

Get The Binaries

use NuGet Visual Studio Extension "Add Libary Package Refrence... from Visual Studio or download the zip file. Source Code for debugging the binaries can be provided automatically from SymbolSource.org

Get The Samples

There is a Sample mercurial repository for code samples. Currently it has an ImpromptuInterface.MVVM based calculator implemented in WPF or Silverlight or F#. sample repository.

Something went wrong with that request. Please try again.