|
The easiest way to do that would be to use a hashtable to map "Blue" to "The Color Blue".
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
namespace CSFoo
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("The Color {0}", ETest.Blue.ToString());
}
}
enum ETest
{
Red,
White,
Blue
}
}
|
|
|
|
|
should have extended subject to say
"that can be easily modified by non-programmers outside of the .cs file"
I think I can probably build a ResourceDictionary in XAML that would provide a basic lookup capability at application scope. Thus my UI guy can tweak the XAML and I can simply do a FindResource using the enum value identifier as the key.
|
|
|
|
|
Are you looking for something that can be modified at runtime or just modified by a "non-programmer" at design time?
You can also look at using the DescriptionAttribute and using a little bit of reflection to retrieve the attribute value at runtime. I believe the strings used in the attribute constructor can be referenced from a resource file.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
No runtime modification or localization needs.
Decided to go with a simple XAML declaration of strings in Application.Resources and use typename.value as key (ID) name.
No hard coded string IDs, and easy for non-programmers to maintain (notepad) in a centralized location.
|
|
|
|
|
The meaning is writed as
"If the member was not serialized, the CLR will leave the members's value null rather than throwing an exception."
Visual Studio does the same thing as if this attribute was not used, so why should anyone use it?
Or is it to garantee compatibility with .Net 1.x?
|
|
|
|
|
It is part of the changes made to serialization in .NET 2.0 to help alleviate the versioning issues that can be encountered when dealing with serialized objects.
If you have version 1.0 of your product that serializes an object and then you create version 2.0 of your product that adds new fields, you would get an exception when you tried to deserialize the 1.0 version of the object. By marking the field with the OptionalField attribute, the object will be deserialized properly and the "missing" fields will be null.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
Strange, I can't simulate an exception, what am i doing wrong?
1. Create a class
2. Create an object instance
3. Serialize this object
4. Add a field to the class (value or reference)
5. Deserialize (I supposed .Net would trow an exception here because there's a new field that isn't serialized, but it doesn't)
I think it's just .Net 1.x that generate an exception
-- modified at 4:58 Wednesday 6th December, 2006
|
|
|
|
|
S O L V E D
By using 'BinaryFormatter', the .Net Framework 2.0 doesn't give an exception if you do not use the 'OptionalField' attribute.
But if u use the 'SoapFormatter', the meaning of the 'OptionalField' attribute becomes clear.
|
|
|
|
|
Hiya all.
I instantiated a filesystemwatcher and set it to monitor a directory filtered with a specific file.
Then I made a method which handles the Changed event from the filesystemwatcher.... however when I save/alter the file the watcher monitors - I get the event called twice.
Does anybody know why? Or possible what I need to look for?
|
|
|
|
|
When I first used this class I had this problem - but I don't have the problem anymore.
To resolve my issue I no longer listen to CHange event, but to the Created, Renamed and Deleted events instead.
Depends on what you need to know, but these covered my requirements.
Stuart Wells
Software Engineer
|
|
|
|
|
It's because a changed-event fires more than you probably expect, for example:
- When you create a file
- When you delete a file
- When you rename a file
- ...
|
|
|
|
|
I have a file, in which I need to monitor changes, so I can't use any of the others. The file exits, so it isn't because it gets created that the watcher triggers twice.
Both events are the "Changed" event.
---------------------------
127.0.0.1 - Sweet 127.0.0.1
|
|
|
|
|
I don't know for sure, but maybe you get one event for the content change, and one for the update of the LastWriteTime ?
Luc Pattyn
|
|
|
|
|
Hmm - could be, could be.
|
|
|
|
|
It depends on the file too. If it's a Word document, for example, you're not opening the orignal file. You actually open a copy of it. When you go to save the changes, the file is actually written to the temporary copy (Changed event), then the original file is deleted (Changed event) and the temporary file is renamed (Changed event) to the orignal filename.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
it's an XML document, opened via notepad.
|
|
|
|
|
I have a RichTextBox on a winform, it was placed there by dragging from the datasouces page, so it is bound to the datafield that contains rtf formatted text. However when I scroll through records in the database when I come across a data record that has rtf formatting it shows the RTF code as well as the text in the field As such:
{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil MS Sans Serif;}{\f1\fnil\fcharset0 MS Sans Serif;}}
{\colortbl ;\red0\green0\blue255;}
\viewkind4\uc1\pard\lang1033\b\f0\fs16 #4 Ker Long Heeled --Egg Bar--51/2x63/4\f1 --1/2" wedge\par
\cf1 11/02\cf0 --Changed to Natural Balance shoes \f0\par
}
What do I have to do to get the text only from this field to display?
All I really need to do is extract the text from this field
string text = fRONTRichTextBox.Text; Ithought this returned only the text
string rtf = fRONTRichTextBox.Rtf; I thought this returned the text and rtf code formatting
But..Both return the same value:
{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil MS Sans Serif;}{\f1\fnil\fcharset0 MS Sans Serif;}}
{\colortbl ;\red0\green0\blue255;}
\viewkind4\uc1\pard\lang1033\b\f0\fs16 #4 Ker Long Heeled --Egg Bar--51/2x63/4\f1 --1/2" wedge\par
\cf1 11/02\cf0 --Changed to Natural Balance shoes \f0\par
}
Thanks Jon Stroh
|
|
|
|
|
After digging deeper some records are processed by the control corectly, some are not. The ones that are have double back slashes in them are processed corectly
{\\rtf1\\ansi\\deff0{
the ones that show text and rtf formatting code have single back slashes
{rtf1\ansi\deff0{
How can I get the control to show both corectly?
string text = fRONTRichTextBox.Text;
string rtf = fRONTRichTextBox.Rtf;
This code works just fine as long as there are double \\ in the rtf code.
Thanks Jon
|
|
|
|
|
Hello,
here is a function's signatures for 2 PowerPoint effects event handlers:
SlideShowNextClick(SlideShowWindow Wn,Effect ef)
The effect onNextClick is ef.
SlideShowNextBuild(SlideShowWindow Wn)
What is a currently executed effect??
At the moment I have next implementation:
1. By handle SlideShowNextClick store next effect name ("xyz").
2. By handle SlideShowNextBuild execute my bussiness logic (for effect "xyz").
The problem occurs if the current slide has more than 1 effect on page and "go back" button will be used. ==> I can't catch "goback"-event, thus I can't be sure that my stored "NextEffect" is a next effect realy.
Is it possible to get number/name of currently executed effect directly in SlideShowNextBuild handler?
Thanks for your help.
|
|
|
|
|
Hiya all.
I'm messing about a little with processes, and I've got a question about the name of a process.
I made a service which when ran could be found again using the process name of the assembly (for instance myproject.service) - is this the common method of processnaming in windows services for .NET or is it possible to provide/define the process name itself?
|
|
|
|
|
Does any one have experience working with a gsm modem.
How to communicate with a server(also connected to a GSM mdem).
Dialing a server modem number.and the server returning data to the modem dialling.(the modems are connected to the computers via a serial connection)
|
|
|
|
|
Hello,
I would like to approximate cursor position to some GraphicsPath. Is it possible to do it? I found a function IsOutlineVisible which should work, but I dont know how...
thank you...
|
|
|
|
|
|
In C++ I used CWinThread to create forms on separate threads. Is there a CWinThread equivalent for .NET?
|
|
|
|