Ejemplo n.º 1
0
        public string GetMicroresolverBindCode(ScopeTypeEnum scope)
        {
            var suffix = GetSuffix(scope);

            return($@"
container.Register<{InterfaceName}, {ClassName}>(Lifestyle.{suffix});
");
        }
Ejemplo n.º 2
0
        public string GetDryIocBindCode(ScopeTypeEnum scope)
        {
            var suffix = GetSuffix(scope);


            return($@"
container.Register<{InterfaceName}, {ClassName}>(Reuse.{suffix});
");
        }
Ejemplo n.º 3
0
 public Variable(string var, string val, CodeObject parent, ScopeTypeEnum scope)
 {
     Parent      = parent;
     AccessLevel = scope;
     Name        = var;
     Value       = val;
     Type        = Helpers.GetType(val);
     //do parse work
 }
Ejemplo n.º 4
0
        public void AddVariable(string var, string val, ScopeTypeEnum access)
        {
            var variable = new Variable(var, val, this, access);

            if (HasVariable(variable.Name) || Parent.HasVariable(variable.Name))
            {
                SetVariable(var, val);
            }
            Variables.Add(variable);
        }
Ejemplo n.º 5
0
        private void AddClass(ScopeTypeEnum access, string s)
        {
            var cls = new Class(access, s, this);

            if (HasClass(cls.Name))
            {
                throw new Exception(string.Format("Cannot Create Class {0} class already exists.", cls.Name));
            }
            Classes.Add(cls);
        }
Ejemplo n.º 6
0
        private void AddVariable(ScopeTypeEnum access, string s)
        {
            var var = new Variable(s, this, access);

            if (HasVariable(var.Name))
            {
                throw new Exception(string.Format("Cannot Create {0} Global Variable already exists.", var.Name));
            }
            GlobalVariables.Add(var);
        }
Ejemplo n.º 7
0
        private void AddVariable(string s, ScopeTypeEnum access)
        {
            var var = new Variable(s, this, access);

            if (HasVariable(var.Name) || Parent.HasVariable(var.Name))
            {
                throw new Exception(string.Format("Cannot Create {0} Variable already exists.", var.Name));
            }
            Variables.Add(new Variable(s, this, access));
        }
Ejemplo n.º 8
0
        private void AddMethod(string s, ScopeTypeEnum access)
        {
            var method = new Method(s, this, access);

            if (Methods.Any(x => x.Name == method.Name))
            {
                throw new Exception(string.Format("Cannot Create {0} Method already exists.", method.Name));
            }
            Methods.Add(method);
        }
Ejemplo n.º 9
0
 public Class(ScopeTypeEnum access, string s, CodeObject parent)
 {
     Methods     = new List <Method>();
     Variables   = new List <Variable>();
     Lines       = new List <Line>();
     Parent      = parent;
     AccessLevel = access;
     Name        = ParseName(s);
     ParseCode(s);
 }
Ejemplo n.º 10
0
 public Method(string s, CodeObject parent, ScopeTypeEnum access)
 {
     Variables   = new List <Variable>();
     Code        = new List <Line>();
     Parameters  = new List <Parameters>();
     Parent      = parent;
     AccessLevel = access;
     Name        = ParseName(s);
     ParseCode(s);
     //do parse work here
 }
Ejemplo n.º 11
0
        public string GetDpdtBindCode(ScopeTypeEnum scope)
        {
            var suffix = GetSuffix(scope);

            return($@"
Bind<{InterfaceName}>()
    .To<{ClassName}>()
    .With{suffix}Scope()
    ;
");
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 生成OAuth相关的URL
        /// </summary>
        /// <param name="para_URL"></param>
        /// <param name="scope">应用授权作用域
        /// <param name="state">重定向后会带上state参数</param>
        /// <returns></returns>
        public string GetOAuth_URL(string para_URL, ScopeTypeEnum scope, string state)
        {
            string OAuth_URL = string.Empty;

            try
            {
                OAuth_URL = string.Format("https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id={0}&scope={1}&redirect_uri={2}&state={3}", config.app_id, scope.ToString(), System.Web.HttpUtility.UrlEncode(para_URL), state);
            }
            catch (Exception e)
            {
                log.Error(string.Format("Corp getOAuth_URL:"), e);
            }
            return(OAuth_URL);
        }
Ejemplo n.º 13
0
        private static string GetSuffix(ScopeTypeEnum scope)
        {
            var suffix = "";

            switch (scope)
            {
            case ScopeTypeEnum.Transient:
                suffix = "Transient";
                break;

            case ScopeTypeEnum.Singleton:
                suffix = "Singleton";
                break;

            default:
                throw new ArgumentOutOfRangeException(scope.ToString());
            }

            return(suffix);
        }
Ejemplo n.º 14
0
        private void AddMethod(string s, ScopeTypeEnum access)
        {
            var method = new Method(s, this, access);

            if (method.Name != "main")
            {
                if (Methods.Any(x => x.Name == method.Name))
                {
                    throw new Exception(string.Format("Cannot Create {0} Global Method already exists.", method.Name));
                }
                Methods.Add(method);
            }
            else if (MainMethod != null)
            {
                throw new Exception("Ambiguos Main method found.");
            }
            else
            {
                MainMethod = method;
            }
        }
Ejemplo n.º 15
0
 /// <summary>
 /// 获取Code码接口地址
 /// </summary>
 /// <returns></returns>
 public static string OAuth2_AuthorizeUrl(string appkey, string redirect_uri, ScopeTypeEnum scope, string state = "STATE")
 {
     //https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE#wechat_redirect
     return($"https://open.weixin.qq.com/connect/oauth2/authorize?appid={appkey}&redirect_uri={redirect_uri}&response_type=code&scope={scope.ToString()}&state={state}#wechat_redirect");
 }
Ejemplo n.º 16
0
 public Variable(string s, CodeObject parent, ScopeTypeEnum scope)
 {
     Parent      = parent;
     AccessLevel = scope;
     //do parse work
 }