Example #1
0
        /// <summary>
        /// Creates a collection of <see cref="Field"/> objects corresponding to
        /// the properties of the type supplied.
        /// </summary>
        /// <typeparam name="T">
        /// The type for which fields will be created, based on its properties.
        /// </typeparam>
        /// <returns>A collection of fields.</returns>
        public static IList <Field> BuildForType <T>()
        {
            bool useCamelCase          = SerializePropertyNamesAsCamelCaseAttribute.IsDefinedOnType <T>();
            IContractResolver resolver = useCamelCase
                ? CamelCaseResolver
                : DefaultResolver;

            return(BuildForType <T>(resolver));
        }
        public Task <AzureOperationResponse <DocumentIndexResult> > IndexWithHttpMessagesAsync <T>(
            IndexBatch <T> batch,
            SearchRequestOptions searchRequestOptions         = default(SearchRequestOptions),
            Dictionary <string, List <string> > customHeaders = null,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            bool useCamelCase = SerializePropertyNamesAsCamelCaseAttribute.IsDefinedOnType <T>();
            JsonSerializerSettings jsonSettings = JsonUtility.CreateTypedSerializerSettings <T>(Client.SerializationSettings, useCamelCase);

            return(DoIndexAsync(batch, searchRequestOptions, customHeaders, jsonSettings, cancellationToken));
        }
        public async Task <DocumentIndexResponse> IndexAsync <T>(
            IndexBatch <T> batch,
            CancellationToken cancellationToken) where T : class
        {
            if (batch == null)
            {
                throw new ArgumentNullException("batch");
            }

            bool   useCamelCase = SerializePropertyNamesAsCamelCaseAttribute.IsDefinedOnType <T>();
            string payload      = JsonConvert.SerializeObject(batch, JsonUtility.CreateSerializerSettings <T>(useCamelCase));

            return(await DoIndexAsync(payload, cancellationToken).ConfigureAwait(false));
        }