Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static readonly DependencyProperty ValueProperty =
- DependencyProperty.Register
- ( "Value"
- , typeof(T)
- , typeof(ValidatingTextBox<T,C>)
- , new FrameworkPropertyMetadata(default(T), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)
- );
- public static T MyDefault<T>(){
- switch(typeof(T)){
- case (typeof(String)) : return "";
- case (typeof(Foo)) : return new Foo();
- }
- }
- DefaultGenerator<T>.Default
- private static Dictionary<Type,Func<object>> factory = new Dictionary<Type,Func<object>>{
- {typeof(string), ()=> String.Empty },
- {typeof(MyClass), ()=> new MyClass() },
- };
- public static T MyDefault<T>()
- {
- Type t = typeof(T);
- Func<object> func = null;
- if(factory.TryGetValue(t, out func))
- return (T)func();
- else
- return default(T);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement