/// <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);
        }
示例#2
0
        internal override void BuildConfiguration(ConfigurationBuildContext buildContext)
        {
            if ((null == this._baseToProxyConversionDelegate) && (null == this._proxyToBaseConversionDelegate))
            {
                return;
            }

            var proxyProperty = new ProxyPropertyInfo
            {
                Attributes                  = this.Property.GetCustomAttributes().ToList(),
                PropertyName                = this.Property.Name,
                BasePropertyInfo            = this.Property,
                ConversionToProxyDelegate   = this._baseToProxyConversionDelegate,
                ConversionFromProxyDelegate = this._proxyToBaseConversionDelegate,
                ExcludeFromProxy            = false
            };

            buildContext.ProxyProperties.Add(proxyProperty);
        }
示例#3
0
 internal abstract void BuildConfiguration(ConfigurationBuildContext buildContext);
 internal override void BuildConfiguration(ConfigurationBuildContext buildContext)
 {
 }