Beispiel #1
0
 public static bool Equals(ResourceContent lhs, ResourceContent rhs)
 {
     if (lhs == null)
     {
         return(rhs == null);
     }
     else
     {
         return(lhs.Equals(rhs));
     }
 }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #4
0
 public abstract ResourceContent CreateTargetContent(ResourceContent oldSourceContent, ResourceContent oldTargetContent);
Beispiel #5
0
 public override ResourceContent CreateTargetContent(ResourceContent oldSourceContent, ResourceContent oldTargetContent)
 {
     return(oldTargetContent); // This is the best we can do
 }