本文整理汇总了C#中Castle.DynamicProxy.Generators.Emitters.ClassEmitter.DefineCustomAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# ClassEmitter.DefineCustomAttribute方法的具体用法?C# ClassEmitter.DefineCustomAttribute怎么用?C# ClassEmitter.DefineCustomAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Castle.DynamicProxy.Generators.Emitters.ClassEmitter
的用法示例。
在下文中一共展示了ClassEmitter.DefineCustomAttribute方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Generate
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: Generate
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: Generate
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: CreateTypeAttributes
protected virtual void CreateTypeAttributes(ClassEmitter emitter)
{
emitter.AddCustomAttributes(ProxyGenerationOptions);
#if !SILVERLIGHT
emitter.DefineCustomAttribute<XmlIncludeAttribute>(new object[] { targetType });
#endif
}
示例5: CreateTypeAttributes
protected override void CreateTypeAttributes(ClassEmitter emitter)
{
base.CreateTypeAttributes(emitter);
#if (!SILVERLIGHT)
emitter.DefineCustomAttribute<SerializableAttribute>();
#endif
}
示例6: ReplicateNonInheritableAttributes
protected void ReplicateNonInheritableAttributes(Type targetType, ClassEmitter emitter)
{
object[] attrs = targetType.GetCustomAttributes(false);
foreach(Attribute attribute in attrs)
{
if (ShouldSkipAttributeReplication(attribute)) continue;
emitter.DefineCustomAttribute(attribute);
}
}
示例7: CreateTypeAttributes
protected override void CreateTypeAttributes(ClassEmitter emitter)
{
base.CreateTypeAttributes(emitter);
emitter.DefineCustomAttribute<SerializableAttribute>();
}
示例8: CreateTypeAttributes
protected virtual void CreateTypeAttributes(ClassEmitter emitter)
{
emitter.AddCustomAttributes(ProxyGenerationOptions);
#if FEATURE_SERIALIZATION
emitter.DefineCustomAttribute<XmlIncludeAttribute>(new object[] { targetType });
#endif
}
示例9: CreateTypeAttributes
// 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);
}
}