Ejemplo n.º 1
0
        private static Dictionary <String, AuthConnect> loadConnects()
        {
            Dictionary <String, AuthConnect> map = new Dictionary <String, AuthConnect>();

            foreach (KeyValuePair <String, Type> kv in ObjectContext.Instance.TypeList)
            {
                Type t = kv.Value;

                if (t.IsSubclassOf(typeof(AuthConnect)))
                {
                    AuthConnectConfig cfgConnect = AuthConnectConfig.GetByType(t.FullName);
                    if (cfgConnect == null)
                    {
                        logger.Warn(String.Format("config of '{0}' is empty", t.FullName));
                        continue;
                    }

                    AuthConnect obj = initConnect(t, cfgConnect);

                    map.Add(t.FullName, obj);
                }
            }

            return(map);
        }
Ejemplo n.º 2
0
        private static AuthConnect initConnect( Type t, AuthConnectConfig x )
        {
            AuthConnect obj = ObjectContext.Create( t ) as AuthConnect;

            if (strUtil.IsNullOrEmpty( x.ConsumerKey ))
                throw new Exception( String.Format( "请设置 Consumer Key: {0}", x.Name ) );
            if (strUtil.IsNullOrEmpty( x.ConsumerSecret ))
                throw new Exception( String.Format( "请设置 Consumer Secret: {0}", x.Name ) );

            obj.ConsumerKey = x.ConsumerKey;
            obj.ConsumerSecret = x.ConsumerSecret;

            return obj;
        }
Ejemplo n.º 3
0
        private static AuthConnect initConnect(Type t, AuthConnectConfig x)
        {
            AuthConnect obj = ObjectContext.Create(t) as AuthConnect;

            if (strUtil.IsNullOrEmpty(x.ConsumerKey))
            {
                throw new Exception(String.Format("请设置 Consumer Key: {0}", x.Name));
            }
            if (strUtil.IsNullOrEmpty(x.ConsumerSecret))
            {
                throw new Exception(String.Format("请设置 Consumer Secret: {0}", x.Name));
            }

            obj.ConsumerKey    = x.ConsumerKey;
            obj.ConsumerSecret = x.ConsumerSecret;

            return(obj);
        }
Ejemplo n.º 4
0
        public int CompareTo(object obj)
        {
            AuthConnectConfig t = obj as AuthConnectConfig;

            if (this.OrderId > t.OrderId)
            {
                return(-1);
            }
            if (this.OrderId < t.OrderId)
            {
                return(1);
            }
            if (this.Id > t.Id)
            {
                return(1);
            }
            if (this.Id < t.Id)
            {
                return(-1);
            }
            return(0);
        }
 private void validatePost( AuthConnectConfig x ) {
     if (strUtil.IsNullOrEmpty( x.Name )) errors.Add( "请填写名称" );
     if (strUtil.IsNullOrEmpty( x.TypeFullName )) errors.Add( "请填写TypeFullName" );
     if (strUtil.IsNullOrEmpty( x.ConsumerKey )) errors.Add( "请填写ConsumerKey" );
     if (strUtil.IsNullOrEmpty( x.ConsumerSecret )) errors.Add( "请填写ConsumerSecret" );
 }