Beispiel #1
0
        /// <summary>
        /// Converts a <paramref name="setting"/> to a valid C# formulation.
        /// </summary>
        public static string FromSetting(BlockSetting setting)
        {
            if (setting.InputMode == SettingInputMode.Variable)
            {
                return($"{setting.InputVariableName}{GetCasting(setting)}");
            }

            if (setting.InputMode == SettingInputMode.Interpolated)
            {
                return(setting.InterpolatedSetting switch
                {
                    InterpolatedStringSetting x => SerializeInterpString(x.Value),
                    InterpolatedListOfStringsSetting x => SerializeList(x.Value, true),
                    InterpolatedDictionaryOfStringsSetting x => SerializeDictionary(x.Value, true),
                    _ => throw new NotImplementedException()
                });
Beispiel #2
0
        /// <summary>
        /// Gets the snippet of the value of a <paramref name="setting"/> in LoliCode syntax.
        /// </summary>
        public static string GetSettingValue(BlockSetting setting)
        {
            // TODO: Make a valid variable name if it's invalid
            if (setting.InputMode == SettingInputMode.Variable)
            {
                return($"@{setting.InputVariableName}");
            }

            if (setting.InputMode == SettingInputMode.Interpolated)
            {
                return('$' + setting.InterpolatedSetting switch
                {
                    InterpolatedStringSetting x => ToLiteral(x.Value),
                    InterpolatedListOfStringsSetting x => SerializeList(x.Value),
                    InterpolatedDictionaryOfStringsSetting x => SerializeDictionary(x.Value),
                    _ => throw new NotImplementedException()
                });