Exemplo n.º 1
0
 public static bool Equals(ResourceContent lhs, ResourceContent rhs)
 {
     if (lhs == null)
     {
         return(rhs == null);
     }
     else
     {
         return(lhs.Equals(rhs));
     }
 }
Exemplo n.º 2
0
        public override ResourceContent CreateTargetContent(ResourceContent oldSourceContent, ResourceContent oldTargetContent)
        {
            var oldTarget = (oldTargetContent as PluralsContent) ?? new PluralsContent();
            var newTarget = new PluralsContent();

            foreach (var oldSourceItemKey in this.Values.Keys)
            {
                oldTarget.Values.TryGetValue(oldSourceItemKey, out var oldTargetItemValue);
                newTarget.Values.Add(oldSourceItemKey, oldTargetItemValue);
            }
            return(newTarget);
        }
Exemplo n.º 3
0
        public override ResourceContent CreateTargetContent(ResourceContent oldSourceContent, ResourceContent oldTargetContent)
        {
            var oldTarget = (oldTargetContent as StringArrayContent) ?? new StringArrayContent();

            if (oldSourceContent is StringArrayContent oldSource)
            {
                // Keep translations of unchanged items
                var oldSourceToTarget = new Dictionary <string, string>(StringComparer.Ordinal);
                for (int i = oldSource.Values.Count - 1; i >= 0; --i)
                {
                    string oldTargetString = i < oldTarget.Values.Count ? oldTarget.Values[i] : null;
                    oldSourceToTarget.Add(oldSource.Values[i], oldTargetString);
                }

                oldTarget.Values.Clear();
                foreach (var newSourceString in this.Values)
                {
                    oldSourceToTarget.TryGetValue(newSourceString, out var newTargetString);
                    oldTarget.Values.Add(newTargetString);
                }
            }
            else
            {
                // No way of checking which items have changed - just make the target array lenght the same as the source array
                if (oldTarget.Values.Count > this.Values.Count)
                {
                    oldTarget.Values.RemoveRange(this.Values.Count, oldTarget.Values.Count - this.Values.Count);
                }
                else if (oldTarget.Values.Count < this.Values.Count)
                {
                    oldTarget.Values.AddRange(new string[this.Values.Count - oldTarget.Values.Count]);
                }
            }

            return(oldTarget);
        }
Exemplo n.º 4
0
 public abstract ResourceContent CreateTargetContent(ResourceContent oldSourceContent, ResourceContent oldTargetContent);
Exemplo n.º 5
0
 public override ResourceContent CreateTargetContent(ResourceContent oldSourceContent, ResourceContent oldTargetContent)
 {
     return(oldTargetContent); // This is the best we can do
 }