CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Language: C#

Extender<T>

161 Views
Copy Code Show/Hide Line Numbers
using LinqExtender.Configuration.Serialization;
 
namespace LinqExtender.Configuration
{
    /// <summary>
    /// Fluent generic entry point for configuration settings.
    /// </summary>
    /// <typeparam name="T">query object</typeparam>
    public class Extender<T> : IClassSettings<T>
    {
        /// <summary>
        /// Creates a new instance of <see cref="Extender{T}"/> class.
        /// </summary>
        /// <param name="extender">generic <see cref="Extender"/></param>
        /// <param name="classDescriptor">class settings.</param>
        public Extender(Extender extender, ClassDescriptor classDescriptor)
        {
            this.extender = extender;
            this.classDescriptor = classDescriptor;
        }
 
        /// <summary>
        /// Maps a class to an entity.
        /// </summary> 
        /// <param name="entityName"></param>
        /// <returns></returns>
        public IClassSettings<T> MapToEntity(string entityName)
        {
            classDescriptor.Name = entityName;
            return this;
        }
 
        /// <summary>
        /// Property Settings iterator.
        /// </summary>
        public IPropertySettings<T> Begin
        {
            get
            {
                return new PropertySettings<T>(this, classDescriptor);
            }
        }
 
        /// <summary>
        /// Builds and intantiates <see cref="ExtenderElement"/> and invokes <see cref="Query{T}.BuildSettingElement"/> method
        /// to build the <see cref="ClassElement"/> for current type.
        /// </summary>
        public void InstantiateIn(object obj)
        {
            extender.InstantiateIn(obj);
        }
 
        internal Extender GenericExtender
        {
            get
            {
                return extender;
            }
        }
      
        private readonly ClassDescriptor classDescriptor;
        private readonly Extender extender;
    }
}
by Athens Springer
  December 17, 2009 @ 10:13pm
Tags:

Add a comment


Report Abuse
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate