Esempio n. 1
0
 private void InnerGetListConfiguration(Object source, FieldWithAttribute <CustomerFieldAttribute> fieldWithAttribute, IGrouping <String, InnerXmlNodeInfomation> grouping)
 {
     try
     {
         Object list = fieldWithAttribute.FieldInfo.GetType().Assembly.CreateInstance(fieldWithAttribute.FieldInfo.FieldType.FullName);
         foreach (var infomation in grouping)
         {
             Object fieldInstance = fieldWithAttribute.Attribute.ElementType.Assembly.CreateInstance(fieldWithAttribute.Attribute.ElementType.FullName);
             List <FieldWithName>        names         = TypeHelper.GetFields(fieldInstance.GetType());
             Dictionary <String, String> sectionValues = XmlHelper.GetNodeAttributes(infomation.OutputXml);
             var result = names.Select(name => TypeHelper.SetValue(fieldInstance, name.FieldInfo, sectionValues.Where(value => name.Name == value.Key).First().Value));
             //开始赋值
             foreach (FieldInfo info in result)
             {
             }
             //找到Add方法
             MethodInfo add = list.GetType().GetMethod("Add", new[] { fieldWithAttribute.Attribute.ElementType });
             add.Invoke(list, new[] { fieldInstance });
         }
         fieldWithAttribute.FieldInfo.SetValue(source, list);
     }
     catch (Exception)
     {
         LoadFailedHandler(null);
     }
 }
Esempio n. 2
0
 private void InnerGetSingelConfiguration(Object source, FieldWithAttribute <CustomerFieldAttribute> fieldWithAttribute, InnerXmlNodeInfomation grouping)
 {
     try
     {
         Dictionary <String, String> sectionValues = XmlHelper.GetNodeAttributes(grouping.OutputXml);
         if (sectionValues != null)
         {
             Object obj = fieldWithAttribute.FieldInfo.FieldType.Assembly.CreateInstance(fieldWithAttribute.FieldInfo.FieldType.FullName);
             List <FieldWithName> names = TypeHelper.GetFields(obj.GetType());
             var result = names.Select(name => TypeHelper.SetValue(obj, name.FieldInfo, sectionValues.Where(value => name.Name == value.Key).First().Value));
             //开始赋值
             foreach (FieldInfo info in result)
             {
             }
             fieldWithAttribute.FieldInfo.SetValue(source, obj);
         }
     }
     catch (Exception)
     {
         LoadFailedHandler(null);
     }
 }