Пример #1
0
        public UserSession()
        {
            var logger = ObjectFactory.GetInstance<Logger>();
            logger.Trace("[Session].[UserSession()] invoked.");

            account = new UserAccount();

            Id = Guid.NewGuid();
            Role = UserRole.Anonymous;
            Notifications = new NotificationSet();

            logger.Debug("[Session].[UserSession()] finished work.");
        }
Пример #2
0
        public static void InitializeLogin()
        {
            var logger = ObjectFactory.GetInstance<Logger>();
            logger.Trace("[Initialization].[AutoMapper].[Bootstrapper].[InitializeLogin] invoked.");

            CreateMap<Session.UserSession, ViewModels.Login.Index>()
                .BeforeMap((s, d) => logger.Trace("[Session].[UserSession] mapping to [ViewModels].[Login].[Index]."))
                .AfterMap((s, d) => logger.Trace("[Session].[UserSession] mapped to [ViewModels].[Login].[Index]."))
                .ForMember(d => d.Notifications, o => o.ResolveUsing(s =>
                    {
                        var result = new NotificationSet();
                        s.Notifications.MoveAll(result);
                        return result;
                    }));

            logger.Debug("[Initialization].[AutoMapper].[Bootstrapper].[InitializeLogin] finished work.");
        }
Пример #3
0
        public bool TryMove(NotificationSet destination, Enum key)
        {
            var result = false;

            if (destination != null && key != null && Has(key) && !destination.Has(key))
            {
                notifications.Remove(key);
                destination.Add(key);
                result = true;
            }

            return result;
        }
Пример #4
0
 public void MoveAll(NotificationSet destination)
 {
     destination.TryAddRange(notifications);
     notifications.Clear();
 }
Пример #5
0
        public void Move(NotificationSet destination, Enum key)
        {
            var logger = ObjectFactory.GetInstance<Logger>();

            if (destination == null)
            {
                logger.Error("[ViewModels].[Application].[NotificationSet].[Move] throwing exception ([destination] == null).");
                throw new ArgumentNullException("destination");
            }

            if (key == null)
            {
                logger.Error("[ViewModels].[Application].[NotificationSet].[Move] throwing exception ([key] == null).");
                throw new ArgumentNullException("key");
            }

            if (!Has(key))
            {
                logger.Error("[ViewModels].[Application].[NotificationSet].[Move] throwing exception ([notifications] does not contains [key]).");
                throw new InvalidOperationException("Source NotificationSet does not has item.");
            }

            if (destination.Has(key))
            {
                logger.Error("[ViewModels].[Application].[NotificationSet].[Move] throwing exception ([destination].[Has] == 'true').");
                throw new InvalidOperationException("Destination NotificationSet already has item.");
            }

            notifications.Remove(key);
            destination.Add(key);
        }
Пример #6
0
 protected ViewModel()
 {
     Notifications = new NotificationSet();
 }