Exemplo n.º 1
0
        /// <summary>
        /// Adds a field for every argument that the DataMethos needs in order to be invoked
        /// </summary>
        /// <param name="method">DataMethod which parameters will be used as fields</param>
        public override void AddFields(MethodInfo method)
        {
            if (method == null)
            {
                throw new ArgumentNullException("dmethod");
            }
            uint order = 0;

            //add a field for each parameter
            foreach (ParameterInfo param in method.GetParameters())
            {
                FormField field;

                field = ObjectForm.CreateField(param.ParameterType);

                //set common values
                field.Container           = this;
                field.Name                = param.Name;
                field.Required            = !param.IsOptional && !param.IsOut;
                field.CaptionControl.Text = new System.Resources.ResourceManager(method.DeclaringType).GetString(method.GetFriendlyFullName().Replace('.', '_') + '_' + param.Name);
                field.SortOrder           = order++;

                Fields.Add(field);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a field for a DataMember
        /// </summary>
        public void AddFields(MemberInfo member)
        {
            //if there's no values defined, exit
            if (member == null)
            {
                throw new ArgumentNullException(nameof(member));
            }

            //field
            FormField fieldMin, fieldMax;
            Type      returnType = MemberExpression.GetReturnType(member);

            //DateTime and numeric, create range fields
            if (returnType.Equals(typeof(DateTime)) || returnType.IsNumeric())
            {
                //create fields
                fieldMin = ObjectForm.CreateField(returnType);
                fieldMax = ObjectForm.CreateField(returnType);

                //set id
                fieldMin.Name += "_0";
                fieldMax.Name += "_1";

                //labels
                fieldMin.CaptionControl.Text += Resources.Strings.OKHOSTING_ORM_UI_Forms_FilterDataForm_Min;
                fieldMax.CaptionControl.Text += Resources.Strings.OKHOSTING_ORM_UI_Forms_FilterDataForm_Max;

                //set container
                fieldMin.Container = this;
                fieldMax.Container = this;

                //not required
                fieldMin.Required = false;
                fieldMax.Required = false;

                //set to false always
                fieldMin.TableWide = false;
                fieldMax.TableWide = false;

                //add
                Fields.Add(fieldMin);
                Fields.Add(fieldMax);
            }
            //single value fields
            else
            {
                //create field
                fieldMin = ObjectForm.CreateField(returnType);

                //set container
                fieldMin.Container = this;

                //not required
                fieldMin.Required = false;

                //set to false always
                fieldMin.TableWide = false;

                //add
                Fields.Add(fieldMin);
            }
        }