Samples...

Jun 11, 2010 at 10:45 AM
Marlon, the sample you added was really good. The coin fall in place how to use the Dispatcher and the async service. Good work.
I will come back to you regarding the Exception handling.

Not sure what you have thinking about to put in to the AOP functionality. In PostSharp you can handle exceptions in the aspect so you don't need to catch this in the method. Something like that should be nice. The aspect should be able to cooperate with
for example the LoggingService and maybe the Mediator to send message that something has went wrong. In the View (if possible) the only thing that needs to be there is "some code" (DependencyObject?) that automatically register Mediator for some kind of message.
There should be possibility to handle exceptions manually like this:

This is just a thing I thought about for 5min so there is probably many things that I have not thought about, but this is just a hint to show how I want to have it right now.
Hope you understand what I mean.

public class TestClass
{
[ExceptionHandling(UseLogger=true, ShowUIMessage=true, FriendlyUIMessageKey="TestMessage")]
public void TestMethod(string test)
{

}

}

public class ExceptionHandlingAttribute : Attribute
{
public ExceptionHandlingAttribute()
{
if(UseLogger)
{
this.LoggerService = ViewModelRepository.Instance.Resolver.Container.GetExportedValue<ILoggerService>();
}

if (ShowUIMessage)
{
this.LocalizationService = ViewModelRepository.Instance.Resolver.Container.GetExportedValue<ILocalizationService>();
this.Mediator = ViewModelRepository.Instance.Resolver.Container.GetExportedValue<IMediator>();
}
}

public void OnException(Exception exception)
{
if (UseLogger)
{
this.LoggerService.GetLogger("LoggerType").Error(exception,
LocalizationService == null
? "Not translated"
: LocalizationService[FriendlyUIMessageKey]);
}

if (ShowUIMessage)
{
var translatedMessage = LocalizationService == null
? "Not translated"
: LocalizationService[FriendlyUIMessageKey];
this.Mediator.NotifyColleagues("ExceptionMessage", translatedMessage);
}
}


private ILoggerService LoggerService { get; set; }
private ILocalizationService LocalizationService { get; set; }
IMediator Mediator { get; set; }

public bool UseLogger { get; set; }
public bool ShowUIMessage { get; set; }
public string FriendlyUIMessageKey { get; set; }
}






Best regards,

Patrik Cedendahl,
System Developer
Sandvik IT Services AB
SE-811 81 Sandviken, SWEDEN

Office Phone: +46 26 262997
Mobile: +46 70 2728110
http://www.sandvik.com
patrik.cedendahl@sandvik.com

This e-mail is confidential and it is intended only for the addressees. Any review, dissemination, distribution, or copying of this message by persons or entities other than the intended recipient is prohibited. If you have received this e-mail in error, kindly notify us immediately by telephone or e-mail and delete the message from your system. The sender does not accept liability for any errors or omissions in the contents of this message which may arise as a result of the e-mail transmission.