Exemple #1
0
        public object Run()
        {
            //构建一个请求参数
            var param = new BatchFontFaceParam();

            //开始构建生成项,Tag必填
            param.Tags.Add(new FontFaceParam
            {
                AccessKey        = "xxx",
                Content          = "有字库,让中文跃上云端!",
                Tag              = "#batch-id1",
                UseRanFontFamily = true
            });
            param.Tags.Add(new FontFaceParam
            {
                AccessKey = "xxx",
                Content   = "有字库,让中文跃上云端!",
                Tag       = ".batch-class1"
            });


            //1.全格式
            var response3 = YouzikuClient.GetBatchFontFace(param);

            //2.WOFF格式
            var response4 = YouzikuClient.GetBatchWoffFontFace(param);

            return(null);
        }
Exemple #2
0
        public async Task <dynamic> Run(dynamic p = null)
        {
            //构建一个请求参数
            var param = new BatchFontFaceParam();

            //开始构建生成项,Tag必填
            param.Tags.Add(new FontFaceParam
            {
                AccessKey        = "xxx",
                Content          = "有字库,让中文跃上云端!异步",
                Tag              = "#batch-async-id1",
                UseRanFontFamily = true
            });
            param.Tags.Add(new FontFaceParam
            {
                AccessKey = "e8e8a75c24aa4ac3a9fd5995abe624a8",
                Content   = "有字库,让中文跃上云端!异步",
                Tag       = "#batch-async-id2",
            });


            //1.全格式
            var response3 = await YouzikuClient.GetBatchFontFaceAsync(param);

            //2.WOFF格式
            var response4 = await YouzikuClient.GetBatchWoffFontFaceAsync(param);

            return(null);
        }
Exemple #3
0
 /// <summary>
 /// 验证GetBatchFontFace接口
 /// </summary>
 /// <param name="param">请求参数</param>
 public static void GetBatchFontFace(BatchFontFaceParam param)
 {
     if (param == null)
     {
         throw new ArgumentException(nameof(BatchFontFaceParam) + " instance is null!");
     }
     if (param.Tags.Count <= 0)
     {
         throw new ArgumentException(nameof(BatchFontFaceParam) + " field Tags.Count<=0!");
     }
 }
Exemple #4
0
        /// <summary>
        /// GetBatchFontFace接口
        /// </summary>
        /// <param name="param">param</param>
        /// <param name="config">config</param>
        /// <returns></returns>
        public static IDictionary <string, string> GetBatchFontFace(BatchFontFaceParam param, YouzikuConfig config)
        {
            ParamValidate.GetBatchFontFace(param);
            //builder batch param
            var paramDic = new Dictionary <string, string>
            {
                { "ApiKey", config.ApiKey }
            };

            for (var i = 0; i < param.Tags.Count; i++)
            {
                paramDic.Add($"Tags[{i}][AccessKey]", param.Tags[i].AccessKey);
                paramDic.Add($"Tags[{i}][Tag]", param.Tags[i].Tag);
                paramDic.Add($"Tags[{i}][Content]", param.Tags[i].Content.Replace("&", string.Empty));
                paramDic.Add($"Tags[{i}][UseRanFontFamily]", param.Tags[i].UseRanFontFamily.ToString());
            }

            return(paramDic);
        }
Exemple #5
0
        /// <summary>
        /// 异步多标签生成模式,直接返回仅woff格式的@fontface [Async]
        /// </summary>
        /// <param name="param">请求参数</param>
        /// <returns></returns>
        public Task <BatchFontFaceResult> GetBatchWoffFontFaceAsync(BatchFontFaceParam param)
        {
            var paramDic = ParamBuilder.GetBatchFontFace(param, _config);

            return(CommonGetFontFaceAsync <BatchFontFaceResult>(paramDic, _config.Host + ServiceMethod.BatchWebFont.GetBatchWoffFontFace, _config));
        }