Esempio n. 1
0
 /// <summary>
 /// Returns all Caches the user has access to under a resource group.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Target resource group.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <CachesListResult> ListByResourceGroupAsync(this ICaches operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Esempio n. 2
0
        private async Task <CacheUser> CreateExpectedDocumentAsync(ICaches caches, string id = null, DateTime?createdAt = null)
        {
            // Create the document.
            var expectedDocument = new CacheUser
            {
                Id        = id ?? this.global.RandomId(),
                VersionId = this.global.RandomId(),
                Handle    = "testhandle",
                Email     = "*****@*****.**",
                Entity    = "https://entity.quentez.com",
                CreatedAt = createdAt.GetValueOrDefault(DateTime.UtcNow)
            };

            // Create its various cache Ids.
            var cacheIds = new string[]
            {
                $"id/{this.global.EncodeCacheKeyPart(expectedDocument.Id)}",
                $"id-version/{this.global.EncodeCacheKeyPart(expectedDocument.Id)}/{this.global.EncodeCacheKeyPart(expectedDocument.VersionId)}",
                $"entity/{this.global.EncodeCacheKeyPart(expectedDocument.Entity)}",
                $"email/{this.global.EncodeCacheKeyPart(expectedDocument.Email)}"
            };

            // Add it to the cache.
            await caches.Users.SaveAsync(cacheIds, expectedDocument);

            return(expectedDocument);
        }
Esempio n. 3
0
 /// <summary>
 /// Upgrade a Cache's firmware if a new version is available. Otherwise, this
 /// operation has no effect.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Target resource group.
 /// </param>
 /// <param name='cacheName'>
 /// Name of Cache. Length of name must be not greater than 80 and chars must be
 /// in list of [-0-9a-zA-Z_] char class.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <object> UpgradeFirmwareAsync(this ICaches operations, string resourceGroupName, string cacheName, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.UpgradeFirmwareWithHttpMessagesAsync(resourceGroupName, cacheName, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Create or update a Cache.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Target resource group.
 /// </param>
 /// <param name='cacheName'>
 /// Name of Cache. Length of name must be not greater than 80 and chars must be
 /// in list of [-0-9a-zA-Z_] char class.
 /// </param>
 /// <param name='cache'>
 /// Object containing the user-selectable properties of the new Cache. If
 /// read-only properties are included, they must match the existing values of
 /// those properties.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <Cache> CreateOrUpdateAsync(this ICaches operations, string resourceGroupName, string cacheName, Cache cache = default(Cache), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, cacheName, cache, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Esempio n. 5
0
        public ResourceCacheService(
            ITables tables,
            ICaches caches,
            ITextHelpers textHelpers)
        {
            Ensure.Argument.IsNotNull(tables, nameof(tables));
            Ensure.Argument.IsNotNull(caches, nameof(caches));
            Ensure.Argument.IsNotNull(textHelpers, nameof(textHelpers));

            this.tables      = tables;
            this.caches      = caches;
            this.textHelpers = textHelpers;

            // Create our collections.
            this.resources     = new Dictionary <string, object>();
            this.resourceLocks = new Dictionary <string, AsyncLock>();
        }
Esempio n. 6
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="settings"></param>
        /// <param name="logger"></param>
        public MasterEditorViewModel(ISettings settings, ILogger logger)
        {
            this._settings = settings;
            this._logger   = logger;
            this._master   = this._settings.Master;
            this._caches   = this._settings.Caches;

            this.MealTypes = this._master.MealTypes.ToReadOnlyReactiveCollection().AddTo(this.CompositeDisposable);

            this.Users = this._caches.Users.ToReadOnlyReactiveCollection().AddTo(this.CompositeDisposable);

            this.CreateHolidayDataCommand.Subscribe(async() => {
                await Holiday.CreateHolidayMaster(settings, logger);
            });

            this.AddMealTypeCommand = this.MealNameToAdd.Select(x => !string.IsNullOrEmpty(x)).ToReactiveCommand().AddTo(this.CompositeDisposable);
            this.AddMealTypeCommand.Subscribe(_ => {
                this._master.AddMealType(this.MealNameToAdd.Value);
                this.MealNameToAdd.Value = "";
            }).AddTo(this.CompositeDisposable);

            this.RemoveMealTypeCommand.Subscribe(id => {
                this._master.RemoveMealType(id);
            }).AddTo(this.CompositeDisposable);

            this.AddUserCommand = this.UserNameToAdd.Select(x => !string.IsNullOrEmpty(x)).ToReactiveCommand().AddTo(this.CompositeDisposable);
            this.AddUserCommand.Subscribe(_ => {
                this._caches.Users.Add(new Composition.User.User(0, this.UserNameToAdd.Value));
                this.UserNameToAdd.Value = "";
            }).AddTo(this.CompositeDisposable);

            this.RemoveUserCommand.Subscribe(id => {
                this._caches.Users.Remove(this.Users.Single(x => x.Id.Value == id));
            }).AddTo(this.CompositeDisposable);

            this.IsValidated = new ReactiveProperty <bool>(true);
        }
