private InvariantAvailability(ICSharpContextActionDataProvider provider,
            FieldOrPropertyDeclaration selectedElement)
        {
            Contract.Requires(provider != null);
            
            _classDeclaration = provider.GetSelectedElement<IClassLikeDeclaration>(true, true);
            _selectedElement = selectedElement;

            IsAvailable = AnalyzeAvailability();
            if (IsAvailable)
                SelectedMemberName = _selectedElement.Name;
        }
예제 #2
0
        private InvariantAvailability(ICSharpContextActionDataProvider provider,
                                      FieldOrPropertyDeclaration selectedElement)
        {
            Contract.Requires(provider != null);

            _classDeclaration = provider.GetSelectedElement <IClassLikeDeclaration>(true, true);
            _selectedElement  = selectedElement;

            IsAvailable = AnalyzeAvailability();
            if (IsAvailable)
            {
                SelectedMemberName = _selectedElement.Name;
            }
        }
예제 #3
0
        private static FieldOrPropertyDeclaration?TryCreateFieldOrProperty(ICSharpContextActionDataProvider provider)
        {
            var fieldDeclaration = provider.GetSelectedElement <IFieldDeclaration>(true, true);

            if (fieldDeclaration != null && IsFieldDeclarationValid(fieldDeclaration))
            {
                return(FieldOrPropertyDeclaration.FromFieldDeclaration(fieldDeclaration));
            }

            var propertyDeclaration = provider.GetSelectedElement <IPropertyDeclaration>(true, true);

            if (propertyDeclaration != null && IsPropertyDeclarationValid(propertyDeclaration))
            {
                return(FieldOrPropertyDeclaration.FromPropertyDeclaration(propertyDeclaration));
            }

            return(null);
        }