

using System;
using Unity;
using Prism.Events;
using Unity.Builder.Strategy;
using Unity.Builder;

namespace Valg.EVA.Skanning.UserInterfaceElements.Language
{
    public class AddLanguageChangedNotificationBuilderStrategy : IBuilderStrategy
    {
        private readonly IUnityContainer container;

        public AddLanguageChangedNotificationBuilderStrategy(IUnityContainer container)
        {
            this.container = container;
        }

        public object PreBuildUp(IBuilderContext context)
        {
            var implementsIViewModelBase = context.Existing as IViewModelBase;
            if (implementsIViewModelBase != null)
            {
                var eventAggregator = container.Resolve<IEventAggregator>();
                implementsIViewModelBase.SetupEventSubscriptions(eventAggregator);
            }
            return null;
        }

        public void PostBuildUp(IBuilderContext context, object obj)
        {
            
        }

        public void PreTearDown(IBuilderContext context)
        {
        }

        public void PostTearDown(IBuilderContext context)
        {
        }
    }
}
