public bool SetStateOf <T> (object stateData) where T : WIScript { if (SaveState == null || SaveState.Scripts == null) { return(false); } string scriptName = typeof(T).Name; string scriptStateName = scriptName + "State"; //<-this shit is going to get people in trouble, haha string scriptStateString = string.Empty; //make sure the type matches the state type if (stateData.GetType().Name != scriptStateName) { return(false); } if (!SaveState.Scripts.ContainsKey(scriptName)) { return(false); } if (SaveState.Scripts.ContainsKey(scriptName)) { scriptStateString = WIScript.XmlSerializeToString(stateData); SaveState.Scripts [scriptName] = scriptStateString; return(true); } return(false); }
public bool SetStateData <T> (T stateData) where T : class, new() { if (SaveState == null || SaveState.Scripts == null) { return(false); } string stateStateName = stateData.GetType().Name; string scriptName = stateStateName.Substring(0, stateStateName.Length - 5); //this removes "State" string scriptStateString = string.Empty; if (!SaveState.Scripts.ContainsKey(scriptName)) { return(false); } else { scriptStateString = WIScript.XmlSerializeToString(stateData); SaveState.Scripts [scriptName] = scriptStateString; } return(true); }