コード例 #1
0
        private IStalkNode NewRegexLeafNode(XmlElement fragment)
        {
            RegexLeafNode node;

            switch (fragment.Name)
            {
            case "user":
                node = new UserStalkNode();
                break;

            case "targetuser":
                node = new TargetUserStalkNode();
                break;

            case "actinguser":
                node = new ActingUserStalkNode();
                break;

            case "page":
                node = new PageStalkNode();
                break;

            case "summary":
                node = new SummaryStalkNode();
                break;

            case "flag":
                node = new FlagStalkNode();
                break;

            case "log":
                node = new LogStalkNode();
                break;

            case "additionaldata":
                node = new AdditionalDataNode();
                break;

            default:
                throw new XmlException("Unknown element " + fragment.Name);
            }

            if (fragment.Attributes["caseinsensitive"] != null)
            {
                node.CaseInsensitive = XmlConvert.ToBoolean(fragment.Attributes["caseinsensitive"].Value);
            }

            node.SetMatchExpression(fragment.Attributes["value"].Value);

            return(node);
        }
コード例 #2
0
        public override void OnBodyGUI()
        {
            if (this.node == null)
            {
                this.node = this.target as AdditionalDataNode;
            }
            if (this.node == null)
            {
                Debug.LogError("Editor applied to wrong type");
            }

            this.serializedObject.Update();

            //ID textbox
            NodeEditorGUILayout.PropertyField(this.serializedObject.FindProperty("Id"));

            var removeList = new List <int>();

            for (var i = 0; i < this.node.Options.Count; ++i)
            {
                EditorGUILayout.BeginHorizontal();

                this.node.Options[i] = EditorGUILayout.TextArea(this.node.Options[i]);

                if (GUILayout.Button("-", GUILayout.Width(20)))
                {
                    removeList.Add(i);
                }

                EditorGUILayout.EndHorizontal();
            }

            foreach (var i in Enumerable.Reverse(removeList))
            {
                this.node.Options.RemoveAt(i);
            }

            if (GUILayout.Button("Add"))
            {
                this.node.Options.Add("");
            }

            this.serializedObject.ApplyModifiedProperties();
        }