Candidate of Regex that matches Fully Qualified Names

With the help of Juanmi, and after a few polishing, it works!

(?:([\.\D]+\,\s*){1,2}(?i)Version\=(\d+\.){3}\d+\,\s*(?i)Culture\=[\w\-]+\,\s*(?i)PublicKeyToken\=[\w]{16})

For instance, the following qualified names will be matched:

System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.data, version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
myTypes, Version=1.0.1234.0, Culture=en-US, PublicKeyToken=b77a5c561934e089c

For sure, there will be a lot of cases when the Regex will match incorrectly, but I think it covers most of cases 🙂

ReactiveUI. Excluding already chosen items.

This situation is quite common. Only certain items are available for selection. In the sample, we have 3 hotel rooms and 3 guests. When you assign one guest to a room and want to assign another guest, the first shouldn’t appear on the list of selectable guests. This is done using a derived collection with a filter.

person => !person.IsAdded || (person.IsAdded && Equals(person, SelectedPerson))

Untitled

using System.Collections.Generic;
using System.Linq;
using MEFedMVVM.ViewModelLocator;
using ReactiveUI;

namespace WpfApplication3
{
    [ExportViewModel("Main")]
    public class MainViewModel : ReactiveObject
    {
        public MainViewModel()
        {
            var people = new ReactiveList<Person>
            {
                new Person("Jim"),
                new Person("Tom"),
                new Person("Jack"),
            };
            people.ChangeTrackingEnabled = true;

            Rooms = new ReactiveList<Room>(people.Select((person, i) => new Room(people, string.Format("Room {0}", i))));
        }

        public IReactiveList<Room> Rooms { get; private set; }
    }

    public class Room : ReactiveObject
    {
        private readonly string name;
        private Person selectedPerson;

        public Room(IEnumerable<Person> people, string name)
        {
            this.name = name;
            People = people.CreateDerivedCollection(person => person, person => !person.IsAdded || (person.IsAdded && Equals(person, SelectedPerson)));
        }

        public IReactiveDerivedList<Person> People { get; set; }

        public Person SelectedPerson
        {
            get { return selectedPerson; }
            set
            {
                if (selectedPerson != null)
                {
                    selectedPerson.IsAdded = false;
                }

                if (value != null)
                {
                    value.IsAdded = true;
                }

                this.RaiseAndSetIfChanged(ref selectedPerson, value);
            }
        }

        public string Name
        {
            get { return name; }
        }
    }

    public class Person : ReactiveObject
    {
        private readonly string name;
        private bool isAdded;

        public Person(string name)
        {
            this.name = name;
        }

        public string Name
        {
            get { return name; }
        }

        public bool IsAdded
        {
            get { return isAdded; }
            set { this.RaiseAndSetIfChanged(ref isAdded, value); }
        }

        private bool Equals(Person other)
        {
            return string.Equals(name, other.name);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != this.GetType()) return false;
            return Equals((Person)obj);
        }

        public override int GetHashCode()
        {
            return name.GetHashCode();
        }
    }
}