本文整理汇总了C#中ICodeBlock.Case方法的典型用法代码示例。如果您正苦于以下问题:C# ICodeBlock.Case方法的具体用法?C# ICodeBlock.Case怎么用?C# ICodeBlock.Case使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICodeBlock
的用法示例。
在下文中一共展示了ICodeBlock.Case方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateInterpolateForIndividualState
private static ICodeBlock GenerateInterpolateForIndividualState(IElement element, ICodeBlock codeBlock, ICodeBlock otherBlock, StateSave stateSave, string enumType)
{
codeBlock = codeBlock.Case(enumType + "." + stateSave.Name);
otherBlock = otherBlock.Case(enumType + "." + stateSave.Name);
foreach (InstructionSave instruction in stateSave.InstructionSaves)
{
CustomVariable customVariable = null;
customVariable = element.GetCustomVariable(instruction.Member);
string valueAsString = CodeParser.ParseObjectValue(instruction.Value);
if (customVariable != null && !string.IsNullOrEmpty(valueAsString))
{
NamedObjectSave sourceNamedObjectSave = element.GetNamedObjectRecursively(customVariable.SourceObject);
if (sourceNamedObjectSave == null || sourceNamedObjectSave.IsDisabled == false)
{
if (sourceNamedObjectSave != null)
{
NamedObjectSaveCodeGenerator.AddIfConditionalSymbolIfNecesssary(codeBlock, sourceNamedObjectSave);
NamedObjectSaveCodeGenerator.AddIfConditionalSymbolIfNecesssary(otherBlock, sourceNamedObjectSave);
}
string timeCastString = "";
if (instruction.Value is float)
{
timeCastString = "(float)";
}
if (string.IsNullOrEmpty(customVariable.SourceObject))
{
GenerateInterpolateForIndividualStateNoSource(ref codeBlock, element, ref otherBlock, instruction, customVariable, valueAsString, timeCastString);
}
else
{
GenerateInterpolateForIndividualStateWithSource(ref codeBlock, element, ref otherBlock, customVariable, valueAsString, sourceNamedObjectSave, timeCastString);
}
if (sourceNamedObjectSave != null)
{
NamedObjectSaveCodeGenerator.AddEndIfIfNecessary(codeBlock, sourceNamedObjectSave);
NamedObjectSaveCodeGenerator.AddEndIfIfNecessary(otherBlock, sourceNamedObjectSave);
}
}
}
}
return codeBlock;
}
示例2: GenerateCurrentStateCodeForIndividualState
private static ICodeBlock GenerateCurrentStateCodeForIndividualState(IElement element, ICodeBlock codeBlock, StateSave stateSave, string enumType)
{
var curBlock = codeBlock.Case(enumType + "." + stateSave.Name);
bool doesStateAssignAbsoluteValues = GetDoesStateAssignAbsoluteValues(stateSave, element);
foreach (InstructionSave instruction in stateSave.InstructionSaves)
{
if (instruction.Value != null)
{
// Get the valueAsString, which is the right-side of the equals sign
string rightSideOfEquals = GetRightSideAssignmentValueAsString(element, instruction);
if (!string.IsNullOrEmpty(rightSideOfEquals))
{
CustomVariable customVariable = element.GetCustomVariableRecursively(instruction.Member);
NamedObjectSave referencedNos = element.GetNamedObjectRecursively(customVariable.SourceObject);
if (referencedNos != null)
{
NamedObjectSaveCodeGenerator.AddIfConditionalSymbolIfNecesssary(curBlock, referencedNos);
}
string leftSideOfEquals = GetLeftSideOfEquals(element, customVariable, instruction, false);
string leftSideOfEqualsWithRelative = GetLeftSideOfEquals(element, customVariable, instruction, true);
if (leftSideOfEquals != leftSideOfEqualsWithRelative)
{
string objectWithParent = null;
if (string.IsNullOrEmpty(customVariable.SourceObject))
{
objectWithParent = "this";
}
else
{
objectWithParent = customVariable.SourceObject;
}
curBlock
.If(objectWithParent + ".Parent == null")
.Line(leftSideOfEquals + " = " + rightSideOfEquals + ";")
.End()
.Else()
.Line(leftSideOfEqualsWithRelative + " = " + rightSideOfEquals + ";");
}
else
{
curBlock.Line(leftSideOfEquals + " = " + rightSideOfEquals + ";");
}
if (referencedNos != null)
{
NamedObjectSaveCodeGenerator.AddEndIfIfNecessary(curBlock, referencedNos);
}
}
}
}
return codeBlock;
}
示例3: 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;
}
示例4: SetInterpolateBetweenValuesForStates
private ICodeBlock SetInterpolateBetweenValuesForStates(ElementSave element, string enumType, IEnumerable<StateSave> states, ICodeBlock curBlock, Dictionary<VariableSave, InterpolationCharacteristic> mInterpolationCharacteristics, string firstOrSecondValue)
{
foreach (StateSave state in states)
{
curBlock = curBlock.Case(enumType + "." + state.MemberNameInCode());
foreach (VariableSave variable in state.Variables.Where(item => GetIfShouldGenerateStateVariable(item, element)))
{
var nameInCode = variable.MemberNameInCode(element, mVariableNamesToReplaceForStates);
if (GetValue(mInterpolationCharacteristics, nameInCode, element) != InterpolationCharacteristic.CantInterpolate)
{
string stringSuffix = variable.MemberNameInCode(element, mVariableNamesToReplaceForStates).Replace(".", "");
if (variable.Value == null)
{
//curBlock.Line("set" + stringSuffix + " = false;");
}
else
{
string variableValue = variable.Value.ToString();
bool isEntireAssignment;
GueDerivingClassCodeGenerator.Self.AdjustVariableValueIfNecessary(variable, element, ref variableValue, out isEntireAssignment);
if (isEntireAssignment)
{
throw new NotImplementedException();
}
else
{
curBlock.Line("set" + stringSuffix + firstOrSecondValue + " = true;");
curBlock.Line(variable.MemberNameInCode(element, mVariableNamesToReplaceForStates).Replace(".", "") + firstOrSecondValue + " = " + variableValue + ";");
}
}
}
else if (variable.Value != null) // This value can't be interpolated, but if the user has set a value of 0 or 1, then it should be set
{
ICodeBlock ifBlock;
// value will come from the first state unless the interpolationValue is 1.
// This makes the code behave the same as InterpolateTo which uses instructions.
if (firstOrSecondValue == FirstValue)
{
ifBlock = curBlock.If("interpolationValue < 1");
}
else
{
ifBlock = curBlock.If("interpolationValue >= 1");
}
string variableValue = variable.Value.ToString();
bool isEntireAssignment;
GueDerivingClassCodeGenerator.Self.AdjustVariableValueIfNecessary(variable, element, ref variableValue, out isEntireAssignment);
if(isEntireAssignment)
{
ifBlock.Line(variableValue);
}
else
{
ifBlock.Line("this." + nameInCode + " = " + variableValue + ";");
}
}
}
curBlock = curBlock.End();
}
return curBlock;
}
示例5: SetInterpolateBetweenValuesForStates
private static ICodeBlock SetInterpolateBetweenValuesForStates(IElement element, string enumType, List<StateSave> states, ICodeBlock curBlock, Dictionary<InstructionSave, InterpolationCharacteristic> mInterpolationCharacteristics, string firstOrSecondValue)
{
foreach (StateSave state in states)
{
curBlock = curBlock.Case(enumType + "." + state.Name);
foreach (InstructionSave instructionSave in state.InstructionSaves)
{
var customVariable = element.GetCustomVariable(instructionSave.Member);
NamedObjectSave sourceNamedObjectSave = null;
if (customVariable != null)
{
sourceNamedObjectSave = element.GetNamedObjectRecursively(customVariable.SourceObject);
}
if(sourceNamedObjectSave != null)
{
NamedObjectSaveCodeGenerator.AddIfConditionalSymbolIfNecesssary(curBlock, sourceNamedObjectSave);
}
if (GetValue(mInterpolationCharacteristics, instructionSave.Member) != InterpolationCharacteristic.CantInterpolate)
{
if (instructionSave.Value == null)
{
curBlock.Line("set" + instructionSave.Member + " = false;");
}
else
{
string valueToWrite = GetRightSideAssignmentValueAsString(element, instructionSave);
curBlock.Line(instructionSave.Member + firstOrSecondValue + " = " + valueToWrite + ";");
}
}
else // This value can't be interpolated, but if the user has set a value of 0 or 1, then it should be set
{
ICodeBlock ifBlock;
// value will come from the first state unless the interpolationValue is 1.
// This makes the code behave the same as InterpolateTo which uses instructions.
if (firstOrSecondValue == FirstValue)
{
ifBlock = curBlock.If("interpolationValue < 1");
}
else
{
ifBlock = curBlock.If("interpolationValue >= 1");
}
string valueToWrite = GetRightSideAssignmentValueAsString(element, instructionSave);
ifBlock.Line("this." + instructionSave.Member + " = " + valueToWrite + ";");
}
if (sourceNamedObjectSave != null)
{
NamedObjectSaveCodeGenerator.AddEndIfIfNecessary(curBlock, sourceNamedObjectSave);
}
}
curBlock = curBlock.End();
}
return curBlock;
}