public bool TryGetUIResize(string[] segments, int scope, out UIResizeResult result)
        {
            UIResizeAttachment attachment = this;

            result = null;

            var len = segments.Length;

            for (int i = 0; i < len; i++)
            {
                var segment = segments[i];
                if (attachment.Descendants.TryGetValue(segment, out var newAttachment))
                {
                    if (result == null)
                    {
                        result = newAttachment.Result?.Copy();
                    }
                    else
                    {
                        result.MergeInto(newAttachment.Result);
                    }

                    if (scope != TranslationScopes.None)
                    {
                        if (result == null)
                        {
                            if (newAttachment.ScopedResults.TryGetValue(scope, out var scopedResult))
                            {
                                result = scopedResult.Copy();
                            }
                        }
                        else
                        {
                            if (newAttachment.ScopedResults.TryGetValue(scope, out var scopedResult))
                            {
                                result.MergeInto(scopedResult);
                            }
                        }
                    }

                    attachment = newAttachment;
                }
                else
                {
                    return(result != null);
                }
            }

            return(result != null);
        }
Пример #2
0
        public bool TryGetUIResize(string[] segments, int startIndex, int scope, out UIResizeResult result)
        {
            UIResizeAttachment attachment = this;

            result = null;

            var len = segments.Length;

            for (int i = startIndex; i < len; i++)
            {
                var segment = segments[i];
                if (attachment.Descendants.TryGetValue(segment, out var newAttachment))
                {
                    if (result == null)
                    {
                        result = newAttachment.Result?.Copy();
                    }
                    else
                    {
                        result.MergeInto(newAttachment.Result);
                    }

                    if (scope != TranslationScopes.None)
                    {
                        if (result == null)
                        {
                            if (newAttachment.ScopedResults.TryGetValue(scope, out var scopedResult))
                            {
                                result = scopedResult.Copy();
                            }
                        }
                        else
                        {
                            if (newAttachment.ScopedResults.TryGetValue(scope, out var scopedResult))
                            {
                                result.MergeInto(scopedResult);
                            }
                        }
                    }

                    //if( attachment.HasWildcardBelow )
                    //{
                    //   // we have to iterate all descendants of this attachment
                    //   foreach( var childAttachment in attachment.Descendants.Values )
                    //   {
                    //      if( childAttachment.TryGetUIResize( segments, i + 1, scope, out var otherResult ) )
                    //      {
                    //         if( result == null )
                    //         {
                    //            result = otherResult.Copy();
                    //         }
                    //         else
                    //         {
                    //            result.MergeInto( otherResult );
                    //         }
                    //      }
                    //   }
                    //}

                    attachment = newAttachment;
                }
                else
                {
                    return(result != null);
                }
            }

            return(result != null);
        }