Ejemplo n.º 1
0
 public Parameter this[int index]
 {
     get
     {
         if (innerList == null)
         {
             return null;
         }
         return (Parameter)innerList[index];
     }
     set
     {
         if (innerList == null)
         {
             innerList = new IgnoreCaseStringHashList();
         }
         innerList[index] = value;
     }
 }
Ejemplo n.º 2
0
 public NamedValue this[int index]
 {
     get
     {
         if (innerList == null)
         {
             return null;
         }
         return (NamedValue)innerList[index];
     }
     set
     {
         if (innerList == null)
         {
             innerList = new IgnoreCaseStringHashList();
         }
         innerList[index] = value;
     }
 }
Ejemplo n.º 3
0
 public Parameter this[string parameterName]
 {
     get
     {
         if (innerList == null)
         {
             return null;
         }
         return (Parameter)innerList[parameterName];
     }
     set
     {
         if (innerList == null)
         {
             innerList = new IgnoreCaseStringHashList();
         }
         innerList[parameterName] = value;
         if (value != null)
         {
             value.Name = parameterName;
         }
     }
 }
Ejemplo n.º 4
0
 public NamedValue this[string name]
 {
     get
     {
         if (innerList == null)
         {
             return null;
         }
         return (NamedValue)innerList[name];
     }
     set
     {
         if (innerList == null)
         {
             innerList = new IgnoreCaseStringHashList();
         }
         innerList[name] = value;
         if (value != null)
         {
             value.Name = name;
         }
     }
 }
Ejemplo n.º 5
0
 public void Add(Parameter parameter)
 {
     if (string.IsNullOrEmpty(parameter.Name))
     {
         throw new Exception("参数名称不能为空。");
     }
     if (innerList == null)
     {
         innerList = new IgnoreCaseStringHashList();
     }
     innerList.Add(parameter.Name, parameter);
 }
Ejemplo n.º 6
0
        /**
         * ����ָ��Щ��GetXX��SetXX�������ֶΡ�
         *
         * @param obj
         * @param bRead
         * @param bWrite
         * @return
         * @
         */
        public static StringKeyList GetProperties(Type classType)
        {
            IgnoreCaseStringHashList list = new IgnoreCaseStringHashList();
            String propertyName = "";// ��������//
            String methodName;// ��������//
            int methodFlag;// �������ͣ�0Ϊһ�㷽����1Ϊ��������2Ϊд����//
            Type propertyType = null;// ��������//
            Type[] paramTypes;// �����IJ��������б�//
            MethodInfo[] m = classType.GetMethods();// ȡ�����ж���ķ���//
            for (int i = 0; i < m.Length; i++)
            {
                methodName = m[i].Name;
                methodFlag = 0;
                // ����������Ƶ�ǰ�����ַ���Get��Set������Ϊ�����������ƣ�
                // ���Ƿ�Ϊ��д��������Ҫ��һ���жϡ���Ϊ������û�в�����д
                // ������һ��������
                if (methodName.Substring(0, 3).Equals("Get"))
                {
                    methodFlag = 1;
                }
                else if (methodName.Substring(0, 3).Equals("Set"))
                {
                    methodFlag = 2;
                }
                // ���Ϊ��������Ӧ��û�в���,���Ϊд������Ӧ����һ������//
                paramTypes = TypeUtils.GetParameterTypes(m[i].GetParameters());
                if (methodFlag == 1)
                {
                    if (paramTypes.Length != 0)
                    {

                        methodFlag = 0;
                    }
                    else
                    {
                        propertyName = methodName.Substring(3);
                        propertyType = m[i].ReturnType;
                    }
                }
                else
                {
                    if (paramTypes.Length != 1)
                    {
                        methodFlag = 0;
                    }
                    else
                    {
                        propertyName = methodName.Substring(3);
                        propertyType = paramTypes[0];
                    }
                }
                // ���������Ŀ�Ƿ���ڣ�������ڣ�����Ҫ��һ��������������Ƿ�
                // һ�£������һ�£���ɾ�������ԡ�
                if (methodFlag > 0)
                {
                    PropertyDefinition property = (PropertyDefinition)list.GetValue(propertyName);
                    if (property == null)
                    {
                        // �������Զ���//
                        property = new PropertyDefinition();
                        // ������������//
                        property.PropertyName = propertyName;
                        property.PropertyType = propertyType;
                        // ���ö�д����//
                        if (methodFlag == 1)
                        {
                            property.ReadMethod = m[i];
                        }
                        else
                        {
                            property.WriteMethod = m[i];
                        }
                        // �������Ե������б�//
                        list.Add(property.PropertyName, property);
                    }
                    else
                    {
                        if (property.PropertyType == propertyType)
                        {
                            // ���ö�д����//
                            if (methodFlag == 1)
                            {
                                property.ReadMethod = m[i];
                            }
                            else
                            {
                                property.WriteMethod = m[i];
                            }
                        }
                        else
                        {
                            list.Remove(property.PropertyName);
                        }
                    }
                }
            }
            return list;
        }
Ejemplo n.º 7
0
 public void Add(NamedValue nameValue)
 {
     if (innerList == null)
     {
         innerList = new IgnoreCaseStringHashList();
     }
     innerList.Add(nameValue.Name, nameValue);
 }