13 people like it.

Mini IoC Container

Minimal Inversion of Control (IoC) Container for Dependency Injection (DI) in under 100 lines of code. Implements the 3 Rs of DI: Register, Resolve, Release. Note: missing thread safety and fluent interface.

  1: 
  2: 
  3: 
  4: 
  5: 
  6: 
  7: 
  8: 
  9: 
 10: 
 11: 
 12: 
 13: 
 14: 
 15: 
 16: 
 17: 
 18: 
 19: 
 20: 
 21: 
 22: 
 23: 
 24: 
 25: 
 26: 
 27: 
 28: 
 29: 
 30: 
 31: 
 32: 
 33: 
 34: 
 35: 
 36: 
 37: 
 38: 
 39: 
 40: 
 41: 
 42: 
 43: 
 44: 
 45: 
 46: 
 47: 
 48: 
 49: 
 50: 
 51: 
 52: 
 53: 
 54: 
 55: 
 56: 
 57: 
 58: 
 59: 
 60: 
 61: 
 62: 
 63: 
 64: 
 65: 
 66: 
 67: 
 68: 
 69: 
 70: 
 71: 
 72: 
 73: 
 74: 
 75: 
 76: 
 77: 
 78: 
 79: 
 80: 
 81: 
 82: 
 83: 
 84: 
 85: 
 86: 
 87: 
 88: 
 89: 
 90: 
 91: 
 92: 
 93: 
 94: 
 95: 
 96: 
 97: 
 98: 
 99: 
100: 
101: 
102: 
103: 
104: 
105: 
106: 
107: 
108: 
109: 
110: 
111: 
112: 
113: 
114: 
115: 
116: 
117: 
118: 
119: 
120: 
121: 
122: 
123: 
124: 
125: 
126: 
127: 
128: 
129: 
130: 
131: 
132: 
133: 
134: 
135: 
136: 
137: 
138: 
139: 
140: 
141: 
142: 
143: 
144: 
145: 
146: 
open System
open System.Collections.Generic
open Microsoft.FSharp.Reflection

type Lifetime = Singleton | Transient

type AbstractType = Type
type ConcreteType = Type

type private Constructor =
    | Reflected of ConcreteType
    | Factory of (unit -> obj)
 
let private (|FunType|_|) t =
    if FSharpType.IsFunction t 
    then FSharpType.GetFunctionElements t |> Some
    else None
     
let private (|FuncType|_|) (t:Type) =
    if t.IsGenericType && t.GetGenericTypeDefinition() = typedefof<Func<_>> 
    then t.GetGenericArguments().[0] |> Some
    else None

