Пример #1
0
        /// <summary>
        /// Factory widget creation
        /// </summary>
        /// <param name="aDefaultMethod">
        /// Default creation method fallback <see cref="CellCreationEvent"/>
        /// </param>
        /// <param name="aArgs">
        /// Widget creation arguments <see cref="FactoryInvocationArgs"/>
        /// </param>
        /// <returns>
        /// Result widget <see cref="IMappedColumnItem"/>
        /// </returns>
        public static IMappedColumnItem CreateCell(CellCreationEvent aDefaultMethod, FactoryInvocationArgs aArgs)
        {
            System.Console.WriteLine("CreateCell");
            if (aDefaultMethod == null)
            {
                aDefaultMethod = new CellCreationEvent(CreateDefaultCellWidget);
            }

            IMappedColumnItem wdg = null;

            if (aArgs.PropertyInfo == null)
            {
                return(null);
            }
            if (aArgs.Description != null)
            {
                switch (aArgs.Description.HandlerType)
                {
                case PropertyHandlerType.Default:
                    wdg = aDefaultMethod(aArgs);
                    break;

                case PropertyHandlerType.Custom:
                    wdg = CreateHandlerCell(aDefaultMethod, aArgs);
                    break;
                }
            }
            else if ((aArgs.HandlerOverride != "") && (aArgs.HandlerOverride.ToLower().Trim() != "default"))
            {
                wdg = CreateHandlerCell(aDefaultMethod, aArgs);
            }
            else
            {
                wdg = aDefaultMethod(aArgs);
            }

            return(wdg);
        }
		/// <summary>
		/// Factory widget creation
		/// </summary>
		/// <param name="aDefaultMethod">
		/// Default creation method fallback <see cref="CellCreationEvent"/>
		/// </param>
		/// <param name="aArgs">
		/// Widget creation arguments <see cref="FactoryInvocationArgs"/>
		/// </param>
		/// <returns>
		/// Result widget <see cref="IMappedColumnItem"/>
		/// </returns>
		public static IMappedColumnItem CreateCell (CellCreationEvent aDefaultMethod, FactoryInvocationArgs aArgs)
		{
System.Console.WriteLine("CreateCell");
			if (aDefaultMethod == null)
				aDefaultMethod = new CellCreationEvent (CreateDefaultCellWidget);
			
			IMappedColumnItem wdg = null;
			if (aArgs.PropertyInfo == null)
				return (null);
			if (aArgs.Description != null) {
				switch (aArgs.Description.HandlerType) {
				case PropertyHandlerType.Default:
					wdg = aDefaultMethod (aArgs);
					break;
				case PropertyHandlerType.Custom:
					wdg = CreateHandlerCell (aDefaultMethod, aArgs);
					break;
				}
			}
			else if ((aArgs.HandlerOverride != "") && (aArgs.HandlerOverride.ToLower().Trim() != "default"))
				wdg = CreateHandlerCell (aDefaultMethod, aArgs);
			else
				wdg = aDefaultMethod (aArgs);
			
			return (wdg);
		}
