本文整理汇总了C#中IElement.GetNamedObject方法的典型用法代码示例。如果您正苦于以下问题:C# IElement.GetNamedObject方法的具体用法?C# IElement.GetNamedObject怎么用?C# IElement.GetNamedObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IElement
的用法示例。
在下文中一共展示了IElement.GetNamedObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateInitializeForEvent
private static void GenerateInitializeForEvent(ICodeBlock codeBlock, IElement element, EventResponseSave ers)
{
bool wasEventAdded = false;
//We always want this to happen, even if it's
// emtpy
//if (!string.IsNullOrEmpty(ers.Contents))
//{
NamedObjectSave sourceNos = null;
bool shouldCloseIfStatementForNos = false;
if (!string.IsNullOrEmpty(ers.SourceVariable))
{
// This is tied to a variable, so the name comes from the variable event rather than the
// event name itself
string eventName = ers.BeforeOrAfter.ToString() + ers.SourceVariable + "Set";
codeBlock.Line("this." + eventName + " += On" + ers.EventName + ";");
wasEventAdded = true;
}
else if (string.IsNullOrEmpty(ers.SourceObject))
{
string leftSide = null;
EventSave eventSave = ers.GetEventSave();
if (eventSave == null || string.IsNullOrEmpty(eventSave.ExternalEvent))
{
leftSide = "this." + ers.EventName;
}
else
{
leftSide = eventSave.ExternalEvent;
}
codeBlock.Line(leftSide + " += On" + ers.EventName + ";");
wasEventAdded = true;
}
else if (!string.IsNullOrEmpty(ers.SourceObjectEvent))
{
// Only append this if the source NOS is fully-defined. If not, we don't want to generate compile errors.
sourceNos = element.GetNamedObject(ers.SourceObject);
if (sourceNos != null && sourceNos.IsFullyDefined)
{
NamedObjectSaveCodeGenerator.AddIfConditionalSymbolIfNecesssary(codeBlock, sourceNos);
string leftSide = null;
leftSide = ers.SourceObject + "." + ers.SourceObjectEvent;
codeBlock.Line(leftSide + " += On" + ers.EventName + ";");
wasEventAdded = true;
shouldCloseIfStatementForNos = true;
}
}
if (!string.IsNullOrEmpty(ers.SourceObject) && !string.IsNullOrEmpty(ers.SourceObjectEvent) && wasEventAdded)
{
codeBlock.Line(ers.SourceObject + "." + ers.SourceObjectEvent + " += On" + ers.EventName + "Tunnel;");
if (shouldCloseIfStatementForNos)
{
NamedObjectSaveCodeGenerator.AddEndIfIfNecessary(codeBlock, sourceNos);
}
}
}
示例2: GetEventThisTunnelsTo
public static EventResponseSave GetEventThisTunnelsTo(this EventResponseSave instance, IElement element, out IElement containingElement)
{
if (instance.GetIsTunneling() == false)
{
containingElement = null;
return null;
}
else
{
NamedObjectSave nos = element.GetNamedObject(instance.SourceObject);
if (nos != null && nos.SourceType == SourceType.Entity)
{
containingElement = ObjectFinder.Self.GetIElement(nos.SourceClassType);
if (containingElement != null)
{
return containingElement.GetEvent(instance.SourceObjectEvent);
}
}
}
containingElement = null;
return null;
}
示例3: AppendAssignmentForCustomVariableInElement
public static ICodeBlock AppendAssignmentForCustomVariableInElement(ICodeBlock codeBlock, CustomVariable customVariable, IElement saveObject)
{
bool hasBase = !string.IsNullOrEmpty(((INamedObjectContainer)saveObject).BaseObject);
// Victor Chelaru
// December 17, 2014
// We used to not go into
// this if statement if SetByDerived
// was true, but actually since variables
// are set bottom-up, there's really no reason
// to set it only on the derived, because the base
// will always get assigned first, then the derived
// can override it.
//if (!customVariable.SetByDerived &&
if (customVariable.DefaultValue != null && // if it's null the user doesn't want to change what is set in the file or in the source object
!customVariable.IsShared && // no need to handle statics here because they're always defined in class scope
!IsVariableTunnelingToDisabledObject(customVariable, saveObject)
)
{
string variableToAssign = "";
CustomVariable variableConsideringDefinedByBase = customVariable.GetDefiningCustomVariable();
IElement containerOfState = null;
// This can be null
// if the user takes
// an Element that inherits
// from another and has variables
// from it, then changes the Element
// to no longer inherit.
if (variableConsideringDefinedByBase != null)
{
containerOfState = BaseElementTreeNode.GetElementIfCustomVariableIsVariableState(variableConsideringDefinedByBase, saveObject);
if (containerOfState == null)
{
variableToAssign =
CodeParser.ParseObjectValue(customVariable.DefaultValue);
NamedObjectSave namedObject = saveObject.GetNamedObject(customVariable.SourceObject);
if (customVariable.GetIsFile())
{
variableToAssign = variableToAssign.Replace("\"", "").Replace("-", "_");
if (variableToAssign == "<NONE>")
{
variableToAssign = "null";
}
}
else if (customVariable != null && customVariable.GetIsCsv())
{
if (ShouldAssignToCsv(customVariable, variableToAssign))
{
variableToAssign = GetAssignmentToCsvItem(customVariable, saveObject, variableToAssign);
}
else
{
variableToAssign = null;
}
}
else if (customVariable.Type == "Color")
{
variableToAssign = "Color." + variableToAssign.Replace("\"", "");
}
else if (customVariable.Type != "string" && variableToAssign == "\"\"")
{
variableToAssign = null;
}
else
{
//Not sure why this wasn't localizing variables but it caused a problem with
//variables that tunnel in to a Text's DisplayText not being localized
//finish here
// Special Case:
// We don't want to
// set Visible on NOS's
// which are added/removed
// when Visible is set on them:
// Update March 7, 2014
// We do want to set it because if we don't,
// then the checks inside the Visible property
// don't properly detect that they've been changed.
// Therefore, we're going to set it on the underlying
// object
bool shouldSetUnderlyingValue = namedObject != null && namedObject.RemoveFromManagersWhenInvisible &&
customVariable.SourceObjectProperty == "Visible";
if (shouldSetUnderlyingValue)
{
// Don't change the variable to assign
}
//.........这里部分代码省略.........