当前位置: 首页>>代码示例>>C#>>正文


C# Transformation.ToString方法代码示例

本文整理汇总了C#中Transformation.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Transformation.ToString方法的具体用法?C# Transformation.ToString怎么用?C# Transformation.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Transformation的用法示例。


在下文中一共展示了Transformation.ToString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EndIf

 public void EndIf()
 {
     Transformation transformation = new Transformation().IfCondition("w_lt_200").Crop("fill").Height(120).Width(80).Effect("sharpen")
         .Chain().Effect("brightness", 50)
         .Chain().Effect("shadow").Color("red")
         .EndIf();
     string sTransform = transformation.ToString();
     Assert.IsTrue(sTransform.EndsWith("if_end"), "should include the if_end as the last parameter in its component");
     Assert.AreEqual("if_w_lt_200/c_fill,e_sharpen,h_120,w_80/e_brightness:50/co_red,e_shadow/if_end", sTransform, "should be proper transformation string");
 }
开发者ID:cloudinary,项目名称:CloudinaryDotNet,代码行数:10,代码来源:TransformationApiTest.cs

示例2: EndIf2

        public void EndIf2()
        {
            Transformation transformation = new Transformation().IfCondition().Width("gt", 100).And().Width("lt", 200).Then().Width(50).Crop("scale").EndIf();
            Assert.AreEqual("if_w_gt_100_and_w_lt_200/c_scale,w_50/if_end", transformation.ToString(), "should serialize to 'if_end'");

            transformation = new Transformation().IfCondition().Width("gt", 100).And().Width("lt", 200).Then().Width(50).Crop("scale").EndIf();
            Assert.AreEqual("if_w_gt_100_and_w_lt_200/c_scale,w_50/if_end", transformation.ToString(), "force the if clause to be chained");

            transformation = new Transformation().IfCondition().Width("gt", 100).And().Width("lt", 200).Then().Width(50).Crop("scale").IfElse().Width(100).Crop("crop").EndIf();
            Assert.AreEqual("if_w_gt_100_and_w_lt_200/c_scale,w_50/if_else/c_crop,w_100/if_end", transformation.ToString(), "force the if_else clause to be chained");
        }
开发者ID:cloudinary,项目名称:CloudinaryDotNet,代码行数:11,代码来源:TransformationApiTest.cs

示例3: ChainedConditions

        public void ChainedConditions()
        {
            Transformation transformation = new Transformation().IfCondition().AspectRatio("gt", "3:4").Then().Width(100).Crop("scale");
            Assert.AreEqual("if_ar_gt_3:4,c_scale,w_100", transformation.ToString(), "passing an operator and a value adds a condition");

            transformation = new Transformation().IfCondition().AspectRatio("gt", "3:4").And().Width("gt", 100).Then().Width(50).Crop("scale");
            Assert.AreEqual("if_ar_gt_3:4_and_w_gt_100,c_scale,w_50", transformation.ToString(), "should chaining condition with `and`");

            transformation = new Transformation().IfCondition().AspectRatio("gt", "3:4").And().Width("gt", 100).Or().Width("gt", 200).Then().Width(50).Crop("scale");
            Assert.AreEqual("if_ar_gt_3:4_and_w_gt_100_or_w_gt_200,c_scale,w_50", transformation.ToString(), "should chain conditions with `or`");

            transformation = new Transformation().IfCondition().AspectRatio(">", "3:4").And().Width("<=", 100).Or().Width("gt", 200).Then().Width(50).Crop("scale");
            Assert.AreEqual("if_ar_gt_3:4_and_w_lte_100_or_w_gt_200,c_scale,w_50", transformation.ToString(), "should translate operators");

            transformation = new Transformation().IfCondition().AspectRatio(">", "3:4").And().Width("<=", 100).Or().Width(">", 200).Then().Width(50).Crop("scale");
            Assert.AreEqual("if_ar_gt_3:4_and_w_lte_100_or_w_gt_200,c_scale,w_50", transformation.ToString(), "should translate operators");

            transformation = new Transformation().IfCondition().AspectRatio(">=", "3:4").And().PageCount(">=", 100).Or().PageCount("!=", 0).Then().Width(50).Crop("scale");
            Assert.AreEqual("if_ar_gte_3:4_and_pc_gte_100_or_pc_ne_0,c_scale,w_50", transformation.ToString(), "should translate operators");
        }
