private List <AuthNode> FormatPlatForm(PlatFormInfo platform, IEnumerable <AuthenticationInfo> auths, Dictionary <AuthKey, string> authKeys, Dictionary <string, string> alias) { var list = new List <AuthNode>(auths.Count() + 1); var node = new AuthNode(); node.PlatformId = platform.PlatformID.ToString(); node.Licence = null; foreach (string attrName in _attrNames) { FormatStrAttr(platform, node, attrName); } foreach (string attrName in _attrBoolNames) { FormatBoolAttr(platform, node, attrName); } list.Add(node); if (!string.IsNullOrEmpty(platform.Alias)) { var pas = platform.Alias.Split(_splictword, StringSplitOptions.RemoveEmptyEntries); foreach (var alia in pas) { alias.Add(alia, node.PlatformName); } } foreach (var auth in auths) { FormatAuth(platform, auth, list, authKeys); } return(list); }
private void FormatStrAttr(PlatFormInfo platform, AuthenticationInfo auth, AuthNode node, string attrName) { var attrValue = ReflectionOptimizer.GetProperty <AuthenticationInfo, string>(auth, attrName); if (string.IsNullOrEmpty(attrValue)) { attrValue = ReflectionOptimizer.GetProperty <PlatFormInfo, string>(platform, attrName); } ReflectionOptimizer.SetProperty <AuthNode, string>(node, attrValue, attrName); }
private void FormatBoolAttr(PlatFormInfo platform, AuthNode node, string attrName) { bool value; if (!string.IsNullOrEmpty(node.PlatformName) && AppSettingCache.Instance.ContainerKey(node.PlatformName) && string.Compare(attrName, AppSettingCache.Instance[node.PlatformName]) == 0) { value = true; } else { var attrValue = ReflectionOptimizer.GetProperty <PlatFormInfo, string>(platform, attrName); value = Convert.ToBoolean(int.Parse(attrValue)); } ReflectionOptimizer.SetProperty <AuthNode, bool>(node, value, attrName); }
private void FormatAuth(PlatFormInfo platform, AuthenticationInfo auth, List <AuthNode> list, Dictionary <AuthKey, string> authKeys) { var node = new AuthNode(); var licences = auth.AuthLicence.Split(_splictword, StringSplitOptions.RemoveEmptyEntries); node.PlatformId = platform.PlatformID.ToString(); node.Licence = auth.AuthKey; foreach (string attrName in _attrNames) { FormatStrAttr(platform, auth, node, attrName); } foreach (string attrName in _attrBoolNames) { FormatBoolAttr(platform, auth, node, attrName); } list.Add(node); foreach (var licence in licences) { authKeys.Add(new AuthKey() { Auth = licence, PlatForm = node.PlatformName }, node.Licence); } }
private void FormatStrAttr(PlatFormInfo platform, AuthNode node, string attrName) { var attrValue = ReflectionOptimizer.GetProperty <PlatFormInfo, string>(platform, attrName); ReflectionOptimizer.SetProperty <AuthNode, string>(node, attrValue, attrName); }