本文整理汇总了C#中IMvxViewModel.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IMvxViewModel.GetType方法的具体用法?C# IMvxViewModel.GetType怎么用?C# IMvxViewModel.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMvxViewModel
的用法示例。
在下文中一共展示了IMvxViewModel.GetType方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Close
public override sealed void Close(IMvxViewModel viewModel)
{
if (_fragmentHostRegistrationSettings.IsTypeRegisteredAsFragment(viewModel.GetType()))
CloseFragment(viewModel);
else
CloseActivity(viewModel);
}
示例2: Bind
public void Bind(IMvxViewModel viewModel, IMvxBundle parameterValues = null, IMvxBundle savedState = null)
{
var controllerAware = viewModel as IControllerAware;
if (controllerAware != null)
{
var viewModelType = viewModel.GetType();
var name = viewModelType.FullName.Replace("ViewModel", "Controller");
Type controllerType = GetControllerTypeForViewModel(_getCreateableTypes(), viewModel);
if (controllerType == null)
{
throw new ArgumentException(string.Format("Controller for view model {0} cannot be found.", viewModelType));
}
try
{
var controller = (IMvxController) Mvx.IocConstruct(controllerType);
controllerAware.AttachController(controller);
var viewModelAware = controller as IViewModelAware;
if (viewModelAware != null)
{
viewModelAware.AttachViewModel(viewModel);
}
try
{
CallControllerInitMethods(controller, parameterValues);
if (savedState != null)
{
CallReloadStateMethods(controller, savedState);
}
}
catch (Exception ex)
{
MvxTrace.Error("MvxControllers: Problem initialising controller of type {0} - problem {1}",
controllerType.Name, ex.ToLongString());
throw;
}
controller.WaitForInitialize();
}
catch (Exception ex)
{
MvxTrace.Error("MvxControllers: Problem creating controller of type {0} - problem {1}",
controllerType,
ex.ToLongString());
throw;
}
}
}
示例3: RequestClose
public void RequestClose(IMvxViewModel viewModel)
{
var topPage = _frame.Content;
var view = topPage as IMvxView;
if (view == null)
{
MvxTrace.Trace("request close ignored for {0} - no current view", viewModel.GetType().Name);
return;
}
if (view.ViewModel != viewModel)
{
MvxTrace.Trace("request close ignored for {0} - current view is registered for a different viewmodel of type {1}", viewModel.GetType().Name, view.ViewModel.GetType().Name);
return;
}
MvxTrace.Trace("request close for {0} - will close current page {1}", viewModel.GetType().Name, view.GetType().Name);
_frame.GoBack();
}
示例4: Close
public virtual bool Close(IMvxViewModel viewModel)
{
//Workaround for closing fragments. This will not work when showing multiple fragments of the same viewmodel type in one activity
var frag = GetCurrentCacheableFragmentsInfo ().FirstOrDefault (x => x.ViewModelType == viewModel.GetType());
if (frag == null)
{
return false;
}
// Close method can not be fully fixed at this moment. That requires some changes in main MvvmCross library
CloseFragment(frag.Tag, frag.ContentId);
return true;
}
示例5: RequestClose
public void RequestClose(IMvxViewModel viewModel)
{
var nav = MasterNavigationController;
var top = nav.TopViewController;
var view = top as IMvxTouchView;
if (view == null)
{
MvxTrace.Trace("request close ignored for {0} - no current view controller", viewModel.GetType().Name);
return;
}
if (view.ViewModel != viewModel)
{
MvxTrace.Trace("request close ignored for {0} - current view controller is registered for a different viewmodel of type {1}", viewModel.GetType().Name, view.ViewModel.GetType().Name);
return;
}
MvxTrace.Trace("request close for {0} - will close current view controller {1}", viewModel.GetType().Name, view.GetType().Name);
nav.PopViewControllerAnimated(true);
}
示例6: RequestClose
public void RequestClose(IMvxViewModel viewModel)
{
var topActivity = Mvx.Resolve<IMvxAndroidCurrentTopActivity>();
var activity = topActivity.Activity;
var view = activity as IMvxAndroidView;
if (view == null)
{
MvxTrace.Trace("request close ignored for {0} - no current activity", viewModel.GetType().Name);
return;
}
if (view.ViewModel != viewModel)
{
MvxTrace.Trace("request close ignored for {0} - current activity is registered for a different viewmodel of type {1}", viewModel.GetType().Name, view.ViewModel.GetType().Name);
return;
}
MvxTrace.Trace("request close for {0} - will close current activity {1}", viewModel.GetType().Name, view.GetType().Name);
activity.Finish();
}
示例7: CreateView
public virtual IMvxTouchView CreateView(IMvxViewModel viewModel)
{
var viewModelType = viewModel.GetType();
var request = MvxShowViewModelRequest.GetDefaultRequest(viewModelType);
var view = CreateView(request);
var viewModelProperty = view.GetType().GetProperty("ViewModel");
if (viewModelProperty == null)
throw new MvxException("ViewModel Property missing for " + view.GetType());
if (!viewModelProperty.CanWrite)
throw new MvxException("ViewModel Property readonly for " + view.GetType());
viewModelProperty.SetValue(view, viewModel, null);
return view;
}
示例8: RunViewModelLifecycle
protected void RunViewModelLifecycle(IMvxViewModel viewModel, IMvxBundle parameterValues, IMvxBundle savedState)
{
try
{
CallCustomInitMethods(viewModel, parameterValues);
if (savedState != null)
{
CallReloadStateMethods(viewModel, savedState);
}
viewModel.Start();
}
catch (Exception exception)
{
throw exception.MvxWrap("Problem running viewModel lifecycle of type {0}", viewModel.GetType().Name);
}
}
示例9: GetControllerTypeForViewModel
protected virtual Type GetControllerTypeForViewModel(IEnumerable<Type> createableTypes, IMvxViewModel viewModel)
{
var name = viewModel.GetType().FullName.Replace("ViewModel", "Controller");
var controllerType = createableTypes.FirstOrDefault(t => t.FullName == name);
if (controllerType == null)
{
throw new ArgumentException(string.Format("Controller type {0} cannot be found.", name));
}
return controllerType;
}
示例10: GetControl
public IMvxControl GetControl(IMvxViewModel viewModelType)
{
return GetControl(viewModelType.GetType());
}
示例11: MvxViewModelInstanceRequest
public MvxViewModelInstanceRequest(IMvxViewModel viewModelInstance)
: base(viewModelInstance.GetType(), null, null, MvxRequestedBy.Unknown)
{
_viewModelInstance = viewModelInstance;
}
示例12: RunViewModelLifecycle
private static void RunViewModelLifecycle(IMvxViewModel viewModel, IMvxBundle savedState,
MvxViewModelRequest request)
{
try
{
if (request != null)
{
var parameterValues = new MvxBundle(request.ParameterValues);
viewModel.CallBundleMethods("Init", parameterValues);
}
if (savedState != null)
{
viewModel.CallBundleMethods("ReloadState", savedState);
}
viewModel.Start();
}
catch (Exception exception)
{
throw exception.MvxWrap("Problem running viewModel lifecycle of type {0}", viewModel.GetType().Name);
}
}
示例13: FragmentInfo
public FragmentInfo(string title, string tag, Type fragmentType, IMvxViewModel viewModel, object parameterValuesObject = null)
: this(title, tag, fragmentType, viewModel.GetType(), parameterValuesObject)
{
ViewModel = viewModel;
}
示例14: GetIntentWithKeyFor
public virtual Tuple<Intent, int> GetIntentWithKeyFor(IMvxViewModel viewModel)
{
var request = MvxViewModelRequest.GetDefaultRequest(viewModel.GetType());
var intent = this.GetIntentFor(request);
var key = Mvx.Resolve<IMvxChildViewModelCache>().Cache(viewModel);
intent.PutExtra(SubViewModelKey, key);
return new Tuple<Intent, int>(intent, key);
}