|
Hi fellow CP'ians,
i encountered a "problem" i am a bit shy to try my self. I am creating a localizible application (WinForms) which means i use the designer to create the UI for the different languages. Now, since i have ReSharper, i encountered the "problem" that the resx files either contain duplicates which are not overvritten or contain stuff which is not depending on localization. This hands me a lot of "possible code quality issues" which i understand seems reasonable. But how would i get rid of those except for telling ReSharper to ignore it?
My Question therefore is that is it possible to delete those lines in the resx files and if needed set the values in the designer.cs ? I have no idea how deep the resx files go and how they work 100% so any advice / experience you have would be a great help
Thanks in advance
Rules for the FOSW ![ ^]
if(this.signature != "")
{
MessageBox.Show("This is my signature: " + Environment.NewLine + signature);
}
else
{
MessageBox.Show("404-Signature not found");
}
modified 7-Mar-17 4:13am.
|
|
|
|
|
resx files are "name-value" pairs.
Unless someone used "non-standard" access methods, you should be able to to a "global search" of the "solution" files for the "name" keys to see if they are being referenced.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I think you got me wrong on this, im not talking about the stuff you see when you open a .resx file in visual studio normally. Im talking about the XML behind it like :
<data name=">>_mainMenu.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="_explBarProjInfo.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="_lbCustomerName.Text" xml:space="preserve">
<value>Customer Name :</value>
</data>
Where the _lbCustomerName.Text value is reasonable for the sake of translations, the ZOrder and the Dock are not necessary for localization as the UI shall not look different. Therefore i was asking about those parts (which are actually auto generated) to be deletable.
Rules for the FOSW ![ ^]
if(this.signature != "")
{
MessageBox.Show("This is my signature: " + Environment.NewLine + signature);
}
else
{
MessageBox.Show("404-Signature not found");
}
|
|
|
|
|
Whether it's "XML" or some other format, it's still "name-value" pairs.
If you're looking for "parsing rules", start by ignoring the types that contain the key words you want to skip (e.g. .dock).
Process the XML using XPATH, XmlDocument, XSD, a deserializer, or whatever else you fancy.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Alright so just to confirm if i understood. If i search globally for a reference of the key / value pair and do not find anything refering to it i can ignore it, which means i can safely delete it without destroying my UI right?
Rules for the FOSW ![ ^]
if(this.signature != "")
{
MessageBox.Show("This is my signature: " + Environment.NewLine + signature);
}
else
{
MessageBox.Show("404-Signature not found");
}
|
|
|
|
|
Familiarize yourself with the "patterns" used to access resources; to satisfy yourself that your searches are hiiting the "right things" ... e.g. "$this.Icon" is the "key" of the "resource" is this case:
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Well, i use this "pattern" for my global resources and there i have no problems. What i am specifically pointing to is the resource files generated for each usercontrol as soon as you set the control to localizable true. And after doing that there was a lot of useless (as mentioned before like docking position) stuff autogenerated into the resource file instead of still being in the designer class.
But since i was not sure how to handle this, because the designer sets the resources according to the culture of the system or the one in which i start up the app during initialization of the usercontrol, i asked wether it is possible to remove those lines from the res files back to the designer without destroying the layout of the usercontrol.
So i would actually never find a "hit" since all the initialization in the designer.cs does this ->
this._lbBegin.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
resources.ApplyResources(this._lbBegin, "_lbBegin");
this._lbBegin.Name = "_lbBegin";
So it feels like either we both are talking past each other or i stand on the tube
Rules for the FOSW ![ ^]
if(this.signature != "")
{
MessageBox.Show("This is my signature: " + Environment.NewLine + signature);
}
else
{
MessageBox.Show("404-Signature not found");
}
|
|
|
|
|
|
Okay
Thanks a lot for your patience with me and helping me out.
I'll close the question now.
Rules for the FOSW ![ ^]
if(this.signature != "")
{
MessageBox.Show("This is my signature: " + Environment.NewLine + signature);
}
else
{
MessageBox.Show("404-Signature not found");
}
|
|
|
|
|
No problem! There are many ways to do something in .NET. It all depends on what you want to accomplish in the long run.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Hello
I define a HtppWebRequest ending with the following lines :
...
req.Credentials = new NetworkCredential(...);
Stream theStream = req.GetRequestStream();
theStream.Write(bytes, 0, bytes.Length);
theStream.Close();
req.GetResponse();
Then, the request is sent twice. A first time with the theStream.Write line, and a second one with the req.GetResponse() line. I have a 401 (unauthorized) response with the first request and a 403 (forbidden) with the second one.
I Wonder if the 403 error is due to the previous 401.
In any case, I would not to send the first request.
Thanks for your help
|
|
|
|
|
You only need to use the stream if you have parameter data to be written to the URL.
req.Credentials = new NetworkCredential(...);
req.GetResponse();
Will do the trick.
|
|
|
|
|
No, the GetResponse is not enough because I have data to write into the request. I don't know how to send data without the GetRequestStream.
|
|
|
|
|
Apologise, put my reading glasses on..
|
|
|
|
|
Sounds like a typical authentication challenge - the request doesn't send the credentials unless the server indicates that it needs to.
Try setting the PreAuthenticate property[^] to true :
req.Credentials = new NetworkCredential(...);
req.PreAuthenticate = true;
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks for your idea, but it doesn't work .
I have the same behavior : a 401 error followed by a 403.
|
|
|
|
|
I've just solved my problem. Le number of - characters was not good on the boundary line.
|
|
|
|
|
Hi experts ,
we are using this code to read xml file, we want to optimize the code .
Issue is that in our xml file around 50 attributes are there , but from that we want hardly 2 to 3 attributes value.
but here while loop is executing 50 times , that we don't want.
Please give suggestion .
Thanks
using (XmlReader reader = XmlReader.Create(@"C:\abc.xml"))
{
while (reader.Read() )
{
if (reader.IsStartElement("AccountNumber"))
{
listBox1.Items.Add(reader.ReadString());
}
else if ((reader.IsStartElement("AvailableDate")))
{
listBox1.Items.Add(reader.ReadString());
}
}
}
|
|
|
|
|
Rather than adding data to the ListBox directly inside your loop, add this data to a List<string>. Once you have exited the loop, use AddRange to add it to the ListBox.
This space for rent
|
|
|
|
|
Hello,
this might not be a real question, more like an interest about, how bad my current workaround is. I hope it's OK to post here .
I have an application which I have started developing for WPF and now I also want to port it to UWP. I have created some custom visual controls for the app in a Controls library, which is a Class Library in C# and references .Net WPF libraries.
Some custom panels would look very similar with code working in both frameworks, so I thought it would be nice to reuse my old code.
This is the solution I came up and currently porting the library to:
- left the original Controls class library project untouched
- created a Controls.UWP class library for UWP platform
- added source files from Controls to Controls.UWP as linked files
- finally - and currently working on - resolving the namespace changes by adding stuff like this at the beginning of source files:
#if WINDOWS_UWP
using Windows.Foundation;
#else
using System.Windows;
#endif
However, in some cases I must completely rewrite the class eg. because I used OnRender function to draw it, so now I have to rewrite it to use Win2D. For this reason I don't know if it's worth bother with #if statements.
What do you think, is this a bad idea?
|
|
|
|
|
How I would tend to do this is put common code inside a PCL which can be used by both sides. Then all you have to do is write your platform specific code and call the shared functionality.
This space for rent
|
|
|
|
|
Thank you for the reply! Then I guess, I wanted to create a monster with platform specific code (the UI controls) for two frameworks in common source files.
I have already used PCL, that's why I thought it would be nice to have something similar for UI, too.
Also, since my post I found other issues, like the missing FrameworkPropertyMetadata from UWP and more restricted attached property accessors. So, it seems, that I couldn't save anyway as much code-rewriting as I wanted .
|
|
|
|
|
The biggest problem you will face is that, despite appearances, WPF and UWA are two vastly different beasts. Universal Windows programs are a lot closer to Silverlight, so there are things that you can do in WPF that just aren't available in WPF (and vice versa). This would have a fundamental impact on things such as what your XAML does, which would be a major pain to work around.
This space for rent
|
|
|
|
|
Wrong post.Deleted.
modified 19-Jan-21 21:04pm.
|
|
|
|
|
Please do not repost, especially with just a link to the other forum.
|
|
|
|