Hi David I've tried that here is my Attribute class:
using System;
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property, AllowMultiple = true)]
public class PermissionsAttribute : System.Attribute
{
public PermissionsAttribute(Permissions permission, String role)
{
this._permission = permission;
this._role = role;
}
private String _role;
public String Role
{
get { return this._role; }
set { this._role = value; }
}
private Permissions _permission;
public Permissions Permission
{
get { return this._permission; }
set { this._permission = value; }
}
public enum Permissions
{
ReadWrite,
ReadOnly,
Hidden
}
}Here is My Metadata class
using System;
using System.ComponentModel.DataAnnotations;
//using NotAClue;
[MetadataType(typeof(OrderMetadata))]
public partial class Order
{
}
[Permissions(PermissionsAttribute.Permissions.ReadOnly, "User")]
[Permissions(PermissionsAttribute.Permissions.ReadWrite, "Admin")]
public class OrderMetadata
{
[Permissions(PermissionsAttribute.Permissions.Hidden, "*")]
[Permissions(PermissionsAttribute.Permissions.ReadWrite, "Admin")]
public Object OrderDate { get; set; }
}
The problem I'm having is that if I include two attibute on the class (see above) I get the error below:
The main type 'Order' already contains at least one attribute of type 'PermissionsAttribute'.
And if I have two attributes on the property (see above) only the first on shows in the collection.
Steve
Seeking the elegant solution.
[Oh! If olny I colud tpye!

]
c# Bits blog