本文整理汇总了C#中IMvxBundle类的典型用法代码示例。如果您正苦于以下问题:C# IMvxBundle类的具体用法?C# IMvxBundle怎么用?C# IMvxBundle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IMvxBundle类属于命名空间,在下文中一共展示了IMvxBundle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CallBundleMethod
public static void CallBundleMethod(this IMvxViewModel viewModel, MethodInfo methodInfo, IMvxBundle bundle)
{
var parameters = methodInfo.GetParameters().ToArray();
if (parameters.Count() == 1
&& parameters[0].ParameterType == typeof(IMvxBundle))
{
// this method is the 'normal' interface method
methodInfo.Invoke(viewModel, new object[] { bundle });
return;
}
if (parameters.Count() == 1
&& !MvxSingletonCache.Instance.Parser.TypeSupported(parameters[0].ParameterType))
{
// call method using typed object
var value = bundle.Read(parameters[0].ParameterType);
methodInfo.Invoke(viewModel, new[] { value });
return;
}
// call method using named method arguments
var invokeWith = bundle.CreateArgumentList(parameters, viewModel.GetType().Name)
.ToArray();
methodInfo.Invoke(viewModel, invokeWith);
}
开发者ID:MvvmCross,项目名称:MvvmCross,代码行数:25,代码来源:MvxViewModelExtensions.cs
示例2: Load
public virtual IMvxViewModel Load(Intent intent, IMvxBundle savedState, Type viewModelTypeHint)
{
if (intent == null)
{
MvxTrace.Error("Null Intent seen when creating ViewModel");
return null;
}
if (intent.Action == Intent.ActionMain)
{
MvxTrace.Trace("Creating ViewModel for ActionMain");
return this.DirectLoad(savedState, viewModelTypeHint);
}
if (intent.Extras == null)
{
MvxTrace.Trace("Null Extras seen on Intent when creating ViewModel - have you tried to navigate to an MvvmCross View directly? Will try direct load");
return this.DirectLoad(savedState, viewModelTypeHint);
}
IMvxViewModel mvxViewModel;
if (this.TryGetEmbeddedViewModel(intent, out mvxViewModel))
{
MvxTrace.Trace("Embedded ViewModel used");
return mvxViewModel;
}
MvxTrace.Trace("Attempting to load new ViewModel from Intent with Extras");
var toReturn = this.CreateViewModelFromIntent(intent, savedState);
if (toReturn != null)
return toReturn;
MvxTrace.Trace("ViewModel not loaded from Extras - will try DirectLoad");
return this.DirectLoad(savedState, viewModelTypeHint);
}
开发者ID:MvvmCross,项目名称:MvvmCross,代码行数:35,代码来源:MvxAndroidViewsContainer.cs
示例3: OnCreate
public static void OnCreate(this IMvxFragmentView fragmentView, IMvxBundle bundle, MvxViewModelRequest request = null)
{
if (fragmentView.ViewModel != null)
{
//TODO call MvxViewModelLoader.Reload when it's added in MvvmCross, tracked by #1165
//until then, we're going to re-run the viewmodel lifecycle here.
RunViewModelLifecycle(fragmentView.ViewModel, bundle, request);
return;
}
Fragment fragment = fragmentView as Fragment;
if (fragmentView == null)
throw new InvalidOperationException($"Something really weird. ${nameof(fragmentView)} passed is not a Fragment!");
// as it is called during onCreate it is safe to assume that fragment has Activity attached.
var viewModelType = fragmentView.FindAssociatedViewModelType(fragment.Activity.GetType());
var view = fragmentView as IMvxView;
var cache = Mvx.Resolve<IMvxMultipleViewModelCache>();
var cached = cache.GetAndClear(viewModelType, fragmentView.UniqueImmutableCacheTag);
view.OnViewCreate(() => cached ?? LoadViewModel(fragmentView, bundle, fragment.Activity.GetType(), request));
}
开发者ID:MvvmCross,项目名称:MvvmCross,代码行数:25,代码来源:MvxFragmentExtensions.cs
示例4: Load
public virtual IMvxViewModel Load(Type viewModelType,
IMvxBundle parameterValues,
IMvxBundle savedState)
{
IMvxViewModel viewModel;
try
{
viewModel = (IMvxViewModel)Mvx.IocConstruct(viewModelType);
}
catch (Exception exception)
{
throw exception.MvxWrap("Problem creating viewModel of type {0}", viewModelType.Name);
}
try
{
CallCustomInitMethods(viewModel, parameterValues);
if (savedState != null)
{
CallReloadStateMethods(viewModel, savedState);
}
viewModel.Start();
}
catch (Exception exception)
{
throw exception.MvxWrap("Problem initialising viewModel of type {0}", viewModelType.Name);
}
return viewModel;
}
开发者ID:indazoo,项目名称:MvvmCross_DesignData,代码行数:30,代码来源:MvxDefaultViewModelLocator.cs
示例5: LoadViewModel
// private static IMvxBundle GetSavedStateFromBundle(Bundle bundle)
// {
// if (bundle == null)
// return null;
//
// IMvxSavedStateConverter converter;
// if (!Mvx.TryResolve<IMvxSavedStateConverter>(out converter))
// {
// MvxTrace.Trace("No saved state converter available - this is OK if seen during start");
// return null;
// }
// var savedState = converter.Read(bundle);
// return savedState;
// }
private static IMvxViewModel LoadViewModel(this IMvxUnityView unityView, IMvxBundle savedState = null)
{
#warning NullViewModel needed?
// how to do N
//if (typeof (TViewModel) == typeof (MvxNullViewModel))
// return new MvxNullViewModel() as TViewModel;
if (unityView.Request == null)
{
MvxTrace.Trace(
"Request is null - assuming this is a TabBar type situation where ViewDidLoad is called during construction... patching the request now - but watch out for problems with virtual calls during construction");
unityView.Request = Mvx.Resolve<IMvxCurrentRequest>().CurrentRequest;
}
var instanceRequest = unityView.Request as MvxViewModelInstanceRequest;
if (instanceRequest != null)
{
return instanceRequest.ViewModelInstance;
}
var loader = Mvx.Resolve<IMvxViewModelLoader>();
var viewModel = loader.LoadViewModel(unityView.Request, savedState);
if (viewModel == null)
throw new MvxException("ViewModel not loaded for " + unityView.Request.ViewModelType);
return viewModel;
}
开发者ID:ylyking,项目名称:mvx-unity-ngui,代码行数:42,代码来源:MvxViewControllerExtensionMethods.cs
示例6: Load
public virtual IMvxViewModel Load(Intent intent, IMvxBundle savedState, Type viewModelTypeHint)
{
if (intent == null)
{
MvxTrace.Error( "Null Intent seen when creating ViewModel");
return null;
}
if (intent.Action == Intent.ActionMain)
{
MvxTrace.Trace("Creating ViewModel for ActionMain");
var loaderService = Mvx.Resolve<IMvxViewModelLoader>();
var viewModelRequest = MvxViewModelRequest.GetDefaultRequest(viewModelTypeHint);
var viewModel = loaderService.LoadViewModel(viewModelRequest, savedState);
return viewModel;
}
if (intent.Extras == null)
{
MvxTrace.Error(
"Null Extras seen on Intent when creating ViewModel - this should not happen - have you tried to navigate to an MvvmCross View directly?");
return null;
}
IMvxViewModel mvxViewModel;
if (TryGetEmbeddedViewModel(intent, out mvxViewModel))
{
MvxTrace.Trace("Embedded ViewModel used");
return mvxViewModel;
}
MvxTrace.Trace("Loading new ViewModel from Intent with Extras");
return CreateViewModelFromIntent(intent, savedState);
}
开发者ID:darkice-matt-crombie,项目名称:MvxSpinnerTest,代码行数:34,代码来源:MvxAndroidViewsContainer.cs
示例7: Reload
public virtual IMvxViewModel Reload(IMvxViewModel viewModel,
IMvxBundle parameterValues,
IMvxBundle savedState)
{
RunViewModelLifecycle(viewModel, parameterValues, savedState);
return viewModel;
}
开发者ID:talisqualis,项目名称:MvvmCross-Build,代码行数:8,代码来源:MvxDefaultViewModelLocator.cs
示例8: GetDeviceFromBundle
protected IDevice GetDeviceFromBundle(IMvxBundle parameters)
{
if (!parameters.Data.ContainsKey(DeviceIdKey)) return null;
var deviceId = parameters.Data[DeviceIdKey];
return Adapter.ConnectedDevices.FirstOrDefault(d => d.Id.ToString().Equals(deviceId));
}
开发者ID:xabre,项目名称:xamarin-bluetooth-le,代码行数:8,代码来源:BaseViewModel.cs
示例9: InitFromBundle
protected override void InitFromBundle(IMvxBundle parameters)
{
// TODO get and cast incomming bundle to the parameter passed from FirstViewModel
// details here
// https://github.com/MvvmCross/MvvmCross/wiki/ViewModel--to-ViewModel-navigation
base.InitFromBundle(parameters);
}
开发者ID:muroslavko,项目名称:xamarin,代码行数:8,代码来源:DetailsViewModel.cs
示例10: InitFromBundle
protected override void InitFromBundle(IMvxBundle parameters)
{
string value;
if (parameters.Data != null && parameters.Data.TryGetValue("StationId", out value))
{
_followStation = _followService.GetFollowStation(value);
}
}
开发者ID:nycmobiledev,项目名称:transit-app,代码行数:8,代码来源:FollowEditViewModel.cs
示例11: InitFromBundle
protected override void InitFromBundle(IMvxBundle parameters)
{
var nutritionTable = parameters.Read<NutritionTable>();
Score = NutritionService.GetScore(nutritionTable);
Balance = Mvx.Create<BalanceViewModel>();
Balance.Update(nutritionTable);
}
开发者ID:SamirHafez,项目名称:Nutrition,代码行数:9,代码来源:InfoViewModel.cs
示例12: MvxViewModelRequest
public MvxViewModelRequest(Type viewModelType,
IMvxBundle parameterBundle,
IMvxBundle presentationBundle,
MvxRequestedBy requestedBy)
{
ViewModelType = viewModelType;
ParameterValues = parameterBundle.SafeGetData();
PresentationValues = presentationBundle.SafeGetData();
RequestedBy = requestedBy;
}
开发者ID:darkice-matt-crombie,项目名称:MvxSpinnerTest,代码行数:10,代码来源:MvxViewModelRequest.cs
示例13: 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;
}
}
}
开发者ID:woellij,项目名称:mvvmcross-controllers,代码行数:55,代码来源:ViewModelBinder.cs
示例14: LoadViewModel
public IMvxViewModel LoadViewModel(MvxViewModelRequest request, IMvxBundle savedState)
{
if (request.ViewModelType == typeof (MvxNullViewModel))
{
return new MvxNullViewModel();
}
var viewModelLocator = FindViewModelLocator(request);
return LoadViewModel(request, savedState, viewModelLocator);
}
开发者ID:ylyking,项目名称:mvx-unity-ngui,代码行数:11,代码来源:MvxViewModelLoader.cs
示例15: InitFromBundle
protected override async void InitFromBundle(IMvxBundle parameters)
{
base.InitFromBundle (parameters);
// TODO: heavy loading here
Loading = "Loading...";
Mvx.Trace (MvxTraceLevel.Diagnostic, "Before delay... instance id: {0:X}", this.GetHashCode());
await Task.Delay (3000);
Loading = null;
Mvx.Trace (MvxTraceLevel.Diagnostic, "After delay...");
}
开发者ID:skyflyer,项目名称:PlayingWithMvvmCross,代码行数:11,代码来源:FragViewModel.cs
示例16: CreateViewModelFromIntent
private IMvxViewModel CreateViewModelFromIntent(Intent intent, IMvxBundle savedState)
{
var extraData = intent.Extras.GetString(ExtrasKey);
if (extraData == null)
return null;
var converter = Mvx.Resolve<IMvxNavigationSerializer>();
var viewModelRequest = converter.Serializer.DeserializeObject<MvxViewModelRequest>(extraData);
return ViewModelFromRequest(viewModelRequest, savedState);
}
开发者ID:darkice-matt-crombie,项目名称:MvxSpinnerTest,代码行数:11,代码来源:MvxAndroidViewsContainer.cs
示例17: InitFromBundle
protected override void InitFromBundle(IMvxBundle parameters)
{
base.InitFromBundle(parameters);
_device = GetDeviceFromBundle(parameters);
if (_device == null)
{
Close(this);
}
}
开发者ID:xabre,项目名称:xamarin-bluetooth-le,代码行数:11,代码来源:ServiceListViewModel.cs
示例18: InitFromBundle
protected override void InitFromBundle(IMvxBundle bundle)
{
// TODO get and cast incomming bundle to the parameter passed from FirstViewModel
// details here
// https://github.com/MvvmCross/MvvmCross/wiki/ViewModel--to-ViewModel-navigation
string id = bundle.Data["id"];
_books.GetById(id, result => Book = result ,error => { });
base.InitFromBundle(bundle);
}
开发者ID:GerasimIG,项目名称:BSA-Xamarin-MvvmCross-Task,代码行数:11,代码来源:DetailsViewModel.cs
示例19: Load
public IMvxViewModel Load(Type viewModelType, IMvxBundle parameterValues, IMvxBundle savedState)
{
var viewModel = _coreViewModelLocator.Load(viewModelType, parameterValues, savedState);
if (viewModel != null)
{
_viewModelBinder.Bind(viewModel, parameterValues, savedState);
}
return viewModel;
}
开发者ID:woellij,项目名称:mvvmcross-controllers,代码行数:11,代码来源:BindingViewModelLocator.cs
示例20: SaveStateToBundle
protected override void SaveStateToBundle(IMvxBundle bundle)
{
if (AdditionalSaveStateFields != null)
{
foreach (var kvp in AdditionalSaveStateFields)
{
bundle.Data[kvp.Key] = kvp.Value;
}
}
base.SaveStateToBundle(bundle);
}
开发者ID:indazoo,项目名称:MvvmCross_DesignData,代码行数:11,代码来源:Test3ViewModel.cs
注:本文中的IMvxBundle类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论