Exemple #1
0
        public static object Build(Type interfaceWebao, IRequest req)
        {
            var typeInformation  = TypeInfoCache.Get(interfaceWebao);
            var baseUrl          = typeInformation.GetClassAttributesByName("BaseUrl");
            var parametersByName = typeInformation.GetClassAttributesByName("AddParameter");

            if (baseUrl[0] is BaseUrlAttribute baseUrlAttribute)
            {
                req.BaseUrl(baseUrlAttribute.host);
            }

            foreach (var param in parametersByName)
            {
                if (param is AddParameterAttribute parameterAttribute)
                {
                    req.AddParameter(parameterAttribute.name, parameterAttribute.val);
                }
            }


            var typeMethods       = interfaceWebao.GetMethods();
            var methodInformation = typeMethods.Select(BuilderHelper.ProcessMethod).ToList();

            return(BuildTask(interfaceWebao, req, methodInformation));
        }
Exemple #2
0
        public static AbstractAccessObject Build(Type webao, IRequest req)
        {
            var typeInformation  = TypeInfoCache.Get(webao);
            var baseUrl          = typeInformation.GetClassAttributesByName("BaseUrl");
            var parametersByName = typeInformation.GetClassAttributesByName("AddParameter");

            if (baseUrl[0] is BaseUrlAttribute baseUrlAttribute)
            {
                req.BaseUrl(baseUrlAttribute.host);
            }

            foreach (var param in parametersByName)
            {
                if (param is AddParameterAttribute parameterAttribute)
                {
                    req.AddParameter(parameterAttribute.name, parameterAttribute.val);
                }
            }
            return((AbstractAccessObject)Activator.CreateInstance(webao, req));
        }
Exemple #3
0
        public static object Build(Type interfaceWebao, IRequest req)
        {
            var typeInformation  = TypeInfoCache.Get(interfaceWebao);
            var baseUrl          = typeInformation.GetClassAttributesByName("BaseUrl");
            var parametersByName = typeInformation.GetClassAttributesByName("AddParameter");

            if (baseUrl[0] is BaseUrlAttribute baseUrlAttribute)
            {
                req.BaseUrl(baseUrlAttribute.host);
            }

            foreach (var param in parametersByName)
            {
                if (param is AddParameterAttribute parameterAttribute)
                {
                    req.AddParameter(parameterAttribute.name, parameterAttribute.val);
                }
            }

            builderHelper.SetModuleBuilder(interfaceWebao.Name.Remove(0, 1));
            builderHelper.SetTypeBuilder(interfaceWebao);
            emitter.EmitConstructor(builderHelper.TypeBuilder, builderHelper.GetBaseCtor());

            var methods = interfaceWebao.GetMethods();

            foreach (var method in methods)
            {
                var info = builderHelper.ProcessMethod(method);
                emitter.EmitMethod(builderHelper.TypeBuilder, info);
            }

            var type = builderHelper.TypeBuilder.CreateType();

            builderHelper.Save();
            return(Activator.CreateInstance(type, req));
        }