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

RegisterView() public static method

public static RegisterView ( Type type, Type viewType ) : void
type System.Type
viewType System.Type
return void
		public static void RegisterView(Type type, Type viewType)
		{
			if (viewType != null)
			{
				if (!typeof(UIView).IsAssignableFrom(viewType))
				{
					throw new Exception(string.Format("{0} must be a descendent of UIView", viewType));
				}
				
				if (_TypeViewMap.ContainsKey(type))
				{
					_TypeViewMap[type] = viewType;
				}
				else
					_TypeViewMap.Add(type, viewType);
			}
		}
		

Usage Example

Beispiel #1
0
        public static void InitializeViewContainer()
        {
            //Integral types
            ViewContainer.RegisterView(typeof(sbyte), typeof(StringCellView));
            ViewContainer.RegisterView(typeof(byte), typeof(StringCellView));
            ViewContainer.RegisterView(typeof(char), typeof(StringCellView));
            ViewContainer.RegisterView(typeof(short), typeof(StringCellView));
            ViewContainer.RegisterView(typeof(ushort), typeof(StringCellView));
            ViewContainer.RegisterView(typeof(int), typeof(StringCellView));
            ViewContainer.RegisterView(typeof(uint), typeof(StringCellView));
            ViewContainer.RegisterView(typeof(long), typeof(StringCellView));
            ViewContainer.RegisterView(typeof(ulong), typeof(StringCellView));

            //float types
            ViewContainer.RegisterView(typeof(float), typeof(StringCellView));
            ViewContainer.RegisterView(typeof(double), typeof(StringCellView));
            ViewContainer.RegisterView(typeof(decimal), typeof(StringCellView));

            //bool
            ViewContainer.RegisterView(typeof(bool), typeof(BooleanCellView));

            //Reference types
            ViewContainer.RegisterView(typeof(object), typeof(ObjectCellView <object>));
            ViewContainer.RegisterView(typeof(string), typeof(StringCellView));

            //Enum
            ViewContainer.RegisterView(typeof(Enum), typeof(ListCellView));

            //IEnumerable
            ViewContainer.RegisterView(typeof(IEnumerable), typeof(ListCellView));
            ViewContainer.RegisterView(typeof(IEnumerable <object>), typeof(ListCellView));

            //Other
            ViewContainer.RegisterView(typeof(UIView), typeof(ObjectCellView <UIView>));
            ViewContainer.RegisterView(typeof(ICommand), typeof(CommandCellView));
            ViewContainer.RegisterView(typeof(DateTime), typeof(DateCellView));
            ViewContainer.RegisterView(typeof(NSDate), typeof(DateCellView));
        }
All Usage Examples Of MonoMobile.Views.ViewContainer::RegisterView