//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Visits. </summary> /// <remarks> Neil MacMullen, 18/02/2011. </remarks> /// <param name="entry"> The entry to visit </param> /// <returns> . </returns> //////////////////////////////////////////////////////////////////////////////////////////////////// public new string Visit(ConfigEntry entry) { base.Visit(entry); return _text.ToString(); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Removes the given class from the ItemisedClass. </summary> /// <remarks> /// Note that only classes can be removed from an ItemisedClass. If you try to /// remove any other kind of class, an ArgumentException will be thrown. /// </remarks> /// <exception cref="ArgumentException"> Thrown when anything other than a class is removed. </exception> /// <param name="entry"> The class to remove. </param> //////////////////////////////////////////////////////////////////////////////////////////////////// public override void Remove(ConfigEntry entry) { if (!(entry is ConfigClass)) throw new ArgumentException("Attempt to remove something other than a ConfigClass from an ItemisedClass"); base.Remove(entry); RenumberItems(); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Visits a configEntry and all of its children </summary> /// <param name="root"> The root of the tree to visit </param> //////////////////////////////////////////////////////////////////////////////////////////////////// public void Visit(ConfigEntry root) { // hacky reflection magic - can fail drastically if the Visitor has not been fleshed out correctly MethodInfo method = null; var type = root.GetType(); while (method == null) { var methodName = "Visit" + type.Name; method = typeof (ConfigVisitor).GetMethod(methodName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); if (method == null) { type = type.BaseType; if (type == typeof (object)) { //we've exhausted the search unfortunately throw new NotImplementedException(); } } } method.Invoke(this, new object[] {root}); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Adds an entry to the class. </summary> /// <remarks> /// Note that only classes can be added to an ItemisedClass. If you try to /// add any other kind of class, an ArgumentException will be thrown. /// </remarks> /// <exception cref="ArgumentException"> Thrown when anything other than a ConfigClass is added. </exception> /// <param name="entry"> The class to add. </param> //////////////////////////////////////////////////////////////////////////////////////////////////// public override void Add(ConfigEntry entry) { if (! (entry is ConfigClass)) throw new ArgumentException("Attempt to add something other than a ConfigClass to an ItemisedClass"); base.Add(entry); RenumberItems(); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Visits. </summary> /// <remarks> Neil MacMullen, 18/02/2011. </remarks> /// <param name="entry"> The entry to visit </param> /// <returns> . </returns> //////////////////////////////////////////////////////////////////////////////////////////////////// public new string Visit(ConfigEntry entry) { base.Visit(entry); return(_text.ToString()); }