динамическое ключевое слово в C# 4.0
можно использовать динамическое ключевое слово, если Вы хотите, чтобы Ваши вызовы метода были разрешены только во времени выполнения.
dynamic invoker=new DynamicInvoker();
dynamic result1=invoker.MyMethod1();
dynamic result2=invoker.MyMethod2();
Здесь я реализую динамический invoker.
public class DynamicInvoker : IDynamicObject
{
public MetaObject GetMetaObject
(System.Linq.Expressions.Expression parameter)
{
return new DynamicReaderDispatch (parameter);
}
}
public class DynamicDispatcher : MetaObject
{
public DynamicDispatcher (Expression parameter)
: base(parameter, Restrictions.Empty){ }
public override MetaObject Call(CallAction action, MetaObject[] args)
{
//You'll get MyMethod1 and MyMethod2 here (and what ever you call)
Console.WriteLine("Logic to invoke Method '{0}'", action.Name);
return this; //Return a meta object
}
}
Расширить TabHost и переопределить методы:
@Override
public void setCurrentTab(int currentTab) {
if (currentTab != 2) // position of the tab that should not get selected
super.setCurrentTab(currentTab);
else
// in my case I want to trigger something here but I don't want the button to get selected
}
@Override
public void setCurrentTabByTag(String tag) {
if (!"\"plus_tab\"".equals(tag)) // tag of the tab that should not get selected
super.setCurrentTabByTag(tag);
else
// in my case I want to trigger something here but I don't want the button to get selected
}