private static int Action( out IntPtr stream, IntPtr subtransport, IntPtr url, GitSmartSubtransportAction action) { stream = IntPtr.Zero; SmartSubtransport t = GCHandle.FromIntPtr(Marshal.ReadIntPtr(subtransport, GitSmartSubtransport.GCHandleOffset)).Target as SmartSubtransport; String urlAsString = LaxUtf8Marshaler.FromNative(url); if (null != t && !String.IsNullOrEmpty(urlAsString)) { try { stream = t.Action(urlAsString, action).GitSmartTransportStreamPointer; return(0); } catch (Exception ex) { Proxy.git_error_set_str(GitErrorCategory.Net, ex); } } return((int)GitErrorCode.Error); }
private static void Free(IntPtr subtransport) { SmartSubtransport t = GCHandle.FromIntPtr(Marshal.ReadIntPtr(subtransport, GitSmartSubtransport.GCHandleOffset)).Target as SmartSubtransport; if (null != t) { try { t.Dispose(); } catch (Exception ex) { Proxy.git_error_set_str(GitErrorCategory.Net, ex); } } }
private static int Close(IntPtr subtransport) { SmartSubtransport t = GCHandle.FromIntPtr(Marshal.ReadIntPtr(subtransport, GitSmartSubtransport.GCHandleOffset)).Target as SmartSubtransport; if (null != t) { try { t.Close(); return(0); } catch (Exception ex) { Proxy.git_error_set_str(GitErrorCategory.Net, ex); } } return((int)GitErrorCode.Error); }
private static int Action( out IntPtr stream, IntPtr subtransport, IntPtr url, GitSmartSubtransportAction action) { stream = IntPtr.Zero; SmartSubtransport t = GCHandle.FromIntPtr(Marshal.ReadIntPtr(subtransport, GitSmartSubtransport.GCHandleOffset)).Target as SmartSubtransport; String urlAsString = LaxUtf8Marshaler.FromNative(url); if (t == null) { Proxy.git_error_set_str(GitErrorCategory.Net, "no subtransport provided"); return (int)GitErrorCode.Error; } if (String.IsNullOrEmpty(urlAsString)) { urlAsString = t.LastActionUrl; } if (String.IsNullOrEmpty(urlAsString)) { Proxy.git_error_set_str(GitErrorCategory.Net, "no url provided"); return (int)GitErrorCode.Error; } try { stream = t.Action(urlAsString, action).GitSmartTransportStreamPointer; t.LastActionUrl = urlAsString; return 0; } catch (Exception ex) { Proxy.git_error_set_str(GitErrorCategory.Net, ex); return (int)GitErrorCode.Error; } }
/// <summary> /// Base constructor for SmartTransportStream. Make sure that your derived class calls this base constructor. /// </summary> /// <param name="subtransport">The subtransport that this stream represents a connection over.</param> protected SmartSubtransportStream(SmartSubtransport subtransport) { this.subtransport = subtransport; }
public TfsSmartSubtransportStream(SmartSubtransport smartSubtransport) : base(smartSubtransport) { responseStream = new Lazy<Stream> (CreateResponseStream); }