예제 #1
0
 /// <summary>
 /// Create an ExtractMethodRequestView with values taken from template.
 /// </summary>
 public ExtractMethodRequestView(IServiceProvider serviceProvider, ExtractedMethodCreator previewer, ExtractMethodRequest template)
     : this(serviceProvider, previewer)
 {
     // Access properties rather than underlying variables to ensure dependent properties
     // are also updated.
     Name = template.Name;
     //TargetScope = template.TargetScope;
     foreach (var cv in ClosureVariables)
     {
         cv.IsClosure = !template.Parameters.Contains(cv.Name);
     }
 }
예제 #2
0
        public ExtractMethodRequest GetExtractionInfo(ExtractedMethodCreator previewer)
        {
            var requestView = new ExtractMethodRequestView(_serviceProvider, previewer);
            var dialog      = new ExtractMethodDialog(requestView);

            bool res = dialog.ShowModal() ?? false;

            if (res)
            {
                return(requestView.GetRequest());
            }

            return(null);
        }
예제 #3
0
        /// <summary>
        /// Create an ExtractMethodRequestView with default values.
        /// </summary>
        public ExtractMethodRequestView(IServiceProvider serviceProvider, ExtractedMethodCreator previewer)
        {
            _previewer       = previewer;
            _serviceProvider = serviceProvider;

            //ScopeStatement lastClass = null;
            //for (int i = _previewer.Scopes.Length - 1; i >= 0; i--)
            //{
            //    if (_previewer.Scopes[i] is ClassDefinition)
            //    {
            //        lastClass = _previewer.Scopes[i];
            //        break;
            //    }
            //}
            //_defaultScope = lastClass;

            //var targetScopes = new List<ScopeStatement>();
            //foreach (var scope in _previewer.Scopes)
            //{
            //    if (!(scope is ClassDefinition) || scope == lastClass)
            //    {
            //        targetScopes.Add(scope);
            //    }
            //}

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

            //_name = null;
            //_targetScope = null;

            _previewFontFamily = new FontFamily(GetTextEditorFont());

            PropertyChanged += ExtractMethodRequestView_PropertyChanged;

            // Access properties rather than underlying variables to ensure dependent properties
            // are also updated.
            //Name = _defaultName;
            //TargetScope = _defaultScope;
        }