/// <summary> /// Converts this object to source code for the given OS, Language and Library. /// </summary> /// <returns>The object represented as source code in a `string`.</returns> /// <param name="outputOS">The `CodeOutputOS`.</param> /// <param name="outputLanguage">The `CodeOutputLanguage`.</param> /// <param name="outputLibrary">The `CodeOutputLibrary`.</param> public override string ToCode(CodeOutputOS outputOS, CodeOutputLanguage outputLanguage, CodeOutputLibrary outputLibrary) { var sourceCode = ""; // Is this shape using a custom style? if (Style.StyleType == KimonoStyleType.Custom || Style.StyleType == KimonoStyleType.CustomText) { // Yes, include it in the source code Style.Name = $"{Name} Style"; Style.ElementName = KimonoCodeGenerator.MakeElementName(Style.Name); // Take action based on the output language switch (outputLanguage) { case CodeOutputLanguage.CSharp: sourceCode += Style.ToCSharp(outputLibrary); break; case CodeOutputLanguage.ObiScript: sourceCode += Style.ToObiScript(); break; } } else { // Accumulate linked styles KimonoCodeGenerator.AddSupportingStyle(Style); } // Return results return(sourceCode); }
/// <summary> /// Converts this object to source code for the given OS, Language and Library. /// </summary> /// <returns>The object represented as source code in a `string`.</returns> /// <param name="outputOS">The `CodeOutputOS`.</param> /// <param name="outputLanguage">The `CodeOutputLanguage`.</param> /// <param name="outputLibrary">The `CodeOutputLibrary`.</param> public override string ToCode(CodeOutputOS outputOS, CodeOutputLanguage outputLanguage, CodeOutputLibrary outputLibrary) { var sourceCode = ""; // Accumulate color if (Value != null) { // Yes, add as a supporting color KimonoCodeGenerator.AddSupportingStyle(Value); } // Take action based on the output language switch (outputLanguage) { case CodeOutputLanguage.CSharp: sourceCode = ToCSharp(outputLibrary); break; } // Return results return(sourceCode); }