/// <summary> /// Reveals any hidden members using the given property name and revealing convention. /// </summary> /// <param name="name"> /// The property name. /// </param> /// <param name="convention"> /// The convention. /// </param> /// <returns> /// The name of the hidden member. /// </returns> /// <exception cref="ArgumentException"> /// <paramref name="name" /> is null or empty. /// </exception> /// <exception cref="ArgumentNullException"> /// <paramref name="convention" /> is null. /// </exception> protected virtual string Reveal(string name, IRevealConvention convention) { if (string.IsNullOrEmpty(name)) { throw new ArgumentException("name"); } if (convention == null) { throw new ArgumentNullException("convention"); } if (name.Contains(".")) { string[] splits = name.Split('.'); string temp = string.Empty; for (int i = 0; i < splits.Length - 1; i++) { temp += splits[i] + "."; } return(temp + convention.RevealFrom(splits[splits.Length - 1])); } return(convention.RevealFrom(name)); }
public new IFetchBuilder <IDummyQuery3> Fetch ( Expression <Func <UserEntity, object> > expression, Expression <Func <object> > alias = null, IRevealConvention revealConvention = null ) { throw new NotImplementedException(); }
/// <summary> /// Sets the default <see cref="IRevealConvention" /> instance (<seealso cref="DefaultConvention" />). /// </summary> /// <param name="convention"> /// The <see cref="IRevealConvention" /> instance. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="convention" /> is null. /// </exception> public static void SetDefaultConvention(IRevealConvention convention) { if (convention == null) { throw new ArgumentNullException("convention"); } DefaultConvention = convention; }
/// <summary> /// Sets the default <see cref="IRevealConvention" /> instance (<seealso cref="DefaultConvention" />) using /// the specified convention. /// </summary> /// <param name="convention"> /// The convention. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="convention" /> is null. /// </exception> public static void SetDefaultConvention(Func <string, string> convention) { if (convention == null) { throw new ArgumentNullException("convention"); } DefaultConvention = new CustomConvention(convention); }
/// <inheritdoc /> public virtual string Reveal ( Expression <Func <TEntity> > alias, Expression <Func <TEntity, object> > expression, IRevealConvention convention ) { return(Reveal <TEntity>(alias, expression, convention)); }
/// <summary> /// Initializes a new instance of the <see cref="RevealerBase" /> class. /// </summary> /// <param name="convention"> /// The <see cref="IRevealConvention" /> instance. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="convention" /> is null. /// </exception> protected RevealerBase(IRevealConvention convention) { if (convention == null) { throw new ArgumentNullException("convention"); } RevealConvention = convention; }
/// <summary> /// Reveals any hidden members using the provided expression and revealing convention. /// </summary> /// <param name="expression"> /// The expression. /// </param> /// <param name="convention"> /// The revealing convention. /// </param> /// <typeparam name="TEntity"> /// The <see cref="System.Type" /> of the entity. /// </typeparam> /// <returns> /// The hidden member name. /// </returns> public static string ByConvention <TEntity> ( Expression <Func <TEntity, object> > expression, IRevealConvention convention ) { IRevealer revealer = new Revealer(convention); return(revealer.Reveal(expression)); }
/// <inheritdoc /> public virtual string Reveal(Expression <Func <object> > expression, IRevealConvention convention) { if (expression == null) { throw new ArgumentNullException("expression"); } string property = ExpressionHelper.GetPropertyName(expression.Body); return(Reveal(property, convention)); }
/// <inheritdoc /> public IFilterableQuery <TSource> Join <TAlias> ( Expression <Func <TSource, object> > projection, Expression <Func <TAlias> > alias, IRevealConvention revealConvention ) { _joinBuilder.Join(projection, alias, revealConvention); return(_query); }
public void SetDefaultConventionThrowsIfConventionIsNull() { IRevealConvention c = null; // ReSharper disable once ExpressionIsAlwaysNull Assert.That(() => Reveal.SetDefaultConvention(c), Throws.InstanceOf <ArgumentNullException>()); Func <string, string> d = null; // ReSharper disable once ExpressionIsAlwaysNull Assert.That(() => Reveal.SetDefaultConvention(d), Throws.InstanceOf <ArgumentNullException>()); }
/// <inheritdoc /> public IFilterableQuery <T> Join <TAlias> ( Expression <Func <T, object> > projection, Expression <Func <TAlias> > alias, IRevealConvention revealConvention ) { var temp = _rebaser.RebaseTo <TSource, object>(projection); _joinBuilder.Join(temp, alias, revealConvention); return(_query); }
/// <inheritdoc /> public virtual IFetchBuilder <TQuery> Fetch ( Expression <Func <TSource, object> > expression, Expression <Func <object> > alias = null, IRevealConvention revealConvention = null ) { if (revealConvention == null) { revealConvention = Reveal.DefaultConvention ?? new CustomConvention(x => x); } string path = Reveal.ByConvention(expression, revealConvention); string aliasValue = alias != null ? ExpressionHelper.GetPropertyName(alias) : path; return(FetchCore(path, aliasValue)); }
/// <inheritdoc /> public virtual string Reveal <TEntity> ( Expression <Func <TEntity> > alias, Expression <Func <TEntity, object> > expression, IRevealConvention convention ) { if (expression == null) { throw new ArgumentNullException("expression"); } if (alias == null) { throw new ArgumentNullException("alias"); } string property = ExpressionHelper.GetPropertyName(expression); string aliasName = ExpressionHelper.GetPropertyName(alias); return(Reveal(aliasName + "." + property, convention)); }
/// <summary> /// Initializes a new instance of the <see cref="Revealer" /> class. /// </summary> /// <param name="convention"> /// The <see cref="IRevealConvention" /> convention. /// </param> public Revealer(IRevealConvention convention) : base(convention) { }
/// <summary> /// Creates a new <see cref="IRevealer" /> instance using the specified <see cref="IRevealConvention" /> /// instance. /// </summary> /// <param name="convention"> /// The <see cref="IRevealConvention" /> instance. /// </param> /// <returns> /// The created <see cref="IRevealer" /> instance. /// </returns> public static IRevealer CreateRevealer(IRevealConvention convention) { return(new Revealer(convention)); }
/// <summary> /// Creates a new <see cref="IRevealer{TEntity}" /> instance using the specified /// <see cref="IRevealConvention" /> instance. /// </summary> /// <param name="convention"> /// The <see cref="IRevealConvention" /> instance. /// </param> /// <typeparam name="TEntity"> /// The <see cref="System.Type" /> of the entity. /// </typeparam> /// <returns> /// The created <see cref="IRevealer{TEntity}" /> instance. /// </returns> public static IRevealer <TEntity> CreateRevealer <TEntity>(IRevealConvention convention) { return(new Revealer <TEntity>(convention)); }
/// <summary> /// Removes the default <see cref="IRevealConvention" /> instance (<seealso cref="DefaultConvention" />). /// </summary> public static void ClearDefaultConvention() { DefaultConvention = null; }