当前位置: 首页>>代码示例>>C#>>正文


C# IGroup.GetConfigurationService方法代码示例

本文整理汇总了C#中IGroup.GetConfigurationService方法的典型用法代码示例。如果您正苦于以下问题:C# IGroup.GetConfigurationService方法的具体用法?C# IGroup.GetConfigurationService怎么用?C# IGroup.GetConfigurationService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IGroup的用法示例。


在下文中一共展示了IGroup.GetConfigurationService方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HistoryBuilder

        public HistoryBuilder(IGroup group, string name)
        {
            m_Group = @group;
            m_Name = name;
            m_Group.GetHistoryService().CreateHistory(m_Name);

            SyncFolder = new SyncFolder(m_Name) { Path = "Irrelevant" };

            m_Group.GetConfigurationService().AddItem(SyncFolder);
        }
开发者ID:ap0llo,项目名称:SyncTool,代码行数:10,代码来源:HistoryBuilder.cs

示例2: Synchronize

        public void Synchronize(IGroup group)
        {
            var syncFolders = group.GetConfigurationService().Items.ToArray();

            // there need to be at least 2 sync folders, otherwise, syncing makes no sense
            if (syncFolders.Length < 2)
            {
                return;
            }

            var historyService = group.GetService<IMultiFileSystemHistoryService>();
            historyService.CreateSnapshot();

            // we cannot sync if there isn't at least one snapshot
            if(!historyService.Snapshots.Any())
            {
                return;                
            }
            
            // we cannot sync if there is not at least one snapshot per history
            if (historyService.LatestSnapshot.HistoryNames.Any(name => historyService.LatestSnapshot.GetSnapshot(name) == null))
            {
                return;
            }

            // get required services
            var syncPointService = group.GetSyncPointService();
            var conflictService = group.GetSyncConflictService();
            var syncActionService = group.GetSyncActionService();

            var filter = syncFolders.ToMultiFileSystemChangeFilter(m_FilterFactory);

            var latestSyncPoint = syncPointService.LatestSyncPoint;
            var diff = GetDiff(historyService, latestSyncPoint, filter);

            var wasReset = ResetSyncStateIfNecessary(group, diff);
            if (wasReset)
            {
                diff = GetDiff(historyService, latestSyncPoint, filter);
                latestSyncPoint = syncPointService.LatestSyncPoint;
            }
            
            // for all folders, get the changes since the last sync
                
            var newSyncPoint = new MutableSyncPoint()
            {
                Id = GetNextSyncPointId(syncPointService.LatestSyncPoint),                                
                MultiFileSystemSnapshotId = diff.ToSnapshot.Id,
                FilterConfigurations = syncFolders.ToDictionary(f => f.Name, f => f.Filter)
            };

            
                                                   
            
            var syncStateUpdater = new SyncActionUpdateBuilder();
            var changeGraphBuilder = new ChangeGraphBuilder(m_FileReferenceComparer);

            foreach (var graph in changeGraphBuilder.GetChangeGraphs(diff))
            {
                var path = graph.ValueNodes.First(node => node.Value != null).Value.Path;

                // skip if there is a conflict for the current file
                if (conflictService.ItemExists(path))
                {
                    continue;                    
                }                

                // check if all pending sync actions can be applied to the change graph
                var unapplicaleSyncActions = GetUnapplicableSyncActions(graph, syncActionService[path].Where(IsPendingSyncAction));

                // pending sync actions could not be applied => skip file
                if (unapplicaleSyncActions.Any())
                {
                    // cancel unapplicable actions
                    syncStateUpdater.UpdateSyncActions(unapplicaleSyncActions.Select(a => a.WithState(SyncActionState.Cancelled)));
                   
                    // add a conflict for the file (the snapshot id of the conflict can be determined from the oldest unapplicable sync action)
                    var oldestSyncPointId = unapplicaleSyncActions.Min(a => a.SyncPointId);                    
                    var snapshotId = oldestSyncPointId > 1 
                        ? syncPointService[oldestSyncPointId - 1].MultiFileSystemSnapshotId
                        : null;                    
                    syncStateUpdater.AddConflict(new ConflictInfo(unapplicaleSyncActions.First().Path, snapshotId));
                                        
                    continue;
                }
                
                //in the change graph, detect conflicts
                // if there is only one sink, no conflicts exist
                var acylicGraph = graph.ToAcyclicGraph();
                var sinks = acylicGraph.GetSinks().ToArray();
                if (!sinks.Any())
                {
                    // not possible (in this case the graph would be empty, which cannot happen)
                    throw new InvalidOperationException();
                }

                if (sinks.Length == 1)
                {                 
                    // no conflict => generate sync actions, to replace the outdated file versions or add the file to a target

//.........这里部分代码省略.........
开发者ID:ap0llo,项目名称:SyncTool,代码行数:101,代码来源:Synchronizer.cs

示例3: ResetSyncStateIfNecessary

        bool ResetSyncStateIfNecessary(IGroup group, IMultiFileSystemDiff diff)
        {
            var syncPointService = group.GetSyncPointService();
            var syncActionService = group.GetSyncActionService();
            var conflictService = group.GetSyncConflictService();

            var syncFolders = group.GetConfigurationService().Items.ToArray();
                
            var latestSyncPoint = syncPointService.LatestSyncPoint;

            if (ContainsNewFolders(diff) || WasFilterModified(syncFolders, latestSyncPoint))
            {
                // insert "Reset" sync point
                var resetSyncPoint = new MutableSyncPoint()
                {
                    Id = GetNextSyncPointId(latestSyncPoint),                    
                    MultiFileSystemSnapshotId = null,
                    FilterConfigurations = syncFolders.ToDictionary(f => f.Name, f => f.Filter)
                };

                syncPointService.AddItem(resetSyncPoint);

                // cancel all pending sync actions
                var cancelledSyncActions = syncActionService.PendingItems
                    .Select(a => a.WithState(SyncActionState.Cancelled));

                syncActionService.UpdateItems(cancelledSyncActions);

                // remove all conflicts                
                conflictService.RemoveItems(conflictService.Items.ToArray());


                return true;
            }

            return false;

        }
开发者ID:ap0llo,项目名称:SyncTool,代码行数:38,代码来源:Synchronizer.cs


注:本文中的IGroup.GetConfigurationService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。