本文整理汇总了C#中IElement.GetCustomVariableRecursively方法的典型用法代码示例。如果您正苦于以下问题:C# IElement.GetCustomVariableRecursively方法的具体用法?C# IElement.GetCustomVariableRecursively怎么用?C# IElement.GetCustomVariableRecursively使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IElement
的用法示例。
在下文中一共展示了IElement.GetCustomVariableRecursively方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetRightSideAssignmentValueAsString
public static string GetRightSideAssignmentValueAsString(IElement element, InstructionSave instruction)
{
CustomVariable customVariable = element.GetCustomVariableRecursively(instruction.Member);
IElement referencedElement = null;
#region Determine if the assignment is a file
bool isFile = false;
if (customVariable != null)
{
referencedElement =
BaseElementTreeNode.GetElementIfCustomVariableIsVariableState(customVariable, element);
isFile = customVariable.GetIsFile();
}
#endregion
string valueAsString = "";
if (referencedElement == null)
{
valueAsString = CodeParser.ParseObjectValue(instruction.Value);
if (isFile)
{
valueAsString = valueAsString.Replace("\"", "");
if (valueAsString == "<NONE>")
{
valueAsString = "null";
}
}
else if (CustomVariableCodeGenerator.ShouldAssignToCsv(customVariable, valueAsString))
{
valueAsString = CustomVariableCodeGenerator.GetAssignmentToCsvItem(customVariable, element, valueAsString);
}
else if (customVariable != null && customVariable.Type == "Color")
{
valueAsString = "Color." + valueAsString.Replace("\"", "");
}
if (customVariable != null && !string.IsNullOrEmpty(customVariable.SourceObject) && !isFile)
{
NamedObjectSave namedObject = element.GetNamedObjectRecursively(customVariable.SourceObject);
bool isVariableState = customVariable.GetIsVariableState();
IElement objectElement = null;
if (namedObject != null)
{
ObjectFinder.Self.GetIElement(namedObject.SourceClassType);
}
if (objectElement != null)
{
if (isVariableState)
{
string typeName = "VariableState";
StateSaveCategory category = objectElement.GetStateCategoryRecursively(customVariable.Type);
if(category != null && category.SharesVariablesWithOtherCategories == false)
{
typeName = category.Name;
}
valueAsString = objectElement.Name.Replace("/", ".").Replace("\\", ".") + "." + typeName + "." + valueAsString.Replace("\"", "");
}
}
valueAsString = CodeWriter.MakeLocalizedIfNecessary(
namedObject,
instruction.Member,
instruction.Value,
valueAsString,
customVariable);
}
}
else
{
string enumValue = (string)instruction.Value;
if (!string.IsNullOrEmpty(enumValue))
{
string variableType = "VariableState";
if (customVariable != null && customVariable.Type.ToLower() != "string")
{
variableType = customVariable.Type;
}
valueAsString = FullyQualifyStateValue(referencedElement, enumValue, variableType);
}
}
return valueAsString;
}
示例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: GetDoesStateAssignAbsoluteValues
private static bool GetDoesStateAssignAbsoluteValues(StateSave stateSave, IElement element)
{
bool returnValue = false;
foreach (InstructionSave instruction in stateSave.InstructionSaves)
{
CustomVariable customVariable = element.GetCustomVariableRecursively(instruction.Member);
if (customVariable != null)
{
returnValue |= !string.IsNullOrEmpty(RelativeValueForInstruction(instruction, customVariable, element));
}
}
return returnValue;
}
示例4: CreateInstanceMembersForVariables
private static void CreateInstanceMembersForVariables(IElement element, MemberCategory category)
{
foreach (CustomVariable variable in element.CustomVariables)
{
Type type = variable.GetRuntimeType();
if (type == null)
{
type = typeof(string);
}
string name = variable.Name;
//object value = variable.DefaultValue;
// todo - do something with converter
var instanceMember = new DataGridItem();
instanceMember.CustomGetTypeEvent += (throwaway) => type;
string displayName = StringFunctions.InsertSpacesInCamelCaseString(name);
instanceMember.DisplayName = displayName;
instanceMember.UnmodifiedVariableName = name;
TypeConverter converter = variable.GetTypeConverter(element);
instanceMember.TypeConverter = converter;
instanceMember.CustomSetEvent += (intance, value) =>
{
instanceMember.IsDefault = false;
RefreshLogic.IgnoreNextRefresh();
element.GetCustomVariableRecursively(name).DefaultValue = value;
GlueCommands.Self.GluxCommands.SaveGlux();
GlueCommands.Self.RefreshCommands.RefreshPropertyGrid();
GlueCommands.Self.GenerateCodeCommands.GenerateCurrentElementCode();
};
instanceMember.CustomGetEvent += (instance) =>
{
return element.GetCustomVariableRecursively(name).DefaultValue;
};
instanceMember.IsDefaultSet += (owner, args) =>
{
element.GetCustomVariableRecursively(name).DefaultValue = null;
GlueCommands.Self.GluxCommands.SaveGlux();
GlueCommands.Self.RefreshCommands.RefreshPropertyGrid();
GlueCommands.Self.GenerateCodeCommands.GenerateCurrentElementCode();
};
instanceMember.SetValueError = (newValue) =>
{
if (newValue is string && string.IsNullOrEmpty(newValue as string))
{
element.GetCustomVariableRecursively(name).DefaultValue = null;
GlueCommands.Self.GluxCommands.SaveGlux();
GlueCommands.Self.RefreshCommands.RefreshPropertyGrid();
GlueCommands.Self.GenerateCodeCommands.GenerateCurrentElementCode();
}
};
category.Members.Add(instanceMember);
}
}