/// <summary>
 /// Creates a new instance of the proxy type implementer. The constructor is private to force the use of the Create method which uses the compiler to enforce that
 /// the base type is a class type without making this class a generic type.
 /// </summary>
 /// <param name="baseType">Base type to implement a proxy type for.</param>
 /// <param name="moduleBuilder">Instance of the module builder for this serializer context.</param>
 private ProxyTypeImplementer(Type baseType, ProxyModuleBuilder moduleBuilder)
 {
     this._baseType      = baseType;
     this._moduleBuilder = moduleBuilder;
     this._properties    = baseType.GetProperties(BindingFlags.Instance)
                           .Where(e => e.CanRead && e.CanWrite)
                           .ToDictionary(e => e.Name, this.GetDefaultProxyPropertyImplementer);
 }
Example #2
0
        /// <summary>
        /// Gets a singleton instance of the proxy module builder.
        /// </summary>
        internal static ProxyModuleBuilder GetInstance(Type contextType)
        {
            ProxyModuleBuilder context;

            if (_proxyModuleBuilders.TryGetValue(contextType, out context))
            {
                return(context);
            }

            context = new ProxyModuleBuilder();
            _proxyModuleBuilders.Add(contextType, context);
            return(context);
        }
Example #3
0
        /// <summary>
        /// Gets a singleton instance of the proxy module builder.
        /// </summary>
        internal static ProxyModuleBuilder GetInstance <T>()
            where T : XmlSerializerContext
        {
            ProxyModuleBuilder context;

            if (_proxyModuleBuilders.TryGetValue(typeof(T), out context))
            {
                return(context);
            }

            context = new ProxyModuleBuilder();
            _proxyModuleBuilders.Add(typeof(T), context);
            return(context);
        }
 /// <summary>
 /// Creates a new instance of a proxy type implementer for the given type.
 /// </summary>
 /// <param name="baseType">Base type that the proxy is to be implemented for.</param>
 /// <param name="moduleBuilder">Instance of the module builder for this serializer context.</param>
 /// <returns>New instance of a proxy type implementer for the given type <paramref name="baseType"/>.</returns>
 internal static ProxyTypeImplementer GetInstance(Type baseType, ProxyModuleBuilder moduleBuilder)
 {
     return(new ProxyTypeImplementer(baseType, moduleBuilder));
 }
 /// <summary>
 /// Creates a new instance of a proxy type implementer for type <typeparamref name="T"/>.
 /// </summary>
 /// <typeparam name="T">Base type that the proxy is to be implemented for.</typeparam>
 /// <returns>New instance of a proxy type implementer for the given type <typeparamref name="T"/>.</returns>
 internal static ProxyTypeImplementer GetInstance <T>(ProxyModuleBuilder moduleBuilder)
     where T : class
 {
     return(new ProxyTypeImplementer(typeof(T), moduleBuilder));
 }