public static TObjectType DeserializeFromFile <TObjectType>(IFormatter objFormatter, string strFilePath) where TObjectType : ObjectBase { TObjectType objValue = default(TObjectType); if ((strFilePath == null) || (strFilePath.Trim().Length == 0)) { throw new ArgumentException("strFilePath", "A valid non-null, non-empty string is required."); } if (File.Exists(strFilePath) == false) { throw new FileNotFoundException("The requested '" + typeof(TObjectType).FullName + "' file could not be found.", strFilePath); } try { SerializedObject objSerializedObject = objFormatter.DeserializeFromFile(strFilePath); objValue = (TObjectType)objSerializedObject.Deserialize(); } catch (Exception objException) { throw new Exception("An error was encountered while attempting to load '" + strFilePath + "'.", objException); } return(objValue); }