public virtual void Generate(ClassEmitter @class, ProxyGenerationOptions options)
		{
			var interceptors = @class.GetField("__interceptors");
#if !SILVERLIGHT
			ImplementGetObjectData(@class);
#endif
			ImplementProxyTargetAccessor(@class, interceptors);
			foreach (var attribute in targetType.GetNonInheritableAttributes())
			{
				@class.DefineCustomAttribute(attribute);
			}
		}
Пример #2
0
		public virtual void Generate(ClassEmitter @class, ProxyGenerationOptions options)
		{
			var interceptors = @class.GetField("__interceptors");
#if FEATURE_SERIALIZATION
			ImplementGetObjectData(@class);
#endif
			ImplementProxyTargetAccessor(@class, interceptors);
			foreach (var attribute in targetType.GetTypeInfo().GetNonInheritableAttributes())
			{
				@class.DefineCustomAttribute(attribute.Builder);
			}
		}
Пример #3
0
		public override void Generate(ClassEmitter @class, ProxyGenerationOptions options)
		{
			var interceptors = @class.GetField("__interceptors");
#if FEATURE_SERIALIZATION
			if (implementISerializable)
			{
				ImplementGetObjectData(@class);
				Constructor(@class);
			}
#endif
			ImplementProxyTargetAccessor(@class, interceptors);
			foreach (var attribute in targetType.GetNonInheritableAttributes())
			{
				@class.DefineCustomAttribute(attribute);
			}
		}
Пример #4
0
		protected virtual void CreateTypeAttributes(ClassEmitter emitter)
		{
			emitter.AddCustomAttributes(ProxyGenerationOptions);
#if !SILVERLIGHT
			emitter.DefineCustomAttribute<XmlIncludeAttribute>(new object[] { targetType });
#endif
		}
		protected override void CreateTypeAttributes(ClassEmitter emitter)
		{
			base.CreateTypeAttributes(emitter);
#if (!SILVERLIGHT)
			emitter.DefineCustomAttribute<SerializableAttribute>();
#endif
		}
Пример #6
0
		protected void ReplicateNonInheritableAttributes(Type targetType, ClassEmitter emitter)
		{
			object[] attrs = targetType.GetCustomAttributes(false);

			foreach(Attribute attribute in attrs)
			{
				if (ShouldSkipAttributeReplication(attribute)) continue;

				emitter.DefineCustomAttribute(attribute);
			}
		}
		protected override void CreateTypeAttributes(ClassEmitter emitter)
		{
			base.CreateTypeAttributes(emitter);
			emitter.DefineCustomAttribute<SerializableAttribute>();
		}
Пример #8
0
		protected virtual void CreateTypeAttributes(ClassEmitter emitter)
		{
			emitter.AddCustomAttributes(ProxyGenerationOptions);
#if FEATURE_SERIALIZATION
			emitter.DefineCustomAttribute<XmlIncludeAttribute>(new object[] { targetType });
#endif
		}
 // If it turns out the proxy type needs a parameterless constructor,
 // override the BuildClassEmitter method here, call base, and then
 // add a constructor to the ClassEmitter like this:
 // emitter.CreateConstructor(new ArgumentReference[0]);
 // If it turns out custom attributes also need to be copied at the
 // method/property/field level, the appropriate overrides need to happen
 // just like the CreateTypeAttributes override, below.
 /// <summary>
 /// Adds custom attributes to the generated type.
 /// </summary>
 /// <param name="emitter">The class emitter.</param>
 /// <remarks>
 /// <para>
 /// This override calls the base functionality and then uses the metadata
 /// buddy class (as specified by a <see cref="Autofac.Extras.Multitenant.Wcf.ServiceMetadataTypeAttribute"/>
 /// on the service interface) to copy over class-level attributes to the
 /// dynamic hosting proxy.
 /// </para>
 /// </remarks>
 /// <exception cref="System.ArgumentNullException">
 /// Thrown if <paramref name="emitter" /> is <see langword="null" />.
 /// </exception>
 protected override void CreateTypeAttributes(ClassEmitter emitter)
 {
     if (emitter == null)
     {
         throw new ArgumentNullException("emitter");
     }
     base.CreateTypeAttributes(emitter);
     if (_metadataBuddyType == null)
     {
         return;
     }
     var attribs = _metadataBuddyType.GetCustomAttributesData();
     foreach (var attrib in attribs)
     {
         var builder = attrib.ToAttributeBuilder();
         emitter.DefineCustomAttribute(builder);
     }
 }