Skip to content

Inject FSharpFunc automatically #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Brains opened this issue Sep 12, 2020 · 2 comments
Closed

Inject FSharpFunc automatically #2

Brains opened this issue Sep 12, 2020 · 2 comments

Comments

@Brains
Copy link

Brains commented Sep 12, 2020

Based on #1 (comment)

I really tried to add support for FSharp.Core.FSharpFunc but this extension is much more complicated than I expected.

Instead, added few small helpers which worked great.

module CFunc =
    open System
    let one (func:Func<_,_>)       =        func.Invoke
    let two (func:Func<_,_,_>)     = curry  func.Invoke
    let tri (func:Func<_,_,_,_>)   = curry3 func.Invoke
    let fou (func:Func<_,_,_,_,_>) = curry4 func.Invoke

These are completely enough in my case.
Thank you again for performed migration to Unity.5 #1

Opened this ticket just to document my case, for future reference if somebody needs or else.

@Brains Brains closed this as completed Sep 12, 2020
@Brains
Copy link
Author

Brains commented Sep 12, 2020

The only thing I would add to your extension is

container.AddNewExtension<Unity.Diagnostic>(); 

for Tests projects.

http://unitycontainer.org/tutorials/Extensions/diagnostic.html
Quite detailed and useful errors description instead of cryptic default one

Application.Bootstrapper   Unity.ResolutionFailedException: The type System.String cannot be constructed. You must configure the container to supply this value.
_____________________________________________________
Exception occurred while:

� while resolving:  String registered with name: Manager.Live
    for parameter:  address
   on constructor:  Client(IEventAggregator messages, FSharpFunc`2 factory, String address)

� while resolving:  Client
    for parameter:  server
   on constructor:  Training(IEventAggregator messages, Client server, Subscriber stream)

� while resolving:  Training
    for parameter:  collection
   on constructor:  List`1(IEnumerable`1 collection)

� while resolving:  List`1 registered with name: Admin.Tabs
    for parameter:  tabs
   on constructor:  Admin(IEventAggregator messages, Screen whitelist, IEnumerable`1 tabs)

� while resolving:  Admin
    for parameter:  tabs
   on constructor:  Model(IEventAggregator events, Settings settings, Config config, IGeneral dialog, ISettings options, IDatabase db, Screen[] tabs)
        mapped to:  IShell

@mykolav
Copy link
Owner

mykolav commented Dec 27, 2020

I didn't know about

container.AddNewExtension<Unity.Diagnostic>(); 

Just added it to the Unity5 tests project.
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants