本文整理汇总了C#中IMvxBundle.Read方法的典型用法代码示例。如果您正苦于以下问题:C# IMvxBundle.Read方法的具体用法?C# IMvxBundle.Read怎么用?C# IMvxBundle.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMvxBundle
的用法示例。
在下文中一共展示了IMvxBundle.Read方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例2: InitFromBundle
protected override void InitFromBundle(IMvxBundle parameters)
{
var nutritionTable = parameters.Read<NutritionTable>();
Score = NutritionService.GetScore(nutritionTable);
Balance = Mvx.Create<BalanceViewModel>();
Balance.Update(nutritionTable);
}
示例3: InvokeMethodWithBundle
/// <summary>
/// Invokes a method using a bundle to find the appropriate
/// invocation parameters.
/// </summary>
/// <param name="controller"></param>
/// <param name="methodInfo"></param>
/// <param name="bundle"></param>
public static void InvokeMethodWithBundle(this IMvxController controller, MethodInfo methodInfo, IMvxBundle bundle)
{
if (bundle.Data.Count == 0)
{
return;
}
ParameterInfo[] parameterInfoArray = methodInfo.GetParameters();
if (parameterInfoArray.Length == 1 && parameterInfoArray[0].ParameterType == typeof(IMvxBundle))
{
//Method accepts bundle directly as parameter.
methodInfo.Invoke(controller, new object[]
{
bundle
});
}
else if (parameterInfoArray.Length == 1 &&
!MvxSingleton<IMvxSingletonCache>.Instance.Parser.TypeSupported(parameterInfoArray[0].ParameterType))
{
//Single parameter is an aggregate type that the bundle can deserialize
object obj = bundle.Read(parameterInfoArray[0].ParameterType);
methodInfo.Invoke(controller, new[]
{
obj
});
}
else
{
//Bundle is an argument list.
object[] parameters = bundle.CreateArgumentList(parameterInfoArray, controller.GetType().Name).ToArray();
methodInfo.Invoke(controller, parameters);
}
}
示例4: InitFromBundle
protected override void InitFromBundle(IMvxBundle parameters)
{
base.InitFromBundle(parameters);
var nutritionTable = parameters.Read<NutritionTable>();
Update(nutritionTable);
}