Click here to Skip to main content
15,896,269 members
Home / Discussions / C#
   

C#

 
Questionhow to know a file is accessed by another process Pin
NotProfessional3-Nov-03 17:13
NotProfessional3-Nov-03 17:13 
AnswerRe: how to know a file is accessed by another process Pin
Heath Stewart4-Nov-03 3:20
protectorHeath Stewart4-Nov-03 3:20 
GeneralRe: Using ADO Recordset.AddNew in C# Pin
Heath Stewart4-Nov-03 3:03
protectorHeath Stewart4-Nov-03 3:03 
QuestionImage composition ?? Pin
azusakt3-Nov-03 14:26
azusakt3-Nov-03 14:26 
AnswerRe: Image composition ?? Pin
Christian Graus3-Nov-03 15:01
protectorChristian Graus3-Nov-03 15:01 
GeneralCreating Attributes At Run Time Pin
Markyg3-Nov-03 14:02
Markyg3-Nov-03 14:02 
GeneralRe: Creating Attributes At Run Time Pin
Mike Ellison4-Nov-03 2:51
Mike Ellison4-Nov-03 2:51 
GeneralRe: Creating Attributes At Run Time Pin
Heath Stewart4-Nov-03 3:00
protectorHeath Stewart4-Nov-03 3:00 
Actually, you cannot create attributes at runtime. They represent meta-data, or data that describes data (the compiled code). They are set only by the compiler for the particular source file.

However, there are a couple ways around this. The first it so emit an assembly (see System.Reflection.Emit) and attribute a emitted class with attributes before compiling the assembly.

The second way is to implement ICustomTypeDescriptor. For the most part, most methods can use the appropriate overloaded TypeDescriptor method that takes a bool dictating whether or not to query for said interface (that way, while you still have to implement every method, you don't have to write any custom code when you don't need to). In your implementation of ICustomTypeDescriptor.GetAttributes, return a custom set of attribute classes.

Implementing ICustomTypeDescriptor is only useful when something uses the TypeDescriptor class (or something else that uses it, like the PropertyGrid component - we the interface to custom some of this stuff in a runtime grid in our app). Of course, a class of yours could query for it, too, but usually the TypeDescriptor is sufficient.

 

-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
GeneralRe: Creating Attributes At Run Time Pin
Mike Ellison4-Nov-03 6:20
Mike Ellison4-Nov-03 6:20 
GeneralRe: Creating Attributes At Run Time Pin
Markyg4-Nov-03 10:34
Markyg4-Nov-03 10:34 
GeneralRe: Creating Attributes At Run Time Pin
Roger Alsing4-Nov-03 3:52
Roger Alsing4-Nov-03 3:52 
GeneralWAN IP address Pin
marnicola3-Nov-03 13:10
marnicola3-Nov-03 13:10 
GeneralRe: WAN IP address Pin
Heath Stewart4-Nov-03 2:53
protectorHeath Stewart4-Nov-03 2:53 
GeneralRe: WAN IP address Pin
martiwy4-Nov-03 20:30
martiwy4-Nov-03 20:30 
GeneralRe: WAN IP address Pin
marnicola5-Nov-03 12:02
marnicola5-Nov-03 12:02 
GeneralRe: WAN IP address Pin
martiwy6-Nov-03 7:05
martiwy6-Nov-03 7:05 
GeneralRe: WAN IP address Pin
marnicola9-Nov-03 16:47
marnicola9-Nov-03 16:47 
Generalproblem Pin
bora3ee3-Nov-03 12:54
bora3ee3-Nov-03 12:54 
GeneralRe: problem Pin
Divyesh Virani3-Nov-03 19:39
Divyesh Virani3-Nov-03 19:39 
GeneralZ Buffer question in D3d 9 Pin
Arturo Mayorga3-Nov-03 12:09
Arturo Mayorga3-Nov-03 12:09 
GeneralRe: Z Buffer question in D3d 9 Pin
Kentamanos3-Nov-03 12:25
Kentamanos3-Nov-03 12:25 
GeneralRe: Z Buffer question in D3d 9 Pin
Heath Stewart4-Nov-03 3:09
protectorHeath Stewart4-Nov-03 3:09 
Generalusing variable declared in another class [NEWBIE] Pin
Paolo Ponzano3-Nov-03 8:57
Paolo Ponzano3-Nov-03 8:57 
GeneralRe: using variable declared in another class [NEWBIE] Pin
Alvaro Mendez3-Nov-03 9:04
Alvaro Mendez3-Nov-03 9:04 
GeneralConfused about Resources Pin
Alvaro Mendez3-Nov-03 8:28
Alvaro Mendez3-Nov-03 8:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.