Skip to content

Commit 749d5c2

Browse files
committed
Typo fixed
1 parent 0818732 commit 749d5c2

File tree

4 files changed

+73
-73
lines changed

4 files changed

+73
-73
lines changed

README.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,27 @@ delegate for default constructor can be obtained with DelegateFactory in followi
3838

3939
1. If you are have access to type in compile time:
4040

41-
`var cd = DelegateFactory.DefaultContructor<TestClass>();`
41+
`var cd = DelegateFactory.DefaultConstructor<TestClass>();`
4242

4343
Created delegate in such case is `Func<TestClass>`
44-
The same delegate can be created with Contructor method:
44+
The same delegate can be created with Constructor method:
4545

46-
`var cd = DelegateFactory.Contructor<Func<TestClass>>();`
46+
`var cd = DelegateFactory.Constructor<Func<TestClass>>();`
4747

4848
2. If you do not have access to type in compile time (private type, dynamic or otherwise inaccessible)
4949

50-
`var cd = TestClassType.DefaultContructor();`
50+
`var cd = TestClassType.DefaultConstructor();`
5151

5252
Created delegate in such case is `Func<object>`
53-
The same delegate can be created with Contructor method:
53+
The same delegate can be created with Constructor method:
5454

55-
`var cd = TestClassType.Contructor<Func<object>>();`
55+
`var cd = TestClassType.Constructor<Func<object>>();`
5656

5757
Return value is of object type, so we cannot access its members directly, without casting or if it is not possible, members can be accessed via delegates.
5858

59-
3. If for some reason you want to create delegate to different constructor depending on some arbitrary, runtime conditions or you do not have access to parameter types in compile time, Contructor(params Type[]) method overload can be used:
59+
3. If for some reason you want to create delegate to different constructor depending on some arbitrary, runtime conditions or you do not have access to parameter types in compile time, Constructor(params Type[]) method overload can be used:
6060

61-
`var cd = TestClassType.Contructor();`
61+
`var cd = TestClassType.Constructor();`
6262

6363
Created delegate in such case is `Func<object[]. object>`
6464
You can call it in following way:
@@ -80,25 +80,25 @@ delegate can be created in following ways:
8080

8181
1. If you are have access to type in compile time:
8282

83-
`var c = DelegateFactory.Contructor<Func<int, TestClass>>();`
83+
`var c = DelegateFactory.Constructor<Func<int, TestClass>>();`
8484

8585
Created delegate can be called as any other method that accepts single parameter of Int type:
8686

8787
`var instance = c(0);`
8888

8989
2. If you do not have access to type in compile time:
9090

91-
`var c = TestClassType.Contructor<Func<int, object>>();`
91+
`var c = TestClassType.Constructor<Func<int, object>>();`
9292

9393
Created delegate can be called as any other method that accepts single parameter of Int type:
9494

9595
`var instance = c(0);`
9696

9797
Return value is type of object, so we cannot access its members directly, without casting or if it is not possible, members can be accessed via delegates.
9898

99-
3. If for some reason you want to create delegate to different constructor depending on some arbitrary, runtime conditions or you do not have access to parameter types in compile time, Contructor(params Type[]) method overload can be used:
99+
3. If for some reason you want to create delegate to different constructor depending on some arbitrary, runtime conditions or you do not have access to parameter types in compile time, Constructor(params Type[]) method overload can be used:
100100

101-
`var c = TestClassType.Contructor(typeof(int));`
101+
`var c = TestClassType.Constructor(typeof(int));`
102102

103103
Created delegate in such case is `Func<object[]. object>`
104104
You can call it in following way:
@@ -109,7 +109,7 @@ delegate can be created in following ways:
109109

110110
Delegates can be created for any constructor (visibility do not matter) with any combination of parameters. There is no limitation for number of parameters of constructor. All of above methods works for both classes and structures.
111111

