示例#1
0
        static unsafe /*svn_error_t*/ IntPtr _svn_auth_username_prompt_func(
            /*out svn_auth_cred_username_t*/ void **credPtr, IntPtr baton, sbyte *realm, int maySave, /*apr_pool_t*/ IntPtr pool)
        {
            var wrapper = AprBaton <SvnAuthWrapper <SvnUserNameEventArgs> > .Get(baton);

            var args = new SvnUserNameEventArgs(SvnBase.Utf8_PtrToString(realm), maySave != 0);

            var cred = (svn_auth_cred_username_t.__Internal * *)credPtr;

            using (var tmpPool = new AprPool(pool, false))
            {
                *cred = null;
                try
                {
                    wrapper.Raise(args);
                }
                catch (Exception e)
                {
                    return(SvnException.CreateExceptionSvnError("Authorization handler", e).__Instance);
                }

                if (args.Cancel)
                {
                    return(svn_error.svn_error_create((int)SvnErrorCode.SVN_ERR_CANCELLED, null, "Authorization canceled operation").__Instance);
                }
                if (args.Break)
                {
                    return(IntPtr.Zero);
                }

                *cred = (svn_auth_cred_username_t.__Internal *)tmpPool.AllocCleared(sizeof(svn_auth_cred_username_t.__Internal));

                (*cred)->username = new IntPtr(tmpPool.AllocString(args.UserName));
                (*cred)->may_save = args.Save ? 1 : 0;

                return(IntPtr.Zero);
            }
        }
示例#2
0
 static void ImpSubversionFileUserNameHandler(object sender, SvnUserNameEventArgs e) => e.Break = true;