Archive | dicembre, 2008

Microsoft Sync Framework using IronRuby

25 Dic

Microsoft Sync Framework is a comprehensive synchronization platform that enables collaboration and offline access for applications, services and devices. It features technologies and tools that enable roaming, sharing, and taking data offline. Using Microsoft Sync Framework, developers can build sync ecosystems that integrate any application, with any data from any store using any protocol over any network.

In these days we used Microsoft Sync Framework to develop some occasionally connected application. These application use Microsoft Sync Framework to synchronize their local storage with the centralized database hosted on-line.

Microsoft Sync Framework includes a number of providers that support common data sources. The following providers are included:

  • Sync Services for ADO.NET: Synchronization for ADO.NET enabled data sources
  • Sync Services for File Systems: Synchronization for files and folders
  • Sync Services for FeedSync: Synchronization for RSS and ATOM feeds

Key features of the File system provider include:

    • Incremental synchronization of changes between two file system locations specified via a local or UNC path.
    • Synchronization of file contents, file and folder names, file timestamps, and attributes.
    • Support for optional filtering of files based on filename/extensions, sub-directories, or file attributes
    • Optional use of file hashes to detect changes to file contents if file timestamps are not reliable
    • Reliable detection of conflicting changes to the same file and automatic resolution of conflicts with a no-data-loss policy
    • Allow for limited user undo operation by optionally allowing file deletes and overwrites to be moved to the Recycle Bin
    • Support for Preview mode which provides a preview of the incremental sync operation without committing changes to the file system
    • First-class support for the scenario where the user may start synchronization with equal or partially equal file hierarchies on more than one replica.
    • Support for graceful cancellation of an ongoing sync operation such that the remaining changes can be synchronized later without having to re-sync changes that were already synchronized.

An example of Sync Services for File Systems usage can be found here. In order to test IronRuby I decided to convert this sample from C# to Ruby

require "mscorlib" require "Microsoft.Synchronization.dll" require "Microsoft.Synchronization.Files.dll" include System include Microsoft::Synchronization include Microsoft::Synchronization::Files class Syncronizer def DoWork replica1RootPath, replica2RootPath idFileName = ""; replica1Id = GetReplicaId( replica1RootPath + "/" + idFileName) replica2Id = GetReplicaId( replica2RootPath + "/" + idFileName) options = FileSyncOptions.RecycleDeletedFiles filter = filter.FileNameExcludes.Add idFileName DetectChangesOnFileSystemReplica replica1Id, replica1RootPath, filter, options DetectChangesOnFileSystemReplica replica2Id, replica2RootPath, filter, options SyncFileSystemReplicasOneWay replica1Id, replica2Id, replica1RootPath, replica2RootPath, filter, options SyncFileSystemReplicasOneWay replica2Id, replica1Id, replica2RootPath, replica1RootPath, filter, options end def GetReplicaId path id = Guid.NewGuid if File.exist? path str = path id = else, 'w') {|f| f.write(id.ToString) } end id end def DetectChangesOnFileSystemReplica replicaId, rootPath, filter, options provider =, rootPath, filter, options) provider.DetectChanges; provider.Dispose end def SyncFileSystemReplicasOneWay sourceReplicaId, destinationReplicaId, sourceReplicaRootPath, destinationReplicaRootPath, filter, options agent = agent.LocalProvider =, sourceReplicaRootPath, filter, options) agent.RemoteProvider =, destinationReplicaRootPath, filter, options) agent.Direction = SyncDirectionOrder.Upload agent.Synchronize end end sync = sync.DoWork "D:/tmp/SyncFXSamples/A", "D:/tmp/SyncFXSamples/B"

I have uploaded a little zip here that contains all the stuff you need to get ready. If you want to run the sample you have to run the command: ir sync.rb as show below


Technorati Tag: ,

Use NAnt to run mbunit tests using gallio

1 Dic

Gallio has a great build-in support for NAnt!
Unfortunately at the moment this is not well document so if you need to create a target to execute all tests inside an assembly you can write this xml fragment inside your NAnt project file:

<target name=”test” depends=”build”>
    failonerror=”false” >
    <runner-extension value=”TeamCityExtension,Gallio.TeamCityIntegration” />
      <!– Specify the tests assemblies –>
      <include name=”${src.dir}Data.Fixturebin${project.config}Data.Fixture.dll”/>
  <fail if=”${exitCode != ‘0’}” >One or more tests failed. Please check the log for more details</fail>   

don’t forget to load Gallio NAnt Tasks before start with this line of xml

<loadtasks assembly=”.toolsGallioGallio.NAntTasks.dll” />

If you need more information you can take a look at comment in the source code here

Technorati Tag: ,,