Exemplo n.º 1
0
        private async Task <List <PartialUpdateOperation> > GetUpdates(string Id, string message)
        {
            // Verify that the tags are a valid JSON array.
            var tags = JArray.Parse(message);

            // Define a collection of PartialUpdateOperations. Note that
            // only one '/tags' path is permitted in a given collection.
            var updates = new List <PartialUpdateOperation>();

            // Add a update operation for the tag.
            UpdateOperationType operation = UpdateOperationType.Replace;

            var existingTags = await GetTagsByInstallationId(Id);

            if (existingTags == null || !existingTags.Any())
            {
                operation = UpdateOperationType.Add;
            }

            updates.Add(new PartialUpdateOperation
            {
                Operation = operation,
                Path      = "/tags",
                Value     = tags.ToString()
            });

            return(updates);
        }
Exemplo n.º 2
0
            public AnimationBuilderStackEntry(Type type, int startIndex, int endIndex, int operationIndex)
            {
                Type       = type;
                StartIndex = startIndex;
                EndIndex   = endIndex;

                ObjectStartOffset = 0;

                Member         = null;
                LeaveOperation = UpdateOperationType.Invalid;
                LeaveOffset    = 0;

                OperationIndex = operationIndex;
            }
Exemplo n.º 3
0
            public AnimationBuilderStackEntry(Type type, int startIndex, int endIndex, int operationIndex)
            {
                Type = type;
                StartIndex = startIndex;
                EndIndex = endIndex;

                ObjectStartOffset = 0;

                Member = null;
                LeaveOperation = UpdateOperationType.Invalid;
                LeaveOffset = 0;

                OperationIndex = operationIndex;
            }
Exemplo n.º 4
0
        private async Task PatchTagsForUserDevicesAsync(Guid userId, UpdateOperationType op, string tag)
        {
            var devices = await _deviceRepository.GetManyByUserIdAsync(userId);

            var operation = new PartialUpdateOperation
            {
                Operation = op,
                Path      = "/tags",
                Value     = tag
            };

            foreach (var device in devices)
            {
                await _client.PatchInstallationAsync(device.Id.ToString(), new List <PartialUpdateOperation> {
                    operation
                });
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the DnsSecurityUpdateExtension class
        /// </summary>
        /// <param name="operationType">Update operation type</param>
        /// <param name="delSigData">Set of adding or changing delegation signer data items</param>
        public DnsSecurityUpdateExtension(UpdateOperationType operationType, params DelegationSignerData[] delSigData)
        {
            if (delSigData == null)
            {
                throw new ArgumentNullException("delSigData");
            }

            if (delSigData.Length == 0)
            {
                throw new ArgumentException("parameter must contain at least one DelegationSignerData object", "delSigData");
            }

            if (operationType == UpdateOperationType.Remove)
            {
                throw new ArgumentOutOfRangeException("operationType");
            }

            this.DelSigData    = Array.AsReadOnly(delSigData);
            this.OperationType = operationType;
        }
Exemplo n.º 6
0
        private async Task PatchTagsForUserDevicesAsync(IEnumerable <string> deviceIds, UpdateOperationType op,
                                                        string tag)
        {
            if (!deviceIds.Any())
            {
                return;
            }

            var operation = new PartialUpdateOperation
            {
                Operation = op,
                Path      = "/tags"
            };

            if (op == UpdateOperationType.Add)
            {
                operation.Value = tag;
            }
            else if (op == UpdateOperationType.Remove)
            {
                operation.Path += $"/{tag}";
            }

            foreach (var id in deviceIds)
            {
                try
                {
                    await _client.PatchInstallationAsync(id, new List <PartialUpdateOperation> {
                        operation
                    });
                }
                catch (Exception e)
                {
                    if (e.InnerException == null || !e.InnerException.Message.Contains("(404) Not Found"))
                    {
                        throw e;
                    }
                }
            }
        }
Exemplo n.º 7
0
        private async Task PatchTagsForUserDevicesAsync(IEnumerable <string> deviceIds, UpdateOperationType op, string tag)
        {
            if (!deviceIds.Any())
            {
                return;
            }

            var operation = new PartialUpdateOperation
            {
                Operation = op,
                Path      = "/tags",
                Value     = tag
            };

            foreach (var id in deviceIds)
            {
                await _client.PatchInstallationAsync(id, new List <PartialUpdateOperation> {
                    operation
                });
            }
        }