Ejemplo n.º 1
0
        private void DomainGeneratorForm_Load(object sender, EventArgs e)
        {
            List <string> listPathRadio = new List <string>();

            for (int i = 0; i < m_domainController.ListDomainSupport.Count; i++)
            {
                IUIDataModelSupport domainSupport = m_domainController.ListDomainSupport[i];

                if (domainSupport is EVORadioButton)
                {
                    EVORadioButton radio = (EVORadioButton)domainSupport;
                    if (listPathRadio.Contains(radio.PathString))
                    {
                        continue;
                    }

                    listPathRadio.Add(radio.PathString);
                }

                // add item in listview.
                ListViewItem lsvItem = new ListViewItem(m_domainController.ExtractNestedPropertyName(domainSupport.PathString)[0]);
                lsvItem.SubItems.Add(domainSupport.GetType().Name);
                lsvItem.Tag = domainSupport;
                lsvSource.Items.Add(lsvItem);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Set value to domain
        /// </summary>
        /// <param name="domainSupport"></param>
        /// <param name="data"></param>
        /// <param name="value"></param>
        /// <exception cref="ApplicationException"><c>ApplicationException</c>.</exception>
        private void SetValueIntoDomain(IUIDataModelSupport domainSupport, IUIDataModel data, object value)
        {
            string path = domainSupport.PathString;

            //string domainName = ExtractDomainName(path);
            string[] nestedPropertyNames = ExtractNestedPropertyName(path);
            string   resutlPropertyName  = ExtractResultPropertyName(path);

            // ค้นหาทุกๆ Nested Property เพื่อทำการ Get
            object objLastNestedProperty = data;

            if (nestedPropertyNames != null)
            {
                for (int i = 0; i < nestedPropertyNames.Length; i++)
                {
                    Type         typeProperty = objLastNestedProperty.GetType();
                    PropertyInfo propInfo     = typeProperty.GetProperty(nestedPropertyNames[i]);
                    if (propInfo == null)
                    {
                        throw new ApplicationException(String.Format("Not found property \"{0}\" on path: \"{1}\"", nestedPropertyNames[i], path));
                    }

                    if (!propInfo.CanRead)
                    {
                        throw new ApplicationException(String.Format("path: \"{0}\", cannot access property name \"{1}\"", path, nestedPropertyNames[i]));
                    }
                    objLastNestedProperty = propInfo.GetGetMethod().Invoke(objLastNestedProperty, null);
                }
            }

            // ค้นหา Result Property เพื่อทำการ get object

            Type         typeObject     = objLastNestedProperty.GetType();
            PropertyInfo propResultInfo = typeObject.GetProperty(resutlPropertyName);

            if (propResultInfo == null)
            {
                throw new ApplicationException(String.Format("Not found property \"{0}\" on path: \"{1}\"", resutlPropertyName, path));
            }

            if (!propResultInfo.CanWrite)
            {
                throw new ApplicationException(String.Format("path: \"{0}\", cannot access property name \"{1}\"", path, resutlPropertyName));
            }

            if (objLastNestedProperty is NZBaseObject)
            {
                ((NZBaseObject)objLastNestedProperty).Owner = domainSupport;
            }

            propResultInfo.SetValue(objLastNestedProperty, value, null);
        }
Ejemplo n.º 3
0
        private string GetPropertyMethod(IUIDataModelSupport component)
        {
            string propName = m_domainController.ExtractNestedPropertyName(component.PathString)[0];
            string varName  = GetVariableName(propName);
            string dataType = GetDataTypeOfControl(component);

            StringBuilder sb = new StringBuilder();

            sb.AppendLine(String.Format("\t\tpublic {0} {1} {{",
                                        dataType,
                                        propName
                                        ));

            sb.AppendLine(String.Format("\t\t\tget {{ return {0}; }}", varName));
            sb.AppendLine(String.Format("\t\t\tset {{ {0} = value; }}", varName));
            sb.AppendLine("\t\t}");
            return(sb.ToString());
        }
Ejemplo n.º 4
0
        private string GetDataTypeOfControl(IUIDataModelSupport component)
        {
            if (component is EVOTextBox)
            {
                return("NZString");
            }

            if (component is EVOCheckBox)
            {
                return("NZBoolean");
            }

            if (component is EVORadioButton)
            {
                return("NZString");
            }

            if (component is EVOComboBox)
            {
                return("NZObject");
            }

            return("NZObject");
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Add an object to the last of list.
 /// </summary>
 /// <param name="domainSupport">Object which implement interface IDomainSupport</param>
 public void AddControl(IUIDataModelSupport domainSupport)
 {
     ListDomainSupport.Add(domainSupport);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Remove the first occurence of a specific object.
 /// </summary>
 /// <param name="domainSupport">The object to remove</param>
 public void RemoveControl(IUIDataModelSupport domainSupport)
 {
     ListDomainSupport.Remove(domainSupport);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Insert an element at the specified index.
 /// </summary>
 /// <param name="index">The zero-based index at which item should be inserted.</param>
 /// <param name="domainSupport">The object to insert</param>
 /// <exception cref="System.ArgumentOutOfRangeException">index is less than 0.-or-index is greater than <see cref="P:System.Collections.Generic.List`1.Count" />.</exception>
 public void InsertControl(int index, IUIDataModelSupport domainSupport)
 {
     ListDomainSupport.Insert(index, domainSupport);
 }