DryIocInversion of control containerCreates new container with default rules .Creates new container, optionally providing to modify default container behavior.
(optional) Rules to modify container default resolution behavior.
If not specified, then will be used.
(optional) Scope context to use for scoped reuse.
Creates new container with configured rules.
Allows to modify rules.
(optional) Scope context to use for .
Helper to create singleton scopePretty prints the container info including the open scope details if any.Dispose either open scope, or container with singletons, if no scope opened.Identifies the service when resolving collectionFactory, the required partOptional keyOptional required service type, can be an open-generic type.Constructs the struct.Directly uses generated factories to resolve service. Or returns the default if service does not have generated factory.Directly uses generated factories to resolve service. Or returns the default if service does not have generated factory.Resolves many generated only services. Ignores runtime registrations.Returns all registered service factories with their Type and optional Key.Decorator and Wrapper types are not included.Searches for registered factories by type, and key (if specified),
and by factory type (by default uses ).
May return empty, 1 or multiple factories.Stores factory into container using and as key
for later lookup.
Any subtypes of .
Type of service to resolve later.
(optional) Service key of any type with and
implemented.
(optional) Says how to handle existing registration with the same
and .
Confirms that service and implementation types are statically checked by compiler.
True if factory was added to registry, false otherwise.
False may be in case of setting and already existing factory.
[Obsolete("Please use `RegisterInstance` or `Use` method instead")]
Adding the factory directly to scope for resolution
The rules object defines policies per container for registration and resolution.Represents scope bound to container itself, and not the ambient (context) thing.Indicates that container is disposed.Produces new container which prevents any further registrations.
(optional) Controls what to do with the next registration: ignore or throw exception. Throws exception by default.
Converts known item into literal expression or wraps it in a constant expression.
Switched off until I (or someone) will figure it out.
Tries to return instance directly from scope or singleton, and fallbacks to expression for decorator.
Called for Injection as dependency.The int key is the `FactoryID`
Special service key with info about open-generic service type
Open-generic required service-typeOptional keyConstructs the thingHides/wraps object with disposable interface.Wrapped valueWraps the value
Interpreter of expression - where possible uses knowledge of DryIoc internals to avoid reflection
Calls `TryInterpret` inside try-catch and unwraps/re-throws `ContainerException` from the reflection `TargetInvocationException`
Stores parent lambda params and args Parent or the `null` for the root Params Args Constructs with parent parent or `null` for the rootInterprets passed expressionCompiles expression to factory delegate.Resolver context parameter expression in FactoryDelegate.
[Obsolete("Not used anymore")]
Optimization: singleton array with the parameter expression of IResolverContext
Strips the unnecessary or adds the necessary cast to expression return result
Wraps service creation expression (body) into and returns result lambda expression.First wraps the input service expression into lambda expression and
then compiles lambda expression to actual used for service resolution.Compiles lambda expression to actual `FactoryDelegate` wrapper.
[Obsolete("Use the version with `preferInterpretation` parameter instead")]
Restores the expression from LightExpression, or returns itself if already an Expression.Container extended features.The default key for services registered into container created by Uses the provided or the default to tweak the rules
to use with the `CreateFacade` methodsAllows to register new specially keyed services which will facade the same default service,
registered earlier. May be used to "override" registrations when testing the container.
Facade will clone the source container singleton and open scope (if any) so
that you may safely disposing the facade without disposing the source container scopes.The "child" container detached from the parent:
Child creation has O(1) cost - it is cheap thanks to the fast immutable collections cloning.
Child has all parent registrations copied, then the registrations added or removed in the child are not affecting the parent.
By default child will use the parent policy - you may specify `IfAlreadyRegistered.Replace` to "shadow" the parent registrations
Child has an access to the scoped services and singletons already created by parent.
Child can be disposed without affecting the parent, disposing the child will dispose only the scoped services and singletons created in the child and not in the parent (can be opt-out)Shares all of container state except the cache and the new rules.Prepares container for expression generation.Returns new container with all expression, delegate, items cache removed/reset.
But it will preserve resolved services in Singleton/Current scope.Creates new container with state shared with original, except for the singletons and cache.Shares the setup with original container but copies the registrations, so the new registrations
won't be visible in original. Registrations include decorators and wrappers as well.Shares the setup with original container but copies the registrations, so the new registrations
won't be visible in original. Registrations include decorators and wrappers as well.
You may control behavior and opt-in for the keeping or cloning the cache.For given instance resolves and sets properties and fields.
It respects rules set per container,
or if rules are not set it uses .For given instance resolves and sets properties and fields. You may specify what
properties and fields.Creates service using container for injecting parameters without registering anything in if the TYPE is not registered yet.
The note is that container will share the singletons though.Creates service using container for injecting parameters without registering anything in .
Container to use for type creation and injecting its dependencies.
Type to instantiate. Wrappers (Func, Lazy, etc.) is also supported.
(optional) Injection rules to select constructor/factory method, inject parameters,
properties and fields.
The default is Object instantiated by constructor or object returned by factory method.Creates service using container for injecting parameters without registering anything in .Type to instantiate.
Container to use for type creation and injecting its dependencies.
(optional) Injection rules to select constructor/factory method, inject parameters, properties and fields.
The default is Object instantiated by constructor or object returned by factory method.Creates service given strongly-typed creation expression.
Can be used to invoke arbitrary method returning some value with injecting its parameters from container.Method or constructor result type.
Container to use for injecting dependencies.
Creation expression.
The default is Created result.Registers new service type with factory for registered service type.
Throw if no such registered service type in container.
Container New service type.
Existing registered service type.
(optional) (optional)
Registers new service type with factory for registered service type.
Throw if no such registered service type in container.
Container
New service type.Existing registered service type.
(optional) (optional)
Forwards to .Register a service without implementation which can be provided later in terms
of normal registration with IfAlreadyRegistered.Replace parameter.
When the implementation is still not provided when the placeholder service is accessed,
then the exception will be thrown.
This feature allows you to postpone decision on implementation until it is later known.Internally the empty factory is registered with the setup asResolutionCall set to true.
That means, instead of placing service instance into graph expression we put here redirecting call to
container Resolve.
Obsolete: please use WithAutoFallbackDynamicRegistration
Obsolete: please use WithAutoFallbackDynamicRegistration
Provides automatic fallback resolution mechanism for not normally registered
services. Underneath it uses the `WithDynamicRegistrations`.Provides automatic fallback resolution mechanism for not normally registered
services. Underneath it uses the `WithDynamicRegistrations`.Provides automatic fallback resolution mechanism for not normally registered
services. Underneath it uses the `WithDynamicRegistrations`.Provides automatic fallback resolution mechanism for not normally registered
services. Underneath it uses the `WithDynamicRegistrations`.Provides automatic fallback resolution mechanism for not normally registered
services. Underneath it uses the `WithDynamicRegistrations`.Provides automatic fallback resolution mechanism for not normally registered
services. Underneath it uses the `WithDynamicRegistrations`.Provides automatic fallback resolution mechanism for not normally registered
services. Underneath it uses the `WithDynamicRegistrations`.Creates new container with provided parameters and properties
to pass the custom dependency values for injection. The old parameters and properties are overridden,
but not replaced.
Container to work with.
(optional) Parameters specification, can be used to proved custom values.
(optional) Properties and fields specification, can be used to proved custom values.
New container with adjusted rules.(_ => "Nya!"));
var a = c.Resolve(); // where A accepts string parameter in constructor
Assert.AreEqual("Nya!", a.Message)
]]>Result of GenerateResolutionExpressions methodsResolutions rootsDependency of Resolve callsErrorsGenerates expressions for specified roots and their "Resolve-call" dependencies.
Wraps exceptions into errors. The method does not create any actual services.
You may use Factory .Generates expressions for provided root servicesGenerates expressions for provided root servicesExcluding open-generic registrations, cause you need to provide type arguments to actually create these types.Helps to find potential problems in service registration setup. Method tries to resolve the specified registrations, collects exceptions,
and returns them to user. Does not create any actual service objects. You must specify to define your resolution roots,
otherwise container will try to resolve all registrations, which usually is not realistic case to validate.Same as the Validate with the same parameters but throws the exception with all collected errorsHelps to find potential problems when resolving the .
Method will collect the exceptions when resolving or injecting the specific root. Does not create any actual service objects.
You must specify to define your resolution roots, otherwise container will try to resolve all registrations,
which usually is not realistic case to validate.Same as the Validate with the same parameters but throws the exception with all collected errorsHelps to find potential problems in service registration setup by trying to resolve the and
returning the found errors. This method does not throw.Same as the Validate with the same parameters but throws the exception with all collected errorsRe-constructs the whole request chain as request creation expression.Clears delegate and expression cache for specified .
But does not clear instances of already resolved/created singletons and scoped services!Clears delegate and expression cache for specified service.
But does not clear instances of already resolved/created singletons and scoped services!Interface used to convert reuse instance to expression.Returns expression representation without closure.
Use to converting the sub-items, constants to container.Used to represent multiple default service keys.
Exposes to determine order of service added.Default value.Allows to determine service registration order.Returns the default key with specified registration order.Converts to expressionReturns next default key with increased .Compares keys based on registration order. The null (represents default) key is considered equal.Returns registration order as hash.Prints registration order to string.Represents default key for dynamic registrationsDefault value.Associated ID.Returns dynamic key with specified ID.Converts to expressionReturns next dynamic key with increased .Compares key's IDs. The null (default) key is considered equal!Returns key index as hash.Prints registration order to string.Extends IResolver to provide an access to scope hierarchy.True if container is disposed.Parent context of the scoped context.The root context of the scoped context.Singleton scope, always associated with root scope.Optional ambient scope context.Current opened scope. May return the current scope from if context is not null.
Creates the resolver context with specified current Container-OWN scope
Put instance into the current scope or singletons.
Puts instance created via the passed factory on demand into the current or singleton scope
For given instance resolves and sets properties and fields.Provides a usable abstractions for Just a sugar that allow to get root or self container.Returns root or self resolver based on request.Resolver context parameter expression in FactoryDelegate.Resolver parameter expression in FactoryDelegate.Resolver parameter expression in FactoryDelegate.Access to scopes in FactoryDelegate.
Indicates that context is scoped - that's is only possible if container is not the Root one and has a Parent context
Provides access to the current scope - may return `null` if ambient scope context has it scope changed in-between
Gets current scope matching the Opens scope with optional name and optional tracking of new scope in a parent scope.
Parent context to use.
(optional)
(optional) Instructs to additionally store the opened scope in parent,
so it will be disposed when parent is disposed. If no parent scope is available the scope will be tracked by Singleton scope.
Used to dispose a resolution scope.
Scoped resolver context.();
handler.Handle(data);
}
]]>A bit if sugar to track disposable in the current scope or in the singleton scope as a fallbackThe result delegate generated by DryIoc for service creation.The stronly typed delegate for service creation registered as a Wrapper.Adds to Container support for:
Open-generic servicesService generics wrappers and arrays using extension point.
Supported wrappers include: Func of , Lazy, Many, IEnumerable, arrays, Meta, KeyValuePair, DebugExpression.
All wrapper factories are added into collection of .
unregistered resolution rule.Supported Func types.Supported Action types. Yeah, action I can resolve or inject void returning method as action.Supported open-generic collection types - all the interfaces implemented by array.Returns true if type is supported , and false otherwise.Registered wrappers by their concrete or generic definition service type.Gets the expression for wrapper.
The resolution request.
if set to true then check for service registration before creating resolution expression.
Expression: new Lazy(() => r.Resolve{TService}(key, ifUnresolved, requiredType))]]>Discovers and combines service with its setup metadata.
Works with any generic type with first Type arg - Service type and second Type arg - Metadata type,
and constructor with Service and Metadata arguments respectively.
- if service key is not specified in request then method will search for all
registered factories with the same metadata type ignoring keys.
- if metadata is IDictionary{string, object},
then the First value matching the TMetadata type will be returned.Represents info required for dynamic registration: service key, factory,
and option how to combine dynamic with normal registrations.FactoryOptional: will be by default.Optional service key: if null the default will be used. Constructs the infoThe options for the single dynamic registration provider.
The dynamic Wrapper registration is not supported.No flags - to use in `GetDynamicRegistrationProvidersOrDefault`Use as AsFallback onlyProvider may have the services providedProvider may have the decorators provided Defines resolution/registration rules associated with Container instance. They may be different for different containers.Default rules as a staring point.The rules implementing the conventions of Microsoft.Extension.DependencyInjection library.Returns the copy of the rules with the applied conventions of Microsoft.Extension.DependencyInjection library.Does nothingDoes nothingThe default total dependency count - a expression tree node count to split the object graphThe total dependency count - the expression tree node count to split the object graph.
That does not mean the graph can be always split at this number, consider the example graph and
the dependency count threshold set to 3:
`x = new X(new Y(A, new B(K), new C(new L(), new M())), new Z())`
The tree is resolved from the left to the right in the depth-first order:
A; then K, B (at this point Y is already has 3 dependencies but is not fully resolved until C is resolved);
then L, M, C (here Y is fully resolved with 6 dependencies) so we can split it only on 6 dependencies instead of 3.
The split itseft just wraps the node in `Func{T}` delegate making it a separate compilation unit.
In our example it will be `Func{Y} f = () => new Y(A, new B(K), new C(new L(), new M()))` considering
that everything is transient.
Does nothingSets the Does nothingDisables the limitation.Shorthand to Shorthand to Shorthand to Instructs to override per-registration made settings with these rules settings.Returns the parameter selector based on Returns the properties and fields selectorbased on Returns new instance of the rules new Made composed out of
provided factory method, parameters, propertiesAndFields.Returns new instance of the rules with specified .
New Made.Of rules.
Instructs to override registration level Made.Of
New rules.Service key to be used instead on `null` in registration.Sets the Defines single factory selector delegate.
Provides service request leading to factory selection.
Registered factories with corresponding key to select from.
Single selected factory, or null if unable to select.Rules to select single matched factory default and keyed registered factory/factories.
Selectors applied in specified array order, until first returns not null .
Default behavior is to throw on multiple registered default factories, cause it is not obvious what to use.Sets Select last registered factory from the multiple default.Tries to select a single factory based on the minimal reuse life-span ignoring the TransientsTries either SelectFactoryWithTheMinReuseLifespan or SelectLastRegisteredFactoryPrefer specified service key (if found) over default key.
Help to override default registrations in Open Scope scenarios:
I may register service with key and resolve it as default in current scope.Specify the method signature for returning multiple keyed factories.
This is dynamic analog to the normal Container Registry.
Requested service type.
(optional) If null will request all factories of Key-Factory pairs.Providers for resolving multiple not-registered services. Null by default.The flags per dynamic registration providerGet the specific providers with the specified flags and without the flags or return `null` if nothing foundReturns the new rules with the passed dynamic registration rule appended.Returns the new rules with the passed dynamic registration rules appended.Returns the new rules with the passed dynamic registration rules appended.
The rules applied only when no normal registrations found!Returns the new rules with the passed dynamic registration rules appended.
The rules applied only when no normal registrations found!Obsolete["Instead use "]Defines delegate to return factory for request not resolved by registered factories or prior rules.
Applied in specified array order until return not null .Gets rules for resolving not-registered services. Null by default.Appends resolver to current unknown service resolvers.Removes specified resolver from unknown service resolvers, and returns new Rules.
If no resolver was found then will stay the same instance,
so it could be check for remove success or fail.Sugar on top of to simplify setting the diagnostic action.
Does not guard you from action throwing an exception. Actually can be used to throw your custom exception
instead of .The alternative is ConcreteTypeDynamicRegistrationsRule to automatically resolves non-registered service type which is: nor interface, nor abstract.
For constructor selection we are using .
The resolution creates transient services.
(optional) Condition for requested service type and key.
(optional) Reuse for concrete types.
New rule.Automatically resolves non-registered service type which is: nor interface, nor abstract.
The resolution creates Transient services.
Replaced with `WithConcreteTypeDynamicRegistrations`
Creates dynamic fallback registrations for the requested service type
with provided .
Fallback means that the dynamic registrations will be applied Only if no normal registrations
exist for the requested service type, hence the "fallback".
Implementation types to select for service.
(optional) Handler to customize the factory, e.g.
specify reuse or setup. Handler should not return null.
Registration provider.Obsolete: replaced by See The reuse used in case if reuse is unspecified (null) in Register methods.Replaced by WithDefaultReuse because for some cases InsteadOfTransient does not make sense.Given item object and its type should return item "pure" expression presentation,
without side-effects or external dependencies.
e.g. for string "blah" Expression.Constant("blah", typeof(string)).
If unable to convert should return null..Specifies custom rule to convert non-primitive items to their expression representation.
That may be required because DryIoc by default does not support non-primitive service keys and registration metadata.
To enable non-primitive values support DryIoc need a way to recreate them as expression tree..Turns off throwing exception when dependency has shorter reuse lifespan than its parent or ancestor.New rules with new setting value..Turns On throwing the exception when Singleton or Scope service has a Transient dependencyTurns Off throwing the exception when Singleton or Scope service has a Transient dependency (the default)Turns Off the rule .
Allows to register disposable transient but it is up to you to handle their disposal.
You can use to actually track disposable transient in
container, so that disposal will be handled by container.Turns tracking of disposable transients in dependency parent scope, or in current scope if service
is resolved directly.
If there is no open scope at the moment then resolved transient won't be tracked and it is up to you
to dispose it! That's is similar situation to creating service by new - you have full control.
If dependency wrapped in Func somewhere in parent chain then it also won't be tracked, because
Func supposedly means multiple object creation and for container it is not clear what to do, so container
delegates that to user. Func here is the similar to Owned relationship type in Autofac library.
Turning this setting On automatically turns off ..Turns off optimization: creating singletons during resolution of object graph..Indicates that container is used for generation purposes, so it should use less runtime stateSpecifies to generate ResolutionCall dependency creation expression and stores the result
in the-per rules collection.Indicates that rules are used for the validation, e.g. the rules created in `Validate` methodSpecifies to generate ResolutionCall dependency creation expression and stores the result
in the-per rules collection.Removes implicit Factory for non-transient service.
The Condition filters out factory without matching scope.Removes runtime optimizations preventing an expression generation..Specifies to resolve IEnumerable as LazyEnumerable..Flag instructs to include covariant compatible types into the resolved collection.Flag instructs to exclude covariant compatible types into the resolved collection..Flag instructs to include covariant compatible types into the resolved generic.Flag instructs to exclude covariant compatible types into the resolved generic..Specifies default setting for container. By default is .
Example of use: specify Keep as a container default, then set AppendNonKeyed for explicit collection registrations..Specifies to throw an exception in attempt to resolve service which require runtime state for resolution.
Runtime state may be introduced by RegisterDelegate, RegisterInstance, or registering with non-primitive service key, or metadata..Instructs to capture Dispose stack-trace to include it later into
exception for easy diagnostics.Allows Func with args specify its own reuse (sharing) behavior.Allows Func with args specify its own reuse (sharing) behavior.Allows Func of service to be resolved even without registered service.Allows Func of service to be resolved even without registered service.
Commands to use FastExpressionCompiler - set by default.
Fallbacks to system `Expression.Compile()`
Subject-subject
Fallbacks to system `Expression.Compile()`
Subject
Uses DryIoc own interpretation mechanism or is falling back to `Compile(preferInterpretation: true)`Uses DryIoc own interpretation mechanism or is falling back to `Compile(preferInterpretation: true)`If Decorator reuse is not set instructs to use `Decorator.SetupWith(useDecarateeReuse: true)`If Decorator reuse is not set instructs to use `Decorator.SetupWith(useDecarateeReuse: true)`
Outputs most notable non-default rules
Wraps constructor or factory method optionally with factory instance to create service.Constructor or method to use for service creation.Identifies factory service if factory method is instance member.
Alternatively you may just provide an expression for factory
Contains resolved parameter expressions found when looking for most resolvable constructorWraps method and factory instance.
Where is constructor, static or instance method, property or field.Wraps method and factory instance.
Where is constructor, static or instance method, property or field.Discovers the static factory method or member by name in .
Should play nice with C# operator.Pretty prints wrapped method.Easy way to specify non-public and most resolvable constructor.
(optional) Instructs to select constructor with max number of params which all are resolvable.
(optional) Consider the non-public constructors.
Constructor or null if not found.Easy way to specify default constructor to be used for resolution.
Better be named `ConstructorWithMostResolvableArguments`.
Searches for public constructor with most resolvable parameters or throws if not found.
Works both for resolving service and `Func{TArgs..., TService}`
Searches for constructor (including non public ones) with most
resolvable parameters or throws if not found.
Works both for resolving service and Func{TArgs..., TService}Just creates a thingy from the constructorRules how to: Select constructor for creating service with .Specify how to resolve constructor parameters with .Specify what properties/fields to resolve and how with .Returns delegate to select constructor based on provided request.Return type of strongly-typed factory method expression.
Has any conditional flags
True is made has properties or parameters with custom value.
That's mean the whole made become context based which affects caching.
Indicates that the implementation type depends on request.
Indicates that the member depends on request
Specifies how constructor parameters should be resolved:
parameter service key and type, throw or return default value if parameter is unresolved.Specifies what should be used when resolving property or field.Outputs whatever is possible (known) for MadeContainer will use some sensible defaults for service creation.Creates rules with only specified.Creates rules with only specified.Creates rules with only specified.Specifies injections rules for Constructor, Parameters, Properties and Fields. If no rules specified returns rules.Specifies injections rules for Constructor, Parameters, Properties and Fields. If no rules specified returns rules.
Known factory method.
(optional) (optional)
New injection rules.Creates factory method specificationCreates factory specification with implementation type, conditionally depending on request.Creates factory specification with method or member selector based on request.
Where is method, or constructor, or member selector.Creates factory specification with method or member selector based on request.
Where Method, or constructor, or member selector.Defines how to select constructor from implementation type.
Where is delegate taking implementation type as input
and returning selected constructor info.Defines factory method using expression of constructor call (with properties), or static method call.Type with constructor or static method.
Expression tree with call to constructor with properties:
new Car(Arg.Of()) { Color = Arg.Of("CarColor") }]]>
or static method call Car.Create(Arg.Of())]]>
(optional) Primitive custom values for dependencies.
New Made specification.Defines creation info from factory method call Expression without using strings.
You can supply any/default arguments to factory method, they won't be used, it is only to find the .Factory type.Factory product type.
Returns or resolves factory instance.
Method, property or field expression returning service.
(optional) Primitive custom values for dependencies.
New Made specification.
Composes Made.Of expression with known factory instance and expression to get a service
Typed version of specified with statically typed expression tree.Class for defining parameters/properties/fields service info in expressions.
Arg methods are NOT actually called, they just used to reflect service info from call expression.Specifies required service type of parameter or member. If required type is the same as parameter/member type,
the method is just a placeholder to help detect constructor or factory method, and does not have additional meaning.Specifies both service and required service types.Specifies required service type of parameter or member. Plus specifies if-unresolved policy.Specifies both service and required service types.Specifies required service type of parameter or member. Plus specifies service key.Specifies both service and required service types.Specifies required service type of parameter or member. Plus specifies service key.Specifies both service and required service types.Specifies required service type of parameter or member. Plus specifies if-unresolved policy. Plus specifies service key.Specifies both service and required service types.Specifies required service type, default value and .Specifies required service type, default value and .Specifies argument index starting from 0 to use corresponding custom value factory,
similar to String.Format "{0}, {1}, etc".Name is close to method itself to not forget when renaming the method.Contains extension methods to simplify general use cases.The base method for registering service with its implementation factory. Allows to specify all possible options.Registers service with corresponding .Registers service of .
ServiceType may be the same as .Registers service of type
implemented by type.Registers implementation type with itself as service type.Registers service type returned by Made expression.Registers service returned by Made expression.
Registers the instance creating a "normal" DryIoc registration so you can check it via `IsRegestered`,
apply wrappers and decorators, etc.
Additionally, if instance is `IDisposable`, then it tracks it in a singleton scope.
NOTE: Look at the `Use` method to put instance directly into current or singleton scope,
though without ability to use decorators and wrappers on it.
Registers the instance creating a "normal" DryIoc registration so you can check it via `IsRegestered`,
apply wrappers and decorators, etc.
Additionally, if instance is `IDisposable`, then it tracks it in a singleton scope.
NOTE: Look at the `Use` method to put instance directly into current or singleton scope,
though without ability to use decorators and wrappers on it.
Registers the instance creating a "normal" DryIoc registration so you can check it via `IsRegestered`,
apply wrappers and decorators, etc.
Additionally, if instance is `IDisposable`, then it tracks it in a singleton scope.
NOTE: Look at the `Use` method to put instance directly into current or singleton scope,
though without ability to use decorators and wrappers on it.
Registers the instance with possible multiple service types creating a "normal" DryIoc registration
so you can check it via `IsRegestered` for each service type,
apply wrappers and decorators, etc.
Additionally, if instance is `IDisposable`, then it tracks it in a singleton scope.
NOTE: Look at the `Use` method to put instance directly into current or singleton scope,
though without ability to use decorators and wrappers on it.
Registers the instance with possible multiple service types creating a "normal" DryIoc registration
so you can check it via `IsRegestered` for each service type,
apply wrappers and decorators, etc.
Additionally, if instance is `IDisposable`, then it tracks it in a singleton scope.
NOTE: Look at the `Use` method to put instance directly into current or singleton scope,
though without ability to use decorators and wrappers on it.
Registers the instance with possible multiple service types creating a "normal" DryIoc registration
so you can check it via `IsRegestered` for each service type,
apply wrappers and decorators, etc.
Additionally, if instance is `IDisposable`, then it tracks it in a singleton scope.
NOTE: Look at the `Use` method to put instance directly into current or singleton scope,
though without ability to use decorators and wrappers on it.
List of types excluded by default from RegisterMany convention.Checks that type is not in the list of .Checks that type can be used a service type.Checks if type can be used as implementation type for reflection factory,
and therefore registered to container. Usually used to discover implementation types from assembly.Returns only those types that could be used as service types of .
It means that for open-generic its service type should supply all type arguments.The same `GetImplementedServiceTypes` but instead of collecting the service types just check the is implementedReturns the sensible services automatically discovered for RegisterMany implementation type.
Excludes the collection wrapper interfaces. The may be concrete, abstract or
generic definition.Returns the types suitable to be an implementation types for :
actually a non abstract and not compiler generated classes.Returns the types suitable to be an implementation types for :
actually a non abstract and not compiler generated classes.Sugar, so you can say (Registrator.Interfaces)]]>Checks if implements a service type,
along the checking if is a valid implementation type.Checks if implements a service type,
along the checking if and service type
are valid implementation and service types.Wraps the implementation type in factory.Wraps the implementation type in factory plus allow to provide factory parameters.
Batch registering the implementations with possibly many service types,
throwing the error when there are no services types to register.
You may pass the predefined to .
By default uses the with the default reuse,
or you may return the with the of your choice.
Batch registering the implementations with possibly many service types,
ignoring the case when there are no services types to register.
You may pass the predefined to .
By default uses the with the default reuse,
or you may return the with the of your choice.
Batch registers implementation with possibly many service types.Batch registers assemblies of implementation types with possibly many service types.
The default factory is the with default reuse.Registers many implementations with their auto-figured service types.Registers many implementations with auto-figured service types.Registers single registration for all implemented public interfaces and base classes.Registers single registration for all implemented public interfaces and base classes.Registers a factory delegate for creating an instance of .
Delegate can use resolver context parameter to resolve any required dependencies, e.g.:
(r => new Car(r.Resolve()))]]>The alternative to this method please consider using instead:
(Made.Of(() => new Car(Arg.Of())))]]>.
Registers delegate to be injected by container avoiding the ServiceLocator anti-patternRegisters delegate with explicit arguments to be injected by container avoiding the ServiceLocator anti-patternRegisters delegate with explicit arguments to be injected by container avoiding the ServiceLocator anti-patternRegisters delegate with explicit arguments to be injected by container avoiding the ServiceLocator anti-patternRegisters delegate with explicit arguments to be injected by container avoiding the ServiceLocator anti-patternRegisters delegate with explicit arguments to be injected by container avoiding the ServiceLocator anti-patternRegisters delegate with explicit arguments to be injected by container avoiding the ServiceLocator anti-patternRegisters delegate with explicit arguments to be injected by container avoiding the ServiceLocator anti-patternRegisters delegate with explicit arguments to be injected by container avoiding the ServiceLocator anti-pattern
Minimizes the number of allocations when converting from Func to named delegate
Lifts the result to the factory delegate without allocations on capturing value in lambda closure
Registers a factory delegate for creating an instance of .
Delegate can use resolver context parameter to resolve any required dependencies, e.g.:
(r => new Car(r.Resolve()))]]>IMPORTANT: The method should be used as the last resort only! Though powerful it is a black-box for container,
which prevents diagnostics, plus it is easy to get memory leaks (due variables captured in delegate closure),
and impossible to use in compile-time scenarios.
Consider using instead:
(Made.Of(() => new Car(Arg.Of())))]]>
A special performant version mostly for integration with other libraries,
that already check compatibility between delegate result and the service type
[Obsolete("Replaced with RegisterDelegate{Dep1...Dep2, R}()")]
Will become OBSOLETE! in the next major version:
Please use `RegisterInstance` or `Use` method instead.
Will become OBSOLETE! in the next major version:
Please use `RegisterInstance` or `Use` method instead.
Will become OBSOLETE! in the next major version:
Please use `RegisterInstance` or `Use` method instead.
Will become OBSOLETE! in the next major version:
Please use `RegisterInstance` or `Use` method instead.
Will become OBSOLETE! in the next major version:
Please use `RegisterInstance` or `Use` method instead.
Will become OBSOLETE! in the next major version:
Please use `RegisterInstance` or `Use` method instead.
Will become OBSOLETE! in the next major version:
Please use `RegisterInstance` or `Use` method instead.
Will become OBSOLETE! in the next major version:
Please use `RegisterInstance` or `Use` method instead.
Will become OBSOLETE! in the next major version:
Please use `RegisterInstance` or `Use` method instead.
Will become OBSOLETE in the next major version!
Please use `RegisterInstance` or `Use` method instead.
Adding the factory directly to scope for resolutionAdding the instance directly to the scope for resolutionAdding the instance directly to the scope for resolutionAdding the factory directly to the scope for resolutionAdding the instance directly to scope for resolutionAdding the instance directly to scope for resolutionAdding the factory directly to scope for resolutionAdding the instance directly to scope for resolutionAdding the instance directly to scope for resolution
Registers initializing action that will be called after service is resolved
just before returning it to the caller. You can register multiple initializers for a single service.
Or you can register initializer for the type to be applied
for all services and use to specify the target services.
Note: The initializer action has the same reuse as a initialized (decorated) service.
Registers initializing action that will be called after service is resolved
just before returning it to the caller. You can register multiple initializers for a single service.
Or you can register initializer for the type to be applied
for all services and use to specify the target services.
Note: You may specify a different from the initiliazed object enabling the
action to run once (Singleton), run once-per-scope (Scoped), run always (Transient).
Registers dispose action for reused target service.Returns true if is registered in container OR
its open generic definition is registered in container.
The additional implementation factory may be specified to narrow the search.Returns true if is registered in container OR
its open generic definition is registered in container.
The additional implementation factory may be specified to narrow the search.Removes specified registration from container.
It also tries to remove the cached resolutions for the removed registration, But it may not work depending on context.
Check the docs for more info: https://github.com/dadhi/DryIoc/blob/master/docs/DryIoc.Docs/UnregisterAndResolutionCache.md Removes specified registration from container.
It also tries to remove the cached resolutions for the removed registration, But it may not work depending on context.
Check the docs for more info: https://github.com/dadhi/DryIoc/blob/master/docs/DryIoc.Docs/UnregisterAndResolutionCache.md Registers new service type with factory for registered service type.
Throw if no such registered service type in container.
Registrator New service type.
Existing registered service type.
The registration to overwrite or preserve the already registered service
(optional) (optional)
(optional) By default is Registers new service type with factory for registered service type.
Throw if no such registered service type in container.Registers new service type with factory for registered service type.
Throw if no such registered service type in container.
Registrator
New service type.Existing registered service type.
(optional) (optional)
(optional) By default is Registers new service type with factory for registered service type.
Throw if no such registered service type in container.
Container
New service type.Existing registered service type.
The registration to overwrite or preserve the already registered service
(optional) (optional)
Register a service without implementation which can be provided later in terms
of normal registration with IfAlreadyRegistered.Replace parameter.
When the implementation is still not provided when the placeholder service is accessed,
then the exception will be thrown.
This feature allows you to postpone decision on implementation until it is later known.Internally the empty factory is registered with the setup asResolutionCall set to true.
That means, instead of placing service instance into graph expression we put here redirecting call to
container Resolve.Extension methods for .Resolves instance of service type from container. Throws exception if unable to resolve.Resolves instance of service type from container.Resolves instance of type TService from container.Tries to resolve instance of service type from container.Tries to resolve instance of TService from container.Returns instance of searching for .
In case of being generic wrapper like Func, Lazy, IEnumerable, etc.
allow you to specify wrapped service type.();
var services = container.Resolve(typeof(IEnumerableReturns instance of searching for .
In case of being generic wrapper like Func, Lazy, IEnumerable, etc.
allow you to specify wrapped service type.();
var services = container.Resolve>(typeof(IService));
]]>Returns instance of searching for .
In case of being generic wrapper like Func, Lazy, IEnumerable, etc.
allow you to specify wrapped service type.();
var services = container.Resolve, IService>();
]]>Returns instance of searching for .
In case of being generic wrapper like Func, Lazy, IEnumerable, etc.,
could specify wrapped service type.Using implicitly support Covariance for generic wrappers even in .Net 3.5.();
var services = container.Resolve(typeof(LazyReturns instance of type.The type of the requested service.The requested service instance.Using implicitly support Covariance for generic wrappers even in .Net 3.5.Resolves the service supplying all or some of its dependencies
(including nested) with the . The rest of dependencies is injected from
container.Resolves the service supplying all or some of its dependencies
(including nested) with the . The rest of dependencies is injected from
container.Returns all registered services instances including all keyed and default registrations.
Use to return either all registered services at the moment of resolve (dynamic fresh view) or
the same services that were returned with first call (fixed view).Return collection item type.
It denotes registered service type if is not specified.The same result could be achieved by directly calling:
>(); // for dynamic result - default behavior
container.Resolve(); // for fixed array
container.Resolve>(); // same as fixed array
]]>Returns all registered services as objects, including all keyed and default registrations.Creates a service by injecting its parameters registered in the container but without registering the service itself in the container.Creates a service by injecting its parameters registered in the container but without registering the service itself in the container.Creates a service by injecting its parameters registered in the container but without registering the service itself in the container.Specifies result of : either dynamic(lazy) or fixed view.Lazy/dynamic item resolve.Fixed array of item at time of resolve, newly registered/removed services won't be listed.Controls the registry changeChange is permitted - the default settingThrows the error for the new registrationIgnores the next registrationProvides information required for service resolution: service type
and optional The required piece of info: service type.Additional optional details: service key, if-unresolved policy, required service type.Creates info from service type and details.Provides optional service resolution details: service key, required service type, what return when service is unresolved,
default value if service is unresolved, custom service value.
Default details if not specified, use default setting values, e.g.
Default details with option.
Default details with option.
Creates new details out of provided settings, or returns default if all settings have default value.Sets custom value for service. This setting is orthogonal to the rest.
Using default value with invalid ifUnresolved.Throw option to indicate custom value.Service type to search in registry. Should be assignable to user requested service type.Service key provided with registration.Metadata key to find in metadata dictionary in resolved service.Metadata value to find in resolved service.Policy to deal with unresolved request.Indicates that the custom value is specified.Either default or custom value depending on setting.Value to use in case is set to not Throw.Custom value specified for dependency. The IfUnresolved.Throw is the marker of custom value comparing to default value.Pretty prints service details to string for debugging and errors.Details string.Contains tools for combining or propagating of independent of its concrete implementations.Creates service info with new type but keeping the details.Creates new info with new IfUnresolved behavior or returns the original info if behavior is not different,
or the passed info is not a .Combines service info with details. The main goal is to combine service and required service type.Enables propagation/inheritance of info between dependency and its owner:
for instance for wrappers.Returns required service type if it is specified and assignable to service type,
otherwise returns service type.Appends info string representation into provided builder.Represents custom or resolution root service info, there is separate representation for parameter,
property and field dependencies.Empty service info for convenience.Creates info out of provided settingsCreates info out of provided settingsCreates service info using typed .Strongly-typed version of Service Info.Service type.Creates service info object.Type of service to create. Indicates registered service in registry.Shortcut access to service keyAdditional settings. If not specified uses .Creates info from service type and details.Prints info to string using .Printed string.Provides for parameter,
by default using parameter name as .For parameter default setting is .Creates service info from parameter alone, setting service type to parameter type,
and setting resolution policy to if parameter is optional.The parameter type or dereferenced parameter type for `ref`, `in`, `out` parametersService type specified by .Optional service details.Creates info from service type and details.Parameter info.Prints info to string using .Printed string.Base class for property and field dependency info.Create member info out of provide property or field.
Member is either property or field. Created info.The required service type. It will be either or .Optional details: service key, if-unresolved policy, required service type.Creates info from service type and details.
Required service type. Optional details. Create info.Either or .Sets property or field value on provided holder object.
Holder of property or field. Value to set.
Stored check results of two kinds: inherited down dependency chain and not.Not inheritedInheritedInheritedIndicates that the request is the one from Resolve call.Non inheritedNon inheritedNon inherited. Marks the expression to be added to generated resolutions to prevent infinite recursionNon inherited. Indicates the root service inside the function.
Helper extension methods to use on the bunch of factories instead of lambdas to minimize allocations
Tracks the requested service and resolved factory details in a chain of nested dependencies.Empty terminal request.Empty request which opens resolution scope.Creates the Resolve request. The container initiated the Resolve is stored within request.Creates the Resolve request. The container initiated the Resolve is stored within request.Available in runtime only, provides access to container initiated the request.Request immediate parent.Persisted request conditions
mutable, so that the ServiceKey or IfUnresolved can be changed in place.
Input arguments provided with `Resolve`Runtime known resolve factory, otherwise is nullResolved factory ID, used to identify applied decorator.Type of factory: Service, Wrapper, or Decorator.Combines decorator and Service implementation type if known.Service reuse.ID of decorated factory in case of decorator factory typeNumber of nested dependencies. Set with each new Push.The total dependency countIndicates that request is empty initial request.Returns true if request is First in First Resolve call.Returns true if request is First in Resolve call.Not the root resolution call.Returns true if request is First in First Resolve call.Checks if the request Or its parent is wrapped in Func.
Use for the direct Func wrapper.Checks if the request is directly wrapped in FuncChecks if request has parent with service type of Func with arguments.Returns expression for func arguments.Indicates that requested service is transient disposable that should be tracked.Indicates the request is singleton or has singleton upper in dependency chain.Is not usedCurrent scopeSingletonsShortcut to issued container rules.(optional) Made spec used for resolving request.Returns service parent skipping wrapper if any. To get direct parent use .Requested service type.Compatible required or service type.Optional service key to identify service of the same type.Metadata key to find in metadata dictionary in resolved service.Metadata or the value (if key specified) to find in resolved service.Policy to deal with unresolved service.Required service type if specified.Relative number representing reuse lifespan.Known implementation, or otherwise actual service type.Creates new request with provided info, and links current request as a parent.
Allows to set some additional flags. Existing/parent request should be resolved to
factory via `WithResolvedFactory` before pushing info into it.Composes service description into and Pushes the new request.Creates info by supplying all the properties and chaining it with current (parent) info.Creates info by supplying all the properties and chaining it with current (parent) info.Creates info by supplying all the properties and chaining it with current (parent) info.Creates info by supplying all the properties and chaining it with current (parent) info.Allow to switch current service info to the new one, e.g. in decorators.
If info did not change then return the same this request.
Produces the new request with the changed `ifUnresolved` or returns original request otherwise
Updates the flagsSets service key to passed value. Required for multiple default services to change null key to
actual Prepends input arguments to existing arguments in request. It is done because the
nested Func/Action input argument has a priority over outer argument.
The arguments are provided by Func and Action wrappers, or by `args` parameter in Resolve call.Returns new request with set implementation details.
Factory to which request is resolved.
(optional) does not check for recursive dependency.
Use with caution. Make sense for Resolution expression.
(optional) allows to skip reuse mismatch aka captive dependency check.
Make a defensive copy of request.
New request with set factory.Check for the parents.If request corresponds to dependency injected into parameter,
then method calls handling and returns its result.
If request corresponds to property or field, then method calls respective handler.
If request does not correspond to dependency, then calls handler.Obsolete: now request is directly implements the .Enumerates self and all request stack parents.Prints current request info only (no parents printed) to provided builder.Prints full stack of requests starting from current one using .Prints whole request chain.Returns true if request info and passed object are equal, and their parents recursively are equal.Returns true if request info and passed info are equal, and their parents recursively are equal.Compares self properties but not the parents.Calculates the combined hash code based on factory IDs.
Severe the connection with the request pool up to the parent so that noone can change the Request state
Type of services supported by Container.(default) Defines normal service factoryDefines decorator factoryDefines wrapper factory.Base class to store optional settings.Factory type is required to be specified by concrete setups as in
, , .Predicate to check if factory could be used for resolved request.Relative disposal order when defined. Greater number, later dispose.Arbitrary metadata object associated with Factory/Implementation, may be a dictionary of key-values.Returns true if passed meta key and value match the setup metadata.Indicates that injected expression should be:
(...)]]>
instead of:
Setup with the only setting: `AsResolutionCall`
Works as `AsResolutionCall` but only with `Rules.UsedForExpressionGeneration`Specifies to use `asResolutionCall` but only in expression generation context, e.g. for compile-time generationMarks service (not a wrapper or decorator) registration that is expected to be resolved via Resolve call.Opens scope, also implies .Stores reused instance as WeakReference.Allows registering transient disposable.Turns On tracking of disposable transient dependency in parent scope or in open scope if resolved directly.Instructs to use parent reuse. Applied only if is not specified.Prevents disposal of reused instance if it is disposable.When single service is resolved, but multiple candidates found, this options will be used to prefer this one.Default setup for service factories.Constructs setup object out of specified settings.
If all settings are default then setup will be returned.
is metadata object or Func returning metadata object.Default setup which will look for wrapped service type as single generic parameter.Returns generic wrapper setup.
Default for is -1 for generic wrapper with single type argument.
Index need to be set for multiple type arguments. need to be set
when generic wrapper type arguments should be ignored.Default decorator setup: decorator is applied to service type it registered with.Creates setup with optional condition.
The specifies relative decorator position in decorators chain.
Greater number means further from decoratee - specify negative number to stay closer.
Decorators without order (Order is 0) or with equal order are applied in registration order
- first registered are closer decoratee.
Creates a condition for both , and additional condition
Setup for decorator of type .Setup for decorator of type .Service setup.Evaluates metadata if it specified as Func of object, and replaces Func with its result!.
Otherwise just returns metadata object.Invocation of Func metadata is Not thread-safe. Please take care of that inside the Func.
All settings are set to defaults.
Specify all the individual settings.
Setup applied for wrappers.Returns type.Delegate to get wrapped type from provided wrapper type.
If wrapper is generic, then wrapped type is usually a generic parameter.Per name.Delegate returning wrapped type from wrapper type. Overwrites other options.Default setup
Default is -1 for generic wrapper with single type argument.
Need to be set for multiple type arguments.
Returns generic wrapper setup.
Default for is -1 for generic wrapper with single type argument.
Index need to be set for multiple type arguments. need to be set
when generic wrapper type arguments should be ignored.Unwraps service type or returns the as-is.Setup applied to decorators.Returns Decorator factory type.If provided specifies relative decorator position in decorators chain.
Greater number means further from decoratee - specify negative number to stay closer.
Decorators without order (Order is 0) or with equal order are applied in registration order
- first registered are closer decoratee.Instructs to use decorated service reuse. Decorated service may be decorator itself.Default setup.Creates decorator setup with optional condition. applied to
decorated service to find that service is the decorator target. specifies
relative decorator position in decorators chain. Greater number means further from decoratee -
specify negative number to stay closer. Decorators without order (Order is 0) or with equal order
are applied in registration order - first registered are closer decoratee.Facility for creating concrete factories from some template/prototype. Example:
creating closed-generic type reflection factory from registered open-generic prototype factory.Generated factories so far, identified by the service type and key pair.Returns factory per request. May track already generated factories and return one without regenerating.
Instructs how to deal with factory result expression:
Is up to DryIoc to decide,
Prevents DryIoc to set `DoNotCache`.
If set, the expression won't be cached
Base class for different ways to instantiate service:
Through reflection - Using custom delegate - Using custom expression - A placeholder for future actual implementation -
For all of the types Factory should provide result as and .
Factories are supposed to be immutable and stateless.
Each created factory has an unique ID set in .Get next factory ID in a atomic way.The ID.Unique factory id generated from static seed.Reuse policy for created services.Setup may contain different/non-default factory settings.Checks that condition is met for request or there is no condition setup.Shortcut for .Non-abstract closed implementation type. May be null if not known beforehand, e.g. in .Allow inheritors to define lazy implementation typeIndicates that Factory is factory provider and
consumer should call to get concrete factory.Registration order.Settings (if any) to select Constructor/FactoryMethod, Parameters, Properties and Fields.The factory inserts the runtime-state into result expression, e.g. delegate or pre-created instance.
Indicates how to deal with the result expression
Instructs to skip caching the factory unless it really wants to do so via `PleaseDontSetDoNotCache`
Initializes reuse and setup. Sets the
(optional) (optional)
The main factory method to create service expression, e.g. "new Client(new Service())".
If has specified, they could be used in expression.
Service request.
Created expression.Returns service expression: either by creating it with or taking expression from cache.
Before returning method may transform the expression by applying , or/and decorators if found any.Applies reuse to created expression, by wrapping passed expression into scoped access
and producing the result expression.
[Obsolete("Not need to control on the factory level, the remaining UseInstanceFactory will be removed")]
Creates factory delegate from service expression and returns it.
Returns nice string representation of factory.Declares delegate to get single factory method or constructor for resolved request.Specifies how to get parameter info for injected parameter and resolved requestSpecifies what properties or fields to inject and how.DSL for specifying injection rules.Returns default service info wrapper for each parameter info.Returns service info which considers each parameter as optional.Combines source selector with other. Other is used as fallback when source returns null.Obsolete: please use Overrides source parameter rules with specific parameter details.
If it is not your parameter just return null.
Original parameters rules
Should return specific details or null.
New parameters rules.Adds to selector service info for parameter identified by .
Original parameters rules. Name to identify parameter.
(optional) (optional)
(optional) By default throws exception if unresolved.
(optional) Specifies default value to use when unresolved.
(optional) Required metadata key Required metadata or value.
New parameters rules.Specify parameter by name and set custom value to it.Specify parameter by name and set custom value to it.Adds to selector service info for parameter identified by type .
Source selector. The type of the parameter.
(optional) (optional)
(optional) By default throws exception if unresolved.
(optional) Specifies default value to use when unresolved.
(optional) Required metadata key Required metadata or value.
Combined selector.Adds to selector service info for parameter identified by type .Type of parameter. Source selector.
(optional) (optional)
(optional) By default throws exception if unresolved.
(optional) Specifies default value to use when unresolved.
(optional) Required metadata key Required metadata or value.
Combined selector.Specify parameter by type and set its details.Specify parameter by type and set custom value to it.Specify parameter by type and set custom value to it.
Original parameters rules.
The type of the parameter.
Custom value provider.
New parameters rules.DSL for specifying injection rules.Say to not resolve any properties or fields.Public assignable instance members of any type except object, string, primitives types, and arrays of those.Public, declared, assignable, non-primitive properties.Should return service info for input member (property or field).Generates selector property and field selector with settings specified by parameters.
If all parameters are omitted the return all public not primitive members.Combines source properties and fields with other. Other will override the source condition.
Source selector. Specific other selector to add.
Combined result selector.Obsolete: please use Specifies service details (key, if-unresolved policy, required type) for property/field with the name.
Original member selector. Member name. Details.
New selector.Adds to selector service info for property/field identified by .
Source selector. Name to identify member.
(optional) (optional)
(optional) By default returns default value if unresolved.
(optional) Specifies default value to use when unresolved.
(optional) Required metadata key Required metadata or value.
Combined selector.Specifies custom value for property/field with specific name.Returns true if property matches flags provided.
Property to match
Says to include non public properties.
Says to include properties of primitive type.
True if property is matched and false otherwise.Returns true if field matches flags provided.
Field to match.
Says to include non public fields.
Says to include fields of primitive type.
True if property is matched and false otherwise.Reflects on constructor parameters and members,
creates expression for each reflected dependency, and composes result service expression.Non-abstract service implementation type. May be open generic.False for lazy implementation type, to prevent its early materialization.Provides closed-generic factory for registered open-generic variant.Injection rules set for Constructor/FactoryMethod, Parameters, Properties and Fields.FactoryID of generator (open-generic) factory.Will contain factory ID of generator's factory for generated factory.Creates factory providing implementation type, optional reuse and setup.
(optional) Optional if Made.FactoryMethod is present Non-abstract close or open generic type.
(optional) (optional) (optional)
Creates factory providing implementation type, optional reuse and setup.
Provider of non-abstract closed or open-generic type.
(optional) (optional) (optional)
Creates service expression.Creates service expression using client provided expression factory delegate.Wraps provided delegate into factory.
Delegate that will be used internally to create service expression.
(optional) Reuse. (optional) Setup.
Creates service expression using wrapped delegate.
Request to resolve. Expression returned by stored delegate.
Wraps the instance in registry
The registered pre-created object instanceNon-abstract closed implementation type.
Simplified specially for register instance
Creates factory.Wraps the instance in expression constantSimplified path for the registered instanceUsed at resolution root too simplify getting the actual instanceThis factory is the thin wrapper for user provided delegate
and where possible it uses delegate directly: without converting it to expression.Non-abstract closed implementation type.Creates factory.Create expression by wrapping call to stored delegate with provided request.If possible returns delegate directly, without creating expression trees, just wrapped in .
If decorator found for request then factory fall-backs to expression creation.
Request to resolve.
Factory delegate directly calling wrapped delegate, or invoking expression if decorated.
Should return value stored in scope
Lazy object storage that will create object with provided factory on first access,
then will be returning the same object for subsequent access.Parent scope in scope stack. Null for root scope.Optional name object associated with scope.True if scope is disposed.Looks up for stored item by id.
Create the value via `FactoryDelegate` passing the `IResolverContext`
Creates, stores, and returns created item
Tracked item will be disposed with the scope.
Smaller will be disposed first.Tracked item will be disposed with the scope.Sets or adds the service item directly to the scope services
[Obsolete("Removing because it is not used")]
Sets (replaces) the factory for specified type.
Looks up for stored item by type.
Clones the scope.The method will clone the scope factories and already created services,
but may or may not drop the disposables thus ensuring that only the new disposables added in clone will be disposed
Scope is container to hold the shared per scope items and dispose items.
Scope uses Locking to ensure that the object factory called only once.
Parent scope in scope stack. Null for the root scope.Optional name associated with scope.True if scope is disposed.Creates scope with optional parent and name.The amount of time to wait for the other party to create the scoped (or singleton) service.
The default value of 5000 ticks rougly corresponds to the 5 seconds.
[Obsolete("Removing because it is not used")]
Can be used to manually add service for disposalTracked item will be disposed with the scope.
[Obsolete("Removing because it is not used")]
Try retrieve instance from the small registry.Enumerates all the parent scopes upwards starting from this one.Disposes all stored objects and empties item storage.
The disposal happens in REVERSE resolution / injection order, consumer first, dependency next.
It will allow consumer to do something with its dependency before it is disposed.All disposal exceptions are swallowed except the ContainerException,
which may indicate container misconfiguration.Prints scope info (name and parent) to string for debug purposes.Delegate to get new scope from old/existing current scope.
Old/existing scope to change.
New scope or old if do not want to change current scope.Provides ambient current scope and optionally scope storage for container,
examples are HttpContext storage, Execution context, Thread local.Returns current scope or null if no ambient scope available at the moment.Current scope or null.Changes current scope using provided delegate. Delegate receives current scope as input and
should return new current scope.
Delegate to change the scope.
Important: may be called multiple times in concurrent environment.
Make it predictable by removing any side effects.New current scope. So it is convenient to use method in "using (var newScope = ctx.SetCurrent(...))".Tracks one current scope per thread, so the current scope in different tread would be different or null,
if not yet tracked. Context actually stores scope references internally, so it should be disposed to free them.Provides static name for context. It is OK because its constant.Returns current scope in calling Thread or null, if no scope tracked.Change current scope for the calling Thread.Disposes the scopes and empties internal scope storage.
Collection of scoped by their managed thread id
Simplified scope agnostic reuse abstraction. More easy to implement,
and more powerful as can be based on other storage beside reuse.Relative to other reuses lifespan value.Optional name. Use to find matching scope by the name.
It also may be interpreted as object[] Names for matching with multiple scopes Returns true if reuse can be applied: may check if scope or other reused item storage is present.Returns composed expression.Returns container bound scope for storing singleton objects.Big lifespan.Relative to other reuses lifespan value.Returns true because singleton is always available.Returns expression call to GetOrAddItem.Pretty prints reuse name and lifespanSpecifies that instances are created, stored and disposed together with some scope.Less than Singleton'sRelative to other reuses lifespan value.Returns true if scope is open and the name is matching with reuse .Creates scoped item creation and access expression.Pretty prints reuse to string.Reuse string.Creates the reuse.Creates the reuse optionally specifying its name.Flag indicating that it is a scope or singleton.
Subject
Tracks the Unordered disposal in the current scope or in the singleton as fallback
Subject
Subject
Subject
Subject
Subject
Abstracts way to match reuse and scope namesDoes the job.Represents multiple namesWraps multiple namesMatches all the name in a loop until first match is found, otherwise returns false.Holds the name for the resolution scope.Creates scope with specified service type and keyCreates scope with specified service type and key.Type of service opening the scope.Optional service key of service opening the scope.String representation for easy debugging and understood error messages.Specifies pre-defined reuse behaviors supported by container:
used when registering services into container with methods.Synonym for absence of reuse.Specifies to store single service instance per .Same as InCurrentScope. From now on will be the default name.Same as InCurrentNamedScope. From now on will be the default name.Specifies all the scope detailsScoped to multiple names.[Obsolete("Use ScopedToService to prevent ambiguity with the ScopeTo(object name) where name is the Type")]Scoped to the scope created by the service with the specified type and optional keyScoped to the scope created by the service with the specified type and optional keyScoped to the scope created by the service with the specified type and optional keyThe same as but if no open scope available will fallback to The is applied the same way as for reuse.Obsolete: same as .Obsolete: same as .Returns current scope reuse with specific name to match with scope.
If name is not specified then function returns .
(optional) Name to match with scope.
Created current scope reuse.Obsolete: will be soon - please use ScopedToService instead.Obsolete: will be soon - please use ScopedToService instead.Same as Scoped but requires .Special name that by convention recognized by .Obsolete: please prefer using instead.
The named scope has performance drawback comparing to just a scope.
If you need to distinguish nested scope, give names to them instead of naming the top web request scope.Policy to handle unresolved service.If service is unresolved for whatever means, it will throw the respective exception.If service is unresolved for whatever means, it will return default(serviceType) value.If service is not registered, then it will return default, for other errors it will throw.Declares minimal API for service resolution.
Resolve default and keyed is separated because of optimization for faster resolution of the former.Resolves default (non-keyed) service from container and returns created service object.
Service type to search and to return.
Says what to do if service is unresolved.
Created service object or default based on provided.Resolves service instance from container.
Service type to search and to return.
(optional) service key used for registering service.
(optional) Says what to do if service is unresolved.
(optional) Registered or wrapped service type to use instead of ,
or wrapped type for generic wrappers. The type should be assignable to return .
(optional) Dependency chain info.
(optional) To specify the dependency objects to use instead of resolving them from container.
Created service object or default based on parameter.Resolves all services registered for specified , or if not found returns
empty enumerable. If specified then returns only (single) service registered with this type.
Return type of an service item.
(optional) Resolve only single service registered with the key.
(optional) Actual registered service to search for.
Dependency resolution path info.
(optional) To specify the dependency objects to use instead of resolving them from container.
Enumerable of found services or empty. Does Not throw if no service found.Specifies options to handle situation when registered service is already present in the registry.Appends new default registration or throws registration with the same key.Throws if default or registration with the same key is already exist.Keeps old default or keyed registration ignoring new registration: ensures Register-Once semantics.Replaces old registration with new one.Adds the new implementation or null (Made.Of),
otherwise keeps the previous registration of the same implementation type.Existing registration info.Registered factory.Required service type.May be null for single default service, or for multiple default services.Provides registration order across all factory registrations in container.May be the same for factory registered with multiple services
OR for closed-generic factories produced from the single open-generic registration.Implementation type if available.Shortcut to property, useful to find all rootsShortcut to service info.Overrides the service type and pushes the original service type to required service typeOverrides the service type and pushes the original service type to required service typeCreates info. Registration order is figured out automatically based on Factory.Orders by registrationPretty-prints info to string.Defines operations that for changing registry, and checking if something exist in registry.Registers factory in registry with specified service type and key for lookup.
Returns true if factory was added to registry, false otherwise. False may be in case of
setting and already existing factory
To register.
Service type as unique key in registry for lookup.
Service key as complementary lookup for the same service type.
Policy how to deal with already registered factory with same service type and key.
[performance] Confirms that service and implementation types are statically checked by compiler.
True if factory was added to registry, false otherwise.
False may be in case of setting and already existing factory.Returns true if expected factory is registered with specified service key and type.
Not provided or null means to check the
alone with any service key.Removes factory with specified service type and key from registry and cache.
BUT consuming services may still hold on the resolved service instance.
The cache of consuming services may also hold on the unregistered service. Use `IContainer.ClearCache` to clear all cache.Returns all registered service factories with their Type and optional Key.
Decorator and Wrapper types are not included.Searches for registered factories by type, and key (if specified),
and by factory type (by default uses ).
May return empty, 1 or multiple factories.
Puts instance into the current scope or singletons.
Puts instance created via the passed factory on demand into the current or singleton scopeWhat to do with registrations when creating the new container from the existent one.Shares both registrations and resolution cache if anyClones the registrations but preserves the resolution cacheClones the registrations and drops the cache -- full reset!Combines registrator and resolver roles, plus rules and scope management.Rules for defining resolution/registration behavior throughout container.Represents scope bound to container itself, and not an ambient (context) thingy.Creates new container from the current one by specifying the listed parameters.
If the null or default values are provided then the default or new values will be applied.
Nothing will be inherited from the current container.
If you want to inherit something you need to provide it as parameter.Creates new container from the current one by specifying the listed parameters.
If the null or default values are provided then the default or new values will be applied.
Nothing will be inherited from the current container. If you want to inherit something you need to provide it as parameter.Creates new container from the current one by specifying the listed parameters.
If the null or default values are provided then the default or new values will be applied.
Nothing will be inherited from the current container. If you want to inherit something you need to provide it as parameter.Produces new container which prevents any further registrations.
(optional)Controls what to do with registrations: ignore or throw exception.
Throws exception by default.
New container preserving all current container state but disallowing registrations.Searches for requested factory in registry, and then using .
Factory request.
Found factory, otherwise null if is set to .Searches for registered service factory and returns it, or null if not found.
Will use if specified.
Factory request.
Found factory or null.Finds all registered default and keyed service factories and returns them.
It skips decorators and wrappers.
Service type to look for, may be open-generic type too.
(optional) For generic serviceType instructs to look for
both closed and open-generic registrations.
Enumerable of found pairs.Returned Key item should not be null - it should be .Searches for registered wrapper factory and returns it, or null if not found.
Service type to look for. Found wrapper factory or null.Returns all decorators registered for the service type.Decorator factories.Creates decorator expression: it could be either Func{TService,TService},
or service expression for replacing decorators.
Decorated service request.
Decorator expression.If is generic type then this method checks if the type registered as generic wrapper,
and recursively unwraps and returns its type argument. This type argument is the actual service type we want to find.
Otherwise, method returns the input .
Type to unwrap. Method will return early if type is not generic.
Required service type or null if don't care.
Unwrapped service type in case it corresponds to registered generic wrapper, or input type in all other cases.Converts known items into custom expression or wraps in a constant expression.
Item to convert.
(optional) Type of item, otherwise item .
(optional) Throws for non-primitive and not-recognized items,
identifying that result expression require run-time state. For compiled expression it means closure in lambda delegate.
Returns constant or state access expression for added items.Clears cache for specified service(s). But does not clear instances of already resolved/created singletons and scoped services!
Target service type.
(optional) If not specified, clears cache for all .
(optional) If omitted, the cache will be cleared for all registrations of .
True if target service was found, false - otherwise.
Puts instance created via the passed factory on demand into the current or singleton scope
[Obsolete("Replaced by `Use` to put runtime data into container scopes and with `RegisterInstance` as a sugar for `RegisterDelegate(_ => instance)`")]
Resolves all registered services of type on demand,
when enumerator called. If service type is not found, empty returned.Service type to resolve.Exposes internal items enumerable.Wraps lazy resolved items. Lazy resolved items.
Return items enumerator.Wrapper type to box service with associated arbitrary metadata object.Service type.Arbitrary metadata object type.Value or object with associated metadata.Associated metadata object. Could be anything.Boxes value and its associated metadata together.
Exception that container throws in case of error. Dedicated exception type simplifies
filtering or catching container relevant exceptions from client code.
Error code of exception, possible values are listed in class.Simplifies the access to the error name.Many collected exceptionsCreates exception by wrapping and its message,
optionally with exception.Gets error message based on provided args.Prints argument for formatted message. To print. Printed string.Collects many exceptions.Creates exception with message describing cause and context of error.Creates exception with message describing cause and context of error,
and leading/system exception causing it.The default exception message format.Allows the formatting of the final exception message.Defines error codes and error messages for all DryIoc exceptions (DryIoc extensions may define their own.)List of error messages indexed with code.Returns the name of error with the provided error code.Checked error condition, possible error sources.Unspecified, just throw.Predicate evaluated to false.Checked object is null.Checked object is of unexpected type.Checked type is not assignable to expected typeInvoked operation throws, it is source of inner exception.Just stores many collected exceptions.Enables more clean error message formatting and a bit of code contracts.Returns the default message specified for code.Declares mapping between type and code to specific .Returns matched exception for error check and error code.Throws matched exception with provided error code if throw condition is true.Throws matched exception with provided error code if throw condition is true.
Otherwise returns source .Throws exception if is null, otherwise returns .Throws exception if is not assignable to type specified by ,
otherwise just returns .Throws if is not assignable from .Invokes and in case of re-throws it as inner-exception.Just throws the exception with the code.Throws instead of returning value of .
Supposed to be used in expression that require some return value.Throws if contidion is true, otherwise returns the `default(T)` valueThrows the one with manyh collected exceptionsCalled from the generated code to check if WeakReference.Value is GCed.Throws if the object is null.Contains helper methods to work with Type: for instance to find Type implemented base types and interfaces, etc.Preserves the stack trace before re-throwing.Flags for method.Include nor object not source type.Include source type to list of implemented types.Include type to list of implemented types.Returns all interfaces and all base types (in that order) implemented by .
Specify to include itself as first item and
type as the last item.Gets a collection of the interfaces implemented by the current type and its base types.Gets all declared and if specified, the base members too.Returns true if the contains all generic parameters
from .Returns true if class is compiler generated. Checking for CompilerGeneratedAttribute
is not enough, because this attribute is not applied for classes generated from "async/await".Returns true if type is generic.Returns true if type is generic type definition (open type).Returns true if type is closed generic: does not have open generic parameters, only closed/concrete ones.Returns true if type if open generic: contains at list one open generic parameter. Could be
generic type definition as well.Returns generic type definition if type is generic and null otherwise.Returns generic type parameters and arguments in order they specified. If type is not generic, returns empty array.Returns array of interface and base class constraints for provider generic parameter type.If type is array returns is element type, otherwise returns null.
Source type. Array element type or null.Return base type or null, if not exist (the case for only for object type).Checks if type is public or nested public in public type.Returns true if type is class.Returns true if type is value type.Returns true if type is interface.Returns true if type if abstract or interface.Returns true if type is static.Returns true if type is enum type.Returns true if type can be casted with conversion operators.
Returns `target source.op_(Explicit|Implicit)(source)` or null if not found
Returns `target target.op_(Explicit|Implicit)(source)` or null if not found
Returns true if type is assignable to type.Returns true if type is assignable to type.`to` should be the closed-generic typeReturns true if type of is assignable to source .Returns true if provided type IsPrimitive in .Net terms, or enum, or string,
or array of primitives if is true.Returns all attributes defined on .Recursive method to enumerate all input type and its base types for specific details.
Details are returned by delegate.Returns all public instance constructors for the typeReturns all public instance constructors for the typeEnumerates all constructors from input type.Searches and returns the first constructor by its signature, e.g. with the same number of parameters of the same type.Searches and returns constructor by its signature.Searches and returns constructor by its signature, or throws if not foundReturns single constructor otherwise (if no constructor or more than one) returns null.Returns single constructor otherwise (if no or more than one) throws an exceptionLooks up for single declared method with the specified name. Returns null if method is not found.Looks for single declared (not inherited) method by name, and throws if not found.Looks up for method with and specified parameter types.Looks up for method with and specified parameter types.Returns property by name, including inherited. Or null if not found.Returns property by name, including inherited. Or null if not found.Returns field by name, including inherited. Or null if not found.Returns field by name, including inherited. Or null if not found.Returns type assembly.Is true for interface declared property explicitly implemented, e.g. IInterface.PropReturns true if member is static, otherwise returns false.
Find if property is static
Return either , or ,
.Returns true if field is backing field for property.Returns true if property is indexer: aka this[].Returns true if type is generated type of hoisted closure.Returns attributes defined for the member/method.Returns attributes defined for parameter.Get types from assembly that are loaded successfully.
Hacks the to get failing to load types metadata.Creates default(T) expression for provided .Provides pretty printing/debug view for number of types.Default separator used for printing enumerable.Prints input object by using corresponding Print methods for know types.
Builder to append output to. Object to print.
(optional) Quote to use for quoting string object.
(optional) Separator for enumerable.
(optional) Custom type printing policy.
String builder with appended output.Appends string to string builder quoting with if provided.
String builder to append string to. String to print.
(optional) Quote to add before and after string.
String builder with appended string.Prints enumerable by using corresponding Print method for known item type.
String builder to append output to.
Items to print.
(optional) Custom separator if provided.
(optional) Custom item printer if provided.
String builder with appended output.Default delegate to print Type details: by default prints Type FullName and
skips namespace if it start with "System."Pretty prints the in proper C# representation.
Allows to specify if you want Name instead of FullName.Pretty-prints the typePorts some methods from .Net 4.0/4.5
Something for portability
Portable version of Assembly.GetTypes or Assembly.DefinedTypes.Portable version of PropertyInfo.GetGetMethod.Portable version of PropertyInfo.GetSetMethod.Returns managed Thread ID either from Environment or Thread.CurrentThread whichever is available.Stores scopes propagating through async-await boundaries.Statically known name of root scope in this context.
It is fine to use a default instance, cause the async local scope are actually a static one
Returns current scope or null if no ambient scope available at the moment.Current scope or null.Changes current scope using provided delegate. Delegate receives current scope as input and should return new current scope.
Delegate to change the scope.
Important: may be called multiple times in concurrent environment.
Make it predictable by removing any side effects.New current scope. It is convenient to use method in "using (var newScope = ctx.SetCurrent(...))".Nothing to dispose.Provides for the type.Wraps input type into structure.
Input type. Type info wrapper.Partial analog of TypeInfo existing in .NET 4.5 and higher.Creates type info by wrapping input type. Type to wrap.
Polyfill for absence of FastExpressionCompiler: https://github.com/dadhi/FastExpressionCompiler Helpers for functional composition
Always a true condition.
Identity function returning passed argument as result.
Forward pipe operator (`|>` in F#)
Forward pipe operator (`|>` in F#) with the additional state A for two arguments function
Cast to the R type with the forward pipe operator (`|>` in F#)
Forward pipe operator (`|>` in F#) but with side effect propagating the original `x` value
Forward pipe operator (`|>` in F#) but with side effect propagating the original `x` value and the state object
Lifts argument to Func without allocations ignoring the first argument.
For example if you have `Func{T, R} = _ => instance`,
you may rewrite it without allocations as `instance.ToFunc{A, R}`
Helpers for lazy instantiationsProvides result type inference for creation of lazy.
Replacement for `Void` type which can be used as a type argument and value.
In traditional functional languages this type is a singleton empty record type,
e.g. `()` in Haskell https://en.wikipedia.org/wiki/Unit_type
Singleton unit value - making it a lower-case so you could import `using static ImTools.Unit;` and write `return unit;`
Equals to any other Unit
Using type hash code for the value
Simple value provider interface - useful for the type pattern matching via `case I{T} x: ...`
The value in this case ;)
Helpers for `Is` and `Union`
Pretty prints the Union using the type information
Wraps the `T` in a typed `TData` struct value in a one-line declaration,
so the ]]>
is different from the ]]>
Creation method for the consistency with other types
Nested structure that hosts a value.
All nested types by convention here are lowercase
The value
Constructor
Item without the data payload
Single item value
Nested structure that hosts a value.
All nested types by convention here are lowercase
Wraps the `T` in a named `TBox` class in a one-line declaration,
so the ]]>
is different from the ]]>
Wraps the value
Unnamed discriminated union (with Empty name), shorter name for simplified inline usage
Discriminated union
To tag the cases with enum value for efficient pattern matching of required -
otherwise we need to use `is CaseN` pattern or similar which is less efficient
Tags Case1
Tags Case2
The base interface for the cases to operate.
The naming is selected to start from the lower letter, cause we need to use the nested type.
It is an unusual case, that's why using the __union__ will be fine to highlight this.
The tag
Matches the union cases to the R value
Creates the respective case
Creates the respective case
Wraps the respective case
Implicit conversion
The case value
Wraps the value
Wraps the respective case
Conversion
The case value
Wraps the value
Methods to work with immutable arrays and some sugar.Returns singleton empty array of provided type.Array item type.Empty array.Wraps item in array.Returns true if array is null or have no items.Type of array item.
Source array to check. True if null or has no items, false otherwise.Returns empty array instead of null, or source array otherwise.Type of array item.
Returns source enumerable if it is array, otherwise converts source to array or an empty array if null.
Returns source enumerable if it is list, otherwise converts source to IList or an empty array if null.
Array copyReturns new array consisting from all items from source array then all items from added array.
If source is null or empty, then added array will be returned.
If added is null or empty, then source will be returned.Array item type.
Array with leading items.
Array with following items.
New array with items of source and added arrays.Append a single item value at the end of source array and returns its copyPerformant concat of enumerables in case of arrays.
But performance will degrade if you use Concat().Where().Type of item.
goes first.
appended to source.
empty array or concat of source and other.Returns new array with appended,
or at , if specified.
If source array could be null or empty, then single value item array will be created despite any index.Array item type.
Array to append value to.
Value to append.
(optional) Index of value to update.
New array with appended or updated value.Calls predicate on each item in array until predicate returns true,
then method will return this item index, or if predicate returns false for each item, method will return -1.Type of array items.
Source array: if null or empty, then method will return -1.
Delegate to evaluate on each array item until delegate returns true.
Index of item for which predicate returns true, or -1 otherwise.
Minimizes the allocations for closure in predicate lambda with the provided Looks up for item in source array equal to provided value, and returns its index, or -1 if not found.Type of array items.
Source array: if null or empty, then method will return -1.
Value to look up.
Index of item equal to value, or -1 item is not found.The same as `IndexOf` but searching the item by referenceProduces new array without item at specified .
Will return array if index is out of bounds, or source is null/empty.Type of array item.
Input array. Index if item to remove.
New array with removed item at index, or input source array if index is not in array.Looks for item in array using equality comparison, and returns new array with found item remove, or original array if not item found.Type of array item.
Input array. Value to find and remove.
New array with value removed or original array if value is not found.Returns first item matching the , or default item value.item type
items collection to search
condition to evaluate for each item.
First item matching condition or default value.
Version of FindFirst with the fixed state used by predicate to prevent allocations by predicate lambda closure
Returns first item matching the , or default item value.item type
items collection to search
condition to evaluate for each item.
First item matching condition or default value.Returns element if collection consist on single element, otherwise returns default value.
It does not throw for collection with many elementsDoes for each item
Appends source to results
MUTATES the source by updating its item or creates another array with the copies,
the source then maybe a partially updatedWhere method similar to Enumerable.Where but more performant and non necessary allocating.
It returns source array and does Not create new one if all items match the condition.Type of source items.
If null, the null will be returned.
Condition to keep items.
New array if some items are filter out. Empty array if all items are filtered out. Original array otherwise.
Match with the additional state to use in to minimize the allocations in lambda closure
Where method similar to Enumerable.Where but more performant and non necessary allocating.
It returns source array and does Not create new one if all items match the condition.Type of source items.Type of result items.
If null, the null will be returned.
Condition to keep items. Converter from source to result item.
New array of result items.
Match with the additional state to use in and to minimize the allocations in lambda closure
Maps all items from source to result array.Source item typeResult item type
Source items Function to convert item from source to result.
Converted items
Map with additional state to use in to minimize allocations in lambda closure
Maps all items from source to result collection.
If possible uses fast array Map otherwise Enumerable.Select.Source item typeResult item type
Source items Function to convert item from source to result.
Converted itemsIf is array uses more effective Match for array, otherwise just calls WhereIf is array uses more effective Match for array,otherwise just calls Where, SelectWrapper that provides optimistic-concurrency Swap operation implemented using .Type of object to wrap.Gets the wrapped value.Creates ref to object, optionally with initial value provided.
(optional) Initial value.
Exchanges currently hold object with - see for details.
Delegate to produce new object value from current one passed as parameter.
Returns old object value the same way as Important: May be called multiple times to retry update with value concurrently changed by other code.
Option without allocation for capturing `a` in closure of `getNewValue`
Option without allocation for capturing `a` and `b` in closure of `getNewValue`
Just sets new value ignoring any intermingled changes and returns the original valueold valueDirectly sets the value and returns the new valueCompares current Referred value with and if equal replaces current with True if current value was replaced with new value, and false if current value is outdated (already changed by other party).[!CDATA[
var value = SomeRef.Value;
if (!SomeRef.TrySwapIfStillCurrent(value, Update(value))
SomeRef.Swap(v => Update(v)); // fallback to normal Swap with delegate allocation
]]Provides optimistic-concurrency consistent operation.
The default max retry count - can be overridden by `Swap` optional parameter
Factory for with type of value inference.Type of value to wrap.
Initial value to wrap.
New ref.Creates new ref to the value of original ref.Ref value type.
Original ref. New ref to original value.First, it evaluates new value using function.
Second, it checks that original value is not changed.
If it is changed it will retry first step, otherwise it assigns new value and returns original (the one used for ).Type of value to swap.
Reference to change to new value
Delegate to get value from old one.
(optional)
Old/original value. By analogy with .Important: May be called multiple times to retry update with value concurrently changed by other code.Swap with the additional state required for the delegate .
May prevent closure creation for the delegateSwap with the additional state required for the delegate .
May prevent closure creation for the delegateSwap with the additional state , required for the delegate .
May prevent closure creation for the delegateSwap with the additional state , , required for the delegate .
May prevent closure creation for the delegatePrintable thing via provided printer Print to the provided string builder via the provided printer.Produces good enough hash codes for the fieldsCombines hashes of two fieldsInspired by System.Tuple.CombineHashCodes
Simple unbounded object pool
Give me an objectGive it backImmutable Key-Value pair. It is reference type (could be check for null),
which is different from System value type .
In addition provides and implementations.Type of Key.Type of Value.Key.Value.Creates Key-Value object by providing key and value. Does Not check either one for null.
key.value.
Creates nice string view.String representation.Returns true if both key and value are equal to corresponding key-value of other object.Combines key and value hash codeHelpers for .Creates the key value pair.Creates the pair with the new value
Simple helper for creation of the pair of two parts.
Pairs key with value.
Helper structure which allows to distinguish null value from the default value for optional parameter.Allows to transparently convert parameter argument to opt structure.Argument value.Indicates that value is provided.Wraps passed value in structure. Sets the flag that value is present.Helper to get value or default value if value is not present.Ever growing listDefault initial capacity
The items array
The count
Constructs the thing
Push the new slot and return the ref to it
Adds the new item possibly extending the item collection
Pops the item - just moving the counter back
Expands the items starting with 2
Immutable list - simplest linked list with the Head and the Tail.Empty list to Push to.True for empty list.First value in a list.The rest of values or Empty if list has a single value.Prepends new value and returns new list.Enumerates the list.String representation for debugging purposesExtension methods providing basic operations on a list.
Split list into (Head, Tail, IsEmpty) tuple
Constructs the reversed list from the parameter array of items
Constructs the list as the reversed input list
Constructs the list as the reversed enumerable
Constructs list of one elementConstructs list from head and tailApples some effect action to each elementFold list to a single value. The respective name for it in LINQ is AggregateFold list to a single value with index of item. The respective name for it in LINQ is Aggregate.Returns new list in reverse order.Maps the items from the first list to the result list.Maps with indexCopies list to array.
Zipper is an immutable persistent data structure, to represent collection with single focused (selected, active) element.
Consist of REVERSED `Left` immutable list, `Focus` element, and the `Right` immutable list. That's why a Zipper name,
where left and right part are joined / zipped in focus item.
Empty singleton instance to start building your zipper
True is zipper does not contain items
Index of Focus item, from `0` to `Count-1`
Number of items
Left REVERSED list, so the Head of the list is just prior the Focus item
Right list, where Head is just after the Focus item
Single focus item
Sets a new focus and pushes the old focus to the Left list.
Sets a new focus and pushes the old focus to the Left list.
Sets a new focus and pushes the old focus to the right list.
Sets a new focus and pushes the old focus to the right list.
Removes a focus, filling the hole with the item from the left list, or from the right if the left is empty
Removes a focus, filling the hole with the item from the right list, or from the left if the right is empty
Shifts focus one element to the left (decrementing its Index).
Shifts focus one element to the right (incrementing its Index).
Sets a new focus and returns a new zipper with the left and right lists unchanged
Maps over the zipper items producing a new zipper
Maps over the zipper items with item index, producing a new zipper
Other ImZipper methods
Appends array items to zipper
Converts to array.
Shifts focus to a specified index, e.g. a random access
Updates a focus element if it is present, otherwise does nothing.
If the focus item is the equal one, then returns the same zipper back.
Update the item at random index, by shifting and updating it
Update the item at random index, by shifting and updating it
Folds zipper to a single value
Folds zipper to a single value by using an item index
Apply some effect action on each element
Given the old value should and the new value should return result updated value.
Update handler including the key
Fold reducer. Designed as a alternative to `Func{V, S, S}` but with possibility of inlining on the call side.
Note: To get the advantage of inlining the can the interface should be implemented and passed as a NON-GENERIC STRUCT
Reduce method
Immutable http://en.wikipedia.org/wiki/AVL_tree with integer keys and values.
Empty tree to start with.Returns true if tree is empty.
Prevents multiple creation of an empty tree
Height of the longest sub-tree/branch - 0 for the empty treePrints "empty"Wraps the stored data with "fixed" reference semantics - when added to the tree it did not change or reconstructed in memory
The Key is basically the hash, or the Height for ImMapTree
The value - may be modified if you need a Ref{V} semantics
Constructs the entry with the default valueConstructs the entry
Prints the key value pair
The two level - two node tree with either left or right
Always two
Contains the once created data node
Right branch or empty.
Constructor
Prints the key value pair
The tree always contains Left and Right node, for the missing leaf we have
Starts from 2
Starts from 2 - allows to access the field directly when you know it is a Tree
Contains the once created data node
Left sub-tree/branch, or empty.
Right sub-tree/branch, or empty.md
Outputs the brief tree info - mostly for debugging purposesAdds or updates the left or right branchAdds the left or right branchAdds to the left or right branch, or keeps the un-modified mapAdds to the left or right branch, or keeps the un-modified mapAdds to the left or right branch, or keeps the un-modified mapImMap methods Adds or updates the value by key in the map, always returns a modified map Adds or updates the value by key in the map, always returns a modified map Adds the value by key in the map - ASSUMES that the key is not in the map, always returns a modified map Adds the value for the key or returns the un-modified map if key is already present Adds the entry with default value for the key or returns the un-modified map if key is already present Adds the entry for the key or returns the un-modified map if key is already present Returns the new map with the updated value for the key, or the same map if the key was not found.Returns the new map with the updated value for the key, ASSUMES that the key is not in the map.Returns the new map with the value set to default, or the same map if the key was not found. Returns `true` if key is found or `false` otherwise. Returns the entry if key is found or null otherwise. Looks for the sure present entry - in cases when we know for certain that the map contains the entry Returns the value if key is found or default value otherwise. Returns true if key is found and sets the value. Returns true if key is found and sets the value.
Enumerates all the map nodes from the left to the right and from the bottom to top
You may pass `parentStacks` to reuse the array memory.
NOTE: the length of `parentStack` should be at least of map (height - 2) - the stack want be used for 0, 1, 2 height maps,
the content of the stack is not important and could be erased.
Folds all the map nodes with the state from left to right and from the bottom to top
You may pass `parentStacks` to reuse the array memory.
NOTE: the length of `parentStack` should be at least of map (height - 2) - the stack want be used for 0, 1, 2 height maps,
the content of the stack is not important and could be erased.
Folds all the map nodes with the state from left to right and from the bottom to top
You may pass `parentStacks` to reuse the array memory.
NOTE: the length of `parentStack` should be at least of map (height - 2) - the stack want be used for 0, 1, 2 height maps,
the content of the stack is not important and could be erased.
Visits all the map nodes with from the left to the right and from the bottom to the top
You may pass `parentStacks` to reuse the array memory.
NOTE: the length of `parentStack` should be at least of map height, content is not important and could be erased.
Wraps Key and Value payload to store inside ImMapEntryThe keyThe valueConstructs a pairUses the user provided hash and adds or updates the tree with passed key-value. Returns a new tree.Efficiently creates the new entryEfficiently creates the new entryUses the user provided hash and adds or updates the tree with passed key-value. Returns a new tree.Adds or updates the Type-keyed entry with the value. Returns a new tree.Uses the provided hash and adds or updates the tree with the passed key-value. Returns a new tree.Adds the new entry or keeps the current map if entry key is already presentAdds the new entry or keeps the current map if entry key is already presentUpdates the map with the new value if key is found, otherwise returns the same unchanged map.Updates the map with the default value if the key is found, otherwise returns the same unchanged map. Returns the entry if key is found or default value otherwise. Returns the value if key is found or default value otherwise. Sets the value if key is found or returns false otherwise. Returns the entry if key is found or `null` otherwise. Returns the value if the Type key is found or default value otherwise. Returns the value if the Type key is found or default value otherwise.
Depth-first in-order traversal as described in http://en.wikipedia.org/wiki/Tree_traversal
The only difference is using fixed size array instead of stack for speed-up.
Depth-first in-order traversal as described in http://en.wikipedia.org/wiki/Tree_traversal
The only difference is using fixed size array instead of stack for speed-up.
Note: By passing you may reuse the stack array between different method calls,
but it should be at least length. The contents of array are not important.
Depth-first in-order traversal as described in http://en.wikipedia.org/wiki/Tree_traversal
The only difference is using fixed size array instead of stack for speed-up.
Note: By passing you may reuse the stack array between different method calls,
but it should be at least length. The contents of array are not important.
Depth-first in-order traversal as described in http://en.wikipedia.org/wiki/Tree_traversal
The only difference is using fixed size array instead of stack for speed-up.
Note: By passing you may reuse the stack array between different method calls,
but it should be at least length. The contents of array are not important.
The array of ImMap slots where the key first bits are used for FAST slot location
and the slot is the reference to ImMap that can be swapped with its updated value
Default number of slots
The default mask to partition the key to the target slot
Creates the array with the empty slots
Returns a new tree with added or updated value for specified key.
Update the ref to the slot with the new version - retry if the someone changed the slot in between
Adds a new value for the specified key or keeps the existing map if the key is already in the map.
Update the ref to the slot with the new version - retry if the someone changed the slot in between
Adds a default value entry for the specified key or keeps the existing map if the key is already in the map.
Update the ref to the slot with the new version - retry if the someone changed the slot in between
Folds all map nodes without the order Wraps the stored data with "fixed" reference semantics - when added to the tree it did not change or reconstructed in memory
Empty thingy
Key hash
The key
The value - may be mutated implementing the Ref CAS semantics if needed
Constructs the data
Constructs the data with the default value
Outputs the brief tree info - mostly for debugging purposes
Stores ALL the data in `Conflicts` array, the fields except the `hash` are just fillers.
This way we preserve the once created `ImHashMapData` so that client can hold the reference to it and update the Value if needed.
Conflicted data
Immutable http://en.wikipedia.org/wiki/AVL_tree
where node key is the hash code of
Empty map to start with.
Calculated key hash.Key of type K that should support and .Value of any type V.In case of conflicts for different keys contains conflicted keys with their values.Left sub-tree/branch, or empty.Right sub-tree/branch, or empty.Height of longest sub-tree/branch plus 1. It is 0 for empty tree, and 1 for single node tree.Returns true if tree is empty.The entry which is allocated once and can be used as a "fixed" reference to the Key and Value
Creates leaf node
Creates a leaf node with default value
Creates a leaf node
Creates the tree and calculates the height for you
Creates the tree with the known height
Outputs the brief tree info - mostly for debugging purposesUses the user provided hash and adds and updates the tree with passed key-value. Returns a new tree.
Adds and updates the tree with passed key-value. Returns a new tree.
Uses the user provided hash and adds and updates the tree with passed key-value and the update function for the existing value. Returns a new tree.
Returns a new tree with added or updated key-value. Uses the provided for updating the existing value.
Returns a new tree with added or updated key-value. Uses the provided for updating the existing value.
Adds a new value for the specified key or keeps the existing map if the key is already in the map.
Adds a new value for the specified key or keeps the existing map if the key is already in the map.
Adds a new value for the specified key or keeps the existing map if the key is already in the map.
Adds a new value for the specified key or keeps the existing map if the key is already in the map.
Updates the map with the new value if key is found, otherwise returns the same unchanged map.
Updates the map with the new value if key is found, otherwise returns the same unchanged map.
Updates the map with the new value if key is found, otherwise returns the same unchanged map.
Updates the map with the Default (null for reference types) value if key is found, otherwise returns the same unchanged map.
Depth-first in-order traversal as described in http://en.wikipedia.org/wiki/Tree_traversal
The only difference is using fixed size array instead of stack for speed-up.
Depth-first in-order traversal as described in http://en.wikipedia.org/wiki/Tree_traversal
The only difference is using fixed size array instead of stack for speed-up.
Note: By passing you may reuse the stack array between different method calls,
but it should be at least length. The contents of array are not important.
Depth-first in-order traversal as described in http://en.wikipedia.org/wiki/Tree_traversal
The only difference is using fixed size array instead of stack for speed-up.
Note: By passing you may reuse the stack array between different method calls,
but it should be at least length. The contents of array are not important.
Depth-first in-order traversal as described in http://en.wikipedia.org/wiki/Tree_traversal
The only difference is using fixed size array instead of stack for speed-up.
Note: By passing you may reuse the stack array between different method calls,
but it should be at least length. The contents of array are not important.
Depth-first in-order traversal as described in http://en.wikipedia.org/wiki/Tree_traversal
The only difference is using fixed size array instead of stack for speed-up.
Note: By passing you may reuse the stack array between different method calls,
but it should be at least length. The contents of array are not important.
Finds the first entry matching the condition, returns `null` if not found
Removes or updates value for specified key, or does nothing if the key is not found (returns the unchanged map)
Based on Eric Lippert http://blogs.msdn.com/b/ericlippert/archive/2008/01/21/immutability-in-c-part-nine-academic-plus-my-avl-tree-implementation.aspx
Removes or updates value for specified key, or does nothing if the key is not found (returns the unchanged map)
Based on Eric Lippert http://blogs.msdn.com/b/ericlippert/archive/2008/01/21/immutability-in-c-part-nine-academic-plus-my-avl-tree-implementation.aspx
Searches for the key in the conflicts and returns true if found Searches for the key in the node conflicts
Searches for the key in the node conflicts
Searches for the key in the node conflicts
ImHashMap methods for faster performance
Looks for key in a tree and returns `true` if found. Looks for key in a tree and returns `true` if found.
Looks for key in a tree and returns the Data object if found or `null` otherwise.
Looks for key in a tree and returns the Data object if found or `null` otherwise.
Looks for key in a tree and returns the key value if found, or otherwise.
Looks for key in a tree and returns the key value if found, or otherwise.
Looks for key in a tree and returns the key value if found, or otherwise.
Looks for key in a tree and returns the key value if found, or otherwise.
Returns true if key is found and sets the value.
Returns true if key is found and sets the value.
Returns true if key is found and the result value.
Returns true if hash and key are found and the result value, or the false otherwise
Uses `RuntimeHelpers.GetHashCode()`
The array of ImHashMap slots where the key first bits are used for FAST slot location
and the slot is the reference to ImHashMap that can be swapped with its updated value
Default number of slots
The default mask to partition the key to the target slot
Creates the array with the empty slots
Returns a new tree with added or updated value for specified key.
Returns a new tree with added or updated value for specified key.
Updates the ref to the slot with the new version - retry if the someone changed the slot in between
Updates the value with help of `updateValue` function
Updates the value with help of `updateValue` function
Update the ref to the slot with the new version - retry if the someone changed the slot in between
Adds a new value for the specified key or keeps the existing map if the key is already in the map.
Adds a new value for the specified key or keeps the existing map if the key is already in the map.
Update the ref to the slot with the new version - retry if the someone changed the slot in between
Updates the specified slot or does not change it
Updates the specified slot or does not change it
Update the ref to the slot with the new version - retry if the someone changed the slot in between
Returns all map tree nodes without the order