type Container () as this =
    let catalog = Dictionary<AbstractType, Constructor * Lifetime>()
    let singletons = Dictionary<ConcreteType,obj>()
    let rec tryResolve t =
        match catalog.TryGetValue t with
        | true, (Factory f, lifetime) -> 
            tryObtain t (fun () -> f() |> Some) lifetime
        | true, (Reflected u, lifetime) -> 
            tryObtain u (fun () -> tryConstruct u) lifetime
        | false, _ -> 
            tryObtain t (fun () -> tryConstruct t) Singleton 
    and tryObtain t f lifetime =
        match singletons.TryGetValue t with
        | true, value -> Some value
        | false, _ ->
            let result = f()
            result |> Option.iter (fun value -> store t value lifetime)
            result
    and store t value = function
        | Singleton -> singletons.Add(t,value)
        | Transient -> ()
    and tryConstruct t =
        t.GetConstructors() 
        |> Array.sortBy (fun c -> c.GetParameters().Length)
        |> Array.tryPick (fun ctr ->
            let ps = ctr.GetParameters()
            let args = ps |> Array.map (fun p -> tryResolveArgument p.ParameterType)             
            match args |> Array.forall Option.isSome with
            | true -> args |> (Array.choose id) |> ctr.Invoke |> Some
            | false -> None
        )
    and tryResolveArgument t =
        match t with         
        | FunType(arg,result) when arg = typeof<unit> ->
            FSharpValue.MakeFunction(t,fun args -> this.Resolve(result)) |> Some
        | FuncType result ->                                
            let mi = typeof<Container>.GetMethod("Resolve",[||]).MakeGenericMethod(result)
            Delegate.CreateDelegate(t, this, mi) |> box |> Some
        | t -> tryResolve t
    static let current = Container()
    static member Current = current
    member container.Register(abstractTypes:AbstractType seq, concreteType:ConcreteType) =    
        for t in abstractTypes do catalog.Add(t, (Reflected concreteType, Singleton))
    member container.Register<'TAbstract when 'TAbstract : not struct>
            (concreteType:ConcreteType, lifetime:Lifetime) =
        catalog.Add(typeof<'TAbstract>, (Reflected(concreteType), lifetime))
    member container.Register<'TAbstract when 'TAbstract : not struct>
            (concreteType:ConcreteType) = 
        container.Register<'TAbstract>(concreteType, Singleton)
#if CSHARP
    member container.Register<'TAbstract when 'TAbstract : not struct>
            (f:Func<'TAbstract>) = 
        catalog.Add(typeof<'TAbstract>, (Factory(fun () -> f.Invoke() |> box), Singleton))   
    member container.Register<'TAbstract when 'TAbstract : not struct>
            (f:Func<'TAbstract>, lifetime:Lifetime) = 
        catalog.Add(typeof<'TAbstract>, (Factory(fun () -> f.Invoke() |> box), lifetime))   
#else
    member container.Register<'TAbstract when 'TAbstract : not struct>(f:unit->'TAbstract) =   
        catalog.Add(typeof<'TAbstract>, (Factory(f >> box), Singleton))
    member container.Register<'TAbstract when 'TAbstract : not struct>
            (f:unit->'TAbstract, lifetime:Lifetime) = 
        catalog.Add(typeof<'TAbstract>, (Factory(f >> box), lifetime))
#endif 
    member container.Resolve<'TAbstract when 'TAbstract : not struct>() =
        container.Resolve(typeof<'TAbstract>) :?> 'TAbstract     
    member container.Resolve(abstractType:AbstractType) =
        match tryResolve abstractType with
        | Some value -> value
        | None -> sprintf "Failed to resolve %A" abstractType |> invalidOp
    member container.Release(instance:obj) =
        singletons 
        |> Seq.filter (fun pair -> pair.Value = instance)
        |> Seq.toList
        |> List.iter (fun pair -> singletons.Remove(pair.Key) |> ignore)

module Usage =

    let container = Container.Current

    type A () =
        do  printfn "A"

    type B () =
        do  printfn "B"

    type C (a:A, B) =
        do  printfn "C"

    type D (a:A, b:B, fc:unit -> C) =
        let c = fc()
        do printfn "D"

    container.Register((fun () -> printfn "B lambda"; B()), Transient)
    container.Register<C>(typeof<C>)
    let c = container.Resolve<C>()
    let c' = container.Resolve<C>()
    container.Release(c)
    let c'' = container.Resolve<C>()
    container.Release(c'')
    let d = container.Resolve<D>()

    type F() =
        override this.ToString() = "Hey"

    type O (f:Func<F>) =
        let s = f.Invoke()
        do printfn "%A" s 

    container.Register<O>(typeof<O>)
    let o = container.Resolve<O>()

    type ICalculate =
        abstract member Incr : int -> int

    type Calculator () =
        interface ICalculate with
            member this.Incr(x:int) = x + 1
    
    container.Register<ICalculate>(typeof<Calculator>)

    let calc = container.Resolve<ICalculate>()
    printfn "%d" (calc.Incr 1)
    Console.ReadLine() |> ignore
namespace System
namespace System.Collections
namespace System.Collections.Generic
namespace Microsoft
namespace Microsoft.FSharp
namespace Microsoft.FSharp.Reflection
type Lifetime =
  | Singleton
  | Transient

Full name: Script.Lifetime
union case Lifetime.Singleton: Lifetime
union case Lifetime.Transient: Lifetime
type AbstractType = Type

Full name: Script.AbstractType
type Type =
  inherit MemberInfo
  member Assembly : Assembly
  member AssemblyQualifiedName : string
  member Attributes : TypeAttributes
  member BaseType : Type
  member ContainsGenericParameters : bool
  member DeclaringMethod : MethodBase
  member DeclaringType : Type
  member Equals : o:obj -> bool + 1 overload
  member FindInterfaces : filter:TypeFilter * filterCriteria:obj -> Type[]
  member FindMembers : memberType:MemberTypes * bindingAttr:BindingFlags * filter:MemberFilter * filterCriteria:obj -> MemberInfo[]
  ...

Full name: System.Type
type ConcreteType = Type

Full name: Script.ConcreteType
type private Constructor =
  | Reflected of ConcreteType
  | Factory of (unit -> obj)

Full name: Script.Constructor
union case Constructor.Reflected: ConcreteType -> Constructor
union case Constructor.Factory: (unit -> obj) -> Constructor
type unit = Unit

Full name: Microsoft.FSharp.Core.unit
type obj = Object

Full name: Microsoft.FSharp.Core.obj
val t : Type
type FSharpType =
  static member GetExceptionFields : exceptionType:Type * ?bindingFlags:BindingFlags -> PropertyInfo []
  static member GetFunctionElements : functionType:Type -> Type * Type
  static member GetRecordFields : recordType:Type * ?bindingFlags:BindingFlags -> PropertyInfo []
  static member GetTupleElements : tupleType:Type -> Type []
  static member GetUnionCases : unionType:Type * ?bindingFlags:BindingFlags -> UnionCaseInfo []
  static member IsExceptionRepresentation : exceptionType:Type * ?bindingFlags:BindingFlags -> bool
  static member IsFunction : typ:Type -> bool
  static member IsModule : typ:Type -> bool
  static member IsRecord : typ:Type * ?bindingFlags:BindingFlags -> bool
  static member IsTuple : typ:Type -> bool
  ...

Full name: Microsoft.FSharp.Reflection.FSharpType
static member FSharpType.IsFunction : typ:Type -> bool
static member FSharpType.GetFunctionElements : functionType:Type -> Type * Type
union case Option.Some: Value: 'T -> Option<'T>
union case Option.None: Option<'T>
property Type.IsGenericType: bool
Type.GetGenericTypeDefinition() : Type
val typedefof<'T> : Type

Full name: Microsoft.FSharp.Core.Operators.typedefof
Multiple items
type Func<'TResult> =
  delegate of unit -> 'TResult

Full name: System.Func<_>

--------------------
type Func<'T,'TResult> =
  delegate of 'T -> 'TResult

Full name: System.Func<_,_>

--------------------
type Func<'T1,'T2,'TResult> =
  delegate of 'T1 * 'T2 -> 'TResult

Full name: System.Func<_,_,_>

--------------------
type Func<'T1,'T2,'T3,'TResult> =
  delegate of 'T1 * 'T2 * 'T3 -> 'TResult

Full name: System.Func<_,_,_,_>

--------------------
type Func<'T1,'T2,'T3,'T4,'TResult> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 -> 'TResult

Full name: System.Func<_,_,_,_,_>

--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'TResult> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 -> 'TResult

Full name: System.Func<_,_,_,_,_,_>

--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'TResult> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 -> 'TResult

Full name: System.Func<_,_,_,_,_,_,_>

--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'TResult> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 -> 'TResult

Full name: System.Func<_,_,_,_,_,_,_,_>

--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'TResult> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 -> 'TResult

Full name: System.Func<_,_,_,_,_,_,_,_,_>

--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'TResult> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 -> 'TResult

Full name: System.Func<_,_,_,_,_,_,_,_,_,_>

--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'TResult> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 -> 'TResult

Full name: System.Func<_,_,_,_,_,_,_,_,_,_,_>

--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'TResult> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 -> 'TResult

Full name: System.Func<_,_,_,_,_,_,_,_,_,_,_,_>

--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'T12,'TResult> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 * 'T12 -> 'TResult

Full name: System.Func<_,_,_,_,_,_,_,_,_,_,_,_,_>

--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'T12,'T13,'TResult> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 * 'T12 * 'T13 -> 'TResult

Full name: System.Func<_,_,_,_,_,_,_,_,_,_,_,_,_,_>

--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'T12,'T13,'T14,'TResult> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 * 'T12 * 'T13 * 'T14 -> 'TResult

Full name: System.Func<_,_,_,_,_,_,_,_,_,_,_,_,_,_,_>

--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'T12,'T13,'T14,'T15,'TResult> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 * 'T12 * 'T13 * 'T14 * 'T15 -> 'TResult

Full name: System.Func<_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_>

--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'T12,'T13,'T14,'T15,'T16,'TResult> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 * 'T12 * 'T13 * 'T14 * 'T15 * 'T16 -> 'TResult

Full name: System.Func<_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_>
Type.GetGenericArguments() : Type []
Multiple items
type Container =
  new : unit -> Container
  member Register : concreteType:ConcreteType -> unit
  member Register : f:(unit -> 'TAbstract) -> unit (requires reference type)
  member Register : abstractTypes:seq<AbstractType> * concreteType:ConcreteType -> unit
  member Register : concreteType:ConcreteType * lifetime:Lifetime -> unit
  member Register : f:(unit -> 'TAbstract) * lifetime:Lifetime -> unit (requires reference type)
  member Release : instance:obj -> unit
  member Resolve : unit -> 'TAbstract (requires reference type)
  member Resolve : abstractType:AbstractType -> obj
  static member Current : Container

Full name: Script.Container

--------------------
new : unit -> Container
val this : Container
val catalog : Dictionary<AbstractType,(Constructor * Lifetime)>
Multiple items
type Dictionary<'TKey,'TValue> =
  new : unit -> Dictionary<'TKey, 'TValue> + 5 overloads
  member Add : key:'TKey * value:'TValue -> unit
  member Clear : unit -> unit
  member Comparer : IEqualityComparer<'TKey>
  member ContainsKey : key:'TKey -> bool
  member ContainsValue : value:'TValue -> bool
  member Count : int
  member GetEnumerator : unit -> Enumerator<'TKey, 'TValue>
  member GetObjectData : info:SerializationInfo * context:StreamingContext -> unit
  member Item : 'TKey -> 'TValue with get, set
  ...
  nested type Enumerator
  nested type KeyCollection
  nested type ValueCollection

Full name: System.Collections.Generic.Dictionary<_,_>

--------------------
Dictionary() : unit
Dictionary(capacity: int) : unit
Dictionary(comparer: IEqualityComparer<'TKey>) : unit
Dictionary(dictionary: IDictionary<'TKey,'TValue>) : unit
Dictionary(capacity: int, comparer: IEqualityComparer<'TKey>) : unit
Dictionary(dictionary: IDictionary<'TKey,'TValue>, comparer: IEqualityComparer<'TKey>) : unit
val singletons : Dictionary<ConcreteType,obj>
val tryResolve : (ConcreteType -> obj option)
val t : ConcreteType
Dictionary.TryGetValue(key: AbstractType, value: byref<Constructor * Lifetime>) : bool
val f : (unit -> obj)
val lifetime : Lifetime
val tryObtain : (ConcreteType -> (unit -> obj option) -> Lifetime -> obj option)
val u : ConcreteType
val tryConstruct : (ConcreteType -> obj option)
val f : (unit -> obj option)
Dictionary.TryGetValue(key: ConcreteType, value: byref<obj>) : bool
val value : obj
val result : obj option
module Option

from Microsoft.FSharp.Core
val iter : action:('T -> unit) -> option:'T option -> unit

Full name: Microsoft.FSharp.Core.Option.iter
val store : (ConcreteType -> obj -> Lifetime -> unit)
Dictionary.Add(key: ConcreteType, value: obj) : unit
Type.GetConstructors() : Reflection.ConstructorInfo []
Type.GetConstructors(bindingAttr: Reflection.BindingFlags) : Reflection.ConstructorInfo []
type Array =
  member Clone : unit -> obj
  member CopyTo : array:Array * index:int -> unit + 1 overload
  member GetEnumerator : unit -> IEnumerator
  member GetLength : dimension:int -> int
  member GetLongLength : dimension:int -> int64
  member GetLowerBound : dimension:int -> int
  member GetUpperBound : dimension:int -> int
  member GetValue : [<ParamArray>] indices:int[] -> obj + 7 overloads
  member Initialize : unit -> unit
  member IsFixedSize : bool
  ...

Full name: System.Array
val sortBy : projection:('T -> 'Key) -> array:'T [] -> 'T [] (requires comparison)

Full name: Microsoft.FSharp.Collections.Array.sortBy
val c : Reflection.ConstructorInfo
Reflection.MethodBase.GetParameters() : Reflection.ParameterInfo []
val tryPick : chooser:('T -> 'U option) -> array:'T [] -> 'U option

Full name: Microsoft.FSharp.Collections.Array.tryPick
val ctr : Reflection.ConstructorInfo
val ps : Reflection.ParameterInfo []
val args : obj option []
val map : mapping:('T -> 'U) -> array:'T [] -> 'U []

Full name: Microsoft.FSharp.Collections.Array.map
val p : Reflection.ParameterInfo
val tryResolveArgument : (Type -> obj option)
property Reflection.ParameterInfo.ParameterType: Type
val forall : predicate:('T -> bool) -> array:'T [] -> bool

Full name: Microsoft.FSharp.Collections.Array.forall
val isSome : option:'T option -> bool

Full name: Microsoft.FSharp.Core.Option.isSome
val choose : chooser:('T -> 'U option) -> array:'T [] -> 'U []

Full name: Microsoft.FSharp.Collections.Array.choose
val id : x:'T -> 'T

Full name: Microsoft.FSharp.Core.Operators.id
Reflection.ConstructorInfo.Invoke(parameters: obj []) : obj
Reflection.MethodBase.Invoke(obj: obj, parameters: obj []) : obj
Reflection.ConstructorInfo.Invoke(invokeAttr: Reflection.BindingFlags, binder: Reflection.Binder, parameters: obj [], culture: Globalization.CultureInfo) : obj
Reflection.MethodBase.Invoke(obj: obj, invokeAttr: Reflection.BindingFlags, binder: Reflection.Binder, parameters: obj [], culture: Globalization.CultureInfo) : obj
active recognizer FunType: Type -> (Type * Type) option

Full name: Script.( |FunType|_| )
val arg : Type
val result : Type
val typeof<'T> : Type

Full name: Microsoft.FSharp.Core.Operators.typeof
type FSharpValue =
  static member GetExceptionFields : exn:obj * ?bindingFlags:BindingFlags -> obj []
  static member GetRecordField : record:obj * info:PropertyInfo -> obj
  static member GetRecordFields : record:obj * ?bindingFlags:BindingFlags -> obj []
  static member GetTupleField : tuple:obj * index:int -> obj
  static member GetTupleFields : tuple:obj -> obj []
  static member GetUnionFields : value:obj * unionType:Type * ?bindingFlags:BindingFlags -> UnionCaseInfo * obj []
  static member MakeFunction : functionType:Type * implementation:(obj -> obj) -> obj
  static member MakeRecord : recordType:Type * values:obj [] * ?bindingFlags:BindingFlags -> obj
  static member MakeTuple : tupleElements:obj [] * tupleType:Type -> obj
  static member MakeUnion : unionCase:UnionCaseInfo * args:obj [] * ?bindingFlags:BindingFlags -> obj
  ...

Full name: Microsoft.FSharp.Reflection.FSharpValue
static member FSharpValue.MakeFunction : functionType:Type * implementation:(obj -> obj) -> obj
val args : obj
member Container.Resolve : unit -> 'TAbstract (requires reference type)
member Container.Resolve : abstractType:AbstractType -> obj
active recognizer FuncType: Type -> Type option

Full name: Script.( |FuncType|_| )
val mi : Reflection.MethodInfo
type Delegate =
  member Clone : unit -> obj
  member DynamicInvoke : [<ParamArray>] args:obj[] -> obj
  member Equals : obj:obj -> bool
  member GetHashCode : unit -> int
  member GetInvocationList : unit -> Delegate[]
  member GetObjectData : info:SerializationInfo * context:StreamingContext -> unit
  member Method : MethodInfo
  member Target : obj
  static member Combine : [<ParamArray>] delegates:Delegate[] -> Delegate + 1 overload
  static member CreateDelegate : type:Type * method:MethodInfo -> Delegate + 9 overloads
  ...

Full name: System.Delegate
Delegate.CreateDelegate(type: Type, method: Reflection.MethodInfo) : Delegate
Delegate.CreateDelegate(type: Type, firstArgument: obj, method: Reflection.MethodInfo) : Delegate
Delegate.CreateDelegate(type: Type, method: Reflection.MethodInfo, throwOnBindFailure: bool) : Delegate
Delegate.CreateDelegate(type: Type, target: Type, method: string) : Delegate
Delegate.CreateDelegate(type: Type, target: obj, method: string) : Delegate
Delegate.CreateDelegate(type: Type, firstArgument: obj, method: Reflection.MethodInfo, throwOnBindFailure: bool) : Delegate
Delegate.CreateDelegate(type: Type, target: Type, method: string, ignoreCase: bool) : Delegate
Delegate.CreateDelegate(type: Type, target: obj, method: string, ignoreCase: bool) : Delegate
Delegate.CreateDelegate(type: Type, target: Type, method: string, ignoreCase: bool, throwOnBindFailure: bool) : Delegate
Delegate.CreateDelegate(type: Type, target: obj, method: string, ignoreCase: bool, throwOnBindFailure: bool) : Delegate
val box : value:'T -> obj

Full name: Microsoft.FSharp.Core.Operators.box
val current : Container
static member Container.Current : Container

Full name: Script.Container.Current
val container : Container
member Container.Register : abstractTypes:seq<AbstractType> * concreteType:ConcreteType -> unit

Full name: Script.Container.Register
val abstractTypes : seq<AbstractType>
Multiple items
val seq : sequence:seq<'T> -> seq<'T>

Full name: Microsoft.FSharp.Core.Operators.seq

--------------------
type seq<'T> = IEnumerable<'T>

Full name: Microsoft.FSharp.Collections.seq<_>
val concreteType : ConcreteType
val t : AbstractType
Dictionary.Add(key: AbstractType, value: Constructor * Lifetime) : unit
member Container.Register : concreteType:ConcreteType * lifetime:Lifetime -> unit

Full name: Script.Container.Register
val not : value:bool -> bool

Full name: Microsoft.FSharp.Core.Operators.not
member Container.Register : concreteType:ConcreteType -> unit

Full name: Script.Container.Register
member Container.Register : concreteType:ConcreteType -> unit
member Container.Register : f:(unit -> 'TAbstract) -> unit (requires reference type)
member Container.Register : abstractTypes:seq<AbstractType> * concreteType:ConcreteType -> unit
member Container.Register : concreteType:ConcreteType * lifetime:Lifetime -> unit
member Container.Register : f:(unit -> 'TAbstract) * lifetime:Lifetime -> unit (requires reference type)
member Container.Register : f:(unit -> 'TAbstract) -> unit (requires reference type)

Full name: Script.Container.Register
val f : (unit -> 'TAbstract) (requires reference type)
member Container.Register : f:(unit -> 'TAbstract) * lifetime:Lifetime -> unit (requires reference type)

Full name: Script.Container.Register
member Container.Resolve : unit -> 'TAbstract (requires reference type)

Full name: Script.Container.Resolve
member Container.Resolve : abstractType:AbstractType -> obj

Full name: Script.Container.Resolve
val abstractType : AbstractType
val sprintf : format:Printf.StringFormat<'T> -> 'T

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.sprintf
val invalidOp : message:string -> 'T

Full name: Microsoft.FSharp.Core.Operators.invalidOp
member Container.Release : instance:obj -> unit

Full name: Script.Container.Release
val instance : obj
module Seq

from Microsoft.FSharp.Collections
val filter : predicate:('T -> bool) -> source:seq<'T> -> seq<'T>

Full name: Microsoft.FSharp.Collections.Seq.filter
val pair : KeyValuePair<ConcreteType,obj>
property KeyValuePair.Value: obj
val toList : source:seq<'T> -> 'T list

Full name: Microsoft.FSharp.Collections.Seq.toList
Multiple items
type List<'T> =
  new : unit -> List<'T> + 2 overloads
  member Add : item:'T -> unit
  member AddRange : collection:IEnumerable<'T> -> unit
  member AsReadOnly : unit -> ReadOnlyCollection<'T>
  member BinarySearch : item:'T -> int + 2 overloads
  member Capacity : int with get, set
  member Clear : unit -> unit
  member Contains : item:'T -> bool
  member ConvertAll<'TOutput> : converter:Converter<'T, 'TOutput> -> List<'TOutput>
  member CopyTo : array:'T[] -> unit + 2 overloads
  ...
  nested type Enumerator

Full name: System.Collections.Generic.List<_>

--------------------
List() : unit
List(capacity: int) : unit
List(collection: IEnumerable<'T>) : unit
val iter : action:('T -> unit) -> list:'T list -> unit

Full name: Microsoft.FSharp.Collections.List.iter
Dictionary.Remove(key: ConcreteType) : bool
property KeyValuePair.Key: ConcreteType
val ignore : value:'T -> unit

Full name: Microsoft.FSharp.Core.Operators.ignore
module Usage

from Script
val container : Container

Full name: Script.Usage.container
property Container.Current: Container
type A =
  new : unit -> A

Full name: Script.Usage.A
val printfn : format:Printf.TextWriterFormat<'T> -> 'T

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn
type B =
  new : unit -> B

Full name: Script.Usage.B
type C =
  new : a:A * B:obj -> C

Full name: Script.Usage.C
val a : A
val B : obj
type D =
  new : a:A * b:B * fc:(unit -> C) -> D

Full name: Script.Usage.D
val b : B
val fc : (unit -> C)
val c : C
new : unit -> B
val c : C

Full name: Script.Usage.c
val c' : C

Full name: Script.Usage.c'
member Container.Release : instance:obj -> unit
val c'' : C

Full name: Script.Usage.c''
val d : D

Full name: Script.Usage.d
type F =
  new : unit -> F
  override ToString : unit -> string

Full name: Script.Usage.F
val this : F
override F.ToString : unit -> string

Full name: Script.Usage.F.ToString
type O =
  new : f:Func<F> -> O

Full name: Script.Usage.O
val f : Func<F>
val s : F
Func.Invoke() : F
val o : O

Full name: Script.Usage.o
type ICalculate =
  interface
    abstract member Incr : int -> int
  end

Full name: Script.Usage.ICalculate
abstract member ICalculate.Incr : int -> int

Full name: Script.Usage.ICalculate.Incr
Multiple items
val int : value:'T -> int (requires member op_Explicit)

Full name: Microsoft.FSharp.Core.Operators.int

--------------------
type int = int32

Full name: Microsoft.FSharp.Core.int

--------------------
type int<'Measure> = int

Full name: Microsoft.FSharp.Core.int<_>
Multiple items
type Calculator =
  interface ICalculate
  new : unit -> Calculator

Full name: Script.Usage.Calculator

--------------------
new : unit -> Calculator
val this : Calculator
override Calculator.Incr : x:int -> int

Full name: Script.Usage.Calculator.Incr
val x : int
val calc : ICalculate

Full name: Script.Usage.calc
abstract member ICalculate.Incr : int -> int
type Console =
  static member BackgroundColor : ConsoleColor with get, set
  static member Beep : unit -> unit + 1 overload
  static member BufferHeight : int with get, set
  static member BufferWidth : int with get, set
  static member CapsLock : bool
  static member Clear : unit -> unit
  static member CursorLeft : int with get, set
  static member CursorSize : int with get, set
  static member CursorTop : int with get, set
  static member CursorVisible : bool with get, set
  ...

Full name: System.Console
Console.ReadLine() : string

More information

Link:http://fssnip.net/9g
Posted:13 years ago
Author:Phillip Trelford
Tags: di , ioc , dependency injection , container