/// <summary>
 /// Adds current theme from WidgetFactory
 /// </summary>
 /// <param name="aArgs">
 /// Arguments <see cref="FactoryInvocationArgs"/>
 /// </param>
 public static void AddDefaultTheme(this FactoryInvocationArgs aArgs)
 {
     foreach (string s in WidgetFactory.DefaultTheme.Filters)
     {
         aArgs.AddFilter(s);
     }
 }
 public IMappedColumnItem Invoke(FactoryInvocationArgs aArgs)
 {
     if (FactoryMethod == null)
     {
         throw new NullReferenceException("Method can't be null");
     }
     return((IMappedColumnItem)FactoryMethod.Invoke(null, new object[1] {
         aArgs
     }));
 }
Ejemplo n.º 3
0
 public IAdaptableControl Invoke(FactoryInvocationArgs aArgs)
 {
     if (FactoryMethod == null)
     {
         throw new NullReferenceException("Method can't be null");
     }
     return((IAdaptableControl)FactoryMethod.Invoke(null, new object[1] {
         aArgs
     }));
 }
 /// <summary>
 /// Adds theme to creation parameters
 /// </summary>
 /// <param name="aArgs">
 /// Arguments <see cref="FactoryInvocationArgs"/>
 /// </param>
 /// <param name="aTheme">
 /// Theme <see cref="WidgetFactoryTheme"/>
 /// </param>
 public static void AddTheme(this FactoryInvocationArgs aArgs, WidgetFactoryTheme aTheme)
 {
     if (aTheme == null)
     {
         return;
     }
     foreach (string s in aTheme.Filters)
     {
         aArgs.AddFilter(s);
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Factory handler invokation
 /// </summary>
 /// <param name="aArgs">
 /// Handler name <see cref="System.String"/>
 /// </param>
 /// <param name="aArgs">
 /// Widget creation arguments <see cref="FactoryInvocationArgs"/>
 /// </param>
 /// <returns>
 /// Result widget <see cref="IMappedColumnItem"/>
 /// </returns>
 private static IMappedColumnItem InvokeCellHandler(string aHandler, FactoryInvocationArgs aArgs)
 {
     foreach (string fn in aArgs.Filter)
     {
         foreach (CellFactoryInvokerClass fi in AllCellsByFilter(fn))
         {
             if (fi.FactoryProvider.HandlerType == aHandler)
             {
                 return(fi.Invoke(aArgs));
             }
         }
     }
     throw new NotImplementedException(string.Format("Handler [{0}] in filter [{1}] is not registered", aHandler, aArgs.Filter));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Factory handler invokation
 /// </summary>
 /// <param name="aArgs">
 /// Handler name <see cref="System.String"/>
 /// </param>
 /// <param name="aArgs">
 /// Widget creation arguments <see cref="FactoryInvocationArgs"/>
 /// </param>
 /// <returns>
 /// Result widget <see cref="IAdaptableControl"/>
 /// </returns>
 private static IAdaptableControl InvokeHandler(string aHandler, FactoryInvocationArgs aArgs)
 {
     foreach (string fn in aArgs.Filter)
     {
         foreach (FactoryInvokerClass fi in AllByFilter(fn))
         {
             if (fi.FactoryProvider.HandlerType == aHandler)
             {
                 return(fi.Invoke(aArgs));
             }
         }
     }
     throw new NotImplementedException(string.Format("Handler [{0}] in filter [{1}] is not registered", aHandler, aArgs.Filter));
 }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Factory widget creation
        /// </summary>
        /// <param name="aDefaultMethod">
        /// Default creation method fallback <see cref="WidgetCreationEvent"/>
        /// </param>
        /// <param name="aArgs">
        /// Widget creation arguments <see cref="FactoryInvocationArgs"/>
        /// </param>
        /// <returns>
        /// Result widget <see cref="IAdaptableControl"/>
        /// </returns>
        public static IAdaptableControl CreateWidget(WidgetCreationEvent aDefaultMethod, FactoryInvocationArgs aArgs)
        {
            if (aDefaultMethod == null)
            {
                aDefaultMethod = new WidgetCreationEvent(CreateDefaultWidget);
            }

            IAdaptableControl 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 = CreateHandlerWidget(aDefaultMethod, aArgs);
                    break;
                }
            }
            else if ((aArgs.HandlerOverride != "") && (aArgs.HandlerOverride.ToLower().Trim() != "default"))
            {
                wdg = CreateHandlerWidget(aDefaultMethod, aArgs);
            }
            else
            {
                wdg = aDefaultMethod(aArgs);
            }

            if (wdg != null)
            {
                wdg.InheritedDataSource = true;
            }
            return(wdg);
        }
Ejemplo n.º 9
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));
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Creates default widgets for properties which don't specify their property description
 /// </summary>
 /// <param name="aArgs">
 /// Widget creation arguments <see cref="FactoryInvocationArgs"/>
 /// </param>
 /// <returns>
 /// Result widget <see cref="IMappedColumnItem"/>
 /// </returns>
 /// <remarks>
 /// Throws exception
 /// </remarks>
 private static IMappedColumnItem CreateDefaultCellWidget(FactoryInvocationArgs aArgs)
 {
     throw new NotSupportedException("Default factory method must be specified");
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Creates default widgets for properties which don't specify their property description
 /// </summary>
 /// <param name="aArgs">
 /// Widget creation arguments <see cref="FactoryInvocationArgs"/>
 /// </param>
 /// <returns>
 /// Result widget <see cref="IAdaptableControl"/>
 /// </returns>
 /// <remarks>
 /// Throws exception
 /// </remarks>
 private static IAdaptableControl CreateDefaultWidget(FactoryInvocationArgs aArgs)
 {
     throw new NotSupportedException("Default factory method must be specified");
 }