Coree.NETStandard
  • API
Show / Hide Table of Contents
  • Coree.NETStandard.Abstractions.DependencySingleton
    • DependencySingleton<T>
    • IDependencySingleton
  • Coree.NETStandard.Abstractions.FluentBase
    • FluentBase
    • IFluentBase
  • Coree.NETStandard.Abstractions.InitializationService
    • InitializationDependentServices
    • InitializationService
  • Coree.NETStandard.Abstractions.ServiceFactory
    • ServiceFactory<T>
  • Coree.NETStandard.Abstractions.ServiceFactoryEx
    • ServiceFactoryEx<T>
    • ServiceFactoryEx<T, K, R, S, U, V, W, X, Y, Z>
    • ServiceFactoryEx<T, K>
    • ServiceFactoryEx<T, K, R>
    • ServiceFactoryEx<T, K, R, S>
    • ServiceFactoryEx<T, K, R, S, U>
    • ServiceFactoryEx<T, K, R, S, U, V>
    • ServiceFactoryEx<T, K, R, S, U, V, W>
    • ServiceFactoryEx<T, K, R, S, U, V, W, X>
    • ServiceFactoryEx<T, K, R, S, U, V, W, X, Y>
  • Coree.NETStandard.Classes.AsyncEventCollection
    • AsyncEventCollection<T>
    • AsyncEventCollection<T>.CustomEventDelegate
  • Coree.NETStandard.Classes.CommonDistinguishedNameBuilder
    • CommonDistinguishedNameBuilder
    • DistinguishedName
  • Coree.NETStandard.Classes.Criteria
    • CriteriaComparisonMethod
    • CriteriaEnumerableExtensions
    • CriteriaExpressionBuilder
    • CriteriaItem<TValue>
    • CriteriaItems
    • CriteriaOperator
    • CriteriaQueryableExtensions
  • Coree.NETStandard.Classes.HttpRequestService
    • ContentComposer
    • HttpRequestHeadersExtensions
    • HttpRequestService
    • HttpRequestServiceHandler
    • HttpRequestServiceUriExtensions
    • ServiceCollectionExtensions
    • TransactionRecord
  • Coree.NETStandard.Classes.Scheduler
    • Scheduler
    • Scheduler.TickerEventArgs
    • Scheduler.TickerEventDelegate
  • Coree.NETStandard.Classes.ThreadSafeCollection
    • ThreadSafeCollection<T>
  • Coree.NETStandard.Classes.ThreadSafeValue
    • ThreadSafeValue<T>
  • Coree.NETStandard.Classes.TimeOfDay
    • TimeOfDay
  • Coree.NETStandard.Extensions.Collections.Enumerable
    • CollectionsEnumerableExtensions
  • Coree.NETStandard.Extensions.Collections.List
    • CollectionsListExtensions
  • Coree.NETStandard.Extensions.Conversions.ByteArray
    • ConversionsByteArrayExtensions
  • Coree.NETStandard.Extensions.Conversions.HostApplicationBuilder
    • ConversionsHostApplicationBuilderExtensions
  • Coree.NETStandard.Extensions.Conversions.String
    • ConversionsStringExtensions
    • Encodings
  • Coree.NETStandard.Extensions.Conversions.Stringbuilder
    • ConversionsStringbuilderExtension
  • Coree.NETStandard.Extensions.Enums
    • EnumExtensions
  • Coree.NETStandard.Extensions.Http.HttpHeader
    • HttpHeadersExtensions
  • Coree.NETStandard.Extensions.Primitives.Bool
    • PrimitivesBoolExtensions
  • Coree.NETStandard.Extensions.Reflection.ServiceProvider
    • ReflectionServiceProviderExtensions
  • Coree.NETStandard.Extensions.ServiceCollection
    • ServiceCollectionExtensions
  • Coree.NETStandard.Extensions.Threading.CancellationToken
    • ThreadingCancellationTokenExtensions
  • Coree.NETStandard.Extensions.Utilities
    • DateTimeExtensions
  • Coree.NETStandard.Extensions.Validations.String
    • ValidationsStringExtensions
  • Coree.NETStandard.HostedServicesCollection
    • HostedServicesCollectionConfig<T>
    • IHostedServicesCollectionConfig<T>
    • ServiceCollectionExtensions
    • ServiceProviderExtensions
  • Coree.NETStandard.Serilog
    • ConditionalLevelSink
    • CustomTheme
    • LoggerSinkConfigurationExtensions
    • OutputTemplates
    • ServiceCollectionExtensions
    • SourceContextShortEnricher
  • Coree.NETStandard.Services.DebugManagement
    • DebugService
    • IDebugService
  • Coree.NETStandard.Services.DirectoryOperationsManagement
    • DirectoryOperationsService
    • IDirectoryOperationsService
  • Coree.NETStandard.Services.FileManagement
    • FileService
    • IFileService
  • Coree.NETStandard.Services.FileOperationsManagement
    • FileOperationsService
    • FileOperationsService.FileSystemEntry
    • FileOperationsService.FileSystemInformation
    • FileOperationsService.VerifiedCopyStatus
    • IFileOperationsService
  • Coree.NETStandard.Services.HashManagement
    • HashService
    • IHashService
  • Coree.NETStandard.Services.NetworkManagement
    • INetworkService
    • NetworkService
    • NetworkService.IpAdressInformation
    • NetworkService.NetworkInterfaceDetail
  • Coree.NETStandard.Services.ProcessManagement
    • IProcessService
    • ProcessRunExitCodeState
    • ProcessRunResult
    • ProcessService
  • Coree.NETStandard.Services.RuntimeInsightsManagement
    • IRuntimeInsightsService
    • RuntimeInsightsService
  • Coree.NETStandard.SpectreConsole
    • CommandAppExtensions
    • HostBuilderExtensions
    • ServiceCollectionExtensions
    • SpectreConsoleHostedService
    • SpectreConsoleHostedService.ExitCode
    • SpectreConsoleTypeRegistrar
    • SpectreConsoleTypeResolver
  • Coree.NETStandard.UnderConstruction
    • DbContextExtensions
    • HttpClientStatic
    • HttpClientStatic.HttpClientResponse
    • HttpClientStatic.XRate
    • HttpClientStatic.XRateGroup
    • HttpClientStatic.XRateItem
    • IScheduleProvider
    • IntervalScheduleProvider
    • LimitedHistory<T>
    • ScheduleCombiner
    • Scheduler
    • Scheduler.TickerEventArgs
    • Scheduler.TickerEventDelegate
    • Scheduler2
    • Scheduler2.TickerEventArgs
    • Scheduler2.TickerEventDelegate
    • Scheduler3
    • Scheduler3.TickerEventArgs
    • Scheduler3.TickerEventDelegate
    • SqlliteMemoryContext
    • SqlliteMemoryContext.UserDataDto
    • TimedEntry<T>
    • Timing
    • Timing.Ticker
    • Timing.Ticker.TickerEventArgs
    • Timing.TickerSync
    • WeekDayAtScheduleProvider
  • Coree.NETStandard.Utilities
    • EventSubscription
    • MainContext

