Exemplo n.º 1
0
        /// <summary>
        /// Create an ExtractMethodRequestView with default values.
        /// </summary>
        public ExtractMethodRequestView(IServiceProvider serviceProvider, ExtractedMethodCreator previewer)
        {
            _previewer       = previewer;
            _serviceProvider = serviceProvider;

            var extraction = _previewer.LastExtraction;

            AP.ScopeInfo lastClass = null;
            for (int i = extraction.scopes.Length - 1; i >= 0; i--)
            {
                if (extraction.scopes[i].type == "class")
                {
                    lastClass = extraction.scopes[i];
                    break;
                }
            }

            var targetScopes = new List <ScopeWrapper>();

            foreach (var scope in extraction.scopes)
            {
                if (!(scope.type == "class") || scope == lastClass)
                {
                    var wrapper = new ScopeWrapper(scope);
                    if (scope == lastClass)
                    {
                        _defaultScope = wrapper;
                    }
                    targetScopes.Add(wrapper);
                }
            }

            _targetScopes = new ReadOnlyCollection <ScopeWrapper>(targetScopes);
            if (_defaultScope == null && _targetScopes.Any())
            {
                _defaultScope = _targetScopes[0];
            }

            _previewFontFamily = new FontFamily(GetTextEditorFont());

            PropertyChanged += ExtractMethodRequestView_PropertyChanged;

            // Access properties rather than underlying variables to ensure dependent properties
            // are also updated.
            Name        = _defaultName;
            TargetScope = _defaultScope;
        }
Exemplo n.º 2
0
 public ScopeWrapper(AP.ScopeInfo scope)
 {
     Scope = scope;
 }