/// <summary> /// 初始化APP /// </summary> /// <param name="cfgAppNodeName"></param> public TencBase(string cfgAppNodeName) { this.app = TencConfig.GetConfigApp(cfgAppNodeName); base.ClientId = this.app.AppKey; base.ClientSecret = this.app.AppSecret; base.RedirectUri = this.app.RedirectUri; base.Scope = this.app.Scope; }
/// <summary> /// 获取配置文件(Wbm.TencV2.config)的application节点 /// </summary> /// <param name="cfgAppNodeName">application子节点的Name</param> /// <returns>APPKey实体</returns> public static Entitys.AppEntity GetConfigApp(string cfgAppNodeName) { string xpath = CONFIG_ROOT + CONFIG_APP + "/" + cfgAppNodeName.Trim('/'); string CONFIG_SCOPE_KEY = "/scope"; string CONFIG_APPLICATION_KEY = "/clientId"; string CONFIG_APPLICATION_SECRET = "/clientSecret"; string CONFIG_APPLICATION_REDIRECTURI = "/redirectUri"; string CONFIG_APPLICATION_USERNAME = "******"; string CONFIG_APPLICATION_PASSWORD = "******"; string scope = xpath + CONFIG_SCOPE_KEY; string key = xpath + CONFIG_APPLICATION_KEY; string secret = xpath + CONFIG_APPLICATION_SECRET; string redirecturi = xpath + CONFIG_APPLICATION_REDIRECTURI; string username = xpath + CONFIG_APPLICATION_USERNAME; string password = xpath + CONFIG_APPLICATION_PASSWORD; var app = new Entitys.AppEntity(); app.AppName = cfgAppNodeName; if (XmlConfig.IsExists(key) && !string.IsNullOrEmpty(XmlConfig.SelectSingleNodeText(key))) { if (XmlConfig.IsExists(secret) && !string.IsNullOrEmpty(XmlConfig.SelectSingleNodeText(secret))) { if (XmlConfig.IsExists(redirecturi) && !string.IsNullOrEmpty(XmlConfig.SelectSingleNodeText(redirecturi))) { app.AppKey = XmlConfig.SelectSingleNodeText(key); app.AppSecret = XmlConfig.SelectSingleNodeText(secret); app.RedirectUri = XmlConfig.SelectSingleNodeText(redirecturi); app.Scope = XmlConfig.SelectSingleNodeText(scope); } else { throw new ArgumentNullException(string.Format("{0}节点:找不到该节点或该值为空", redirecturi)); } } else { throw new ArgumentNullException(string.Format("{0}节点:找不到该节点或该值为空", secret)); } } else { throw new ArgumentNullException(string.Format("{0}节点:找不到该节点或该值为空", key)); } return(app); }
/// <summary> /// 获取配置文件(Wbm.TencV2.config)的application节点 /// </summary> /// <param name="cfgAppNodeName">application子节点的Name</param> /// <returns>APPKey实体</returns> public static Entitys.AppEntity GetConfigApp(string cfgAppNodeName) { string xpath = CONFIG_ROOT + CONFIG_APP + "/" + cfgAppNodeName.Trim('/'); string CONFIG_SCOPE_KEY = "/scope"; string CONFIG_APPLICATION_KEY = "/clientId"; string CONFIG_APPLICATION_SECRET = "/clientSecret"; string CONFIG_APPLICATION_REDIRECTURI = "/redirectUri"; string CONFIG_APPLICATION_USERNAME = "******"; string CONFIG_APPLICATION_PASSWORD = "******"; string scope = xpath + CONFIG_SCOPE_KEY; string key = xpath + CONFIG_APPLICATION_KEY; string secret = xpath + CONFIG_APPLICATION_SECRET; string redirecturi = xpath + CONFIG_APPLICATION_REDIRECTURI; string username = xpath + CONFIG_APPLICATION_USERNAME; string password = xpath + CONFIG_APPLICATION_PASSWORD; var app = new Entitys.AppEntity(); app.AppName = cfgAppNodeName; if (XmlConfig.IsExists(key) && !string.IsNullOrEmpty(XmlConfig.SelectSingleNodeText(key))) { if (XmlConfig.IsExists(secret) && !string.IsNullOrEmpty(XmlConfig.SelectSingleNodeText(secret))) { if (XmlConfig.IsExists(redirecturi) && !string.IsNullOrEmpty(XmlConfig.SelectSingleNodeText(redirecturi))) { app.AppKey = XmlConfig.SelectSingleNodeText(key); app.AppSecret = XmlConfig.SelectSingleNodeText(secret); app.RedirectUri = XmlConfig.SelectSingleNodeText(redirecturi); app.Scope = XmlConfig.SelectSingleNodeText(scope); } else { throw new ArgumentNullException(string.Format("{0}节点:找不到该节点或该值为空", redirecturi)); } } else { throw new ArgumentNullException(string.Format("{0}节点:找不到该节点或该值为空", secret)); } } else { throw new ArgumentNullException(string.Format("{0}节点:找不到该节点或该值为空", key)); } return app; }