This project is read-only.

A few points FYI

Nov 11, 2014 at 8:53 AM
Dear Markus,

I want you to notify for a few points maybe adding them into future releases would be perfect;

LoggingMediater : static class does not return how many logger created added to it's internal logger list.
Returning list count will make useless our Reflection usage for finding loggers count.
static void InitLogging()
        {
            var fields = typeof(LoggingMediator).GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
            List<ILogger> logger = null;
            foreach (var field in fields)
            {
                if (field.Name == "Loggers")
                {
                    logger = field.GetValue("Logger") as List<ILogger>;
                    if (logger != null && (logger.Count == 0 || logger.Count > 1))
                    {
                  //Add and clear is not thread safe 
                        lock (_sync3)
                        {
                         //Register only one logger at a time
                        if (logger.Count > 1)
                        {
                            LoggingMediator.ClearLoggers();
                        }
                       
                             
                            LoggingMediator.AddLogger(new SingleFileLogger(@"D:\Hostlogs\", "Hostlog-" + DateTime.Today.ToString("ddMMyyy") + ".log") { });
                        }
                    }
                }
            }
        }
SimpleFileLogger : it is simple and useful however it is not thread safe. I think all loggers which are internally implementing ILogger must be thread safe. Of cource I can implement ILogger for my logger however I am very lazy :(.

CloseViewAction : does not completely dispose view model, it keeps the created viewmodel stays in some where in memory and causes some unwanted behaviors e.g. when we use a timer and even close the view by that command, it still continue to work behind and crash the software or some other unexpected behaviors. maybe adding IDisposable to CODE.Framework.Wpf.Mvvm.ViewModel class and implementing virtual Dispose method would resolve that problem!!
  public LoginViewModel()
        {
            Actions.Add(new ViewAction("Login", execute: Login));
            Actions.Add(new ApplicationShutdownViewAction("Cancel"));
            Actions.Add(new CloseCurrentViewAction(this));
            int i = 0;
            DispatcherTimer timer = new DispatcherTimer();
            timer.Tick += (o, e) =>
            {
                Shell.Current.ClearNotifications();
                if ((i++) % 2 == 0)
                {
                    Controller.Notification("Tik");
                }
                else
                {
                    Controller.Notification("Tak");
                }
            };
            timer.Interval = new TimeSpan(0, 0, 0, 5);
            timer.Start();
        }
String.ToLower() Usage : We are using Turkish localization and charset on our windows and we have some special letters, such as İi, Iı, Ğğ, Şş, Çç and Öö. when we create controller or view with those letters capital form, Code's internal FindView method searching their lowered form using String.ToLower() method. And after this method if there is capital 'I' in controller or view name its become 'ı' not 'i', so search fails as normal and returns error. is it better to use with English culture parameter instead of empty parametrized one, what do you think?
if (controllerName.ToLower(CultureInfo.CreateSpecificCulture("en-US")).EndsWith("controller"));
Thank you in advance, best regards.

Emrah YILDIRIM
Nov 18, 2014 at 9:55 AM
You raise some good points. I will add notes to our internal list and investigate each item further.

Markus