-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: LovedJohnySmith
Message 2 in Discussion
Sukh: You can achive this using Custom Attribute, lemmi explain with
small example here., the following code snippets illustrates the Authors like
"Shakesphere", "Tolstoy", i need to call the Authors by the method. please take
a look at the following code snippet. namespace MatchCS {
// A custom attribute to allow 2 authors per method.
public class AuthorsAttribute : Attribute {
public AuthorsAttribute(string name1, string name2) {
authorName1 = name1;
authorName2 = name2;
} protected string authorName1;
protected string authorName2;
public string AuthorName1 {
get { return authorName1; }
set { authorName1 = AuthorName1; }
} public string AuthorName2 {
get { return authorName2; }
set { authorName2 = AuthorName2; }
} } // Add some authors to methods of a class.
public class TestClass1 {
[Authors("William Shakespeare", "Herman Melville")]
public void Method1()
{} [Authors("Leo Tolstoy", "John Milton")]
public void Method2()
{}
} class DemoClass {
static void Main(string[] args) {
// Get the type for both classes to access their metadata.
Type clsType1 = typeof(TestClass1); // Iterate through
each method of the first class.
foreach(MethodInfo mInfo1 in clsType1.GetMethods()) {
// Check each method for the Authors attribute.
AuthorsAttribute authAttr1 = (AuthorsAttribute)
Attribute.GetCustomAttribute(mInfo1,
typeof(AuthorsAttribute));
if (authAttr1 != null) {
// Display the authors.
Console.WriteLine("Method {0} was authored by {1} " +
"and {2}.", mInfo1.Name,
authAttr1.AuthorName1,
authAttr1.AuthorName2);
Console.WriteLine("");
<<Here You need to cross check with this assigned user role with your user role
>>
}
}
}
}
}
For more clear information on this, please have a look at the code snippets
from following URL, which suitable for your question.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemattributeclassmatchtopic.asp
Thanx, Smith
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you
received this message by mistake, please click the "Remove" link below. On the
pre-addressed e-mail message that opens, simply click "Send". Your e-mail
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]