本文整理汇总了C#中Rule.SetContext方法的典型用法代码示例。如果您正苦于以下问题:C# Rule.SetContext方法的具体用法?C# Rule.SetContext怎么用?C# Rule.SetContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rule
的用法示例。
在下文中一共展示了Rule.SetContext方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Validate
public bool Validate(out string validateMessage, out Rule rule)
{
bool result = true;
rule = new Rule();
validateMessage = "Rule Ok";
if (m_ConditionContainer.m_ConditionList.Count > 0)
{
GraphToRule converter = new GraphToRule(m_TargetObject.GetComponent<State>() as State);
rule.m_Rule = converter.Convert(m_Rule.m_Name, m_ConditionContainer.m_ConditionList[0], m_ActionContainer.m_ActionList);
rule.SetContext(m_TargetObject.GetComponent<InferenceEngine>() as InferenceEngine);
try
{
result = rule.Validate();
}
catch (InvalidRuleException e)
{
validateMessage = e.Message;
}
}
return result;
}
示例2: ShowRulesGUI
public void ShowRulesGUI()
{
GUI.backgroundColor = new Color(0.8f,0.8f,1);
GUILayout.BeginHorizontal ();
if (GUILayout.Button("Add Rule", GUILayout.MaxWidth(120), GUILayout.ExpandWidth(false)))
{
RuleType xmlRule = new RuleType();
int counter = 0;
string newName = "New Rule ";
List<Rule> newRules = m_Rules.FindAll(x => x.m_Name.Contains(newName));
foreach ( Rule rule in newRules)
{
string numberPart = rule.m_Name.TrimStart(newName.ToCharArray());
if (Convert.ToInt32(numberPart) > counter)
counter = Convert.ToInt32(numberPart);
}
newName += ++counter;
xmlRule.AddName(new Altova.Types.SchemaString(newName));
Rule newRule = new Rule(xmlRule);
newRule.SetContext(m_Context);
m_Rules.Add(newRule);
RuleInspector ruleInspector = new RuleInspector(newRule, gameObject);
ruleInspector.ShowEditor();
}
GUILayout.FlexibleSpace(); //Set layout passed this point to align to the right
EditorGUIUtility.labelWidth = 80;
m_DebugMode = EditorGUILayout.Toggle("DebugMode: ", m_DebugMode, GUILayout.MaxWidth(95));
GUILayout.EndHorizontal ();
if (m_Rules.Count != 0)
{
GUILayout.BeginHorizontal();
GUI.color = Color.yellow;
GUILayout.Label("Rule", GUILayout.MaxWidth(100), GUILayout.ExpandWidth(true));
GUI.color = Color.white;
GUILayout.EndHorizontal();
}
else
{
EditorGUILayout.HelpBox("There are no rules in this rule base. Add some with the Add Rule button", MessageType.Info);
}
foreach (Rule rule in m_Rules.ToArray())
{
if (rule != null)
{
GUILayout.BeginHorizontal();
if (!Application.isPlaying)
{
GUI.backgroundColor = new Color(0.7f, 0.7f, 0.7f, 0.3f);
rule.m_Name = EditorGUILayout.TextField(rule.m_Name, GUILayout.MaxWidth(100), GUILayout.ExpandWidth(true));
if (GUI.changed == true)
{
rule.m_Rule.ReplaceNameAt(new Altova.Types.SchemaString(rule.m_Name), 0);
}
}
else
{
GUI.backgroundColor = new Color(0.7f,0.7f,0.7f);
GUI.color = new Color(0.8f,0.8f,1f);
GUILayout.Label(rule.m_Name, GUILayout.MaxWidth(100), GUILayout.ExpandWidth(true));
}
GUI.color = Color.white;
GUI.backgroundColor = Color.white;
if (!Application.isPlaying)
{
GUI.backgroundColor = new Color(0.6f, 1f, 0.6f);
if (GUILayout.Button("E", GUILayout.MaxWidth(20)))
{
RuleInspector ruleInspector = new RuleInspector(rule, gameObject);
ruleInspector.ShowEditor();
}
GUI.backgroundColor = new Color(1,0.6f,0.6f);
if (GUILayout.Button("X", GUILayout.MaxWidth(20)))
{
if (EditorUtility.DisplayDialog("Delete Rule " + rule.m_Name, "Are you sure?", "Yes", "No"))
RemoveRule(rule.m_Name);
}
}
GUI.backgroundColor = new Color(0.7f,0.7f,0.7f);
GUILayout.EndHorizontal();
}
}
GUI.backgroundColor = Color.white;
//.........这里部分代码省略.........
示例3: AddRule
public void AddRule(Rule rule)
{
rule.SetContext(m_Context);
m_Rules.Add(rule);
}