/// <summary>
        /// Prepares the entity serialization configuration to be bound to the Xml serializer.
        /// </summary>
        /// <param name="context">Xml serializer context that the entity will be bound to.</param>
        internal void ConfigureEntity(SerializerConfigurationContext context)
        {
            var buildContext = new ConfigurationBuildContext();

            foreach (var p in this.PropertyConfigurations)
            {
                p.BuildConfiguration(buildContext);
            }

            if (false == buildContext.ProxyProperties.Any())
            {
                return;
            }

            var moduleBuilder    = ProxyModuleBuilder.GetInstance(this._contextType);
            var proxyImplementer = ProxyTypeImplementer.GetInstance(this.EntityType, moduleBuilder);
            var proxyProperties  = this.EntityType.GetProperties()                                                       // Get all of the properties from the entity
                                   .Where(e => e.CanRead && e.CanWrite)                                                  // That have setters and getters
                                   .Where(e => false == buildContext.ProxyProperties.Any(i => i.PropertyName == e.Name)) // That are not overridden by one of the property configs
                                   .Select(this.CreateProxyProperty)                                                     // And build up a proxy property info object for each
                                   .Union(buildContext.ProxyProperties)                                                  // Combine these with the overridden proxy properties
                                   .ToArray();

            foreach (var p in proxyProperties)
            {
                proxyImplementer.AddPropertyInfo(p);
            }

            var proxyType = proxyImplementer.BuildProxyType();

            context.ProxyTypes.Add(this.EntityType, proxyType);
        }
        /// <summary>
        /// Binds the entity configuration to the Xml serializer context.
        /// </summary>
        /// <param name="context">Xml serializer context to bind the configured entity to.</param>
        internal void BindEntityToModel(SerializerConfigurationContext context)
        {
            var bindingContext = new ConfigurationBindingContext
            {
                Overrides  = context.Attributes,
                ProxyTypes = new ReadOnlyDictionary <Type, Type>(context.ProxyTypes),
                EntityType = this.EntityType
            };

            Type entityProxyType;

            if (context.ProxyTypes.TryGetValue(this.EntityType, out entityProxyType))
            {
                bindingContext.EntityType = entityProxyType;
            }

            foreach (var p in this.PropertyConfigurations)
            {
                p.BindConfiguration(bindingContext);
            }
        }