Пример #1
0
        /// <summary>获取或添加</summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public OAuthItem GetOrAdd(String name)
        {
            if (name.IsNullOrEmpty())
            {
                return(null);
            }

            var mi = Items.FirstOrDefault(e => e.Name.EqualIgnoreCase(name));

            if (mi != null)
            {
                return(mi);
            }

            lock (this)
            {
                var list = new List <OAuthItem>(Items);
                mi = list.FirstOrDefault(e => e.Name.EqualIgnoreCase(name));
                if (mi != null)
                {
                    return(mi);
                }

                mi = new OAuthItem {
                    Name = name
                };
                list.Add(mi);

                Items = list.ToArray();

                return(mi);
            }
        }
Пример #2
0
        /// <summary>已加载</summary>
        protected override void OnLoaded()
        {
            var ms = Items;

            if (ms == null || ms.Length == 0)
            {
                var list = new List <OAuthItem>
                {
                    new OAuthItem {
                        Name = "QQ"
                    },
                    new OAuthItem {
                        Name = "Weixin"
                    },
                    new OAuthItem {
                        Name = "Baidu"
                    },
                    new OAuthItem {
                        Name = "Weibo"
                    },
                    new OAuthItem {
                        Name = "Taobao"
                    },
                    new OAuthItem {
                        Name = "Alipay"
                    },
                    new OAuthItem {
                        Name = "Github"
                    }
                };

                var sc = SysConfig.Current;
                var mi = new OAuthItem
                {
                    Name   = "Ding",
                    Server = "https://sso.haocoding.com/sso",
                    AppID  = sc.Name,
                    Secret = sc.Name.GetBytes().RC4("Ding".GetBytes()).ToBase64(),
                };
                list.Add(mi);
                Items = list.ToArray();
            }

            base.OnLoaded();
        }
Пример #3
0
 /// <summary>应用参数设置</summary>
 /// <param name="mi"></param>
 public virtual void Apply(OAuthItem mi)
 {
     Name = mi.Name;
     if (!mi.Server.IsNullOrEmpty())
     {
         Server = mi.Server;
     }
     if (!mi.AccessServer.IsNullOrEmpty())
     {
         AccessServer = mi.AccessServer;
     }
     if (!mi.AppID.IsNullOrEmpty())
     {
         Key = mi.AppID;
     }
     if (!mi.Secret.IsNullOrEmpty())
     {
         Secret = mi.Secret;
     }
     if (!mi.Scope.IsNullOrEmpty())
     {
         Scope = mi.Scope;
     }
 }