Skip to content

Commit

Permalink
Update README_Wpf.md
Browse files Browse the repository at this point in the history
  • Loading branch information
CrackAndDie committed Feb 19, 2024
1 parent 11a9e36 commit fb462ca
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions README_Wpf.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Demo could be downloaded from [releases](https://github.com/CrackAndDie/Hypocrit
- [Preview window](#preview-window)
- [Theme registrations](#theme-registrations)
- [Localization](#localization)
- [Light container](#light-container)
- [Logging](#logging)
- [Observables and Observers](#observables-and-observers)

Expand Down Expand Up @@ -221,6 +222,81 @@ LocalizationManager.CurrentLanguage = CultureInfo.GetCultureInfo(lang.Name.ToLow
```
In this examle *lang* is an instance of *Language* class.

<h3>Light container:</h3>

*Hypocrite.Services* also provides registrations and resolves of services and other shite in the fast and lightweight container.
<h4>Attribute injections:</h4>

All the registered shite could be resolved via *Injection* attribute (use the attribute only for properties and fields) like this:
```c#
private class NormalClass
{
[Injection]
InjectedClass TestClass { get; set; }
[Injection]
AnotherInjectedClass _anotherTestClass;
}
```

<h4>Constructor injections:</h4>

Parametrised constructors could be used with *Abdrakov.Container*. For example after registering and resolving the class
```c#
private class NormalClass
{
private InjectedClass _testClass;
private int _a;
private string _b;

public NormalClass(InjectedClass testClass, int a, string b = "awd")
{
_testClass = testClass;
_a = a;
_b = b;
}
}
```
the *testClass* parameter would be resolved as usual (if it is not registered in the container then an instance of it would be created); the *a* parameter would have **default type** value (for Int32 is 0); the *b* parameter would have its **default parameter** value (in this case is "awd").

<h4>Inheritance injections:</h4>

The classed from which Your class is inherited would also be prepared for injections:
```c#
private class InjectedClass
{
internal int A { get; set; }
}

private class BaseClass
{
[Injection]
protected InjectedClass TestClass { get; set; }
}

private class NormalClass : BaseClass
{
}
```
So in this case after *NormalClass* registration and resolve, the *TestClass* property would also be injected.

<h4>Recursive injections:</h4>

There could be two classes that require injection of each other:
```c#
private class FirstClass
{
[Injection]
SecondClass InjectedClass { get; set; }
}

private class SecondClass
{
[Injection]
FirstClass InjectedClass { get; set; }
}
```
And this would work as expected!

<h3>Logging:</h3>

To log your app's work you can resolve *ILoggingService* that is just an adapter of *Log4netLoggingService* or use *LoggingService* property of *ViewModelBase*.
Expand Down

0 comments on commit fb462ca

Please sign in to comment.