public MoveStaticMembersDialogViewModel(
            StaticMemberSelectionViewModel memberSelectionViewModel,
            string defaultType,
            ImmutableArray <TypeNameItem> availableTypes,
            string prependedNamespace,
            ISyntaxFacts syntaxFacts)
        {
            MemberSelectionViewModel = memberSelectionViewModel;
            _syntaxFacts             = syntaxFacts ?? throw new ArgumentNullException(nameof(syntaxFacts));
            _searchText        = defaultType;
            _destinationName   = new TypeNameItem(defaultType);
            AvailableTypes     = availableTypes;
            PrependedNamespace = string.IsNullOrEmpty(prependedNamespace) ? prependedNamespace : prependedNamespace + ".";

            PropertyChanged += MoveMembersToTypeDialogViewModel_PropertyChanged;
            OnDestinationUpdated();
        }
Exemplo n.º 2
0
        public static int CompareTo(TypeNameItem x, TypeNameItem y)
        {
            // sort so that history is first, then type name, then file name
            if (x.IsFromHistory ^ y.IsFromHistory)
            {
                // one is from history and the other isn't
                return(x.IsFromHistory ? -1 : 1);
            }
            // compare by each namespace/finally type
            var xnames = x.TypeName.Split('.');
            var ynames = y.TypeName.Split('.');

            for (var i = 0; i < Math.Min(xnames.Length, ynames.Length); i++)
            {
                var comp = xnames[i].CompareTo(ynames[i]);
                if (comp != 0)
                {
                    return(comp);
                }
            }

            return(x.DeclarationFileName.CompareTo(y.DeclarationFileName));
        }