开发者ID:cloudinary,项目名称:CloudinaryDotNet,代码行数:20,代码来源:TransformationApiTest.cs

示例4: IfElse

        public void IfElse()
        {
            List<Transformation> transformations = new List<Transformation>()
            {
                new Transformation().IfCondition("w_lt_200").Crop("fill").Height(120).Width(80),
                new Transformation().IfElse().Crop("fill").Height(90).Width(100)
            };
            var transformation = new Transformation(transformations);
            var sTransform = transformation.ToString();
            Assert.AreEqual("if_w_lt_200,c_fill,h_120,w_80/if_else,c_fill,h_90,w_100", sTransform, "should support if_else with transformation parameters");

            transformations = new List<Transformation>()
            {
                new Transformation().IfCondition("w_lt_200"),
                new Transformation().Crop("fill").Height(120).Width(80),
                new Transformation().IfElse(),
                new Transformation().Crop("fill").Height(90).Width(100)
            };
            transformation = new Transformation(transformations);
            sTransform = transformation.ToString();
            Assert.IsTrue(sTransform.Contains("/if_else/"), "if_else should be without any transformation parameters");
            Assert.AreEqual("if_w_lt_200/c_fill,h_120,w_80/if_else/c_fill,h_90,w_100", sTransform, "should be proper transformation string");
        }
开发者ID:cloudinary,项目名称:CloudinaryDotNet,代码行数:23,代码来源:TransformationApiTest.cs

示例5: testOverlayError2

 public void testOverlayError2()
 {
     var transformation = new Transformation().Overlay(new VideoLayer());
     transformation.ToString();
 }
开发者ID:cloudinary,项目名称:CloudinaryDotNet,代码行数:5,代码来源:ApiTest.cs

示例6: testOverlayError1

 public void testOverlayError1()
 {
     var transformation = new Transformation().Overlay(new TextLayer().PublicId("test").FontStyle("italic"));
     transformation.ToString();
 }
开发者ID:cloudinary,项目名称:CloudinaryDotNet,代码行数:5,代码来源:ApiTest.cs

示例7: LiteralWithSpaces

 public void LiteralWithSpaces()
 {
     Transformation transformation = new Transformation().IfCondition("w < 200").Crop("fill").Height(120).Width(80);
     string sTransform = transformation.ToString();
     Assert.AreEqual("if_w_lt_200,c_fill,h_120,w_80", sTransform, "should translate operators");
 }
开发者ID:cloudinary,项目名称:CloudinaryDotNet,代码行数:6,代码来源:TransformationApiTest.cs

示例8: WithLiteral

        public void WithLiteral()
        {
            Transformation transformation = new Transformation().IfCondition("w_lt_200").Crop("fill").Height(120).Width(80);
            string sTransform = transformation.ToString();
            Assert.AreEqual(sTransform.IndexOf("if"), 0, "should include the if parameter as the first component in the transformation string");
            Assert.AreEqual("if_w_lt_200,c_fill,h_120,w_80", sTransform, "should be proper transformation string");

            transformation = new Transformation().Crop("fill").Height(120).IfCondition("w_lt_200").Width(80);
            sTransform = transformation.ToString();
            Assert.AreEqual(sTransform.IndexOf("if"), 0, "should include the if parameter as the first component in the transformation string");
            Assert.AreEqual("if_w_lt_200,c_fill,h_120,w_80", sTransform, "components should be in proper order");

            transformation = new Transformation().IfCondition("w_lt_200").Crop("fill").Height(120).Width(80).
                                          Chain().IfCondition("w_gt_400").Crop("fit").Height(150).Width(150).
                                          Chain().Effect("sepia");
            sTransform = transformation.ToString();
            Assert.AreEqual("if_w_lt_200,c_fill,h_120,w_80/if_w_gt_400,c_fit,h_150,w_150/e_sepia", sTransform, "should allow multiple conditions when chaining transformations");
        }
开发者ID:cloudinary,项目名称:CloudinaryDotNet,代码行数:18,代码来源:TransformationApiTest.cs


注:本文中的Transformation.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。