|
What is the reason that you need to sort the list of strings? If it should just be a copy of some of the data in the list of objects, can't you just recreate the list? Do you actually have to create the list of strings, can't you just read the data from the list of objects?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
the logic being used is very flexible and was designed to grab strings from any properties contained in a list of any objects. if you know the properties of the object (and you should at least one, otherwise you shouldn't be using it )and return the valu eof that property in each instance of the object in the list. Its hard to read, I know, but it works. the issue is that somewhere along the line, the data is getting out of sort, and I dont have time (yet) to add logic for sorting into the method. (it would have to identify the other property in the object to sort from, if such a property exists, blah blah blah)
Why wouldnt i just access the property of each individual object in the list? Believe it or not, this was written to run through huge XML strings and grab the potential instances of object descriptions contained within, and then return the property values, if the objects exist, and if their properties arent null. I didnt design it, but I have to use it, so this method ignores the "what if" and just returns what is.
And now i have to work with what comes out th eother side.
______________________
Oh Hamburgers!
|
|
|
|
|
As ennis said you have to make comparer by your self
see this link[^]
dhaim
programming is a hobby that make some money as side effect
|
|
|
|
|
Hi,
I need to build XML files and populate them with data from our database.
They need to conform to a schema defined by a third party.
Unfortunately the schema is too complex to build a stronly typed DataSet from so I'm going to have to write the XML building code myself.
I'm having difficulty so I've built a simple test application to build and validate some XML.
But I can't get it to work, XmlDocument.Validate just succeeds even if the XML is wrong.
Here is the sample code as well as the respective XML and XSD files.
Container.xsd:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Container" targetNamespace="http://www.spursolutions.com/Container.xsd" elementFormDefault="qualified" xmlns="http://www.spursolutions.com/Container.xsd" xmlns:mstns="http://www.spursolutions.com/Container.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Envelope" nillable="false">
<xs:complexType>
<xs:sequence>
<xs:element name="Header" nillable="false">
<xs:complexType>
<xs:sequence>
<xs:element name="Source" type="xs:string" nillable="false" />
<xs:element name="Dest" type="xs:string" nillable="false" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Payload" type="xs:anyType" nillable="false" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Code
using System;
using System.Xml;
using System.Xml.Schema;
namespace XMLTest
{
class Program
{
static void Main(string[] args)
{
Validate();
}
public static void Validate()
{
XmlDocument oDoc;
oDoc = new XmlDocument();
oDoc.Schemas.Add("http://www.spursolutions.com/Container.xsd", "Container.xsd");
oDoc.AppendChild(oDoc.CreateXmlDeclaration("1.0", "utf-8", null));
oDoc.AppendChild(oDoc.CreateElement("Envelope"));
oDoc.DocumentElement.SetAttribute("xmlns", "http://www.spursolutions.com/Container.xsd");
ValidationEventHandler eventHandler = new ValidationEventHandler(ValidationEvent);
oDoc.Validate(eventHandler);
}
public static void ValidationEvent(object sender, ValidationEventArgs e)
{
Console.WriteLine(e.Message);
Console.WriteLine(e.Severity.ToString());
if (e.Severity == XmlSeverityType.Error)
{
throw e.Exception;
}
}
}
}
Now, if I save that XML file, then change the code to load it in instead of creating it from scratch, it fails the Validation.
Can anybody help? Having to save and load the XML to validate it is a rather ugly solution.
Thanks,
James.
|
|
|
|
|
|
Hi there.
How can we set a maximum time for a Thread variable.
For example :
I want to create a Thread variable that if it couldn't finish its work in 5 minutes , itself abort.
Do you understand me ?
Thanks in advance.
|
|
|
|
|
Well, one way to do it would be to have the code inside the Thread's callback handler periodically take a look at System.Enviroment.TickCount.
That would only work if the code is performing a loop though, so it could check the time at the start of each loop. Once the time is up, just return; the method.
What's the thread doing?
J.
|
|
|
|
|
|
There is no built in way to time limit a thread, you have to do it yourself.
Store the start time in a variable when the thread method starts. Then periodically check the difference between the start time and the current time, and exit out of the method if the predefined time has elapsed.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
|
Create two BackgroundWorker objects. One of them does the "work", and the other sits/spins until the time limit is reached, and then it cancels the other worker. Piece of cake...
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
|
Hello all,
I have a little problem regarding a double quote. I wrote this filter, to weed out all invalid characters in an Excel sheet. It works fine, however my invalid character list is defined in a string array. One of the invalid characters is "
string invalidChar = "' ` # ";
string[] invChar = invalidChar.Split(' ');
How do I get " into the string as well ?
kind regards,
|
|
|
|
|
|
See above for the solution proposed by leppie, which will work, however I prefer:
string invalidChar = @"' ` "" # ";
string[] invChar = invalidChar.Split(' ');
I find it more readable.
Chris
|
|
|
|
|
Both option works , I tested it
Thank you both
|
|
|
|
|
If we are going for readable:
char[] invalidCharacters = { '"', ',', '$', '\'' };
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
I hadn't thought of that - much neater. For things like file paths it is useful to know about using @ as well.
Chris
|
|
|
|
|
Hi, I'm currently programming ASP.NET and C#. I'm new to ASP.NET and I was wondering, is there a way to right-click a control and select view source ? Is there a add-in that does that or an option.
I find it hard to follow the HTML code to find the button I could have just click a button to view the source.
If seems to be working one way only, if I select in the source, the control became selected, but if I select the control, the source get back to the top.
So is there anyway to view the source of a control ?
|
|
|
|
|
Correction, to make leppie happy, the Visual Designer.
You would be surprised at just how fast you can work in HTML without it once you are used to it.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
Well I use the html code often, but something I don't want to scroll throught 20 pages of code just to find the button in the table in the div tag in the middle of the page. (just to change an OnClientClick event)
|
|
|
|
|
Hit F4 and use the properties window in conjunction with the Visual Designer for properties like that.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
If you are using VS2008 there is an additional tab at the bottom, SPLIT. Its shows the design view and source, highlight in design highlights the source.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
It does not work, if I highlight the source, it hightligth the controls, but it's only one way, if I highlight the control, it does not highlight the source.
|
|
|
|
|
Strange, it works for me - just a single click on the control highlights the source (you do have to scroll to the right place in the source, it does not automatically bring it into view though).
Bob
Ashfield Consultants Ltd
|
|
|
|