public IExpressionNode Visit(IExpressionNode node) { var member = node as IMemberExpressionNode; if (member?.Target == null) { return(node); } var target = member.Target as IMemberExpressionNode; var resourceType = target?.Target as ResourceExpressionNode; ResourceDescriptor resourceDescriptor; if (resourceType == null || !_resourceMemberToDescriptor.TryGetValue(target.Member, out resourceDescriptor)) { return(node); } if (resourceType.Dynamic || resourceDescriptor.GetResource == null) { return(new MethodCallExpressionNode(new ConstantExpressionNode(resourceDescriptor.ExtType, typeof(Type)), resourceDescriptor.MethodName, new IExpressionNode[] { new ConstantExpressionNode(member.Member, typeof(string)), new MemberExpressionNode(ResourceExpressionNode.DynamicInstance, BindingServiceProvider.ResourceResolver.SelfResourceName) }, null)); } var ctx = BindingResourceExtensions.GetContext(_lastContext?.GetData(BindingBuilderConstants.Target)); return(new ConstantExpressionNode(resourceDescriptor.GetResource(ctx, member.Member))); }
public bool Load(IModuleContext context) { if (context.PlatformInfo.Platform == PlatformType.Android) { BindingServiceProvider.Initialize(errorProvider: new AndroidBindingErrorProvider(), converter: BindingConverterExtensions.Convert); BindingServiceProvider.BindingProvider.DefaultBehaviors.Add(DisableEqualityCheckingBehavior.TargetTrueNotTwoWay); BindingResourceExtensions.Initialize(); } AndroidToolkitExtensions.ItemsSourceAdapterFactory = (o, ctx, arg3) => new ItemsSourceAdapter(o, ctx, !ReferenceEquals(ViewGroupItemsSourceGenerator.Context, arg3)); context.TryRegisterDataTemplateSelectorsAndValueConverters(null); MugenMvvmToolkit.Binding.AttachedMembersRegistration.RegisterDefaultMembers(); if (AndroidToolkitExtensions.IsApiGreaterThanOrEqualTo14) { var isActionBar = AndroidToolkitExtensions.IsActionBar; var isFragment = AndroidToolkitExtensions.IsFragment; AndroidToolkitExtensions.IsActionBar = o => isActionBar(o) || o is ActionBar; AndroidToolkitExtensions.IsFragment = o => isFragment(o) || o is Fragment; AttachedMembersRegistration.RegisterActionBarBaseMembers(); AttachedMembersRegistration.RegisterActionBarMembers(); AttachedMembersRegistration.RegisterActionBarTabMembers(); } AttachedMembersRegistration.RegisterObjectMembers(); AttachedMembersRegistration.RegisterViewBaseMembers(); AttachedMembersRegistration.RegisterViewMembers(); AttachedMembersRegistration.RegisterDialogMembers(); AttachedMembersRegistration.RegisterActivityMembers(); AttachedMembersRegistration.RegisterRatingBarMembers(); AttachedMembersRegistration.RegisterAdapterViewBaseMembers(); AttachedMembersRegistration.RegisterAdapterViewMembers(); AttachedMembersRegistration.RegisterViewGroupMembers(); AttachedMembersRegistration.RegisterTabHostMembers(); AttachedMembersRegistration.RegisterTextViewMembers(); AttachedMembersRegistration.RegisterAutoCompleteTextViewMembers(); AttachedMembersRegistration.RegisterDatePickerMembers(); AttachedMembersRegistration.RegisterTimePickerMembers(); AttachedMembersRegistration.RegisterImageViewMembers(); AttachedMembersRegistration.RegisterToolbarMembers(); AttachedMembersRegistration.RegisterButtonMembers(); AttachedMembersRegistration.RegisterCompoundButtonMembers(); AttachedMembersRegistration.RegisterSeekBarMembers(); AttachedMembersRegistration.RegisterMenuMembers(); AttachedMembersRegistration.RegisterMenuItemBaseMembers(); AttachedMembersRegistration.RegisterMenuItemMembers(); AttachedMembersRegistration.RegisterPopupMenuMembers(); AttachedMembersRegistration.RegisterMenuItemActionViewMembers(); AttachedMembersRegistration.RegisterMenuItemActionProviderMembers(); AttachedMembersRegistration.RegisterSearchViewMembers(); return(true); }