/// <summary> /// Initializes a new instance. /// </summary> /// <param name="query"></param> internal ObservableView(ObservableQuery <TElement> query) { expression = query.Expression; // establish root operation, hook up events, and load operation = (Operation <IEnumerable <TElement> >)OperationFactory.FromExpression <IEnumerable <TElement> >(new OperationContext(), expression); SubscribeOperation(operation); OperationChanged(null, operation.Value); }
/// <summary> /// Enables or disables null protection for the given <see cref="ObservableQuery"/>. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="self"></param> /// <returns></returns> public static ObservableQuery <T> WithNullSafe <T>(this ObservableQuery <T> self, bool enable) { Contract.Requires <ArgumentNullException>(self != null); return((ObservableQuery <T>)self.Provider.CreateQuery <T>( Expression.Call( WithNullSafeMethodInfo.MakeGenericMethod(typeof(T)), Expression.Convert(self.Expression, typeof(ObservableQuery <T>)), Expression.Constant(enable, typeof(bool))))); }
/// <summary> /// Enables or disables null protection for the given <see cref="ObservableQuery"/>. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="self"></param> /// <returns></returns> public static ObservableQuery <T> WithNullSafe <T>(this ObservableQuery <T> self, bool enable) { if (self == null) { throw new ArgumentNullException(); } return((ObservableQuery <T>)self.Provider.CreateQuery <T>( Expression.Call( WithNullSafeMethodInfo.MakeGenericMethod(typeof(T)), Expression.Convert(self.Expression, typeof(ObservableQuery <T>)), Expression.Constant(enable, typeof(bool))))); }