New Posts New Posts RSS Feed: Get to imported objects inside server-side methods
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Get to imported objects inside server-side methods

 Post Reply Post Reply
Author
katit View Drop Down
Senior Member
Senior Member


Joined: 09-Sep-2011
Posts: 146
Post Options Post Options   Quote katit Quote  Post ReplyReply Direct Link To This Post Topic: Get to imported objects inside server-side methods
    Posted: 04-Jun-2012 at 8:15pm
I'm trying to implement some server-side methods but not sure how to get to MEF Composition container
 
public class ServerMethods
    {
        [Import]
        public IPushNotificator PushNotificator { get; set; }
        [AllowRpc]   
        public static void PushToDevices(IPrincipal principal, EntityManager entityManager, params object[] args)
        {         
            return;
        }
    }
 
I need to access my PushNotificator from PushToDevices methods. Server-side method is static and I don't get PushNotificator. How do I access this object in my scenario?
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 08-Jun-2012 at 12:40pm
Hi katit,
In this case you might want to try access it within the method itself:
 
  [AllowRpc]
  public static void PushToDevices(IPrincipal principal, EntityManager entityManager, params object[] args) {
    var pushNotificator = IdeaBlade.Core.Composition.CompositionHost.Instance.GetExportedInstance<IPushNotificator>(false);
  }
 
The cause of the issue might be that because ServerMethods is never instantiated, there isn't an instance of it to be referenced by the static method.
 
Regards,
   Silvio.
Back to Top
katit View Drop Down
Senior Member
Senior Member


Joined: 09-Sep-2011
Posts: 146
Post Options Post Options   Quote katit Quote  Post ReplyReply Direct Link To This Post Posted: 08-Jun-2012 at 12:52pm
Yes, sure it's not in Static. Actually, it's not in  IdeaBlade.Core.Composition.CompositionHost either.
 
I got it from my own Bootstrapper class..
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down