Class ContentComposer

Facilitates the creation and management of HTTP request content.

Inheritance
object
ContentComposer
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Coree.NETStandard.Classes.HttpRequestService
Assembly: Coree.NETStandard.dll
Syntax
public class ContentComposer

Constructors

| Edit this page View Source

ContentComposer()

Initializes a new instance of the ContentComposer with no initial content.

Declaration
public ContentComposer()
| Edit this page View Source

ContentComposer(byte[], string?)

Initializes a new instance of the ContentComposer and adds byte array content.

Declaration
public ContentComposer(byte[] bytes, string? name = null)
Parameters
Type Name Description
byte[] bytes

The byte array to be added as content.

string name

An optional name for the content part, useful in multipart form data scenarios.

Remarks

The content type for the byte array is set to 'application/octet-stream' by default.

| Edit this page View Source

ContentComposer(Dictionary<string, string>, string?)

Initializes a new instance of the ContentComposer with form URL encoded content from a dictionary.

Declaration
public ContentComposer(Dictionary<string, string> formData, string? name = null)
Parameters
Type Name Description
Dictionary<string, string> formData

The form data as a dictionary of key-value pairs.

string name

An optional name for the content part in multipart form data.

Remarks

This constructor is ideal for constructing content for HTTP POST requests using 'application/x-www-form-urlencoded'.

| Edit this page View Source

ContentComposer(Stream, string?, string?)

Initializes a new instance of the ContentComposer and adds stream content, suitable for large data uploads like files.

Declaration
public ContentComposer(Stream stream, string? name = null, string? filename = null)
Parameters
Type Name Description
Stream stream

The stream representing the content to be uploaded.

string name

An optional name for the content part, used in multipart form data.

string filename

An optional filename for the content part, used when adding file-based content in multipart form data.

