Questions tagged [impromptu-interface]

ImpromptuInterface is a framework for .net that uses the DLR's api, normally hidden by the compiler, for meta programming purposes such as adding interfaces at runtime.

ImpromptuInterface is a framework for .net that uses the DLR's api, normally hidden by the compiler, for meta programming purposes such as adding interfaces at runtime, Late Binding via API, Inline Fluent Syntaxes, Currying, and Pre-canned DynamicObjects.

Apache Licensed and available at http://code.google.com/p/impromptu-interface/

Examples:

Adding an interface at runtime:

//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);

Late binding a method at via API:

var relUri = Impromptu.InvokeMember(baseUri, "MakeRelativeUri", absUri);

.NET Framework support

ImpromptuInterface runs on .NET 4.0 or later, Mono 2.10 or later,and Silverlight 4 or Later.

Nuget package

There is a binary distribution of ImpromptuInterface on nuget at http://nuget.org/packages/ImpromptuInterface.

Extensions

ImpromptuInterface also includes the following extensions:

19 questions
3
votes
2 answers

Expand a statically typed object into a dynamic object

I am using dynamic objects for my view models, as I find the overhead from using something like Automapper unnecessary and find this approach a lot more flexible and lightweight. I am using the builder from impromptu-interface like this: private…
Can Gencer
  • 8,822
  • 5
  • 33
  • 52
3
votes
1 answer

How to use DuckTyping when implementations vary slightly?

I'm making a Portable Class Library (PCL) in .NET and it happens that, when trying to abstract any behavior, I face the very common annoyance that .NET Framework is very possessive with its types and interfaces. It's very usual to find a type…
SuperJMN
  • 13,110
  • 16
  • 86
  • 185
3
votes
2 answers

Mapping a dynamic object to an interface and register with IoC

I'm trying to register dynamic implementations for interfaces that will be injected into objects created by my IoC container (Unity in this case). Here is the high-level approach I'm taking: Dynamically load a list of properties from a JSON file.…
Jason Young
  • 3,683
  • 4
  • 32
  • 39
3
votes
1 answer

Call a private member of a base class with ImpromptuInterface

I have a framework that allows me to access the state and methods of objects in my project with keyboard. It relies heavily on ImpromptuInterface, which is great and fast and flexible and stuff. For example, I invoke methods with…
Piotr Zierhoffer
  • 5,005
  • 1
  • 38
  • 59
2
votes
1 answer

'ExpandoObject' does not contain a definition for 'PropertyChanged'

I am attempting to use ImpromptuInterface to solve the issue I am having here. Adding Interface Implementation to ExpandoObject. I am now able to access various properties of my interface in my base class but I can no longer subscribe to…
Derrick Moeller
  • 4,808
  • 2
  • 22
  • 48
2
votes
1 answer

Runtime multiple inheritance with impromptu-interface

I'm trying to get runtime multiple inheritance to work using impromptu-interface but I'm stuck when I want to pass the object along to a method. public interface IEngine { void Foo(); } public interface IWheels { void Foo(); } public…
user152949
2
votes
2 answers

How to access proxied object using impromptu-interface

How can I get access to the Duck Typed proxied object when using impromptu-interface. consider my code that illustrates my example where I get a InvalidCastException when I try to cast my Duck Typed Object to the proxied Object: using System; using…
RedStar72
  • 23
  • 5
2
votes
1 answer

Impromptu: Could not load type because it attempts to implement a class as an interface

I have just started using Impromptu after a recommendation from someone on stack. I believe I have implemented it correctly but I am getting the error "Could not load type because it attempts to implement a class as an interface" In my portable…
Trevor Daniel
  • 3,785
  • 12
  • 53
  • 89
2
votes
2 answers

How do I resolve this enum cast issue when using ImpromptuInterface?

Given the following code: public enum Pet { Cat, Dog } public interface IOwner { Pet Pet { get; set; } } public class Owner : IOwner { public Pet Pet { get; set; } } The following…
David Peden
  • 17,596
  • 6
  • 52
  • 72
1
vote
2 answers

Use ExpandoObject to create a 'fake' implementation of an interface - adding methods dynamically

A brainteaser for you! I am developing a modular system, in such a way that module A could need module B and module B could also need module A. But if module B is disabled, it will simply not execute that code and do nothing / return null. A little…
CularBytes
  • 9,924
  • 8
  • 76
  • 101
1
vote
0 answers

Returning Impromptu Object As Class?

I am trying to create a context class that detects any changes to a property. I was able to achieve this by using the ImpromptuInterface package. public class DynamicProxy : DynamicObject, INotifyPropertyChanged where T : class, new() { …
Josh Monreal
  • 754
  • 1
  • 9
  • 29
1
vote
1 answer

Using Impromptu-Interface to obtain the type of a property

I've got a complex solution where part of the problem is model binding from a HTML form to a series of database backed and relatively complex Entity Framework DbSets. The thing is, we have an EF defined domain model that encapsulates everything we'd…
Russ Clarke
  • 17,511
  • 4
  • 41
  • 45
1
vote
1 answer

Custom impromptuobject for json.net deserialization

I was playing around with impromptu interface over a jobject and ran into the following issue https://code.google.com/p/impromptu-interface/issues/detail?id=17 The issue is marked as 'Won't fix' and in the comments the author says that it could be…
Yves Goeleven
  • 2,185
  • 15
  • 13
1
vote
1 answer

What is the best way to map from/to a Dictionary with objects properties based on an interface as contract?

I'm working on a very dynamic Silverlight Application where viewmodels are dynamic models. The WCF service returns a Response object that contains enough information (TableName property and an Dictionary[] array containing entities). So, suppose I…
1
vote
1 answer

How do I make multiple event bindings with ImpromptuInterface.MVVM?

Binding to a single event with ImpromptuInterface.MVVM is very simple:
dkantowitz
  • 1,931
  • 1
  • 16
  • 22
1
2