/// <summary>
        /// Remove a validation rule for a specify property from existing.
        /// </summary>
        /// <example>
        /// RemoveRule(x => x.Surname)...
        /// </example>
        /// <typeparam name="TProperty">The type of property being validated</typeparam>
        /// <param name="expression">The expression representing the property to validate</param>
        /// <returns>Successed removed or not</returns>
        public bool RemoveRule <TProperty>(Expression <Func <T, TProperty> > expression)
        {
            expression.Guard("Cannot pass null to RemoveRule");
            var member = expression.GetMember();
            var rule   = nestedValidators.OfType <PropertyRule>().FirstOrDefault(s => s.Member == member);

            return(nestedValidators.Remove(rule));
        }
    public void RemovingItemsFromCollectionManuallyThrows()
    {
        var source = new Subject<Thing>();
        var col = new TrackingCollection<Thing>(source) { ProcessingDelay = TimeSpan.Zero };
        var count = 0;
        var expectedCount = 2;
        var evt = new ManualResetEvent(false);

        col.Subscribe(t =>
        {
            if (++count == expectedCount)
                evt.Set();
        }, () => { });

        Add(source, GetThing(1, 1));
        Add(source, GetThing(2, 2));
        evt.WaitOne();
        evt.Reset();
        Assert.Throws<InvalidOperationException>(() => col.Remove(GetThing(1)));
        col.Dispose();
    }
Esempio n. 3
0
 public static void RemoveTracking <T>(TrackingCollection <T> collection, T item, out TrackingCollection <T> collectionOut, out T itemOut)
 {
     collection.Remove(item);
     collectionOut = collection;
     itemOut       = item;
 }
Esempio n. 4
0
 public static void RemoveEnity(TrackingCollection <Entity> collection, Entity item, out TrackingCollection <Entity> collectionOut, out Entity itemOut)
 {
     collection.Remove(item);
     collectionOut = collection;
     itemOut       = item;
 }