// method - private: generates a behavior child class instance and returns it for action initialization // // * param inName - Name of the behavior // * param inParams - Set of parameters private Behavior GenerateBehavior(string inName, Dictionary <string, string> inParams) { //Searches for Behavior enum value of given input Behavior.Behaviors classToImplement = Behavior.Behaviors.NONE; string caps = inName.ToUpper(); string[] names = System.Enum.GetNames(typeof(Behavior.Behaviors)); Behavior.Behaviors[] values = (Behavior.Behaviors[])System.Enum.GetValues(typeof(Behavior.Behaviors)); bool found = false; for (int i = 0; i < names.Length; i++) { if (names[i].Equals(caps)) { classToImplement = values[i]; found = true; break; } } ////Exception handling if (!found) { throw new System.InvalidOperationException("No case currently in place for handling behavior '" + inName + "'."); } //if (inParams != null) { throw new MissingReferenceException("Behavior instance was not given a set of parameters."); } return(GetBehaviorInstance(classToImplement, inName, inParams)); }
// method - private: generates and returns a behavior instance based on the enum type // // * param classToImplement - enum type of behavior class to initialize // * param inName - Name of the behavior // * param inParams - Set of parameters private Behavior GetBehaviorInstance(Behavior.Behaviors classToImplement, string inName, Dictionary <string, string> inParams) { switch (classToImplement) { /*TODO * Implement return methods for each potential Behavior class type */ case Behavior.Behaviors.SAMPLE: return(new BehaviorSample(inName, inParams)); // ****NOTE**** Set up a case for returning each potential Behavior class type default: return(null); } }