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


C# ICodeBlock.Switch方法代码示例

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


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

示例1: GenerateInterpolateBetween

        private void GenerateInterpolateBetween(ElementSave elementSave, ICodeBlock currentBlock,
            string enumType, IEnumerable<StateSave> states)
        {
            // We used to only generate these if there was were any states in this category, but
            // since Gum generated code supports dynamic states, there could be states in a category
            // even if they're not defined in Gum.
            //if (states.Count() > 0)
            {
                currentBlock = currentBlock.Function("public void",
                    "InterpolateBetween", enumType + " firstState, " + enumType + " secondState, float interpolationValue");

                GenerateDebugCheckForInterpolationValueNaN(currentBlock);

                Dictionary<VariableSave, InterpolationCharacteristic> interpolationCharacteristics =
                   new Dictionary<VariableSave, InterpolationCharacteristic>();

                CreateStartingValueVariables(elementSave, states, currentBlock, interpolationCharacteristics);

                currentBlock = currentBlock.Switch("firstState");
                currentBlock = SetInterpolateBetweenValuesForStates(elementSave, enumType, states, currentBlock,
                    interpolationCharacteristics, FirstValue);
                currentBlock = currentBlock.End();

                currentBlock = currentBlock.Switch("secondState");
                currentBlock = SetInterpolateBetweenValuesForStates(elementSave, enumType, states, currentBlock,
                    interpolationCharacteristics, SecondValue);
                currentBlock = currentBlock.End();


                currentBlock = AssignValuesUsingStartingValues(elementSave, currentBlock, interpolationCharacteristics);

                currentBlock = currentBlock.If("interpolationValue < 1");

                string fieldToAssign;
                if (enumType == "VariableState")
                {
                    fieldToAssign = "mCurrentVariableState";
                }
                else
                {
                    fieldToAssign = "mCurrent" + enumType + "State";
                }

                currentBlock.Line(fieldToAssign + " = firstState;");
                currentBlock = currentBlock.End().Else();
                currentBlock.Line(fieldToAssign + " = secondState;");
                currentBlock = currentBlock.End();
            }
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:49,代码来源:StateCodeGenerator.Interpolation.cs

示例2: GeneratePreloadStateContentForStateType

        private static ICodeBlock GeneratePreloadStateContentForStateType(ICodeBlock codeBlock, IElement element, List<StateSave> list, string variableType)
        {
            if (list.Count != 0)
            {

                codeBlock = codeBlock.Function("public static void", "PreloadStateContent", variableType + " state, string contentManagerName");
                codeBlock.Line("ContentManagerName = contentManagerName;");

                codeBlock = codeBlock.Switch("state");

                // Loop through states here and access properties that need the values
                foreach (StateSave state in list)
                {
                    codeBlock = codeBlock.Case(variableType + "." + state.Name);
                    foreach (InstructionSave instruction in state.InstructionSaves)
                    {
                        if (instruction.Value != null && instruction.Value is string)
                        {
                            // We insert a block so that object throwaway is not redefined in the switch scope.
                            // We do this instead of making an object throwaway above the switch so that we don't
                            // get warnings if is nothing to load
                            codeBlock.Block().Line("object throwaway = " + GetRightSideAssignmentValueAsString(element, instruction) + ";");
                        }
                    }
                    codeBlock = codeBlock.End();

                }

                codeBlock = codeBlock.End();

                codeBlock = codeBlock.End();
            }
            return codeBlock;
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:34,代码来源:StateCodeGenerator.cs

示例3: InstantiateObjectInSwitchStatement

        private static void InstantiateObjectInSwitchStatement(NamedObjectSave namedObject, ICodeBlock codeBlock,
            List<string[]> referencedFilesAlreadyUsingFullFile, AssetTypeInfo ati, string objectName, ReferencedFileSave rfs,
            List<StateSave> stateSaves, IElement saveObject, string defaultContainer, string overridingName)
        {
            var switchBlock = codeBlock.Switch("LoadingState");

            for (int i = 0; i < stateSaves.Count; i++)
            {
                StateSave stateSave = stateSaves[i];

                string name = "";

                // I don't think we're going to use these anymore
                //NamedObjectPropertyOverride objectOverride = stateSave.GetNamedObjectOverride(objectName);
                //name = FileManager.RemovePath(FileManager.RemoveExtension(objectOverride.SourceFile));

                InstantiateObjectUsingFile(namedObject, switchBlock.Case("VariableState." + stateSave.Name), referencedFilesAlreadyUsingFullFile, ati, objectName, rfs,
                    saveObject,
                    name, overridingName);
            }

            InstantiateObjectUsingFile(namedObject, switchBlock.Case("VariableState.Uninitialized:"), referencedFilesAlreadyUsingFullFile, ati, objectName, rfs,
                saveObject, defaultContainer, overridingName);
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:24,代码来源:NamedObjectSaveCodeGenerator.cs


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