Пример #1
0
            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 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;
                }
            }