The
IInitialMessageProvider is an interface that allows custom messages to be provided to the
InitialMessagesAction. The implemented
IInitialMessageProvider is then configured for the
InitialMessagesAction. To be usable the
IInitialMessageProvider must be exportable from MEF as typeof(IInitialMessageProvider).
Members
Here is the methods,properties, and events that need to be implemented on the interface.
Events
Name | Description |
---|
MessagesLoaded | This event must be raised to signal to the startupAction the messages are loaded by the provider. Failure to do this will hang the application at the point of message loading. |
Methods
Name | Return Type | Description |
---|
LoadMessages() | void | This method is called by the InitialMessagesAction to have the provider initiate the loading of messages. The logic of loading messages should be located inside this method. |
Properties
Implemented Example
[Export(typeof(IInitialMessageProvider))]
public class OvpInitialMessageProvider:IInitialMessageProvider
{
private readonly List<IInitialMessage> _initialMessages = new List<IInitialMessage>();
public IEnumerable<IInitialMessage> InitialMessages
{
get { return _initialMessages; }
}
public void LoadMessages()
{
var binding = new BasicHttpBinding();
var address = new EndpointAddress(new Uri("http://localhost/ovpcomponents/OvpGisService.svc"));
var svs = new OvpGisService.OvpGisServiceClient(binding, address);
svs.GetGeneralMessagesCompleted += SvsGetGeneralMessagesCompleted;
svs.GetGeneralMessagesAsync();
}
void SvsGetGeneralMessagesCompleted(object sender, OvpGisService.GetGeneralMessagesCompletedEventArgs e)
{
_initialMessages.Add(new InitialMessage
{
HeadingText="General Messages",
Messages=e.Result.OrderBy(o=>o.MessageOrder).Select(s=>s.MessageText)
});
MessagesLoaded(this, null);
}
public event EventHandler MessagesLoaded;
}
See Also