コード例 #1
0
        protected virtual bool CheckAdminUserExists()
        {
            var adminUserExists = _applicationState.Get <bool>("AdminUserExists");

            if (!adminUserExists)
            {
                var(status, result) = _handler.HandleUserListRequest();
                if (status is Success && result.Users.Length != 0)
                {
                    _applicationState.Set("AdminUserExists", true);
                    adminUserExists = true;
                }
            }

            return(adminUserExists);
        }
コード例 #2
0
 public void Execute()
 {
     if (_myApplicationWideService.Has <string>("some-key"))
     {
         var someValue = _myApplicationWideService.Get <string>("some-key");
         // Do something with someValue
     }
     // Do something else like:
     _myApplicationWideService.Set("some-key", "some-value");
     // More logic here
 }
コード例 #3
0
 private static async Task HandleGetRequestAsync(IApplicationState myAppState, HttpContext context)
 {
     var key = context.Request.Query["key"];
     if (key.Count != 1)
     {
         await context.Response.WriteAsync("You must specify a single 'key' parameter like '?key=SomeAppStateKey'.");
         return;
     }
     var value = myAppState.Get<string>(key.Single());
     await context.Response.WriteAsync($"{key} = {value ?? "null"}");
 }