|
The source is included with the XC# download. All you have to do is look in $InstallDir$\Source\XCSharp.Attributes\
Hawaian shirts and shorts work too in Summer.
People assume you're either a complete nut (in which case not a worthy target) or so damn good you don't need to worry about camouflage...
-Anna-Jayne Metcalfe on Paintballing
|
|
|
|
|
Hello,
I have an XmlNodeList with attributes and and text values. I am looking for a way to create a function that can return a value from reading a nodelist by specifiying the attribute name. For example, string a = FieldByName("acct") would result in 12345 being returned.
<fields>
<field name="acct">12345
<field name="company">ACME Inc
<field name="city">Dallas
<field name="state">TX
Any help would be greatly appreciated.
Thank you.
|
|
|
|
|
<br />
private string GetAttributeByName( XmlNode node, string name )<br />
{<br />
if( node != null && node.Attributes != null )<br />
{<br />
XmlAttribute attr = ( XmlAttribute )node.Attributes.GetNamedItem( name );<br />
<br />
if( attr != null ) return attr.Value;<br />
}<br />
<br />
return string.Empty;<br />
}<br />
Solutions:
1. Create method which make cycle and check each item in XmlNodeList (value can be taken by method written upper)
2. use XPath, like: //*[@*[local-name()='select123']] - such xpath return to you node(s) with contains attribute select123. After that use method written upper to get atribute value
Good Luck
Alex Kucherenko
|
|
|
|
|
Alex,
I am new to XML and not that familiar with the nodes and attributes. I have started with this by using xmlDocument.
Would you have an example of loading an XML doc similar to below and cycling thru the nodes and using your function of GetAttributeByName to return the value of the company from the below nodelist? I am having difficulties in getting the nodes setup from the nodelist.
<fields>
<field name="acct">12345</field>
<field name="company">ACME Inc</field>
<field name="city">Dallas</field>
<field name="state">TX</field>
</fields>
|
|
|
|
|
First of all, I am new to C# and .NET programming, however initial impression is very favourable, despite my brain complaining that it is already full up.
Anyway, I am trying to get a client system running a web browser, to exchange text with an application, running on a remote server. I have looked at .NET Remoting and it looks like overkill for what I want to do
So does the panel think the following will work ?
Client
- Web browser running the DHTML Webservice Behaviour
Server
- C# WebService talking to
- C# Windows Forms Application
Seems a simple solution to me however I can't work out the best way to get a C# WebService to talk to a C# application.
Appreciation for any help given will be shown with virtual beers (I am sure someone around here uses a beer icon, but I can't see it in the list of smilies)
Cheers
Steve
|
|
|
|
|
For your WebService to talk to your C# application you would again need something like .NET remoting, which brings you back to the first scenario anyways. You are crossing app domains, so communication has to be dealt with anyways.
My suggestion would be use .NET remoting. It's really not an overkill at all. The server (which would be you C# application) simply needs add a couple of lines of code. And your client app can add a couple of lines of code and voila!!! You're done!!!
The good thing here is that with .NET remoting you have all the flexibilty you want and it's very extensible. You can communicate TCP/IP or Http (through IIS or not) etc...
If you need some samples respond back.
Steve
|
|
|
|
|
Many thanks for that, if remoting only needs a few lines of code, then as you say it is not overkill !
I guess the answer then is to connect from the Webservice to the App via TCP/IP. If you have any samples of 'simple' remoting on the same system then that would be great.
Cheers
Steve M
|
|
|
|
|
This example exists within the examples of on your computer.
<frameworksdk>\Samples\Technologies\Remoting\Basic\RemotingHello
Take 15-30 minutes to look at it. It's worth it.
|
|
|
|
|
Hmmm...
Took a little while to make the stuff work. My system has 2 network connections. One for the cable set top box for broadband and one for my local network. Add in ZoneAlarm as the firewall and mix until thoroughly confused.
IIS on this machine is bound to the local network, BUT it is not resolved to LOCALHOST (i may need to switch network connections over). So I had to edit the .config files to use the actual IP address. The web client implementation wants me to log in as I am not authorized to view the page even though IIS is configured for anonymous acess and so refuses my administrator password
However, running the service using DirectHost service works when using the consoleclient. I have loads of questions but I will carry on playing for while...
Cheers
Steve
|
|
|
|
|
hey guys and girls,
im trying to get the ability to embed a hastable value of the password im going to encrypt a file with, in the file its self (but not embedding the password its self though just the hastable it generates). After encrypting it like above, i want the decryptor to beable to compare the incoming password to the hashtable on the encrypted file, if the 2 match, then continue, my problem is i need the incoming stream, to seek passed the hashtable and start there (SeekOrigin.Begin), so the original data is intact,the problem is when i use the FileStream.Seek = Seek(hashtablelength,SeekOrigin.Begin) when it gets to the actualy decryption part, it freezes and doesnt do anything, Ill include the code below, Am i just not doing it right ? If i was unable to make my question clear enough please let me know,
Jesse M
(i clipped the code so it will not be 100% correct, but the bulk of it is there)
///
///Decryption Method
///
<br />
FileStream fin = new FileStream(inName, FileMode.Open, FileAccess.Read);<br />
FileStream fout = new FileStream(outName, FileMode.OpenOrCreate, FileAccess.Write);<br />
fout.SetLength(0);<br />
byte[] bin = new byte[buffersize];
long rdlen = 0;
long totlen = fin.Length;
int len;
RC2CryptoServiceProvider RC2 = new RC2CryptoServiceProvider(); <br />
PasswordDeriveBytes db = new PasswordDeriveBytes(KeySecretString,SaltByte);<br />
byte[] f= db.GetBytes(RC2.LegalKeySizes[0].MaxSize /16);<br />
RC2.IV = f; <br />
RC2.Key =f;<br />
CryptoStream encStream = new CryptoStream(fout, RC2.CreateDecryptor(RC2.Key, RC2.IV), CryptoStreamMode.Write); <br />
Console.WriteLine("Encrypting...");<br />
while(rdlen < totlen)<br />
{<br />
len = fin.Read(bin, 0, buffersize);<br />
encStream.Write(bin, 0, len);<br />
rdlen = rdlen + len;<br />
PD.PerformStep();<br />
Console.WriteLine("{0} bytes processed", rdlen);<br />
} <br />
The Code Project Is Your Friend...
|
|
|
|
|
Code example :
ClassA oClassA = new ClassA();
Thread oWorker = new Thread(new ThreadStart(oClassA.read)); //How??, this is only partially done
My ClassA has a method "read(out ArrayList Something)" which expect a reference to ArrayList as input paratemer. How could I do so in C# with the code above?
Thank You
|
|
|
|
|
Anthony_Yio wrote:
read(out ArrayList Something)"
i guess the delegate ThreadStart encapsulates any methods without any parameters.
Cheers,
Venkatraman Kalyanam
Chennai - India
"Being Excellent is not a skill, it is an attitude"
|
|
|
|
|
Thank you but your help doesn't seem helping.
|
|
|
|
|
Anthony_Yio wrote:
your help doesn't seem helping
Ok. One solution could be use module level variable for storing the parameter and manipulate it from with in the function.
Cheers,
Venkatraman Kalyanam
Chennai - India
"Being Excellent is not a skill, it is an attitude"
|
|
|
|
|
Ok, thank you for this time although I had found some solutions in the web already.
I thought you were just one of those irresponsible people where they like to post and run. Apparently, I am glad you are not because you are trying
Some of the solutions I found was
Thread local storage
or
Save it into the object state.
|
|
|
|
|
Thanks, i forgot to point to this article.
Cheers,
Venkatraman Kalyanam
Chennai - India
"Being Excellent is not a skill, it is an attitude"
|
|
|
|
|
Why can't you pass the reference to ArrayList in the constructor for ClassA()?
Gaulles
|
|
|
|
|
Reason is that I will need to process the reference parameter in the contructor itself unless I would to store the refence to a pointer but it would make my program to be unsafe.
I guess this is not an old C++ style programming anymore.
|
|
|
|
|
You could also and is probably better than spawning a new thread is to use the BeginInvoke(string str, AsyncCallback asc, object stateobject). You then call the EndInvoke(IAsyncResult result) to retrieve the answer from the function. You pass a reference to the Arraylist in the stateobject and your AsyncCallback method handles and the parameter within it's function.
The good thing here is that you don't have to create a new thread, but rather the delagate function is executing on a thread from the thread pool - no creation is necessary.
I understand that this is probably hard to understand if you've never seen it before but you can look up BeginInvoke. .NET supports asynchronous method calls wonderfully with delagate.BeginInvoke.
|
|
|
|
|
Thank you for your suggestion. I will look into it.
Actually, I just want to make a simple thread call with parameter but it ends up in complexities. Gosh, sometimes I just hate new technologies.
|
|
|
|
|
Actually it is already simple. Take a look ...
public delegate int StringDelegate(string str);
.
.
.
private int GetLength(string str)
{
return str.Length;
}
.
.
.
StringDelegate d = new StringDelegate(GetLength);
IAsyncResult ar;
ar = d.BeginInvoke("Hello", null, null);
ar.AsyncWaitHandle.WaitOne(); // Wait for the function to finish
int length = d.EndInvoke(ar); // Voila, the result
// Note that you can also have a callback function defined in the
// second parameter. If defined, this function will be called once
// the delagate has completed. In addition, you can pass a state
// object to your GetLength method like so ...
// private int GetLength(string str, object state) ...
// You now have other information in addition to the passed "Hello"
// parameter.
// Clearly delagates are the way to go. They are simple and are
// extremely flexible. Also remember that the thread runs within the
// thread pool. No creation is required !
|
|
|
|
|
Hi,
I have some postings in a database and these postings are all noted in HTML-form because my initial idea was to show them from a web-application. Now I also want to show them through a windows application, the question is: how?
So I want to render HTML and show it in a .NET Windows Application. But I can't find a control to show the HTML. I know there is a control to show Richt Text Format, but that's still no HTML. I also know you can use the Internet Explorer ActiveX component, but I don't really want to, because that component can only show HTML from physical files and URL's, not directly from a String....
Does anybody know about the existence of a .NET-component that can show HTML directly from a string or do I really have to use the IE-component???
Structured programming vs. chaotic mind boggling
|
|
|
|
|
D.D. de Kerf wrote:
Does anybody know about the existence of a .NET-component that can show HTML directly from a string or do I really have to use the IE-component???
There is no UI Windows Forms components related to HTML rendering.
With enough spare time ahead, you may write a simple HTML renderer from scratch (and post it ).
D.D. de Kerf wrote:
I really have to use the IE-component
What's wrong with it? Drag&drop the web component into your Form, then Navigate the about:blank page, and then retrieve the mshtml (microsoft.mshtml.dll primary interop assembly) object model, get the IHTMLDocument2 interface, and create an HTML rendering from a string using the IHTMLDocument2.write(...) method call. This article[^] uses mshtml.
|
|
|
|
|
Well, I didn't ever know that I could use this write-function. It is also the first time I've ever got it working. Here are the steps:
1) Add Explorer to your toolbox (customize toolbox -> COM components -> Microsoft Web Browser) and add it to your form
2) Add a reference in your C# project to Microsoft.mshtml
3) use mshtml in your .cs-file like this:
using mshtml;
4) Browse to about:blank like this (ieBrowser is the browser-component):
object o = new object();<br />
ieBrowser.Navigate("about:blank", ref o, ref o, ref o, ref o);
5) Fill the HTML from a string like this:
IHTMLDocument2 doc;<br />
object oDoc = ieBrowser.Document;<br />
doc = (IHTMLDocument2)oDoc;<br />
<br />
doc.write("<HTML>This is bold and this is italic</HTML>");
That should do the trick.
Thanks for the tips!!!
Structured programming vs. chaotic mind boggling
|
|
|
|
|
Hi , we have a free but limited control that _might_ do what you want.
http://www.compona.com/WikiEngine/WikiPageViewer.ascx?ID=44[^]
it has its own rendering engine and can render with different font settings and images.
but as i said , it is limited , no tables , no stylesheets , no selections(!) etc.
basiclly the following tags are implemented
<a href=...
<font face=... size=... color=...(named colors only right now)
<br>
<hr>
<img src="file://... or src="1" (refering to an image in an attached imagelist)
<b>
<i>
<u>
it wordwraps and can also autosize to make the content fit.
//Roger - Compona
|
|
|
|