private INotification GetInstance(NotificationDefinition indexerDefinition)
        {
            var type = _notifications.Single(c => c.GetType().Name.Equals(indexerDefinition.Implementation, StringComparison.InvariantCultureIgnoreCase)).GetType();

            var instance = (INotification)_container.Resolve(type);

            instance.InstanceDefinition = indexerDefinition;
            return(instance);
        }
        public Notification Create(Notification notification)
        {
            var definition = new NotificationDefinition();

            definition.InjectFrom(notification);
            definition.Settings = notification.Settings.ToJson();

            definition      = _notificationRepository.Insert(definition);
            notification.Id = definition.Id;

            return(notification);
        }
        private Notification ToNotification(NotificationDefinition definition)
        {
            var notification = new Notification();

            notification.Id                 = definition.Id;
            notification.OnGrab             = definition.OnGrab;
            notification.OnDownload         = definition.OnDownload;
            notification.Instance           = GetInstance(definition);
            notification.Name               = definition.Name;
            notification.Implementation     = definition.Implementation;
            notification.ImplementationName = notification.Instance.ImplementationName;
            notification.Settings           = ((dynamic)notification.Instance).ImportSettingsFromJson(definition.Settings);

            return(notification);
        }