Skip to content

Commit c1904e6

Browse files
authored
Merge pull request #29 from christoerasmus/patch-1
Update quickstart.md
2 parents 2f16da5 + 73e800a commit c1904e6

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

articles/quickstart.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ uid: Article.Unity.Using
44

55
# Using Unity in Applications
66

7-
This topic describes how to develop applications using Unity, and how to create and build instances of objects. It assumes that you familiar with dependency injection and separation of concerns concepts.
7+
This topic describes how to develop applications using Unity and how to create and build instances of objects. It assumes that you are familiar with dependency injection and separation of concern concepts.
88

99
## The Container
1010

11-
Unity exposes very compact API to operate the container. The most operations related to registration, resolution, and lifetime management is exposed through one interface - **[IUnityContainer](xref:Unity.IUnityContainer)**.
11+
Unity exposes a very compact API to operate on the container. Most operations related to registration, resolution and lifetime management is exposed through one interface - **[IUnityContainer](xref:Unity.IUnityContainer)**.
1212

13-
To start using Unity you need to create an instance of the container and get reference to [IUnityContainer](xref:Unity.IUnityContainer) interface:
13+
To start using Unity you need to create an instance of the container and get a reference to the [IUnityContainer](xref:Unity.IUnityContainer) interface:
1414

1515
```cs
1616
IUnityContainer container = new UnityContainer();
1717
```
1818

1919
## Creating instances
2020

21-
Once container is created you could start using it immediately:
21+
Once the container is created you can use it immediately:
2222

2323
```cs
2424
IUnityContainer container = new UnityContainer();
@@ -28,7 +28,7 @@ var value = container.Resolve<object>();
2828
value = new object();
2929
```
3030

31-
It will create any type with accessible constructor. Consider following example:
31+
It will create any type with an accessible constructor. Consider following example:
3232

3333
```cs
3434
// Simple class Foo
@@ -50,9 +50,9 @@ var value = container.Resolve<Foo>();
5050
// value created with constructor 'Foo(object obj)'
5151
```
5252

53-
`Foo` is a simple class with three public constructors. When `Resolve<Foo>()` is called, Unity will evaluate available constructors and select one with longest list of parameters it can satisfy with dependencies. It will create all required dependencies and pass them to selected constructor during initialization.
53+
`Foo` is a simple class with three public constructors. When `Resolve<Foo>()` is called, Unity will evaluate the available constructors and select one with the longest list of parameters it can satisfy with dependencies. It will create all required dependencies and pass them to the selected constructor during initialization.
5454

55-
In this particular case Unity will select second constructor with parameter `obj` of type [Object](xref:System.Object). Although constructor `Foo(string id, object obj)` is longer, it has parameter of type [String](xref:System.String) which is a primitive type. Unity can not create primitive types by itself. If you want to make these available for dependency injection you would need to register them with the container. For Unity to select third constructor `Foo(string id, object obj)` you need to register string instance with container:
55+
In this particular case Unity will select the second constructor with parameter `obj` of type [Object](xref:System.Object). Although constructor `Foo(string id, object obj)` is longer, it has a parameter of type [String](xref:System.String) which is a primitive type. Unity cannot create primitive types by itself. If you want to make these available for dependency injection you would need to register them with the container. For Unity to select the third constructor `Foo(string id, object obj)` you need to register a string instance with container:
5656

5757
```cs
5858
// Register string instance
@@ -95,9 +95,9 @@ public class Foo
9595
}
9696
```
9797

98-
In this example we have `IService` interface defining an API and class `Component` implementing that API. Type `Foo` is a consumer of the service and should be injected by container with an instance of the service during initialization.
98+
In this example we have `IService` interface defining an API and class `Component` implementing that API. Type `Foo` is a consumer of the service and should be injected by the container with an instance of the service during initialization.
9999

100-
If you just call `container.Resolve<IService>()` it will throw an exception complaining that it can not create an interface of type `IService`. You need to register a [Type Mapping](xref:Tutorial.Mapping) to instructs Unity how to create service of type `IService`:
100+
If you just call `container.Resolve<IService>()` it will throw an exception complaining that it cannot create an interface of type `IService`. You need to register a [Type Mapping](xref:Tutorial.Mapping) to instruct Unity how to create a service of type `IService`:
101101

102102
```cs
103103
// Register mapping between IService and Component
@@ -109,13 +109,13 @@ var value = container.Resolve<Foo>();
109109
// value created with constructor 'Foo(IService service)'
110110
```
111111

112-
During the resolution, when Unity will try to satisfy dependencies, it will look for a registration for each dependency and will find this mapping. It will create `Component` and passes it to constructor of `Foo` as `IService`.
112+
During resolution, Unity will try to satisfy dependencies, it will look for a registration for each dependency and find this mapping. It will create `Component` and pass it to the constructor of `Foo` as `IService`.
113113

114114
For more information see [Type Mapping](xref:Tutorial.Mapping)
115115

116116
## Lifetime
117117

118-
By default Unity creates a new instance every time type is requested. Instances it created are not tracked or managed by the container.
118+
By default Unity creates a new instance every time a type is requested. Instances it create are not tracked or managed by the container.
119119

120120
```cs
121121
// Register mapping between IService and Component
@@ -128,7 +128,7 @@ var value2 = container.Resolve<IService>();
128128
// value1 and value2 are not the same
129129
```
130130

131-
To enable lifetime management, type needs to be registered with one of the compatible [lifetime managers](xref:Unity.Lifetime). Depending on registration type Unity provides three helpers:
131+
To enable lifetime management, a type needs to be registered with one of the compatible [lifetime managers](xref:Unity.Lifetime). Depending on registration type Unity provides three helpers:
132132

133133
* [TypeLifetime](xref:Unity.TypeLifetime)
134134
* [InstanceLifetime](xref:Unity.InstanceLifetime)
@@ -147,4 +147,4 @@ var value2 = container.Resolve<IService>();
147147
// value1 and value2 are the same instance of Component
148148
```
149149

150-
For more information see [Lifetime Management](xref:Tutorial.Lifetime)
150+
For more information see [Lifetime Management](xref:Tutorial.Lifetime)

0 commit comments

Comments
 (0)