Note that there are some explanatory texts on larger screens.

plurals
  1. PONo base class problem, How to use Castle.DynamicProxy Mixin in this particular case?
    primarykey
    data
    text
    <p>I have a 3rd party badly designed library that I must use.<br> It has all sorts of types it works with, we'll call them <strong>SomeType1</strong>, <strong>SomeType2</strong> etc.<br> None of those types share a common base class but all have a property named Value with a different return type.<br> All I want to do is to be able to Mixin this class so I'll be able to call <code>someType1Instance.Value</code> and <code>someType2Instance.Value</code> without caring what the concreate type it is and without caring what the return type is (I can use <code>object</code>).<br> So my code is currently: </p> <pre><code>public interface ISomeType&lt;V&gt; { V Value {get; set;} } public interface ISomeTypeWrapper { object Value { get; set; } } public class SomeTypeWrapper&lt;T&gt; : ISomeTypeWrapper where T : ISomeType&lt;???&gt; { T someType; public SomeTypeWrapper(T wrappedSomeType) { someType = wrappedSomeType } public object Value { get { return someType.Value; } set { someType.Value = value != null ? value : default(T); } } } public class SomeType1 { public int Value { get; set; } } public class SomeType2 { public string Value { get; set; } } </code></pre> <p>The problem is that I don't know what T might be until runtime due to the fact that I get a dictionary of objects. </p> <p>I can iterate the dictionary and use reflection to create a SomeWrapperType on runtime but I would like to avoid it.</p> <p>How can I mixin the concreate type of SomeType to ISomeType?<br> How can I know what V type parameter is? (wish I had typedefs and decltype like in c++)</p> <p>How can I, with the minimum of use of reflection possible Mixin those classes with the interface/base class? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload