private static void HandleError(int result) { string errorMessage; GitError error = null; var errHandle = NativeMethods.giterr_last(); if (errHandle != null && !errHandle.IsInvalid) { error = errHandle.MarshalAsGitError(); } if (error == null) { error = new GitError { Category = GitErrorCategory.Unknown, Message = IntPtr.Zero }; errorMessage = "No error message has been provided by the native library"; } else { errorMessage = LaxUtf8Marshaler.FromNative(error.Message); } Func <string, GitErrorCode, GitErrorCategory, LibGit2SharpException> exceptionBuilder; if (!GitErrorsToLibGit2SharpExceptions.TryGetValue((GitErrorCode)result, out exceptionBuilder)) { exceptionBuilder = (m, r, c) => new LibGit2SharpException(m, r, c); } throw exceptionBuilder(errorMessage, (GitErrorCode)result, error.Category); }
/// <summary> /// Enumerates each string from the array using the UTF-8 marshaler. /// </summary> public String[] ReadStrings() { var count = checked ((int)Array.Count.ToUInt32()); String[] toReturn = new String[count]; for (int i = 0; i < count; i++) { toReturn[i] = LaxUtf8Marshaler.FromNative(Marshal.ReadIntPtr(Array.Strings, i * IntPtr.Size)); } return(toReturn); }
private static unsafe void HandleError(int result) { string errorMessage; GitErrorCategory errorCategory = GitErrorCategory.Unknown; GitError * error = NativeMethods.giterr_last(); if (error == null) { errorMessage = "No error message has been provided by the native library"; } else { errorMessage = LaxUtf8Marshaler.FromNative(error->Message); } Func <string, GitErrorCode, GitErrorCategory, LibGit2SharpException> exceptionBuilder; if (!GitErrorsToLibGit2SharpExceptions.TryGetValue((GitErrorCode)result, out exceptionBuilder)) { exceptionBuilder = (m, r, c) => new LibGit2SharpException(m, r, c); } throw exceptionBuilder(errorMessage, (GitErrorCode)result, errorCategory); }
public new static unsafe FilePath FromNative(char *buffer) { return(LaxUtf8Marshaler.FromNative(buffer)); }
public new static FilePath FromNative(IntPtr pNativeData) { return(LaxUtf8Marshaler.FromNative(pNativeData)); }