MonoMobile.Views.ViewContainer.GetExactView C# (CSharp) Method

GetExactView() public static method

public static GetExactView ( Type type ) : Type
type System.Type
return System.Type
		public static Type GetExactView(Type type)
		{
			if (type != null)
			{
				if (_TypeViewMap.ContainsKey(type))
				{
					return _TypeViewMap[type];
				}
			}

			return null;
		}

Usage Example

        private static object GetActualView(object view)
        {
            if (view != null && !(view is IView))
            {
                var type       = view.GetType();
                var actualView = ViewContainer.GetExactView(type);

                if (actualView == null)
                {
                    var viewAttribute = type.GetCustomAttribute <ViewAttribute>();
                    if (viewAttribute != null)
                    {
                        actualView = viewAttribute.ViewType;
                    }
                }

                if (actualView != null)
                {
                    var newView = Activator.CreateInstance(actualView);
                    var dc      = newView as IDataContext <object>;
                    if (dc != null)
                    {
                        dc.DataContext = view;
                    }

                    return(newView);
                }
            }

            return(view);
        }