Пример #3
0
        /// <summary>
        /// Factory handler selector
        /// </summary>
        /// <param name="aDefaultMethod">
        /// Default creation method fallback <see cref="CellCreationEvent"/>
        /// </param>
        /// <param name="aArgs">
        /// Widget creation arguments <see cref="FactoryInvocationArgs"/>
        /// </param>
        /// <returns>
        /// Result widget <see cref="IMappedColumnItem"/>
        /// </returns>
        private static IMappedColumnItem CreateHandlerCell(CellCreationEvent aDefaultMethod, FactoryInvocationArgs aArgs)
        {
            if ((aArgs.HandlerOverride == "") && (aArgs.HandlerOverride.ToLower().Trim() == "default"))
            {
                if (aArgs.Description == null)
                {
                    return(aDefaultMethod(aArgs));
                }

                if (aArgs.Description.HandlerType == PropertyHandlerType.Default)
                {
                    return(aDefaultMethod(aArgs));
                }
            }

            if ((aArgs.Filter == null) || (aArgs.Filter.Length == 0))
            {
                throw new NotSupportedException("Widget created by Handler has to define filter");
            }

            string handler = "default";

            if (aArgs.State == PropertyDefinition.ReadOnly)
            {
                if ((aArgs.HandlerOverride != "") && (aArgs.HandlerOverride.ToLower().Trim() != "default"))
                {
                    handler = aArgs.HandlerOverride;
                }
                else if ((aArgs.Description.ReadOnlyDataTypeHandler != "default") && (aArgs.Description.ReadOnlyDataTypeHandler != ""))
                {
                    handler = aArgs.Description.ReadOnlyDataTypeHandler;
                }
                else if ((aArgs.Description.DataTypeHandler != "default") && (aArgs.Description.DataTypeHandler != ""))
                {
                    handler = aArgs.Description.DataTypeHandler;
                }
                else
                {
                    return(aDefaultMethod(aArgs));
                }
            }
            else
            {
                if ((aArgs.HandlerOverride != "") && (aArgs.HandlerOverride.ToLower().Trim() != "default"))
                {
                    handler = aArgs.HandlerOverride;
                }
                else if ((aArgs.Description.DataTypeHandler != "default") && (aArgs.Description.DataTypeHandler != ""))
                {
                    handler = aArgs.Description.DataTypeHandler;
                }
                else
                {
                    return(aDefaultMethod(aArgs));
                }
            }
            System.Console.WriteLine("Invoking handler [{0}]", handler);
            if (handler == "default")
            {
                return(aDefaultMethod(aArgs));
            }
            return(InvokeCellHandler(handler, aArgs));
        }
		/// <summary>
		/// Factory handler selector
		/// </summary>
		/// <param name="aDefaultMethod">
		/// Default creation method fallback <see cref="CellCreationEvent"/>
		/// </param>
		/// <param name="aArgs">
		/// Widget creation arguments <see cref="FactoryInvocationArgs"/>
		/// </param>
		/// <returns>
		/// Result widget <see cref="IMappedColumnItem"/>
		/// </returns>
		private static IMappedColumnItem CreateHandlerCell (CellCreationEvent aDefaultMethod, FactoryInvocationArgs aArgs)
		{
			if ((aArgs.HandlerOverride == "") && (aArgs.HandlerOverride.ToLower().Trim() == "default")) {
				if (aArgs.Description == null)
					return (aDefaultMethod (aArgs));
			
				if (aArgs.Description.HandlerType == PropertyHandlerType.Default)
					return (aDefaultMethod (aArgs));
			}

			if ((aArgs.Filter == null) || (aArgs.Filter.Length == 0))
				throw new NotSupportedException ("Widget created by Handler has to define filter");
			
			string handler = "default";
			if (aArgs.State == PropertyDefinition.ReadOnly) {
				if ((aArgs.HandlerOverride != "") && (aArgs.HandlerOverride.ToLower().Trim() != "default"))
					handler = aArgs.HandlerOverride;
				else if ((aArgs.Description.ReadOnlyDataTypeHandler != "default") && (aArgs.Description.ReadOnlyDataTypeHandler != ""))
					handler = aArgs.Description.ReadOnlyDataTypeHandler;
				else if ((aArgs.Description.DataTypeHandler != "default") && (aArgs.Description.DataTypeHandler != ""))
					handler = aArgs.Description.DataTypeHandler;
				else
					return (aDefaultMethod (aArgs));
			}
			else {
				if ((aArgs.HandlerOverride != "") && (aArgs.HandlerOverride.ToLower().Trim() != "default"))
					handler = aArgs.HandlerOverride;
				else if ((aArgs.Description.DataTypeHandler != "default") && (aArgs.Description.DataTypeHandler != ""))
					handler = aArgs.Description.DataTypeHandler;
				else
					return (aDefaultMethod (aArgs));
			}
System.Console.WriteLine("Invoking handler [{0}]", handler);
			if (handler == "default")
				return (aDefaultMethod (aArgs));
			return (InvokeCellHandler (handler, aArgs));
		}