Skip to content

Commit

Permalink
优化字符串的拼接逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiang Yin committed Jun 8, 2021
1 parent b2c3ba9 commit 2ce0bf1
Show file tree
Hide file tree
Showing 36 changed files with 4,147 additions and 264 deletions.
8 changes: 4 additions & 4 deletions GameFramework/Base/DataProvider/DataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public void ReadData(string dataAssetName, int priority, object userData)
break;

default:
throw new GameFrameworkException(Utility.Text.Format("Data asset '{0}' is '{1}'.", dataAssetName, result.ToString()));
throw new GameFrameworkException(Utility.Text.Format("Data asset '{0}' is '{1}'.", dataAssetName, result));
}
}

Expand Down Expand Up @@ -284,7 +284,7 @@ public bool ParseData(string dataString, object userData)
throw;
}

throw new GameFrameworkException(Utility.Text.Format("Can not parse data string with exception '{0}'.", exception.ToString()), exception);
throw new GameFrameworkException(Utility.Text.Format("Can not parse data string with exception '{0}'.", exception), exception);
}
}

Expand Down Expand Up @@ -367,7 +367,7 @@ public bool ParseData(byte[] dataBytes, int startIndex, int length, object userD
throw;
}

throw new GameFrameworkException(Utility.Text.Format("Can not parse data bytes with exception '{0}'.", exception.ToString()), exception);
throw new GameFrameworkException(Utility.Text.Format("Can not parse data bytes with exception '{0}'.", exception), exception);
}
}

Expand Down Expand Up @@ -435,7 +435,7 @@ private void LoadAssetSuccessCallback(string dataAssetName, object dataAsset, fl

private void LoadAssetOrBinaryFailureCallback(string dataAssetName, LoadResourceStatus status, string errorMessage, object userData)
{
string appendErrorMessage = Utility.Text.Format("Load data failure, data asset name '{0}', status '{1}', error message '{2}'.", dataAssetName, status.ToString(), errorMessage);
string appendErrorMessage = Utility.Text.Format("Load data failure, data asset name '{0}', status '{1}', error message '{2}'.", dataAssetName, status, errorMessage);
if (m_ReadDataFailureEventHandler != null)
{
ReadDataFailureEventArgs loadDataFailureEventArgs = ReadDataFailureEventArgs.Create(dataAssetName, appendErrorMessage, userData);
Expand Down
8 changes: 4 additions & 4 deletions GameFramework/Base/EventPool/EventPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ public void Subscribe(int id, EventHandler<T> handler)
}
else if ((m_EventPoolMode & EventPoolMode.AllowMultiHandler) != EventPoolMode.AllowMultiHandler)
{
throw new GameFrameworkException(Utility.Text.Format("Event '{0}' not allow multi handler.", id.ToString()));
throw new GameFrameworkException(Utility.Text.Format("Event '{0}' not allow multi handler.", id));
}
else if ((m_EventPoolMode & EventPoolMode.AllowDuplicateHandler) != EventPoolMode.AllowDuplicateHandler && Check(id, handler))
{
throw new GameFrameworkException(Utility.Text.Format("Event '{0}' not allow duplicate handler.", id.ToString()));
throw new GameFrameworkException(Utility.Text.Format("Event '{0}' not allow duplicate handler.", id));
}
else
{
Expand Down Expand Up @@ -197,7 +197,7 @@ public void Unsubscribe(int id, EventHandler<T> handler)

if (!m_EventHandlers.Remove(id, handler))
{
throw new GameFrameworkException(Utility.Text.Format("Event '{0}' not exists specified handler.", id.ToString()));
throw new GameFrameworkException(Utility.Text.Format("Event '{0}' not exists specified handler.", id));
}
}

Expand Down Expand Up @@ -278,7 +278,7 @@ private void HandleEvent(object sender, T e)

if (noHandlerException)
{
throw new GameFrameworkException(Utility.Text.Format("Event '{0}' not allow no handler.", e.Id.ToString()));
throw new GameFrameworkException(Utility.Text.Format("Event '{0}' not allow no handler.", e.Id));
}
}
}
Expand Down
8 changes: 3 additions & 5 deletions GameFramework/Base/GameFrameworkSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public bool Serialize(Stream stream, T data, byte version)
SerializeCallback callback = null;
if (!m_SerializeCallbacks.TryGetValue(version, out callback))
{
throw new GameFrameworkException(Utility.Text.Format("Serialize callback '{0}' is not exist.", version.ToString()));
throw new GameFrameworkException(Utility.Text.Format("Serialize callback '{0}' is not exist.", version));
}

return callback(stream, data);
Expand All @@ -157,16 +157,14 @@ public T Deserialize(Stream stream)
byte header2 = (byte)stream.ReadByte();
if (header0 != header[0] || header1 != header[1] || header2 != header[2])
{
throw new GameFrameworkException(Utility.Text.Format("Header is invalid, need '{0}{1}{2}', current '{3}{4}{5}'.",
((char)header[0]).ToString(), ((char)header[1]).ToString(), ((char)header[2]).ToString(),
((char)header0).ToString(), ((char)header1).ToString(), ((char)header2).ToString()));
throw new GameFrameworkException(Utility.Text.Format("Header is invalid, need '{0}{1}{2}', current '{3}{4}{5}'.", (char)header[0], (char)header[1], (char)header[2], (char)header0, (char)header1, (char)header2));
}

byte version = (byte)stream.ReadByte();
DeserializeCallback callback = null;
if (!m_DeserializeCallbacks.TryGetValue(version, out callback))
{
throw new GameFrameworkException(Utility.Text.Format("Deserialize callback '{0}' is not exist.", version.ToString()));
throw new GameFrameworkException(Utility.Text.Format("Deserialize callback '{0}' is not exist.", version));
}

return callback(stream);
Expand Down
2 changes: 1 addition & 1 deletion GameFramework/Base/Log/GameFrameworkLog.ILogHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public interface ILogHelper
/// </summary>
/// <param name="level">游戏框架日志等级。</param>
/// <param name="message">日志内容。</param>
void Log(GameFrameworkLogLevel level, object message);
void Log(GameFrameworkLogLevel level, string message);
}
}
}
Loading

0 comments on commit 2ce0bf1

Please sign in to comment.