Пример #1
0
        private string GetSingleProperty(TrafficProtocolAttribute attr, MemberInfo m, int tmpOrderCoder, ref string content)
        {
            string str;

            string[] strArrays;
            bool     flag;

            if (string.IsNullOrEmpty(attr.OrderCodeList))
            {
                flag = true;
            }
            else
            {
                flag = (attr.OrderCodeList.IndexOf(string.Concat(",", tmpOrderCoder.ToString(), ",")) >= 0 ? true : attr.OrderCodeList == tmpOrderCoder.ToString());
            }
            if (flag)
            {
                string str1 = "";
                string str2 = "";
                string str3 = "";
                if (!attr.isEnum)
                {
                    str2 = (this.GetType().GetProperty(m.Name).GetValue(this, null) == null ? "" : this.GetType().GetProperty(m.Name).GetValue(this, null).ToString());
                }
                else
                {
                    str2 = ((this.GetType().GetProperty(m.Name).GetValue(this, null) == null ? 0 : (int)this.GetType().GetProperty(m.Name).GetValue(this, null))).ToString();
                }
                str1 = ((attr.OrderCodeList == string.Concat(",", tmpOrderCoder.ToString(), ",") ? false : !string.IsNullOrEmpty(attr.OrderCodeList)) ? this.GetXmlTag(attr.XmlTag, attr.OrderCodeList, tmpOrderCoder.ToString()) : attr.XmlTag);
                if (attr.SourceValueField.Length == 0)
                {
                    str3 = str2;
                }
                else
                {
                    str3 = (this.GetType().GetProperty(attr.SourceValueField).GetValue(this, null) == null ? "" : this.GetType().GetProperty(attr.SourceValueField).GetValue(this, null).ToString());
                }
                if (!string.IsNullOrEmpty(attr.desc))
                {
                    string str4 = content;
                    strArrays = new string[] { str4, attr.desc, "-", str3, "," };
                    content   = string.Concat(strArrays);
                }
                strArrays = new string[] { "<", str1, ">", str2, "</", str1, ">" };
                str       = string.Concat(strArrays);
            }
            else
            {
                str = "";
            }
            return(str);
        }
Пример #2
0
        public virtual string GetMembersXml(ref string content)
        {
            int           orderCode;
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("<Parameter>");
            MemberInfo[] members = this.GetType().GetMembers();
            if (this.TransformCode == -1)
            {
                orderCode = (int)this.OrderCode;
            }
            else
            {
                orderCode = this.TransformCode;
            }
            int num = orderCode;
            Dictionary <string, string> strs = new Dictionary <string, string>();
            string groupName = "";

            MemberInfo[] memberInfoArray = members;
            for (int i = 0; i < (int)memberInfoArray.Length; i++)
            {
                MemberInfo memberInfo = memberInfoArray[i];
                TrafficProtocolAttribute             customAttribute = Attribute.GetCustomAttribute(memberInfo, typeof(TrafficProtocolAttribute)) as TrafficProtocolAttribute;
                TrafficProtocolAttrForArrayAttribute trafficProtocolAttrForArrayAttribute = Attribute.GetCustomAttribute(memberInfo, typeof(TrafficProtocolAttrForArrayAttribute)) as TrafficProtocolAttrForArrayAttribute;
                TrafficProtocolAttrGroupAttribute    trafficProtocolAttrGroupAttribute    = Attribute.GetCustomAttribute(memberInfo, typeof(TrafficProtocolAttrGroupAttribute)) as TrafficProtocolAttrGroupAttribute;
                if (customAttribute != null)
                {
                    stringBuilder.Append(this.GetSingleProperty(customAttribute, memberInfo, num, ref content));
                }
                else if (trafficProtocolAttrForArrayAttribute != null)
                {
                    stringBuilder.Append(this.GetArrayProperty(trafficProtocolAttrForArrayAttribute, memberInfo, num, ref content));
                }
                else if (trafficProtocolAttrGroupAttribute != null)
                {
                    if (trafficProtocolAttrGroupAttribute.HasContainOrderCoder(num.ToString()))
                    {
                        groupName = trafficProtocolAttrGroupAttribute.GroupName;
                        string str = this.GetType().GetProperty(memberInfo.Name).GetValue(this, null).ToString();
                        strs.Add(trafficProtocolAttrGroupAttribute.XmlTag, str);
                    }
                }
            }
            stringBuilder.Append(this.GetGroupAttr(strs, groupName, ref content));
            stringBuilder.Append("</Parameter>");
            return(stringBuilder.ToString());
        }
Пример #3
0
 private string GetSingleProperty(TrafficProtocolAttribute attr, MemberInfo m, int tmpOrderCoder, ref string content)
 {
     string str;
     string[] strArrays;
     bool flag;
     if (string.IsNullOrEmpty(attr.OrderCodeList))
     {
         flag = true;
     }
     else
     {
         flag = (attr.OrderCodeList.IndexOf(string.Concat(",", tmpOrderCoder.ToString(), ",")) >= 0 ? true : attr.OrderCodeList == tmpOrderCoder.ToString());
     }
     if (flag)
     {
         string str1 = "";
         string str2 = "";
         string str3 = "";
         if (!attr.isEnum)
         {
             str2 = (this.GetType().GetProperty(m.Name).GetValue(this, null) == null ? "" : this.GetType().GetProperty(m.Name).GetValue(this, null).ToString());
         }
         else
         {
             str2 = ((this.GetType().GetProperty(m.Name).GetValue(this, null) == null ? 0 : (int)this.GetType().GetProperty(m.Name).GetValue(this, null))).ToString();
         }
         str1 = ((attr.OrderCodeList == string.Concat(",", tmpOrderCoder.ToString(), ",") ? false : !string.IsNullOrEmpty(attr.OrderCodeList)) ? this.GetXmlTag(attr.XmlTag, attr.OrderCodeList, tmpOrderCoder.ToString()) : attr.XmlTag);
         if (attr.SourceValueField.Length == 0)
         {
             str3 = str2;
         }
         else
         {
             str3 = (this.GetType().GetProperty(attr.SourceValueField).GetValue(this, null) == null ? "" : this.GetType().GetProperty(attr.SourceValueField).GetValue(this, null).ToString());
         }
         if (!string.IsNullOrEmpty(attr.desc))
         {
             string str4 = content;
             strArrays = new string[] { str4, attr.desc, "-", str3, "," };
             content = string.Concat(strArrays);
         }
         strArrays = new string[] { "<", str1, ">", str2, "</", str1, ">" };
         str = string.Concat(strArrays);
     }
     else
     {
         str = "";
     }
     return str;
 }