/// <summary> /// Initializes a new instance of the <see cref="CompositeSearchValue"/> class. /// </summary> /// <param name="components">The composite component values.</param> public CompositeSearchValue(IReadOnlyList <IReadOnlyList <ISearchValue> > components) { EnsureArg.IsNotNull(components, nameof(components)); EnsureArg.HasItems(components, nameof(components)); Components = components; }
protected virtual string GenerateRequestBody(PostIndexRequest request) { EnsureArg.HasItems(request.Fields, nameof(request.Fields)); var sb = new StringBuilder(); sb.Append("{"); sb.AppendFormat("{0}", GenerateIndexContent(request.Fields)); if (!string.IsNullOrWhiteSpace(request.DesignDocument)) { sb.AppendFormat(FormatStrings.JsonPropertyAppendFormat, KeyNames.DesignDocument, Serializer.ToJson(request.DesignDocument)); } if (request.Type.HasValue) { sb.AppendFormat(FormatStrings.JsonPropertyAppendFormat, KeyNames.Type, Serializer.ToJson(request.Type.Value.AsString())); } if (!string.IsNullOrWhiteSpace(request.Name)) { sb.AppendFormat(FormatStrings.JsonPropertyAppendFormat, KeyNames.Name, Serializer.ToJson(request.Name)); } sb.Append("}"); return(sb.ToString()); }
public static byte[] Encrypt(byte[] data, byte[] iv, byte[] key) { EnsureArg.IsNotNull(iv, nameof(iv)); EnsureArg.HasItems(iv, nameof(iv)); EnsureArg.IsNotNull(key, nameof(key)); EnsureArg.HasItems(key, nameof(key)); if (data?.Any() == false) { return(null); } using var aes = Aes.Create(); aes.Key = key; aes.IV = iv; var transform = aes.CreateEncryptor(aes.Key, aes.IV); using var stream = new MemoryStream(); using var cryptoStream = new CryptoStream(stream, transform, CryptoStreamMode.Write); using (var streamWriter = new StreamWriter(cryptoStream)) { streamWriter.Write(data); } return(stream.ToArray()); }
/// <inheritdoc/> public async Task <Guid> StartReindexingInstancesAsync(IReadOnlyCollection <int> tagKeys, CancellationToken cancellationToken = default) { EnsureArg.IsNotNull(tagKeys, nameof(tagKeys)); EnsureArg.HasItems(tagKeys, nameof(tagKeys)); // Start the re-indexing orchestration Guid instanceGuid = _guidFactory.Create(); // TODO: Pass token when supported string instanceId = await _durableClient.StartNewAsync( FunctionNames.ReindexInstances, OperationId.ToString(instanceGuid), new ReindexInput { QueryTagKeys = tagKeys }); _logger.LogInformation("Successfully started new orchestration instance with ID '{InstanceId}'.", instanceId); // Associate the tags to the operation and confirm their processing IReadOnlyList <ExtendedQueryTagStoreEntry> confirmedTags = await _extendedQueryTagStore.AssignReindexingOperationAsync( tagKeys, instanceGuid, returnIfCompleted : true, cancellationToken : cancellationToken); return(confirmedTags.Count > 0 ? instanceGuid : throw new ExtendedQueryTagsAlreadyExistsException()); }
public override async Task <IReadOnlyList <int> > CompleteReindexingAsync(IReadOnlyCollection <int> queryTagKeys, CancellationToken cancellationToken = default) { EnsureArg.HasItems(queryTagKeys, nameof(queryTagKeys)); using SqlConnectionWrapper sqlConnectionWrapper = await ConnectionWrapperFactory.ObtainSqlConnectionWrapperAsync(cancellationToken); using SqlCommandWrapper sqlCommandWrapper = sqlConnectionWrapper.CreateSqlCommand(); IEnumerable <ExtendedQueryTagKeyTableTypeV1Row> rows = queryTagKeys.Select(x => new ExtendedQueryTagKeyTableTypeV1Row(x)); VLatest.CompleteReindexing.PopulateCommand(sqlCommandWrapper, rows); try { var keys = new List <int>(); using SqlDataReader reader = await sqlCommandWrapper.ExecuteReaderAsync(cancellationToken); while (await reader.ReadAsync(cancellationToken)) { keys.Add(reader.ReadRow(VLatest.ExtendedQueryTagString.TagKey)); } return(keys); } catch (SqlException ex) { throw new DataStoreException(ex); } }
/// <summary> /// Initializes a new instance of the <see cref="IncludeExpression"/> class. /// </summary> /// <param name="resourceTypes">The resource that supports the reference.</param> /// <param name="referenceSearchParameter">THe search parameter that establishes the reference relationship.</param> /// <param name="sourceResourceType">The source type of the reference.</param> /// <param name="targetResourceType">The target type of the reference.</param> /// <param name="referencedTypes">All the resource types referenced by resourceType</param> /// <param name="wildCard">If this is a wildcard reference include (include all referenced resources).</param> /// <param name="reversed">If this is a reversed include (revinclude) expression.</param> /// <param name="iterate"> If :iterate (:recurse) modifer was applied.</param> public IncludeExpression(string[] resourceTypes, SearchParameterInfo referenceSearchParameter, string sourceResourceType, string targetResourceType, IEnumerable <string> referencedTypes, bool wildCard, bool reversed, bool iterate) { EnsureArg.HasItems(resourceTypes, nameof(resourceTypes)); if (!wildCard) { EnsureArg.IsNotNull(referenceSearchParameter, nameof(referenceSearchParameter)); } if (reversed) { EnsureArg.IsNotNull(sourceResourceType, nameof(sourceResourceType)); } ResourceTypes = resourceTypes; ReferenceSearchParameter = referenceSearchParameter; SourceResourceType = sourceResourceType; TargetResourceType = targetResourceType; ReferencedTypes = referencedTypes?.ToList(); WildCard = wildCard; Reversed = reversed; Iterate = iterate; CircularReference = TargetResourceType != null ? SourceResourceType == TargetResourceType : ReferenceSearchParameter?.TargetResourceTypes != null && ReferenceSearchParameter.TargetResourceTypes.Contains(sourceResourceType); }
public virtual async Task <DeleteManyResult> DeleteManyAsync(DocumentHeader[] documents, CancellationToken cancellationToken = default) { ThrowIfDisposed(); EnsureArg.HasItems(documents, nameof(documents)); var request = new BulkRequest() .Delete(documents); var response = await Client.Documents.BulkAsync(request, cancellationToken); ThrowIfNotSuccessfulResponse(response); return(new DeleteManyResult { Rows = response.Rows.Select(r => new DeleteManyResult.Row { Id = r.Id, Rev = r.Rev, Error = r.Error, Reason = r.Reason, Deleted = r.Succeeded }).ToArray() }); }
/// <summary> /// The list of fields of the documents to be returned. /// </summary> /// <param name="fields"></param> /// <returns></returns> public virtual FindParametersConfigurator Fields(params string[] fields) { EnsureArg.HasItems(fields, nameof(fields)); Parameters.Fields = fields.ToList(); return(this); }
/// <summary> /// List of fields with sort directions to specify sorting of results. /// </summary> /// <param name="fields"></param> /// <returns></returns> public virtual FindParametersConfigurator Sort(params SortableField[] fields) { EnsureArg.HasItems(fields, nameof(fields)); Parameters.Sort = fields.ToList(); return(this); }
/// <summary> /// Returns only documents that matches any of the specified keys. /// </summary> /// <param name="value"></param> /// <returns></returns> public virtual QueryViewParametersConfigurator Keys <T>(params T[] value) { EnsureArg.HasItems(value, nameof(value)); Parameters.Keys = value.Select(i => i as object).ToArray(); return(this); }
public void Any_When_Array_predicate_yields_something_It_should_not_throw() { var values = new[] { 1, 2, 3, 4 }; ShouldNotThrow( () => Ensure.That(values, ParamName).Any(i => i == 1), () => EnsureArg.HasItems(values, ParamName)); }
public void HasItems_WhenNonEmptyArray_ShouldNotThrow() { var values = new[] { 1, 2, 3 }; ShouldNotThrow( () => Ensure.That(values, ParamName).HasItems(), () => EnsureArg.HasItems(values, ParamName)); }
public void HasItems_WhenNullIDictionary_ThrowsArgumentNullException() { var nullDictionary = null as IDictionary <int, string>; AssertIsNotNull( () => Ensure.That(nullDictionary, ParamName).HasItems(), () => EnsureArg.HasItems(nullDictionary, ParamName)); }
public void HasItems_WhenNullIList_ThrowsArgumentNullException() { var nullList = null as IList <int>; AssertIsNotNull( () => Ensure.That(nullList, ParamName).HasItems(), () => EnsureArg.HasItems(nullList, ParamName)); }
public void HasItems_WhenNullICollection_ThrowsArgumentNullException() { var nullCollection = null as ICollection <int>; AssertIsNotNull( () => Ensure.That(nullCollection, ParamName).HasItems(), () => EnsureArg.HasItems(nullCollection, ParamName)); }
/// <summary> /// Index fields /// </summary> /// <param name="fields">Fields</param> /// <returns></returns> public virtual IndexParametersConfigurator Fields(params string[] fields) { EnsureArg.HasItems(fields, nameof(fields)); Parameters.Fields = fields.Select(f => new SortableField(f)).ToList(); return(this); }
public Unsubscriber(IList <IObserver <T> > observers, IObserver <T> observer) { EnsureArg.HasItems(observers, nameof(observers)); EnsureArg.IsNotNull(observer, nameof(observer)); _observers = observers; _observer = observer; }
/// <summary> /// Index fields /// </summary> /// <param name="fields">Fields</param> /// <returns></returns> public virtual IndexParametersConfigurator Fields(params SortableField[] fields) { EnsureArg.HasItems(fields, nameof(fields)); Parameters.Fields = fields.ToList(); return(this); }
public void HasItems_WhenEmptyIReadonlyCollection_ThrowsArgumentException() { IReadOnlyCollection <int> emptyCollection = new ReadOnlyCollection <int>(new List <int>()); AssertIsEmptyCollection( () => Ensure.That(emptyCollection, ParamName).HasItems(), () => EnsureArg.HasItems(emptyCollection, ParamName)); }
public void HasItems_WhenEmptyIList_ThrowsArgumentException() { IList <int> emptyList = new List <int>(); AssertIsEmptyCollection( () => Ensure.That(emptyList, ParamName).HasItems(), () => EnsureArg.HasItems(emptyList, ParamName)); }
public void HasItems_WhenNullArray_ThrowsArgumentNullException() { var nullArray = null as int[]; AssertIsNotNull( () => Ensure.That(nullArray, ParamName).HasItems(), () => EnsureArg.HasItems(nullArray, ParamName)); }
public void HasItems_WhenEmptyArray_ThrowsArgumentException() { var emptyArray = new int[] { }; AssertIsEmptyCollection( () => Ensure.That(emptyArray, ParamName).HasItems(), () => EnsureArg.HasItems(emptyArray, ParamName)); }
public void HasItems_WhenEmptyDictionary_ThrowsArgumentException() { var emptyDict = new Dictionary <string, int>(); AssertIsEmptyCollection( () => Ensure.That(emptyDict, ParamName).HasItems(), () => EnsureArg.HasItems(emptyDict, ParamName)); }
public void HasItems_WhenEmptyCollection_ThrowsArgumentException() { var emptyCollection = new Collection <int>(); AssertIsEmptyCollection( () => Ensure.That(emptyCollection, ParamName).HasItems(), () => EnsureArg.HasItems(emptyCollection, ParamName)); }
public virtual QueryShowParametersConfigurator CustomQueryParameters(IDictionary <string, object> parameters) { EnsureArg.HasItems(parameters, nameof(parameters)); Parameters.CustomQueryParameters = parameters; return(this); }
public virtual QueryShowParametersConfigurator Accepts(params string[] accepts) { EnsureArg.HasItems(accepts, nameof(accepts)); Parameters.Accepts = accepts; return(this); }
private StructureBuilder( IDictionary <Type, IStructureSchema> schemas, IStructureIndexesFactory indexesFactory = null) { EnsureArg.HasItems(schemas, nameof(schemas)); Schemas = schemas; IndexesFactory = indexesFactory ?? new StructureIndexesFactory(); }
public async Task <MsgOp> RequestAsync(string subject, byte[] body, int?timeoutMs = null) { ThrowIfDisposed(); EnsureArg.IsNotNullOrWhiteSpace(subject, nameof(subject)); EnsureArg.HasItems(body, nameof(body)); return(await DoRequestAsync(subject, body, timeoutMs).ConfigureAwait(false)); }
public void HasItems_WhenNonEmptyCollection_ShouldNotThrow() { var collection = new Collection <int> { 1, 2, 3 }; ShouldNotThrow( () => Ensure.That(collection, ParamName).HasItems(), () => EnsureArg.HasItems(collection, ParamName)); }
public AuthorizationHandler(IEnumerable <string> acceptableKeys) { EnsureArg.IsNotNull(acceptableKeys, nameof(acceptableKeys)); var collection = acceptableKeys.ToList(); EnsureArg.HasItems(collection, nameof(acceptableKeys)); this.acceptableKeys = new HashSet <string>(collection); }