本文整理汇总了C#中VariableDef.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# VariableDef.SetValue方法的具体用法?C# VariableDef.SetValue怎么用?C# VariableDef.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VariableDef
的用法示例。
在下文中一共展示了VariableDef.SetValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: setParameter
protected VariableDef setParameter(NodeTag.DefaultObject node, string propertyType, string propertyName)
{
List<ParInfo> allPars = new List<ParInfo>();
((Nodes.Node)node.Behavior).GetAllPars(ref allPars);
if (allPars.Count > 0)
{
string fullname = string.Format("{0} {1}", propertyType, propertyName);
foreach (ParInfo p in allPars)
{
if (p.ToString() == fullname)
{
VariableDef v = new VariableDef(p);
v.SetValue(p, VariableDef.kPar);
return v;
}
}
}
return null;
}
示例2: setParameter
public static VariableDef setParameter(NodeTag.DefaultObject node, string propertyName)
{
Behaviac.Design.Nodes.Behavior behavior = node.Behavior as Behaviac.Design.Nodes.Behavior;
string instance = Plugin.GetInstanceName(propertyName);
if (!string.IsNullOrEmpty(instance))
{
propertyName = propertyName.Substring(instance.Length + 1, propertyName.Length - instance.Length - 1);
VariableDef var = createVariable(behavior.AgentType, instance, propertyName);
if (var != null)
return var;
}
// Try to find the Par parameter with the name.
List<ParInfo> allPars = new List<ParInfo>();
((Nodes.Node)behavior).GetAllPars(ref allPars);
if (allPars.Count > 0)
{
foreach (ParInfo p in allPars)
{
if (p.Name == propertyName
#if BEHAVIAC_NAMESPACE_FIX
|| p.Name.EndsWith(propertyName)
#endif
)
{
VariableDef var = new VariableDef(p);
var.SetValue(p, VariableDef.kPar);
return var;
}
}
}
// Try to find the Agent property with the name.
if (behavior != null && behavior.AgentType != null)
{
IList<PropertyDef> properties = behavior.AgentType.GetProperties();
foreach (PropertyDef p in properties)
{
if (p.Name == propertyName
#if BEHAVIAC_NAMESPACE_FIX
|| p.Name.EndsWith(propertyName)
#endif
)
return new VariableDef(p, VariableDef.kSelf);
}
}
// Try to find the World property with the name.
string instacneName = Plugin.GetClassName(propertyName);
if (!string.IsNullOrEmpty(instacneName) && Plugin.GetInstanceAgentType(instacneName) != null)
{
IList<PropertyDef> properties = Plugin.GetInstanceAgentType(instacneName).GetProperties();
foreach (PropertyDef p in properties)
{
if (p.Name == propertyName
#if BEHAVIAC_NAMESPACE_FIX
|| p.Name.EndsWith(propertyName)
#endif
)
return new VariableDef(p, instacneName);
}
}
return null;
}