|
petermeter wrote: please, I don't know exactly, when/in which moment of my code execution is a customAttribute constructor of MyCustomAttribute:System.Attribute class called/activated
Are you using Visual Studio? Do breakpoints not work for you?
led mike
|
|
|
|
|
Yes, 2008 version.
I discovered that the attribute constructor is activated/initiated when I enumerate attributes of MyMethod...
[Security("Admin")]
public void MyMethod()
{
... Attribute.GetCustomAttributes(....., typeof(....))
...method body
}
but I'd like activate/initiate attribute constructor without MyMethod body modification by .GetCustomAttributes...
and therefore I'm asking - exist a way how to perform custom attribute constructor automatically ?
[Security("Admin")]
public void MyMethod()
{
...method body
}
thanks,
Peter.
|
|
|
|
|
It shouldn't matter. But more detail on what you're trying to accomplish might be helpful.
|
|
|
|
|
Hello everyone,
I want to learn from your advice about how to design data structure in the following scenario to be most efficient.
One thread will create data (composed of ID and content), and output to a queue or something (data structure could be chosen to make the scenario more efficient), the data created is very frequently working to produce data, another thread is responsible to aggregate data (for the same ID, aggregate the content and output to a file), and aggregation thread works less frequently -- sleep 10 minutes, aggregate and then sleep again.
I am going to find a solution which could balance,
1. Less performance impact to the data creating thread;
2. To make data aggregation thread works as efficient as possible and consume less memory.
Any advice about how to design data structures?
Currently,
- I am stupidly using a List, appending data by the data creation thread, and I think appending data to the List is less performance impact to data create thread than using Dictionary to insert. Am I correct?
- Read data from begin to end of another thread -- using ID as key into a Dictionary, since there maybe duplicate ID, so when I insert into the Dictionary, I will check if contains key, if yes, I will update the data, or else insert a new one;
- Using lock on the whole List to make thread safe. Does the lock on the whole List is too heavy?
Any smarter ways?
thanks in advance,
George
|
|
|
|
|
I am thinking this would be better done with a database. Databases have built in functions for maintaining ID's. They also have functions for aggregating the data in most ways you can think of.
|
|
|
|
|
Thanks Christian,
Is there a built-in data structure like MuitlMap in C++, which allows one key maps to multiple values in C#?
regards,
George
|
|
|
|
|
|
Thanks Christian,
If not using database, any ideas about what is the best solution you could have with memory based data structures?
regards,
George
|
|
|
|
|
Can anybody give me the sample code for this.
program that takes as its first argument one of the words 'sum,' 'product,' 'mean,' or 'sqrt' and for further arguments a series of numbers. The program applies the appropriate function to the series.
Requires basic control flow, basic operators, and the math library. (Complex numbers available?)
What are arrays like?
What about parsing / implicit conversion?
Are functions first-class (availability of Map() and Apply())?
Error handling: What happens on invalid data?
Free sample codes are here http://allabout-dotnet.blogspot.com
|
|
|
|
|
How about doing your own homework.
He who makes a beast out of himself gets rid of the pain of being a man
|
|
|
|
|
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
smileguy wrote: program that takes as its first argument one of the words 'sum,' 'product,' 'mean,' or 'sqrt' and for further arguments a series of numbers
Do you mean takes as command line parameters. Or takes as input via the console. Or takes as input via a windows form. Or takes as input via....
smileguy wrote: Requires basic control flow, basic operators, and the math library.
Naturally, what else would it have?
smileguy wrote: What are arrays like?
They are like sequential list of things.
smileguy wrote: What about parsing / implicit conversion?
I don't know what you mean by that.
smileguy wrote: Are functions first-class (availability of Map() and Apply())?
Functions? You might want to go to VB.NET for that. We have methods in C#.
smileguy wrote: Error handling: What happens on invalid data?
You tell me, it is your program.
|
|
|
|
|
|
Is some course just starting, or have you got this far before falling apart ?
You need to do your own homework, if we did it, how would that help you ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Sure:
namespace Homework
{
public static class Math
{
[System.STAThreadAttribute()]
public static int
Main
(
string[] args
)
{
if ( args.Length > 1 )
{
System.Console.WriteLine ( DoMath ( args ) ) ;
}
return ( 0 ) ;
}
}
}
Now just write the DoMath method.
|
|
|
|
|
Now that was a brilliant take on how to answer a homework question... consider it stolen for future use!
Peter the small turnip
(1) It Has To Work. --RFC 1925[^]
|
|
|
|
|
|
I was wondering something...
Is it possible do do something like:
string s1 = "12345";
string s2 = s1.RemoveNum("5");
MessageBox.Show(s2);
Where further down you add the RemoveNum() method ONTO the string type?
something like...
public static string add RemoveNum(string num)
{
return string.Replace(num, "");
}
?
Just wondering...
-= Reelix =-
|
|
|
|
|
Why dont you just test this instead of wondering??
|
|
|
|
|
public static string add RemoveNum(string num)
{
return string.Replace(num, "");
}
obviously doesnt work (Seeing as I made it up on the spot :p)
Was googling around, and couldn't find anything particularly useful...
You can't override, since it doesnt exist...
I'm just wondering if there's a way TO do it
-= Reelix =-
|
|
|
|
|
OOP way to augment functionality is inheritance, but no luck this time: String class is sealed.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Dang :/
No evil way to hack through it? :p
-= Reelix =-
|
|
|
|
|
Of course there are ways, evil,
but you have to ask the devil.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
*Decompiles the .NET Framework into Assembly*
*Inserts a new String Method*
*Recompiles*
*Looks Innocent*
*Thinks...*
Dang... Will only work on my PC
-= Reelix =-
|
|
|
|
|
check out extension methods
betonglasermur.FeedDwarf(pur_is, 17);
ProcessStartupInfo.AintNotCreateNoWindow = (false && !true) != (true || false) ? false == true ? true : false : (true != false && false);
Morgonen är tröttmans mecka
|
|
|
|