コード例 #1
0
 /// <summary>
 /// Returns the integer Profile matching the key given. If no Profile is found, it goes back one Event
 /// and checks again until it gets to the initial state.
 /// </summary>
 /// <typeparam name="T">The type of the profile we are getting</typeparam>
 /// <param name="_key">The state variable key that is being looked up.</param>
 /// <returns>Profile saved in the state.</returns>
 public HSFProfile <T> GetProfile <T>(StateVarKey <T> _key)
 {
     if (_key.GetType() == typeof(StateVarKey <int>))
     {
         HSFProfile <int> valueOut;
         if (Idata.Count != 0)
         {                                              // Are there any Profiles in there?
             if (Idata.TryGetValue(_key, out valueOut)) //see if our key is in there
             {
                 return((dynamic)valueOut);
             }
         }
         return(Previous.GetProfile(_key)); // This isn't the right profile, go back one and try it out!
     }
     else if (_key.GetType() == typeof(StateVarKey <double>))
     {
         HSFProfile <double> valueOut;
         if (Ddata.Count != 0)
         {                                              // Are there any Profiles in there?
             if (Ddata.TryGetValue(_key, out valueOut)) //see if our key is in there
             {
                 return((dynamic)valueOut);
             }
         }
         return(Previous.GetProfile(_key)); // This isn't the right profile, go back one and try it out!
     }
     else if (_key.GetType() == typeof(StateVarKey <bool>))
     {
         HSFProfile <bool> valueOut;
         if (Ddata.Count != 0)
         {                                              // Are there any Profiles in there?
             if (Bdata.TryGetValue(_key, out valueOut)) //see if our key is in there
             {
                 return((dynamic)valueOut);
             }
         }
         return(Previous.GetProfile(_key)); // This isn't the right profile, go back one and try it out!
     }
     else if (_key.GetType() == typeof(StateVarKey <Matrix <double> >))
     {
         HSFProfile <Matrix <double> > valueOut;
         if (Ddata.Count != 0)
         {                                              // Are there any Profiles in there?
             if (Mdata.TryGetValue(_key, out valueOut)) //see if our key is in there
             {
                 return((dynamic)valueOut);
             }
         }
         return(Previous.GetProfile(_key)); // This isn't the right profile, go back one and try it out!
     }
     else if (_key.GetType() == typeof(StateVarKey <Quat>))
     {
         HSFProfile <Quat> valueOut;
         if (Ddata.Count != 0)
         {                                              // Are there any Profiles in there?
             if (Qdata.TryGetValue(_key, out valueOut)) //see if our key is in there
             {
                 return((dynamic)valueOut);
             }
         }
         return(Previous.GetProfile(_key)); // This isn't the right profile, go back one and try it out!
     }
     throw new ArgumentException("Profile Type Not Found");
 }