Class RedbObjectFactory
Factory for creating typed RedbObject<TProps> objects
Ensures proper metadata initialization and caching integration
Usage example:
public static class RedbObjectFactory
Usage example:
1. Factory initialization (once at startup)
RedbObjectFactory.Initialize(schemeSyncProvider, ownerId: 1, whoChangeId: 1);
2. Fast creation without provider
var employee = RedbObjectFactory.CreateFast(new Employee { Name = "Ivan" });
3. Creation with automatic scheme determination
var employee = await RedbObjectFactory.CreateAsync(new Employee { Name = "Ivan" });
4. Child object creation
var child = await RedbObjectFactory.CreateChildAsync(parent, new Employee { Name = "Subordinate" });
5. Batch creation with cache optimization
var employees = await RedbObjectFactory.CreateBatchAsync(
new Employee { Name = "Ivan" },
new Employee { Name = "Peter" },
new Employee { Name = "Sidor" }
);
Inheritance
Properties
Methods
CreateAsync<TProps>()
Create a new object without property initialization
public static Task<RedbObject<TProps>> CreateAsync<TProps>() where TProps : class, new()
CreateAsync<TProps>(TProps, bool)
Create a new object with initialized properties
public static Task<RedbObject<TProps>> CreateAsync<TProps>(TProps properties, bool initializeMetadata) where TProps : class, new()
CreateAsync<TProps>(TProps)
Create a new object with initialized properties
public static Task<RedbObject<TProps>> CreateAsync<TProps>(TProps properties) where TProps : class, new()
CreateBatchAsync<TProps>(IEnumerable<TProps>, bool)
Batch creation of objects with cache preloading
public static Task<List<RedbObject<TProps>>> CreateBatchAsync<TProps>(IEnumerable<TProps> properties, bool initializeMetadata) where TProps : class, new()
CreateBatchAsync<TProps>(IEnumerable<TProps>)
Batch creation of objects with cache preloading
public static Task<List<RedbObject<TProps>>> CreateBatchAsync<TProps>(IEnumerable<TProps> properties) where TProps : class, new()
CreateBatchChildAsync<TProps>(IRedbObject, IEnumerable<TProps>, bool)
Batch creation of child objects with cache preloading
public static Task<List<RedbObject<TProps>>> CreateBatchChildAsync<TProps>(IRedbObject parent, IEnumerable<TProps> properties, bool initializeMetadata) where TProps : class, new()
CreateBatchChildAsync<TProps>(IRedbObject, IEnumerable<TProps>)
Batch creation of child objects with cache preloading
public static Task<List<RedbObject<TProps>>> CreateBatchChildAsync<TProps>(IRedbObject parent, IEnumerable<TProps> properties) where TProps : class, new()
CreateChildAsync<TProps>(IRedbObject, TProps, bool)
Create a new object as a child of an existing parent
public static Task<RedbObject<TProps>> CreateChildAsync<TProps>(IRedbObject parent, TProps properties, bool initializeMetadata) where TProps : class, new()
CreateChildAsync<TProps>(IRedbObject, TProps)
Create a new object as a child of an existing parent
public static Task<RedbObject<TProps>> CreateChildAsync<TProps>(IRedbObject parent, TProps properties) where TProps : class, new()
CreateCopyAsync<TProps>(IRedbObject<TProps>, TProps)
Create copy of existing object with new properties
public static Task<RedbObject<TProps>> CreateCopyAsync<TProps>(IRedbObject<TProps> source, TProps newProperties) where TProps : class, new()
CreateFast<TProps>()
Create object without automatic scheme initialization (fast)
public static RedbObject<TProps> CreateFast<TProps>() where TProps : class, new()
CreateFast<TProps>(TProps)
Create object with properties without automatic scheme initialization (fast)
public static RedbObject<TProps> CreateFast<TProps>(TProps properties) where TProps : class, new()
CreateObject(string?)
Create non-generic RedbObject with basic metadata.
public static RedbObject CreateObject(string? name = null)
CreateWithMetadata<TProps>(TProps, long, string?, long?, long?, long?)
Create object with full manual initialization of all fields
public static RedbObject<TProps> CreateWithMetadata<TProps>(TProps properties, long schemeId, string? name = null, long? parentId = null, long? ownerId = null, long? whoChangeId = null) where TProps : class, new()
CreateWithWarmupAsync<TProps>(TProps)
Create object with metadata preload to cache
public static Task<RedbObject<TProps>> CreateWithWarmupAsync<TProps>(TProps properties) where TProps : class, new()
GetSettings()
Get current factory settings
public static (bool IsInitialized, long CurrentUserId, string CurrentUserName) GetSettings()
Initialize(ISchemeSyncProvider)
Initialize the factory with a scheme provider
public static void Initialize(ISchemeSyncProvider provider)
SetProvider(ISchemeSyncProvider)
Set the scheme provider
public static void SetProvider(ISchemeSyncProvider provider)