Beispiel #1
0
        public void DoMain(Repository rootdirRepo, Repository subdirRepo,
                           ICopyCommitProgressHandler progressHandler)
        {
            var copyContext = new CopyCommitContext(progressHandler, _objectMapping,
                                                    new CopyCommitCallback(_options));

            // ReSharper disable AccessToDisposedClosure
            RecursiveCaller.Call(async() =>
            {
                progressHandler.OnFoundNewCommit(_options.Branches.Count);
                foreach (var convertBranch in _options.Branches)
                {
                    await CopyBranch(rootdirRepo, subdirRepo, convertBranch, copyContext);
                }
            });
            // ReSharper restore AccessToDisposedClosure
        }
 public Commit?CopyCommits(Repository sourceRepo, Commit root, Repository targetRepo, int maxDepth)
 {
     using var ctx = RecursiveCaller.CreateContext();
     return(ctx.Call(ReferenceOrCopyCommit(sourceRepo, root, targetRepo, maxDepth)));
 }
 private static RecursiveCaller GetRecursiveCaller(RecursiveCaller currentCaller, RecursiveCaller receivedCaller)
 {
     return((RecursiveCaller)Math.Max((byte)currentCaller, (byte)receivedCaller));
 }
Beispiel #4
0
        private static void SetRelatedProperties <T>(TextObject parentTextObject, string tag, T entity, bool addLeaderInfo, RecursiveCaller recursiveCaller) where T : class
        {
            switch (entity)
            {
            case Hero hero:
                SetEntitiyProperties(parentTextObject, tag + "_CLAN", hero.Clan, addLeaderInfo, GetRecursiveCaller(RecursiveCaller.Hero, recursiveCaller));
                break;

            case Settlement settlement:
                SetEntitiyProperties(parentTextObject, tag + "_CLAN", settlement.OwnerClan, addLeaderInfo, GetRecursiveCaller(RecursiveCaller.Settlement, recursiveCaller));
                break;

            case Clan clan:
                if (addLeaderInfo)
                {
                    SetEntitiyProperties(parentTextObject, tag + "_LEADER", clan.Leader, false, RecursiveCaller.Clan);
                }
                SetEntitiyProperties(parentTextObject, tag + "_KINGDOM", clan.Kingdom, addLeaderInfo, GetRecursiveCaller(RecursiveCaller.Clan, recursiveCaller));
                break;

            case Kingdom kingdom:
                if (addLeaderInfo)
                {
                    SetEntitiyProperties(parentTextObject, tag + "_LEADER", kingdom.Leader, false, RecursiveCaller.Kingdom);
                }
                break;

            default:
                throw new ArgumentException(string.Format("{0} is not supported type", entity.GetType().FullName), nameof(entity));
            }
        }
Beispiel #5
0
 public static void SetEntitiyProperties <T>(TextObject parentTextObject, string tag, T entity, bool addLeaderInfo = false, RecursiveCaller recursiveCaller = RecursiveCaller.None) where T : class
 {
     if (string.IsNullOrEmpty(tag) || entity is null || recursiveCaller == GetCurrentCaller(entity))
     {
         return;
     }
     if (parentTextObject is null)
     {
         MBTextManager.SetTextVariable(tag, GetEntityTextObject(entity));
     }
     else
     {
         parentTextObject.SetTextVariable(tag, GetEntityTextObject(entity));
     }
     SetRelatedProperties(parentTextObject, tag, entity, addLeaderInfo, recursiveCaller);
 }