Esempio n. 7
0
 /// <summary>
 /// Schedules a Cache for deletion.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Target resource group.
 /// </param>
 /// <param name='cacheName'>
 /// Name of Cache. Length of name must be not greater than 80 and chars must be
 /// in list of [-0-9a-zA-Z_] char class.
 /// </param>
 public static object Delete(this ICaches operations, string resourceGroupName, string cacheName)
 {
     return(operations.DeleteAsync(resourceGroupName, cacheName).GetAwaiter().GetResult());
 }
Esempio n. 8
0
 /// <summary>
 /// Returns all Caches the user has access to under a resource group.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Target resource group.
 /// </param>
 public static CachesListResult ListByResourceGroup(this ICaches operations, string resourceGroupName)
 {
     return(operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult());
 }
Esempio n. 9
0
 /// <summary>
 /// Upgrade a Cache's firmware if a new version is available. Otherwise, this
 /// operation has no effect.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Target resource group.
 /// </param>
 /// <param name='cacheName'>
 /// Name of Cache. Length of name must be not greater than 80 and chars must be
 /// in list of [-0-9a-zA-Z_] char class.
 /// </param>
 public static object UpgradeFirmware(this ICaches operations, string resourceGroupName, string cacheName)
 {
     return(operations.UpgradeFirmwareAsync(resourceGroupName, cacheName).GetAwaiter().GetResult());
 }
Esempio n. 10
0
 /// <summary>
 /// Update a Cache instance.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Target resource group.
 /// </param>
 /// <param name='cacheName'>
 /// Name of Cache. Length of name must be not greater than 80 and chars must be
 /// in list of [-0-9a-zA-Z_] char class.
 /// </param>
 /// <param name='cache'>
 /// Object containing the user-selectable properties of the Cache. If read-only
 /// properties are included, they must match the existing values of those
 /// properties.
 /// </param>
 public static Cache Update(this ICaches operations, string resourceGroupName, string cacheName, Cache cache = default(Cache))
 {
     return(operations.UpdateAsync(resourceGroupName, cacheName, cache).GetAwaiter().GetResult());
 }
Esempio n. 11
0
 /// <summary>
 /// Returns all Caches the user has access to under a subscription.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 public static CachesListResult List(this ICaches operations)
 {
     return(operations.ListAsync().GetAwaiter().GetResult());
 }
 /// <summary>
 /// Schedules a Cache for deletion.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Target resource group.
 /// </param>
 /// <param name='cacheName'>
 /// Name of Cache. Length of name must not be greater than 80 and chars must be
 /// from the [-0-9a-zA-Z_] char class.
 /// </param>
 public static void Delete(this ICaches operations, string resourceGroupName, string cacheName)
 {
     operations.DeleteAsync(resourceGroupName, cacheName).GetAwaiter().GetResult();
 }
 /// <summary>
 /// Upgrade a Cache's firmware if a new version is available. Otherwise, this
 /// operation has no effect.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Target resource group.
 /// </param>
 /// <param name='cacheName'>
 /// Name of Cache. Length of name must not be greater than 80 and chars must be
 /// from the [-0-9a-zA-Z_] char class.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task UpgradeFirmwareAsync(this ICaches operations, string resourceGroupName, string cacheName, CancellationToken cancellationToken = default(CancellationToken))
 {
     (await operations.UpgradeFirmwareWithHttpMessagesAsync(resourceGroupName, cacheName, null, cancellationToken).ConfigureAwait(false)).Dispose();
 }