locked
NotifyingChangeApplier RRS feed

  • Question

  • Why can the NotifyingChangeApplier not work with the FileSyncProvider? I want to make a custom provider to work with the FileSyncProvider. But as "object changeDataRetriever" Parameter i get an object witch seems to be an internal class (filesyncproviderclass) and then the ApplyChanges methode throw an cast error. Please help.... 

    public override void ProcessChangeBatch( ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, object changeDataRetriever, SyncCallbacks syncCallbacks, SyncSessionStatistics sessionStatistics )
            {
                metadataStore.BeginTransaction();
    
                //Get all my local change versions from the metadata store
                IEnumerable<ItemChange> localChanges = metadata.GetLocalVersions(sourceChanges);
    
                //Create a changeapplier object to make change application easier (make the engine call me 
    
                //when it needs data and when I should save data)
                NotifyingChangeApplier changeApplier = new NotifyingChangeApplier(_syncIdFormatGroup);
    
                try
                {
                    //ERROR HERE!!
                    changeApplier.ApplyChanges(resolutionPolicy, sourceChanges, changeDataRetriever as IChangeDataRetriever, localChanges, metadata.GetKnowledge(),
    
                    metadata.GetForgottenKnowledge(), this, _currentSessionContext, syncCallbacks);
                }
                catch (Exception e)
                {
                    throw e;
    
                }
    
                metadataStore.CommitTransaction();
            }
    • Moved by Max Wang_1983 Wednesday, April 20, 2011 9:47 PM Forum consolidation (From:SyncFx - Technical Discussion [ReadOnly])
    Wednesday, April 22, 2009 11:57 AM

Answers

  • Hi -
    You are correct about how we would implement it ( as a ChangeDataAdapter) but you are unable to do it because we did not expose the unmanaged data type. The only way for you to do this would be to write your own COM interop layer over our native FileSyncProvider and then use that.

    Instead I would recommend waiting for our CTP2 release which should solve your problem

    Thanks
    Deepa
    Deepa ( Microsoft Sync Framework)
    Tuesday, May 5, 2009 8:07 PM
    Answerer

All replies

  • Hi -

    Currently you cannot write a matching FileSyncProvider in managed code - you can do it in native. This will however be possible with our next MSF V2 CT2 release.

    Thannks
    Deepa
    Deepa ( Microsoft Sync Framework)
    Wednesday, April 22, 2009 6:09 PM
    Answerer
  • Is there a period for release? Next month, next year, its done when its done... :)
    Thursday, April 23, 2009 8:56 AM
  • I found this class NotifyingChangeApplierIChangeDataRetrieverAdapter  can this not resolve my problem? I think its exactly what im looking for, but how to use?
    My code now is:

    public override void ProcessChangeBatch( ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, object changeDataRetriever, SyncCallbacks syncCallbacks, SyncSessionStatistics sessionStatistics )
    
            {
    
                metadataStore.BeginTransaction();
    
    
    
                //Get all my local change versions from the metadata store
    
                IEnumerable<ItemChange> localChanges = metadata.GetLocalVersions(sourceChanges);
    
    
    
                //Create a changeapplier object to make change application easier (make the engine call me 
    
                //when it needs data and when I should save data)
    
                NotifyingChangeApplier changeApplier = new NotifyingChangeApplier(_syncIdFormatGroup);
    
    
    
               
    
    
    
                NotifyingChangeApplierIChangeDataRetrieverAdapter adapter = new NotifyingChangeApplierIChangeDataRetrieverAdapter(new ChangeDataAdapterClass());
    
    
    
                object managedChangedDataRetriever = adapter.ConvertUnmanagedToManaged(changeDataRetriever);
    
    
    
                try
    
                {
    
                    changeApplier.ApplyChanges(resolutionPolicy, sourceChanges, managedChangedDataRetriever as IChangeDataRetriever, localChanges, metadata.GetKnowledge(),
    
                            metadata.GetForgottenKnowledge(), this, _currentSessionContext, syncCallbacks);
    
    
    
                }
    
                catch (Exception e)
    
                {
    
    
    
                    throw e;
    
                }
    
                metadataStore.CommitTransaction();
    
            }
    
    
    But i dont know how to implemente the abtract class ChangeDataAdapter. Is there a sample?
    Thursday, April 23, 2009 9:09 AM
  • I found this class NotifyingChangeApplierIChangeDataRetrieverAdapter  can this not resolve my problem? I think its exactly what im looking for, but how to use?
    My code now is:

    public override void ProcessChangeBatch( ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, object changeDataRetriever, SyncCallbacks syncCallbacks, SyncSessionStatistics sessionStatistics )
    
            {
    
                metadataStore.BeginTransaction();
    
    
    
                //Get all my local change versions from the metadata store
    
                IEnumerable<ItemChange> localChanges = metadata.GetLocalVersions(sourceChanges);
    
    
    
                //Create a changeapplier object to make change application easier (make the engine call me 
    
                //when it needs data and when I should save data)
    
                NotifyingChangeApplier changeApplier = new NotifyingChangeApplier(_syncIdFormatGroup);
    
    
    
               
    
    
    
                NotifyingChangeApplierIChangeDataRetrieverAdapter adapter = new NotifyingChangeApplierIChangeDataRetrieverAdapter(new ChangeDataAdapterClass());
    
    
    
                object managedChangedDataRetriever = adapter.ConvertUnmanagedToManaged(changeDataRetriever);
    
    
    
                try
    
                {
    
                    changeApplier.ApplyChanges(resolutionPolicy, sourceChanges, managedChangedDataRetriever as IChangeDataRetriever, localChanges, metadata.GetKnowledge(),
    
                            metadata.GetForgottenKnowledge(), this, _currentSessionContext, syncCallbacks);
    
    
    
                }
    
                catch (Exception e)
    
                {
    
    
    
                    throw e;
    
                }
    
                metadataStore.CommitTransaction();
    
            }
    
    
    But i dont know how to implemente the aptract class ChangeDataAdapter. Is there a sample?

    why this not works?

    class ChangeDataAdapterClass : ChangeDataAdapter
        {
            public override object ConvertManagedToUnmanagedData( object managedData )
            {
    
                throw new NotImplementedException();
            }
    
            public override object ConvertUnmanagedToManagedData( object unmanagedData )
            {
                
    
                return new UnmanagedSyncProviderWrapper(unmanagedData);
                
            }
        }
    Wednesday, April 29, 2009 12:08 PM
  • Hi -
    You are correct about how we would implement it ( as a ChangeDataAdapter) but you are unable to do it because we did not expose the unmanaged data type. The only way for you to do this would be to write your own COM interop layer over our native FileSyncProvider and then use that.

    Instead I would recommend waiting for our CTP2 release which should solve your problem

    Thanks
    Deepa
    Deepa ( Microsoft Sync Framework)
    Tuesday, May 5, 2009 8:07 PM
    Answerer
  • Hi Deepa,

    THANKS DUDES IT WORKS!!!!! nice job...

    And by the way, thanks for the great work on sync framework, its a ____ kicking part of net enviroment ;)
    and sorry for my bad english. :(

    Steffen
    Tuesday, May 5, 2009 8:19 PM
  • Hi Deepa,

    Do you know if this was resolved in V2?

    Is it now possible to implement IChangeDataRetriever on an overridden FileSyncProvider class?  It doesn't seem to do anything when I implement IChangeDataRetriever.

    Kind Regards,

    Johann
    Friday, December 11, 2009 5:54 AM