示例#1
0
        public async Task <NavigationNode> AddAsync(NavigationNodeCreationInformation creationInformation, CancellationToken cancellationToken)
        {
            if (creationInformation == null)
            {
                throw new ArgumentNullException(nameof(creationInformation));
            }

#pragma warning disable CA1303 // Do not pass literals as localized parameters
#pragma warning disable CA2208 // Instantiate argument exceptions correctly

            if (string.IsNullOrEmpty(creationInformation.Title))
            {
                throw new ArgumentException(paramName: nameof(creationInformation.Title), message: "Title must be provided");
            }
            if (creationInformation.Url == null)
            {
                throw new ArgumentException(paramName: nameof(creationInformation.Url), message: "URL must be provided");
            }

#pragma warning restore CA2208 // Instantiate argument exceptions correctly
#pragma warning restore CA1303 // Do not pass literals as localized parameters

            this.ContentType = "application/json";
            this.Method      = System.Net.Http.HttpMethod.Post.Method;
            var newEntity = await this.SendAsync <NavigationNode>(creationInformation, cancellationToken).ConfigureAwait(false);

            return(newEntity);
        }
示例#2
0
 public Task <NavigationNode> AddAsync(NavigationNodeCreationInformation creationInformation)
 {
     return(this.AddAsync(creationInformation, CancellationToken.None));
 }