|
I know exactly what you mean, I've even been giving it a bit of a break recently.
The quality of the questions has been low recently, and some claque-y voting for articles etc. The CP has been consistently been the best .net forum for the 10ish years I've been developing, but I'm not confident that will continue to be the case in the next few years unless things improve substantially & soon.
|
|
|
|
|
I don't understand the word "sarcasm". Is there some place I can go to learn more?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
|
Mark Nischalke wrote: I don't understand the word "sarcasm". Is there some place I can go to learn
more?
JSOP's house?
|
|
|
|
|
I'm sure I could get several different calibre of answers there.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Certainly no idiot, that's for sure
...and I have extensive experience writing computer code, including OIC, BTW, BRB, IMHO, LMAO, ROFL, TTYL.....
|
|
|
|
|
Attribute
Developers can add metadata to their code through attributes. There are two types of attributes, custom and pseudo custom attributes, and to the developer these have the same syntax. Attributes in code are messages to the compiler to generate metadata. In CIL, metadata such as inheritance modifiers, scope modifiers, and almost anything that isn't either opcodes or streams, are also referred to as attributes.<br />
A custom attribute is a regular class that inherits from the Attribute class. <br />
Custom attributes are used by the .NET Framework extensively. Windows Communication Framework uses attributes to define service contracts, ASP.NET uses these to expose methods as web services, LINQ to SQL uses them to define the mapping of classes to the underlying relational schema, Visual Studio uses them to group together properties of an object, the class developer indicates the category for the object's class by applying the [Category] custom attribute. Custom attributes are interpreted by application code and not the CLR.When the compiler sees a custom attribute it will generate custom metadata that is not recognised by the CLR. The developer has to provide code to read the metadata and act on it.
|
|
|
|
|
Is there a time-out for a loop.
for example, i have a loop that goes on and on for long time and by some means i could set time to 2 seconds so that it breaks out of loop after specified time.
|
|
|
|
|
I'm not sure if it is the best solution, but you could start a timer when the loop first enters and when the timer expires set a static boolean (or thread safe boolean) to true.
the for loop would like this more or less:
staticbool = false;
for(int i = 0; i < verybiginteger && staticbool == false; i++){
}
private void TimerTimeoutReached(){
staticbool = true;
}
note that it will finish the current loop before exiting.
hope this helps.
V.
|
|
|
|
|
This doesn't feel quite right but you could do it like this
DateTime d = DateTime.Now.AddMinutes(2);
for (int i = 0; i <= veryBigInt; i++ )
{
if (DateTime.Now > d)
break;
}
But as i said this really feels like a hack, and I would say there is a faulty decision in the design somewhere.
...and I have extensive experience writing computer code, including OIC, BTW, BRB, IMHO, LMAO, ROFL, TTYL.....
|
|
|
|
|
First of all, there is no implicit loop operation that breaks out at a specified time interval. You'll have to code it yourself.
Secondly, as your loop depends on reaching a value or a timeout being reached, a for loop is not the appropriate choice - it is designed to work with a fixed number of iterations. In this case, I would choose to use a while loop instead. Then you could do something like the following:
Stopwatch watch = new Stopwatch();
int count = 0;
do
{
if (!watch.IsRunning)
{
watch.Start();
}
PerformSomeLongRunningOperation();
} while (++count < 10 && watch.Elapsed <= TimeSpan.FromSeconds(2) );
watch.Stop();
|
|
|
|
|
Dear all,
In my application i have an XML like this..
I want to perform a search in this XML Based on SubID, ModuleId, TaskName, between start and end dates. Please help me. Also i need all the parents of the searched nodes without siblings.
<Tasks>
<Task TaskId=1 PId=0 SubId=0 ModuleId=0 TaskName="Task 1" StartDate="1 Apr 2011" EndDate="12 Apr 2011">
<Task TaskId=2 PId=1 SubId=0 ModuleId=0 TaskName="Task 2" StartDate="1 Apr 2011" EndDate="12 Apr 2011"/>
<Task TaskId=3 PId=1 SubId=0 ModuleId=0 TaskName="Task 3" StartDate="1 Apr 2011" EndDate="12 Apr 2011"/>
<Task TaskId=4 PId=1 SubId=0 ModuleId=0 TaskName="Task 4" StartDate="1 Apr 2011" EndDate="12 Apr 2011"/>
<Task TaskId=5 PId=1 SubId=1 ModuleId=0 TaskName="Task 5" StartDate="1 Apr 2011" EndDate="12 Apr 2011">
<Task TaskId=6 PId=5 SubId=0 ModuleId=0 TaskName="Task 6" StartDate="1 Apr 2011" EndDate="12 Apr 2011"/>
<Task TaskId=7 PId=5 SubId=0 ModuleId=0 TaskName="Task 7" StartDate="1 Apr 2011" EndDate="12 Apr 2011">
<Task TaskId=8 PId=7 SubId=0 ModuleId=0 TaskName="Task 8" StartDate="1 Apr 2011" EndDate="12 Apr 2011"/>
</Task>
<Task TaskId=9 PId=5 SubId=0 ModuleId=0 TaskName="Task 9" StartDate="1 Apr 2011" EndDate="12 Apr 2011"/>
</Task>
<Task TaskId=10 PId=1 SubId=0 ModuleId=0 TaskName="Task 10" StartDate="1 Apr 2011" EndDate="12 Apr 2011"/>
</Task>
</Tasks>
Please help
Regards,
DJ
|
|
|
|
|
As they are attributes, you need to use attribute based searches in your XPath. The type of syntax you are looking to use is //[@...=value] .
You are going to have a problem with the date part as this stands because your data is all text as far as the parser is concerned. In order to work with date information, you are going to have to provide a schema and set the data types as appropriate.
BTW, your XML is malformed - you must enclose your values in quotes, so having TaskId=9 is incorrect and it should actually be TaskId="9"
|
|
|
|
|
 Re: XML Search
