/// <summary> /// 解析Token /// </summary> /// <param name="token"></param> public static AccessToken ParseToken(string token) { AccessToken tokenEntity = new AccessToken(); if (!string.IsNullOrWhiteSpace(token)) { try { string tokenStr = AES.Decode(token); string[] arr = tokenStr.Split('_'); if (arr.Length >= 9) { Type t = tokenEntity.GetType(); PropertyInfo[] pis = t.GetProperties(); for (int i = 0; i < pis.Length; i++) { pis[i].SetValue(tokenEntity, ReflectionUtil.ChangeType(arr[i], pis[i]), null); } } } catch { tokenEntity = null; } } return(tokenEntity); }
private static void SetProperties(object fromRecordBO, object toRecordDTO, List <PropertyInfo> fromPI) { foreach (PropertyInfo fromField in fromPI) { PropertyInfo[] ToPI = toRecordDTO.GetType().GetProperties(); foreach (PropertyInfo toField in ToPI) { if (fromField.Name == toField.Name && toField.CanWrite) { object fromFieldValue = fromField.GetValue(fromRecordBO, null); if (FieldCanBeSetted(fromField, toField, fromRecordBO)) { toField.SetValue(toRecordDTO, ReflectionUtil.ChangeType(fromFieldValue, toField.PropertyType), null); } break; } } } }