112-
If you have access to all neccessary types and can create compatible delegate type, `Contructor<TDelegate>` method can be used. TDelegate type must follow these rules:
112+
If you have access to all neccessary types and can create compatible delegate type, `Constructor<TDelegate>` method can be used. TDelegate type must follow these rules:
113113
- parameters of delegate *must be* exactly of the same types and order as constructor
114114
- return type of delegate *must be* type with constructor
115115

@@ -119,26 +119,26 @@ I.e. if you constructor have 3 parameters:
119119

120120
TDelegate *must be* `Func<string,int,bool,TestClass>`. It is because collection of constructor parameters are taked from TDelegate definition and constructor is searched in return type of defined TDelegate.
121121

122-
`var c = DelegateFactory.Contructor<Func<string, int, bool, TestClass>>();`
122+
`var c = DelegateFactory.Constructor<Func<string, int, bool, TestClass>>();`
123123

124124
There is no limitation for type of delegate that can be accepted. For example, it can be `Func<>`, but do not have to. You can create your own delegate type, but it is must follow above restrictions.
125125

126126
`public delegate TestClass CustomCtrSingleParam(int i);
127-
var cd = DelegateFactory.Contructor<CustomCtrSingleParam>();
127+
var cd = DelegateFactory.Constructor<CustomCtrSingleParam>();
128128
var instance = cd(0);`
129129

130130

131-
If you do not have access to type with constructor in compile time and still have access to constructor parameters types, `Contructor<TDelegate>(this Type)` extension method can be used. In this case return type of delegate can be any type that can be casted from source type (i.e. interface of TestClass, base type or object).
131+
If you do not have access to type with constructor in compile time and still have access to constructor parameters types, `Constructor<TDelegate>(this Type)` extension method can be used. In this case return type of delegate can be any type that can be casted from source type (i.e. interface of TestClass, base type or object).
132132

133-
`var c = TestClassType.Contructor<Func<string, string, DateTime, object>>();`
133+
`var c = TestClassType.Constructor<Func<string, string, DateTime, object>>();`
134134

135135
Restriction for parameters types and order still applies.
136136

137137

138-
However if you do not have access to parameters types `Contructor(this Type, params Type[])` extension method ca be used. Array of parameters types must be *exactly the same* order and length as type of parameters of constructor. Overload do not require any delegate type. Instead have fixed delegate to `Func<object[], object>`. First parameter of created delegate is array of all constructor parameters values. It can be larger than required collection. Returned object is created instance. There is no limitation of number of parameters of constructor.
138+
However if you do not have access to parameters types `Constructor(this Type, params Type[])` extension method ca be used. Array of parameters types must be *exactly the same* order and length as type of parameters of constructor. Overload do not require any delegate type. Instead have fixed delegate to `Func<object[], object>`. First parameter of created delegate is array of all constructor parameters values. It can be larger than required collection. Returned object is created instance. There is no limitation of number of parameters of constructor.
139139

140-
`var c = TestClassType.Contructor(typeof(bool));`
141-
`var c = TestClassType.Contructor(typeof(string), typeof(bool), typeof(IDisposable));`
140+
`var c = TestClassType.Constructor(typeof(bool));`
141+
`var c = TestClassType.Constructor(typeof(string), typeof(bool), typeof(IDisposable));`
142142

143143

144144
###Static Properties

src/DelegatesApp/ConsoleApplication.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,22 @@ private static void Main(string[] args)
3838

