tags:

views:

177

answers:

2

I want to use the status method but i dont understand how it works. Could someone show me an example of use please?

EventHandler < SvnStatusEventArgs > statusHandler = new EventHandler<SvnStatusEventArgs>(void(object, SvnStatusEventArgs) target);
client.Status(path, statusHandler);
+1  A: 

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<SvnStatusArgs> statusHandler = new EventHandler<SvnStatusArgs>(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'
}
Noon Silk
Thank you very very much, it works, you are the best. Thanks!
Pedro
+1  A: 

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)

Bert Huijben