protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); Forms.Init(this, savedInstanceState); Instance = this; TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; if (Intent.Extras != null) { foreach (var key in Intent.Extras.KeySet()) { var value = Intent.Extras.GetString(key); Log.Debug(TAG, "Key: {0} Value: {1}", key, value); } } MessagingInitializer.CheckPlayServicesAvailable(this); MessagingInitializer.CreateNotificationChannel(this); InjectionContainer.IoCContainer.Register <IMessageManager, MessageManager>(Lifestyle.Singleton); _tokenAccessor = new TokenAccessor(); LoadApplication(new App(_tokenAccessor)); }
public ArpaContext( DbContextOptions options, ITokenAccessor tokenAccessor, IDateTimeProvider dateTimeProvider) : base(options) { _tokenAccessor = tokenAccessor; _dateTimeProvider = dateTimeProvider; }
public App(ITokenAccessor tokenAccessor, int id = 0) { InitializeComponent(); Device.SetFlags(new[] { "SwipeView_Experimental" }); _tokenAccessor = tokenAccessor; MainPage = new MainPage(tokenAccessor, id); }
public Validator(IArpaContext arpaContext, ITokenAccessor tokenAccessor) { CascadeMode = CascadeMode.Stop; When(_ => tokenAccessor.UserRoles.Contains(RoleNames.Staff), () => { RuleFor(c => c.MusicianProfileId) .EntityExists <Query, MusicianProfile>(arpaContext, nameof(Query.MusicianProfileId)); }).Otherwise(() => { RuleFor(c => c.MusicianProfileId) .MustAsync(async(musicianProfileId, cancellation) => await arpaContext .EntityExistsAsync <MusicianProfile>(mp => mp.Id == musicianProfileId && mp.PersonId == tokenAccessor.PersonId, cancellation)) .OnFailure(_ => throw new AuthorizationException("This musician profile is not yours. You don't have access to this musician profile.")); }); }
public Validator(IArpaContext arpaContext, ITokenAccessor tokenAccessor) { CascadeMode = CascadeMode.Stop; RuleFor(c => c.Id) .EntityExists <Command, MusicianProfile>(arpaContext, nameof(Command.Id)); if (!tokenAccessor.UserRoles.Contains(RoleNames.Staff)) { RuleFor(c => c.Id) .MustAsync(async(musicianProfileId, cancellation) => await arpaContext .EntityExistsAsync <MusicianProfile>(mp => mp.Id == musicianProfileId && mp.PersonId == tokenAccessor.PersonId, cancellation)) .OnFailure(_ => throw new AuthorizationException("This musician profile is not yours. You don't have access to this musician profile.")); } RuleFor(c => c.Active) .MustAsync(async(command, active, cancellation) => active ? true : !(await arpaContext.FindAsync <MusicianProfile>(new object[] { command.Id }, cancellation)).ProjectParticipations.Select(pp => pp.Project).All(p => p.IsCompleted)) .WithMessage("You may not deactivate a musician profile which is participating in an active project"); // ToDo: Add additional validation rules if appropriate }
public FirebaseLogging(ITokenAccessor messaging) { _messaging = messaging; InitializeComponent(); }
public MainPage(ITokenAccessor tokenAccessor, int id = 0) { _tokenAccessor = tokenAccessor; InitializeComponent(); NavigateFromMenu(id); }
public void Setup() { _arpaContext = Substitute.For <IArpaContext>(); _tokenAccessor = Substitute.For <ITokenAccessor>(); _validator = new GetForMusicianProfile.Validator(_arpaContext, _tokenAccessor); }
public RoleBasedSetNullAction(ITokenAccessor tokenAccessor) { _tokenAccessor = tokenAccessor ?? throw new ArgumentNullException(nameof(tokenAccessor)); }
public HeaderHandler(IUserAccessor userAccessor = null, ITokenAccessor tokenAccessor = null) { _userAccessor = userAccessor; _tokenAccessor = tokenAccessor; }