Exemplo n.º 1
0
        /// <summary>
        /// Level 2 merge
        /// (1) left 和 right 不能为空
        /// (2) 获取 right 的 TranslationResource 清单
        /// (3) 检测 right Translation Resource 和 right LanguageTag
        /// (4) 将 right Translation Resource 传入 Core Merge 2
        /// </summary>
        /// <param name="left"></param>
        /// <param name="right"></param>
        private static void MergeInLevel2(ITranslatePackageMergeOps left, ITranslatePackageMergeOps right)
        {
            if (left == null || right == null) //(1)
            {
                return;
            }

            foreach (var rightResource in right.ExposeResource())             //(2)
            {
                if (rightResource.Key == null || rightResource.Value == null) //(3)
                {
                    continue;
                }

                left.Merge(rightResource.Value, MergeLevel2CoreFunc(rightResource.Value)); //(4)
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Level 1 merge
        /// (1) left 和 right 不能为空
        /// (2) 获取 right 的 TranslationResource 清单
        /// (3) 检测 right Translation Resource 和 right LanguageTag
        /// (4) 如果 left Translation Resource 包含 right LanguageTag,跳过
        /// (5) 此时 left Translation Resource 不包含 right LanguageTag,将 right Translation Resource 传入 Core Merge 1
        /// </summary>
        /// <param name="left"></param>
        /// <param name="right"></param>
        private static void MergeInLevel1(ITranslatePackageMergeOps left, ITranslatePackageMergeOps right)
        {
            if (left == null || right == null) //(1)
            {
                return;
            }

            var leftResourcesPtr = left.ExposeResource().ToList();

            foreach (var rightResource in right.ExposeResource())             //(2)
            {
                if (rightResource.Key == null || rightResource.Value == null) //(3)
                {
                    continue;
                }

                if (leftResourcesPtr.Any(x => x.Key.Equals((ILanguageTag)rightResource.Key)))  //(4)
                {
                    continue;
                }

                left.Merge(rightResource.Value, MergeLevel1CoreFunc(rightResource.Value)); //(5_
            }
        }