How hard is it to create a repository via c#? What about viewing a source code file, or a diff, in a web app?
Is there an api I need to hook into or is it all custom code I have to write?
SharpSVN provides you with a full API. It's not that easy to use and is generally quite slow unless you cache the items you get back.
SharpSvn is a binding of the Subversion Client API for .Net 2.0 applications contained within a set of xcopy-deployable dll's. Notable users of this api are (at this time):
- AnkhSVN 2.X - Subversion Support for Visual Studio 2005 and 2008
- CollabNet Desktop for Visual Studio
- SharpDevelop (#develop)
- MonoDevelop
- SVN-Monitor
- And many, many other projects..
Here's an example from an ASP.NET project I got about 50% through, that displayed all items from a repository:
using (SvnClient client = new SvnClient())
{
client.LoadConfiguration(Server.MapPath("/"));
SvnUriTarget target = new SvnUriTarget("http://wush.net/svn/yourusername/", SvnRevision.Head);
SvnListArgs args = new SvnListArgs();
Collection<SvnListEventArgs> svnList = new Collection<SvnListEventArgs>();
client.Authentication.DefaultCredentials = new NetworkCredential("username", "password);
args.Depth = SvnDepth.Children;
client.GetList(target, args, out svnList);
foreach (var item in svnList)
{
// display the list
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With