3939
private static void TestConstructors()
4040
{
41-
var cd = DelegateFactory.DefaultContructor<TestClass>();
42-
var cd1 = Type.DefaultContructor();
43-
var cd2 = Type.Contructor<Func<object>>();
41+
var cd = DelegateFactory.DefaultConstructor<TestClass>();
42+
var cd1 = Type.DefaultConstructor();
43+
var cd2 = Type.Constructor<Func<object>>();
4444

4545
var t_ = cd();
4646
var t1 = cd1();
4747
var t2 = cd2();
4848

49-
var c1 = DelegateFactory.Contructor<Func<TestClass>>();
50-
var c2 = DelegateFactory.Contructor<Func<int, TestClass>>();
51-
var c3 = DelegateFactory.Contructor<Func<bool, TestClass>>();
52-
var c4 = DelegateFactory.Contructor<Func<string, TestClass>>();
53-
var c5 = DelegateFactory.Contructor<Func<int, TestClass>>();
54-
var c6 = Type.Contructor(typeof(int));
55-
var c7 = typeof(TestStruct).Contructor<Func<int, object>>();
56-
var c8 = typeof(TestStruct).Contructor(typeof(int));
49+
var c1 = DelegateFactory.Constructor<Func<TestClass>>();
50+
var c2 = DelegateFactory.Constructor<Func<int, TestClass>>();
51+
var c3 = DelegateFactory.Constructor<Func<bool, TestClass>>();
52+
var c4 = DelegateFactory.Constructor<Func<string, TestClass>>();
53+
var c5 = DelegateFactory.Constructor<Func<int, TestClass>>();
54+
var c6 = Type.Constructor(typeof(int));
55+
var c7 = typeof(TestStruct).Constructor<Func<int, object>>();
56+
var c8 = typeof(TestStruct).Constructor(typeof(int));
5757

5858
var t3 = c1();
5959
var t4 = c2(0);

src/DelegatesFactory/DelegateFactory_Constructor.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static partial class DelegateFactory
1616
/// <typeparam name="TDelegate">Constructor delegate type. It should have parameters of searched constructor
1717
/// and return constructed type.</typeparam>
1818
/// <returns>Requested constructor delegate</returns>
19-
public static TDelegate Contructor<TDelegate>() where TDelegate : class
19+
public static TDelegate Constructor<TDelegate>() where TDelegate : class
2020
{
2121
var source = GetDelegateReturnType<TDelegate>();
2222
var ctrArgs = GetDelegateArguments<TDelegate>();
@@ -39,7 +39,7 @@ public static TDelegate Contructor<TDelegate>() where TDelegate : class
3939
/// <param name="source">Type to be constructed</param>
4040
/// <param name="ctrArgs">Array of types of constructor parameters</param>
4141
/// <returns>Constructor delegate</returns>
42-
public static Func<object[], object> Contructor(this Type source, params Type[] ctrArgs)
42+
public static Func<object[], object> Constructor(this Type source, params Type[] ctrArgs)
4343
{
4444
var constructorInfo = source.GetConstructorInfo(ctrArgs);
4545
if (constructorInfo == null)
@@ -69,7 +69,7 @@ public static Func<object[], object> Contructor(this Type source, params Type[]
6969
/// constructor and return constructed type.</typeparam>
7070
/// <param name="source">Type to be constructed</param>
7171
/// <returns>Constructor delegate</returns>
72-
public static TDelegate Contructor<TDelegate>(this Type source)
72+
public static TDelegate Constructor<TDelegate>(this Type source)
7373
where TDelegate : class
7474
{
7575
var ctrArgs = GetDelegateArguments<TDelegate>();
@@ -94,19 +94,19 @@ public static TDelegate Contructor<TDelegate>(this Type source)
9494
/// </summary>
9595
/// <typeparam name="TSource">Type of instance to be created by delegate.</typeparam>
9696
/// <returns>Default constructor delegate</returns>
97-
public static Func<TSource> DefaultContructor<TSource>()
97+
public static Func<TSource> DefaultConstructor<TSource>()
9898
{
99-
return Contructor<Func<TSource>>();
99+
return Constructor<Func<TSource>>();
100100
}
101101

102102
/// <summary>
103103
/// Creates delegate for type default constructor.
104104
/// </summary>
105105
/// <param name="type">Type to be constructed</param>
106106
/// <returns>Default constructor delegate</returns>
107-
public static Func<object> DefaultContructor(this Type type)
107+
public static Func<object> DefaultConstructor(this Type type)
108108
{
109-
return type.Contructor<Func<object>>();
109+
return type.Constructor<Func<object>>();
110110
}
111111
}
112112
}

0 commit comments

Comments
 (0)