using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using CustomDockingPanesFactory.ViewModels;

namespace CustomDockingPanesFactory.ViewModels
{
	public class ViewLocator
	{
		public static UIElement Locate(IPaneViewModel viewModel)
		{
			var viewTypeName = viewModel.GetType().AssemblyQualifiedName?.Replace("Model", string.Empty);

			if (viewTypeName == null)
			{
				return null;
			}
			var viewType = Type.GetType(viewTypeName);

			if (viewType == null)
			{
				return null;
			}

			return (UIElement)Activator.CreateInstance(viewType);
		}
	}
}
