public static void Main()
TestAuthorAttribute.Test();
[System.AttributeUsage(System.AttributeTargets.Class |
System.AttributeTargets.Struct)
public class CouchbaseCollectionAttribute : System.Attribute
public string collection;
public CouchbaseCollectionAttribute(string collection)
this.collection = collection;
public string GetCollection()
[System.AttributeUsage(System.AttributeTargets.Class |
System.AttributeTargets.Struct)
public class CouchbaseScopeAttribute : System.Attribute
public CouchbaseScopeAttribute( string scope)
[CouchbaseScope("entity")]
[CouchbaseCollection("firstclass")]
[CouchbaseCollection("secondclass")]
[CouchbaseCollection("thirdclass")]
[CouchbaseScope("entity")]
public class TestAuthorAttribute
public static void Test()
PrintScopeInfo(typeof(FirstClass));
PrintCollectionInfo(typeof(FirstClass));
PrintCollectionInfo(typeof(SecondClass));
PrintCollectionInfo(typeof(ThirdClass));
private static void PrintScopeInfo(System.Type t)
System.Attribute[] attrs = System.Attribute.GetCustomAttributes(t);
foreach (System.Attribute attr in attrs)
if (attr is CouchbaseScopeAttribute)
CouchbaseScopeAttribute a = (CouchbaseScopeAttribute)attr;
System.Console.WriteLine(" Collection: {0}", a.GetScope());
private static void PrintCollectionInfo(System.Type t)
System.Attribute[] attrs = System.Attribute.GetCustomAttributes(t);
foreach (System.Attribute attr in attrs)
if (attr is CouchbaseCollectionAttribute)
CouchbaseCollectionAttribute a = (CouchbaseCollectionAttribute)attr;
System.Console.WriteLine(" Collection: {0}", a.GetCollection());