/// -----------------------------------------------------------------------------
        /// <summary>
        /// CreateEditControl creates the appropriate Control based on the EditorField or
        /// TypeDataField
        /// </summary>
        /// <param name="editorInfo">An EditorInfo object</param>
        /// <history>
        ///     [cnurse]	03/06/2006	created
        /// </history>
        /// -----------------------------------------------------------------------------
        public static EditControl CreateEditControl(EditorInfo editorInfo)
        {
            EditControl propEditor;

            if (editorInfo.Editor == "UseSystemType")
            {
                Type type = Type.GetType(editorInfo.Type);
                //Use System Type

                switch (type.FullName)
                {
                case "System.DateTime":
                    propEditor = new DateTimeEditControl();
                    break;

                case "System.Boolean":
                    propEditor = new CheckEditControl();
                    break;

                case "System.Int32":
                case "System.Int16":
                    propEditor = new IntegerEditControl();
                    break;

                default:
                    if (type.IsEnum)
                    {
                        propEditor = new EnumEditControl(editorInfo.Type);
                    }
                    else
                    {
                        propEditor = new TextEditControl(editorInfo.Type);
                    }
                    break;
                }
            }
            else
            {
                //Use Editor
                Type editType = Type.GetType(editorInfo.Editor, true, true);
                propEditor = (EditControl)Activator.CreateInstance(editType);
            }
            propEditor.ID       = editorInfo.Name;
            propEditor.Name     = editorInfo.Name;
            propEditor.Category = editorInfo.Category;

            propEditor.EditMode = editorInfo.EditMode;
            propEditor.Required = editorInfo.Required;

            propEditor.Value    = editorInfo.Value;
            propEditor.OldValue = editorInfo.Value;

            propEditor.CustomAttributes = editorInfo.Attributes;

            return(propEditor);
        }
Ejemplo n.º 2
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// CreateEditControl creates the appropriate Control based on the EditorField or
        /// TypeDataField
        /// </summary>
        /// <param name="editorInfo">An EditorInfo object</param>
        /// <history>
        ///     [cnurse]	03/06/2006	created
        /// </history>
        /// -----------------------------------------------------------------------------
        public static EditControl CreateEditControl(EditorInfo editorInfo)
        {
            EditControl propEditor;

            if (editorInfo.Editor == "UseSystemType")
            {
                Type type = Type.GetType(editorInfo.Type);
                //Use System Type

                switch (type.FullName)
                {
                    case "System.DateTime":
                        propEditor = new DateTimeEditControl();
                        break;
                    case "System.Boolean":
                        propEditor = new CheckEditControl();
                        break;
                    case "System.Int32":
                    case "System.Int16":
                        propEditor = new IntegerEditControl();
                        break;
                    default:
                        if (type.IsEnum)
                        {
                            propEditor = new EnumEditControl(editorInfo.Type);
                        }
                        else
                        {
                            propEditor = new TextEditControl(editorInfo.Type);
                        }
                        break;
                }
            }
            else
            {
				//Use Editor
                Type editType = Type.GetType(editorInfo.Editor, true, true);
                propEditor = (EditControl) Activator.CreateInstance(editType);
            }
            propEditor.ID = editorInfo.Name;
            propEditor.Name = editorInfo.Name;
			propEditor.Category = editorInfo.Category;

            propEditor.EditMode = editorInfo.EditMode;
            propEditor.Required = editorInfo.Required;

            propEditor.Value = editorInfo.Value;
            propEditor.OldValue = editorInfo.Value;

            propEditor.CustomAttributes = editorInfo.Attributes;

            return propEditor;
        }
Ejemplo n.º 3
0
        private static EditControl CreateEditControlInternal(string systemType)
        {
            EditControl propEditor = null;

            try
            {
                var type = Type.GetType(systemType);
                if (type != null)
                {
                    switch (type.FullName)
                    {
                    case "System.DateTime":
                        propEditor = new DateTimeEditControl();
                        break;

                    case "System.Boolean":
                        propEditor = new CheckEditControl();
                        break;

                    case "System.Int32":
                    case "System.Int16":
                        propEditor = new IntegerEditControl();
                        break;

                    default:
                        if (type.IsEnum)
                        {
                            propEditor = new EnumEditControl(systemType);
                        }

                        break;
                    }
                }
            }
            catch (Exception)
            {
                // ignore
            }

            return(propEditor ?? new TextEditControl(systemType));
        }