コード例 #1
0
ファイル: SolidMachine.cs プロジェクト: mesh42/vpnet
 /// <summary>
 /// Creates an instance of a specified state type, either through .NET activation
 /// or through a defined state resolver.
 /// </summary>
 /// <param name="stateType"></param>
 /// <returns></returns>
 private ISolidState InstantiateState(Type stateType)
 {
     // Do we have a state resolver?
     if (_stateResolver != null)
     {
         var instance = _stateResolver.ResolveState(stateType);
         if (instance == null)
         {
             throw new SolidStateException(string.Format("State resolver returned null for type '{0}'!",
                                                         stateType.Name));
         }
         return(instance);
     }
     else
     {
         return((ISolidState)Activator.CreateInstance(stateType));
     }
 }
コード例 #2
0
 /// <summary>
 /// Creates an instance of a specified state type, either through .NET activation
 /// or through a defined state resolver.
 /// </summary>
 private ISolidState InstantiateState(Type stateType)
 {
     // Do we have a state resolver?
     if (_stateResolver != null)
     {
         var instance = _stateResolver.ResolveState(stateType);
         if (instance == null)
         {
             Debug.LogError(string.Format("State resolver could not resolve a state for type '{0}'!", stateType.Name));
             return(instance);
         }
         return(instance);
     }
     else
     {
         return((ISolidState)Activator.CreateInstance(stateType));
     }
 }