/// <summary> /// 转换UEP属性的值 /// </summary> /// <param name="UEPFiledType">字段类型</param> /// <param name="FileValue">字段值</param> /// <returns></returns> public static string ConvertUEPFiledValue(string UEPFiledType, string filedValue) { string sapFiledValue = string.Empty; var convertFiledValueElements = ConvertUepFiledValueMapping.GetConfig().Fileds.Cast <ConvertUepFiledValueElement>(); //当前属性的类型匹配到配置文件中的类型,并且执行规则方法 var element = convertFiledValueElements.FirstOrDefault(p => p.UEPValueType == UEPFiledType); if (element != null) { string[] typeStrings = element.UEPValueDelegate.Split(','); if (typeStrings.Length == 2) { Type convertUEPFiledValue = Type.GetType(typeStrings[0]); //创建该程序集下的类实例(用于委托调用a该类实例下的Method) object instance = Activator.CreateInstance(convertUEPFiledValue); //创建委托,指定委托调用的方法 GetConvertUEPFiledValue convertFiledValueMothend = (GetConvertUEPFiledValue)Delegate.CreateDelegate(typeof(GetConvertUEPFiledValue), instance, typeStrings[1]); sapFiledValue = convertFiledValueMothend(filedValue, element.Rule); } } return(sapFiledValue); }
public static ConvertUepFiledValueMapping GetConfig() { ConvertUepFiledValueMapping result = (ConvertUepFiledValueMapping)ConfigurationBroker.GetSection("ConvertFiledValuesMapping"); if (result == null) { result = new ConvertUepFiledValueMapping(); } return(result); }