.net - How to inject an object into a WCF validator class -
After the use of dependency injection for "text" itemprop = "text">
, there are WCF , so that someone can do this:
public class devlidator: user name passwordwidit {personal readonly IService service; [Injection] Public divider (IService service) {this.service = service; } Public override zero valid (string username, string password) {service.login (userName, password); }}
Edit - I tried to apply the recommendation of the Deemptree in my custom behavior extension, because my verifier is defined in app.config. Unfortunately I get a MethodMissingException since WCF wants my validator for a default constructor:
Here is my behavior class: System.MissingMethodException:. A default creator is defined for this object
RuntimeTypeHandle.CreateInstance code>
public class dependencydescriptionAssociation: transaction extensionextensionImagement, IServiceBehavior {Public voidDispatchBehaviorDescription, ServiceHostBase serviceHostBase} {serviceHostBase.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator = DISupport.Kernel.Get & lt; IService & gt; (); }}
After
Normal custom verifier is specified as a program (also there The possibility to do this is to do something like this from the config file) and it is done just before the service is opened to the host and basically it also times when you create examples of your di container examples that serve example examples through the example provider Will be used:
service . Credential Username notification Custom username password passwordData = new local user namepacementditor ();
You can also use the Di Container to create your custom verifier.
serviceHost.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator = unityContainer.Resolve & lt; UserNamePasswordValidator & gt; ();