Hi!
I decorate my unfinished classes and methods with a custom TODO
attribute (as in things To Do). Using reflection, I am then able to
parse through my classes and output all TODOs to a list I can examine
to figure out what is left to be done in my application.
The attribute is coded thusly:
AttributeUsage( (AttributeTarge ts.Class | AttributeTarget s.Method),
AllowMultiple=t rue)]
public class ToDoAttribute : System.Attribut e {
// Private member data
private string _comment;
private string _date;
private string _programmer;
public ToDoAttribute(s tring programmer, string myDate) {
this._programme r = programmer;
this._date = myDate;
}
public string Comment {
get {
return _comment;
}
set {
_comment = value;
}
}
public string LogDate {
get {
return _date;
}
}
public string Programmer {
get {
return _programmer;
}
}
}
All is well and good until I try to decorate a partial class in the
code-behind of an ASP.Net page like this:
[ToDo("hardie.ca ", "2007-07-16", Comment = "Fix recursion!")]
partial class admin_Section : System.Web.UI.P age
The problem is the function that examines all the types in my
application only discovers the TODO decorations if they are decorating
classes or methods that reside in the App_Code folder. I would like to
be able to discover these attributes in webpages that reside outside
of App_Code. I understand that assemblies are generated dynamically
using voodoo I don't fully comprehend, but I would have thought that
by calling AppDomain.curre ntDomain.GetAss emblies() I would have been
able reference all assemblies.
I am trying to output a webpage that publishes my list of TODOs, is it
possible that the assemblies that contain the pages with the partial
classes I'm decorating have not been created when I try to discover
their attributes? Any help would be very much appreciated!
The page that lists all TODOs has the following method:
protected void Page_Unload(obj ect sender, System.EventArg s e) {
AppDomain currentDomain = AppDomain.Curre ntDomain;
Assembly[] assems = currentDomain.G etAssemblies();
string alltypes = "";
Assembly assem;
foreach (assem in assems) {
Type[] types = assem.GetTypes( );
foreach (Type t in types) {
MemberInfo inf = t;
object[] attributes;
attributes =
inf.GetCustomAt tributes(typeof (ToDoAttribute) , false);
foreach (object attribute in attributes) {
ToDoAttribute todo = (ToDoAttribute) attribute;
alltypes = (alltypes + ("<p>" + (t.ToString() +
"<br>")));
alltypes = (alltypes + ("Programmer : "
+ (todo.Programme r + "<br>")));
alltypes = (alltypes + ("Date: "
+ (todo.LogDate + "<br>")));
alltypes = (alltypes + ("Comments: "
+ (todo.Comment + "</p>")));
}
}
}
this.lblLabel.T ext = alltypes;
} 1 2147
there is little voodoo. every page is complied to a dll (if batching is
on, several pages may endup in the same dll). if your site is not
precompiled then the page dll's are created on first reference.
note: asp.net site run from temp folders were all the dll's are copied
to, and new compiles done. this is so site dll's can be updated (avoid
inuse error with copy).
-- bruce (sqlwork.com) ha******@hotmai l.com wrote:
Hi!
I decorate my unfinished classes and methods with a custom TODO
attribute (as in things To Do). Using reflection, I am then able to
parse through my classes and output all TODOs to a list I can examine
to figure out what is left to be done in my application.
The attribute is coded thusly:
AttributeUsage( (AttributeTarge ts.Class | AttributeTarget s.Method),
AllowMultiple=t rue)]
public class ToDoAttribute : System.Attribut e {
// Private member data
private string _comment;
private string _date;
private string _programmer;
public ToDoAttribute(s tring programmer, string myDate) {
this._programme r = programmer;
this._date = myDate;
}
public string Comment {
get {
return _comment;
}
set {
_comment = value;
}
}
public string LogDate {
get {
return _date;
}
}
public string Programmer {
get {
return _programmer;
}
}
}
All is well and good until I try to decorate a partial class in the
code-behind of an ASP.Net page like this:
[ToDo("hardie.ca ", "2007-07-16", Comment = "Fix recursion!")]
partial class admin_Section : System.Web.UI.P age
The problem is the function that examines all the types in my
application only discovers the TODO decorations if they are decorating
classes or methods that reside in the App_Code folder. I would like to
be able to discover these attributes in webpages that reside outside
of App_Code. I understand that assemblies are generated dynamically
using voodoo I don't fully comprehend, but I would have thought that
by calling AppDomain.curre ntDomain.GetAss emblies() I would have been
able reference all assemblies.
I am trying to output a webpage that publishes my list of TODOs, is it
possible that the assemblies that contain the pages with the partial
classes I'm decorating have not been created when I try to discover
their attributes? Any help would be very much appreciated!
The page that lists all TODOs has the following method:
protected void Page_Unload(obj ect sender, System.EventArg s e) {
AppDomain currentDomain = AppDomain.Curre ntDomain;
Assembly[] assems = currentDomain.G etAssemblies();
string alltypes = "";
Assembly assem;
foreach (assem in assems) {
Type[] types = assem.GetTypes( );
foreach (Type t in types) {
MemberInfo inf = t;
object[] attributes;
attributes =
inf.GetCustomAt tributes(typeof (ToDoAttribute) , false);
foreach (object attribute in attributes) {
ToDoAttribute todo = (ToDoAttribute) attribute;
alltypes = (alltypes + ("<p>" + (t.ToString() +
"<br>")));
alltypes = (alltypes + ("Programmer : "
+ (todo.Programme r + "<br>")));
alltypes = (alltypes + ("Date: "
+ (todo.LogDate + "<br>")));
alltypes = (alltypes + ("Comments: "
+ (todo.Comment + "</p>")));
}
}
}
this.lblLabel.T ext = alltypes;
} This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: nospam |
last post by:
Ok, I asked this question before and I also looked at the book "First Look
at ASP.NET 2.0"
I also read Paul wilson's web page explanation. HOWEVER......
The book and that web page talks about partial types and that IF you have a
Extends keyword, I think, before the class name AND the same Namespace, .NET
will automatically compile the rest of the class that is located in another
file.
However, I want to know just exactly how is .NET...
|
by: nospam |
last post by:
I got three (3) files
(1) Untitled.aspx
(2) Untitled.aspx.1.cs
(3) Untitled.aspx.2.cs
These three files must be used together to make file #1, Untitled.aspx, page
work via
J.I.T. when the User first hits Internet Explorer 6.0 on your browser.
|
by: pawel.pabich |
last post by:
Hajo,
I would like to have 2 my own partial classes.
For example:
Default.aspx.cs
Default2.aspx.cs
and they both will relate to
Default.aspx page.
|
by: Julian Jelfs |
last post by:
Hi,
I had an aspx pag in .Net 1.1 with a label on it. As such I had a code
behind page with a declaration for that label.
When I convert to Asp.Net 2.0 the code behind is converted to a partial
class and the declaration for the label is removed. This is what I expected
to happen and I understand why it has happened.
The problem I have is that I had added a custom attribute to my label
|
by: ptass |
last post by:
Hi
In asp.net 2.0 an aspx files .cs file is a partial class and all works fine,
however,
I thought I’d be able to create another class file, call it a partial class
and have
that compile and load as a 3rd partial class. This would be handy so i can
generate
standard code into one of the partial classes, while having my custom code
untouched
| |
by: Atul Thombre |
last post by:
Hello,
I am developing a custom membership provider. For that I built a prototype
that uses a SQL Server 2005 database as a backend store. I implemented the
class System.Web.Security.MembershipProvider and implemented few necessary
methods. The methods use SQL for interacting with the SQL Server database. I
put all this code in a class library.
I also created a simple Website using Visual Studio 2005 and configured the
Web.config to...
|
by: SAL |
last post by:
Hello,
I would like to be able to set the WHERE clause of a select statement on the
fly. I have a DataAccess layer designed using the DataSet designer and a
BusinessLogic layer using classes. The business logic layer is decorated
using the
<System.ComponentModel.DataObject()>
attributes and they are used to bind to controls and Object datasets on web
forms.
Is there a resonable way to set the WHERE clause on the fly with a partial
class...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |