Table of Contents

Class BreezeConfig

Namespace
Breeze.Persistence
Assembly
Breeze.Persistence.dll

Server-wide Breeze settings: JSON serialization, transactions, and enum handling.

public class BreezeConfig
Inheritance
BreezeConfig
Inherited Members

Remarks

To change any of it, derive from this class and override the member concerned - the subclass is found by scanning the loaded assemblies, so nothing needs to register it. Exactly one subclass may be present.

Fields

FrameworkProductNames

Assembly product names treated as framework code by IsFrameworkAssembly(Assembly). Matched as prefixes.

protected static readonly List<string> FrameworkProductNames

Field Value

List<string>

Properties

IncludeLegacyErrorMembers

Whether an error response also carries the pre-3.0 Code, Message and EntityErrors members alongside the RFC 9457 ones.
Default is true, and it costs only a little duplication. RFC 9457 section 3.2 permits extension members and requires consumers to ignore ones they do not recognize, so the response is conformant either way; leaving this on means a breeze-client 2.x or 3.0 application reads errors exactly as it always has, with no coordinated upgrade.
Turn it off once every client is known to read the RFC 9457 members.

public virtual bool IncludeLegacyErrorMembers { get; set; }

Property Value

bool

IncludeStackTraceInErrors

Whether an error response includes the exception's stack trace.
Default is false. A stack trace names source files, line numbers and the directory layout of the machine that built the assembly, so returning it to every caller is an information disclosure. Turn it on deliberately, for development only:

BreezeConfig.Instance.IncludeStackTraceInErrors = env.IsDevelopment();
public virtual bool IncludeStackTraceInErrors { get; set; }

Property Value

bool

Instance

The configuration in force: the one subclass of BreezeConfig found in the loaded assemblies, or a default instance if there is none.

public static BreezeConfig Instance { get; }

Property Value

BreezeConfig

Exceptions

Exception

More than one subclass was found; only one may be defined.

ProbeAssemblies

The loaded assemblies that Breeze searches for entity types, key generators and a BreezeConfig subclass.

public static ReadOnlyCollection<Assembly> ProbeAssemblies { get; }

Property Value

ReadOnlyCollection<Assembly>

Remarks

Framework assemblies are excluded, and the list is rebuilt when new assemblies load.

QueryParamName

Name of query parameter for JSON query string.  Note that this must agree with what the client sends.<br />
Default is null, which means no parameter -- the JSON starts at the question mark: 
?{"take":5}

If non-null, then the JSON is the value of a named parameter.  E.g. if QueryParamName = "bq", then 
?bq={"take":5}
public virtual string? QueryParamName { get; set; }

Property Value

string

UseIntEnums

Whether to serialize enum values as string (false) or int (true). Default is false for backward compatibility. Switch to true for more C#-like behavior and see https://github.com/Breeze/breeze.server.net/issues/196 for guidance. Set this value early in startup, because it affects JSON serialization settings and metadata generation.

public virtual bool UseIntEnums { get; set; }

Property Value

bool

Methods

CreateJsonSerializerSettings()

Override to use a specialized JsonSerializer implementation.

protected virtual JsonSerializerSettings CreateJsonSerializerSettings()

Returns

JsonSerializerSettings

CreateJsonSerializerSettingsForSave()

Override to use a specialized JsonSerializer implementation for saving. Base implementation uses CreateJsonSerializerSettings() then sets TypeNameHandling to None

protected virtual JsonSerializerSettings CreateJsonSerializerSettingsForSave()

Returns

JsonSerializerSettings

GetJsonSerializerSettings()

The serializer settings used for query results, created once and cached.

public JsonSerializerSettings GetJsonSerializerSettings()

Returns

JsonSerializerSettings

The settings. Override CreateJsonSerializerSettings to change them.

GetJsonSerializerSettingsForSave()

The serializer settings used for reading a save bundle, created once and cached.

public JsonSerializerSettings GetJsonSerializerSettingsForSave()

Returns

JsonSerializerSettings

The settings. Override CreateJsonSerializerSettingsForSave to change them.

GetTransactionSettings()

Returns TransactionSettings.Default. Override to return different settings.

public virtual TransactionSettings GetTransactionSettings()

Returns

TransactionSettings

GetTypes(Assembly)

The types in an assembly, or an empty array if they cannot all be loaded.

protected static IEnumerable<Type> GetTypes(Assembly assembly)

Parameters

assembly Assembly

The assembly to read.

Returns

IEnumerable<Type>

Its types, or an empty array.

Remarks

A failure is traced rather than thrown: one unloadable assembly should not stop the probe.

IsFrameworkAssembly(Assembly)

Whether an assembly is a framework assembly, and so not worth searching for application types.

public static bool IsFrameworkAssembly(Assembly assembly)

Parameters

assembly Assembly

The assembly to test.

Returns

bool

True for the Microsoft, Entity Framework and NHibernate assemblies, and for anything whose product name is in FrameworkProductNames.