Ok.. fine..
Updated the XML taskXML =
<Tasks>
<Task TaskId="1" PId="0" SubId="0" ModuleId="0" TaskName="Task 1" StartDate="1 Apr 2011" EndDate="12 Apr 2011">
<Task TaskId="2" PId="1" SubId="0" ModuleId="0" TaskName="Task 2" StartDate="1 Apr 2011" EndDate="12 Apr 2011"/>
<Task TaskId="3" PId="1" SubId="0" ModuleId="0" TaskName="Task 3" StartDate="1 Apr 2011" EndDate="12 Apr 2011"/>
<Task TaskId="4" PId="1" SubId="0" ModuleId="0" TaskName="Task 4" StartDate="1 Apr 2011" EndDate="12 Apr 2011"/>
<Task TaskId="5" PId="1" SubId="1" ModuleId="0" TaskName="Task 5" StartDate="1 Apr 2011" EndDate="12 Apr 2011">
<Task TaskId="6" PId="5" SubId="0" ModuleId="0" TaskName="Task 6" StartDate="1 Apr 2011" EndDate="12 Apr 2011"/>
<Task TaskId="7" PId="5" SubId="0" ModuleId="0" TaskName="Task 7" StartDate="1 Apr 2011" EndDate="12 Apr 2011">
<Task TaskId="8" PId="7" SubId="0" ModuleId="0" TaskName="Task 8" StartDate="1 Apr 2011" EndDate="12 Apr 2011"/>
</Task>
<Task TaskId="9" PId="5" SubId="0" ModuleId="0" TaskName="Task 9" StartDate="1 Apr 2011" EndDate="12 Apr 2011"/>
</Task>
<Task TaskId="10" PId="1" SubId="0" ModuleId="0" TaskName="Task 10" StartDate="1 Apr 2011" EndDate="12 Apr 2011"/>
</Task>
</Tasks>
And perform the search criteria as follows (My code)
public XMLNode searchXML()
{
if ((null != taskXML) && 0 < subProjectId)
{
taskXML = taskXML.SelectSingleNode("//Task[@SubId ='" + subProjectId.ToString() + "']");
}
if ((null != taskXML) && 0 < moduleId)
{
taskXML = taskXML .SelectSingleNode("//Task[@TaskId ='" + moduleId.ToString() + "']");
}
if ((null != taskXML) && (null != startDate && null != endDate))
{
taskXML= taskXML.SelectSingleNode("//Task[@StartDate >'" + startDate.ToString() + "']");
if (null != taskXML)
taskXML= taskXML.SelectSingleNode("//Task[@StartDate < '" + endDate.ToString() + "']");
}
if ((null != taskXML) && 0 < statusId)
{
taskXML = taskXML .SelectSingleNode("//Task[@StatusId='" + statusId + "']");
}
if ((null != projectTaskXML) && string.Empty != taskName)
{
taskXML = taskXML .SelectSingleNode("//Task[@TaskName='" + taskName + "']");
}
return taskXML;
}
But the date search and name search not working.
Also i need to get the parents of searched tasks
Could u please help me?
|
|
|
|
|
I already told you that your date search wouldn't work because the data type is a string, and you need to create a schema for this. If you had read my answer fully, you'd have seen that vital piece of information.
|
|
|
|
|
The date search might work if you use the ISO 8601-compliant format YYYY-DD-MM -- which is what the W3C recommends for XML anyway.
|
|
|
|
|
I have a requirement to convert tiff files to pdf. But the problem is, for some tiff files, the header information is missing.
If I opened this tiff files using IrfanView and save it again(I mean overwrite the file in the same location), the header information is automatically added.
Is there any way which I can open those tiff files and save it again (as I done manually using Irfanview) programmatically using C#?
Please provide any solution.
Thanks
meeram395.
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
There's a fairly detailed explanation here[^] on writing out a TIFF file.
|
|
|
|
|
We have a good article on CP about this[^]
// ♫ 99 little bugs in the code,
// 99 bugs in the code
// We fix a bug, compile it again
// 101 little bugs in the code ♫
|
|
|
|
|
|
Hello,
I wonder if there is a services-like platform in C# where I can build addons onto. And when I say services, I mean the kind of services Windows has, which I can inject dependencies, trigger a start\stop and add\remove addons as I wish.
I will also need a way of controling it, like a console, MMC or some other kind of UI.
Does anyone know of something similar to what I'm looking for? it'll really help me out
Thanks in advance.
|
|
|
|
|
Just for clarification:
Why not just create windows services that you can control using all the tools you mentioned? What is the requirement that is driving you away from that much simpler solution?
~Justin_H
|
|
|
|
|
I'd like to be able to make it cross-platform using MONO
|
|
|
|
|
I would search codeproject for examples of using Managed Extensibility Framework (MEF). I did a quick search and the latest versions should work under Mono.
Try: http://www.codeproject.com/Articles/56635/Managed-Extensibility-Framework.aspx for a MEF intro.
Going the MEF / roll your own solution route you can't avoid writing some OS specific code to start your "services" with the system but that shouldn't be too hard.
Option 2: Check out http://linux.die.net/man/1/mono-service[^] which basically allows you to run .net windows services under mono/linux with little if any code change required.
~Justin_H
|
|
|
|
|
hi
i want windows application that Frequency-shifting Auditory Feedback from microphone. for example file download from http://www.artefactsoft.com/daf.htm
thanks.
|
|
|
|
|
Is this a C# question?
The best things in life are not things.
|
|
|
|