Using client.status in c# with sharpsvn

孤街醉人 提交于 2019-12-05 15:52:06
Noon Silk

Well, it'll work exactly like the svn status command : http://svnbook.red-bean.com/en/1.0/re26.html

You'll get the list of files pumped to the EventHandler:

using(SvnClient client = /* set up a client */ ){
    EventHandler<SvnStatusEventArgs> statusHandler = new EventHandler<SvnStatusEventArgs>(HandleStatusEvent);
    client.Status(@"c:\foo\some-working-copy", statusHandler);
}

...

void HandleStatusEvent (object sender, SvnStatusEventArgs args)
{
    switch(args.LocalContentStatus){
        case SvnStatus.Added: // Handle appropriately
            break;
    }

    // review other properties of 'args'
}

Or if you don't mind inline delegates:

using(SvnClient client = new SvnClient())
{
   client.Status(path,
                 delegate(object sender, SvnStatusEventArgs e)
                 {
                    if (e.LocalContentStatus == SvnStatus.Added)
                       Console.WriteLine("Added {0}", e.FullPath);
                 });
}

Note that the delegate versions of the SharpSvn functions are always a (tiny) bit faster than the revisions returns a collection as this method allows marshalling the least amount of information to the Managed world. You can use Svn*EventArgs.Detach() to marshall everything anyway. (This is what the .GetXXX() functions do internally)

The inline delegate version worked for me but the EventHandler<T> version didn't work until I set the type to EventHandler<SvnStatusEventArgs>.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!