Remarks

Stream content is not read into memory all at once, making this method suitable for large file uploads.

| Edit this page View Source

ContentComposer(string, string, Encoding?, string?)

Initializes a new instance of the ContentComposer and adds plain string content with a specified media type.

Declaration
public ContentComposer(string data, string mediaType, Encoding? encoding = null, string? name = null)
Parameters
Type Name Description
string data

The string data to add as content.

string mediaType

The media type to use for the content (e.g., "text/plain", "application/json").

Encoding encoding

The encoding of the string content, defaulting to UTF-8 if not specified.

string name

An optional descriptor for the content part, useful in multipart scenarios.

Remarks

This method directly adds string content with the specified media type, useful for simple text-based content types.

| Edit this page View Source

ContentComposer(string, Encoding?, string?)

Initializes a new instance of the ContentComposer and adds string content automatically determining the media type.

Declaration
public ContentComposer(string data, Encoding? encoding = null, string? name = null)
Parameters
Type Name Description
string data

The string data to be added as content.

Encoding encoding

The encoding to use for the content. Defaults to UTF-8 if not specified.

string name

An optional name for the content part in a multipart form data context.

Remarks

The content type is determined based on whether the data is valid JSON or XML. If neither, 'text/plain' is used.

Methods

| Edit this page View Source

AddAutoStringContent(string, Encoding?, string?)

Adds string content to the composer, automatically determining the appropriate media type based on the content.

Declaration
public void AddAutoStringContent(string data, Encoding? encoding = null, string? name = null)
Parameters
Type Name Description
string data

The string data to be added as content.

Encoding encoding

The encoding to use for the content. Defaults to UTF-8 if not specified.

string name

An optional name for the content part in a multipart form data context.

Remarks

This method checks if the data is valid JSON or XML and sets the content type accordingly. If neither JSON nor XML is detected, the content type defaults to 'text/plain'.

| Edit this page View Source

AddByteArrayContent(byte[], string?)

Adds byte array content to the composer.

Declaration
public void AddByteArrayContent(byte[] bytes, string? name = null)
Parameters
Type Name Description
byte[] bytes

The byte array to be added as content.

string name

An optional name for the content part, useful in multipart form data scenarios.

Remarks

This method wraps the provided byte array into a ByteArrayContent and sets the content type to 'application/octet-stream' by default.

| Edit this page View Source

AddFormUrlEncodedContent(Dictionary<string, string>, string?)

Adds form URL encoded content constructed from a dictionary of key-value pairs.

Declaration
public void AddFormUrlEncodedContent(Dictionary<string, string> formData, string? name = null)
Parameters
Type Name Description
Dictionary<string, string> formData

The dictionary containing form data as key-value pairs.

string name

An optional name for the content part in multipart form data.

Remarks

Use this method to encode dictionary data as 'application/x-www-form-urlencoded', which is commonly used in HTTP POST requests.

| Edit this page View Source

AddPlainStringContent(string, string, Encoding?, string?)

Adds plain string content with a specified media type to the content composer.

Declaration
public void AddPlainStringContent(string data, string mediaType, Encoding? encoding = null, string? name = null)
Parameters
Type Name Description
string data

The string data to add as content.

string mediaType

The media type to use for the content (e.g., "text/plain", "application/json").

Encoding encoding

The encoding of the string content, defaulting to UTF-8 if not specified.

string name

An optional descriptor for the content part, useful in multipart scenarios.

Remarks

This method directly adds string content with the specified media type, useful for simple text-based content types.

| Edit this page View Source

AddStreamContent(Stream, string?, string?)

Adds stream content to the composer, useful for large data uploads like files.

Declaration
public void AddStreamContent(Stream stream, string? name = null, string? filename = null)
Parameters
Type Name Description
Stream stream

The stream representing the content to be uploaded.

string name

An optional name for the content part, used in multipart form data.

string filename

An optional filename for the content part, used when adding file-based content in multipart form data.

Remarks

Stream content is not read into memory all at once, making this method suitable for large file uploads.

| Edit this page View Source

Build()

Consolidates all added content into a single HttpContent instance, suitable for HTTP transmission.

Declaration
public HttpContent? Build()
Returns
Type Description
HttpContent

A HttpContent instance containing all the previously added content pieces, or null if no content was added.

Remarks

If multiple content pieces are added, they are combined into a MultipartFormDataContent. If only one piece is added, it is returned directly.

  • Edit this page
  • View Source
In this article
Back to top