|
I'm serializing xml data to files and need to find a way to add an xsi:schemaLocation="path\schema.xsd" atribute to the data being written.
|
|
|
|
|
[System.Xml.Serialization.XmlAttribute<br />
(Namespace="http://www.w3.org/2001/XMLSchema-instance")]<br />
public string schemaLocation = "Namespace path\\SchemaName.xsd";
I can get it in by adding this to the C# file autogenerated by the XSD tool, but this is obviously a suboptimum solution. I know for a fact that when I update the schema and rerun XSD several months later I'll forget I need to modify the file again. Is there a way I can do this from either a wrapper class or the IO class using filestreams and serializers?
|
|
|
|
|
I have some perl functions that get called through SOAP and C#. Is there a way to call these functions going from perl to C#?
** NOTE If this shows up twice, its because there was an error and I had to rename my post to post it. **
Mike - I love to program!
|
|
|
|
|
The virtual machine implementations of C# and Perl are radically different so calling methods between "byte codes" is almost impossible. You can however do a SOAP proxy like that to do interprocess communications at that level if the lower level IPC is too low.
|
|
|
|
|
Alright, I have the following perl code:
<br />
sub getComplexObj<br />
{<br />
my $_count = 12<br />
my $mike = {<br />
'Count'=> SOAP::Data->new( name => 'Count', value => $_count, type => 'xsd:int' )->attr({ 'xmlns' => $MC_XMLNS }),<br />
'test' => SOAP::Data->new( name => 'test', value => 'test string', type =>'xsd:string' )->attr({ 'xmlns'=> $MC_XMLNS })};<br />
<br />
my $foo = SOAP::Data->new(<br />
name => 'return',<br />
value =>bless{ $self ,('compObj')->attr({ 'xsi:type' => typens:'compObj' })}<br />
)->attr({ 'xmlns' => $MC_XMLNS });<br />
<br />
return $foo;<br />
}<br />
I have a WSDL file and I use that to automatically generate a C# file that uses a SOAP proxy to call this function. When I run my code, I get the following error from .NET:
"Failed to access class (CS3::SOAP::ComplexObject): syntax error at CS3/SOAP/ComplexObject.pm line 13, near \"typens:\"\nCompilation failed in require at (eval 201) line 3.\n"
When I change the $foo object to:
my $foo = SOAP::Data->name('return')->value(bless{ $self ,'compObj'})->attr({ 'xmlns' => $MC_XMLNS });
I get this error from .NET:
"Cannot assign object of type System.Xml.XmlNode[] to an object of type compObj."
Just for reference, my C# file looks like this:
<br />
[System.Web.Services.WebServiceBinding(Name="ComplexObjectPort", Namespace="http://VALIDHTTP")]<br />
[System.Diagnostics.DebuggerStepThroughAttribute()]<br />
[System.ComponentModel.DesignerCategoryAttribute("code")]<br />
public class ComplexObj : System.Web.Services.Protocols.SoapHttpClientProtocol {<br />
<br />
public ComplexObj() {<br />
this.Url = "http://VALIDHTTP/co.pcgi";<br />
}<br />
<br />
[System.Web.Services.Protocols.SoapRpcMethodAttribute("http://VALIDHTTP#getComplexObj", RequestNamespace="http://VALIDHTTP", ResponseNamespace="http://VALIDHTTP")]<br />
[return: System.Xml.Serialization.SoapElement("return")]<br />
public compObj getComplexObj() {<br />
object[] results = this.Invoke("getComplexObj", new object[]);<br />
return ((compObj)(results[0]));<br />
}<br />
<br />
public System.IAsyncResult BegingetComplexObj(System.AsyncCallback callback, object asyncState) {<br />
return this.BeginInvoke("getComplexObj", new object[], callback, asyncState);<br />
}<br />
<br />
public compObj EndgetComplexObj(System.IAsyncResult asyncResult) {<br />
object[] results = this.EndInvoke(asyncResult);<br />
return ((compObj)(results[0]));<br />
}<br />
}<br />
<br />
[System.Xml.Serialization.SoapType(Namespace="http://VALID HTTP")]<br />
public class compObj {<br />
<br />
public int Count;<br />
<br />
public string test;<br />
}<br />
Then in a main file I have:
<br />
try<br />
{<br />
ComplexObject co = new ComplexObject();<br />
compObj comp = co.getComplexObj();<br />
}<br />
catch( Exception e )<br />
{<br />
richTextBox1.Text+=e.Message + "\n" + e.StackTrace;<br />
}<br />
My ultimate goal is simply to call a function from perl that returns a complex object. ANY help would be greatly appreciated.
Mike - I love to program!
-- modified at 16:42 Saturday 25th March, 2006
|
|
|
|
|
I am trying to create a data connection in Visual studio using the above provider. The connection tests fine but I cannot see any tables. I suspect that is due to the initial catalog setting on the connection tab.
It will not allow me to put anything else than the server name of the as/400. How do I go about putting a library name(this is the equivelant of a database schema) so that I can view the tables and use them ??
Enasromios
|
|
|
|
|
i like to know how can i view the labels in runtime and edit they propertys like in desing time
|
|
|
|
|
nameOfYourLabel.WhateverProperty
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
i dont get your reply please be mor especific
|
|
|
|
|
You access properties of a label trough it's name.
Label is just a class so if you know how to work with clasess I don't know why you would not know how to work with labels...
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
now i understand you brother but its simple i have this problem and i dont know how to view a label at runtime like if it was in runtime i want that my lable be able to can be moved resize etc like in desing time
|
|
|
|
|
Well that is not so simple...
You will have to do a lot more work, write some code, respond to various events etc.
Maybe the best way would be to look at the source code of the SharpDevelop IDE...
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
You'll have to creat a new class, inheriting from Label. You'll need to handle the MouseMove, MouseDown, and MouseUp events so your mouse tracking code can work. You'll also need to track where in your control the mouse was clicked (MouseDown event), an offset from the top-left corner of your control. It might also be helper to change the mouse cursor while the mouse is being held down.
Here's the code I wrote to do this very thing (converted from VB.NET):
public class MovableLabel : Label
{
private Point cursorOffset;
private bool moving = false;
private Cursor currentCursor;
private void MovableLabel_MouseDown(object sender, System.Windows.Forms.MouseDownEventArgs e)
{
if (e.Button == Windows.Forms.MouseButtons.Left) {
cursorOffset = e.Location;
moving = true;
currentCursor = base.Cursor;
base.Cursor = Cursors.SizeAll;
}
}
private void MovableLabel_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (moving) {
object clientPosition = base.Parent.PointToClient(System.Windows.Forms.Cursor.Position);
base.Location = new Point(clientPosition.x - cursorOffset.X, clientPosition.y - cursorOffset.Y);
}
}
private void MoveableLabel_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
moving = Flase;
base.Cursor = currentCursor;
}
}
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
how can i view a label in runtime like if i was on desing time change his propetys etc
|
|
|
|
|
Do not post the same question more than once. If you require elaboration; 1) Edit your question with your new questions, or 2) Reply to the answer for which you do not understand stating so. Regards,
Jason Pezzimenti.
If you liked the answer that I have provided, then please click the 'Good Answer' link on the bottom-right of this post. Thank you.
|
|
|
|
|
Do not post the same question more than once. If you require elaboration; 1) Edit your question with your new questions, or 2) Reply to the answer for which you do not understand stating so.
|
|
|
|
|
I need to rip or lets say download a xhtml page from a webserver,
the problem is that i only get the source of the site and i would like also to get the dynanic part of the site.
My code so far (taken from an example), which i only get the static part of the site.
<br />
string lcUrl = url;<br />
<br />
HttpWebRequest loHttp =(HttpWebRequest)WebRequest.Create(lcUrl);<br />
<br />
loHttp.Timeout = 10000;
loHttp.UserAgent = "test";<br />
<br />
HttpWebResponse loWebResponse = (HttpWebResponse)loHttp.GetResponse();<br />
<br />
Encoding enc = Encoding.GetEncoding(1252);
<br />
StreamReader loResponseStream = new StreamReader(loWebResponse.GetResponseStream(), enc);<br />
<br />
string lcHtml = loResponseStream.ReadToEnd();<br />
<br />
loWebResponse.Close();<br />
loResponseStream.Close();<br />
return lcHtml;<br />
-- modified at 13:31 Monday 20th March, 2006
|
|
|
|
|
What 'dynamic part' are you trying to get?
If you mean the code behind, you can't.
|
|
|
|
|
no no , more like if have a tv guide site and you want to see whats on one channel ?
-- modified at 15:44 Monday 20th March, 2006
|
|
|
|
|
Well a lot depending on how consistant is the format of the site. You can use the source and find some constant word as an anchor and grab the text off the source.
Alternatively, what I had done previously was (on VB6) run a web control in the application, point it to the target URL, send a ctrl-A key and paste it on a text box / rich text box, then grab the data from the text box.
|
|
|
|
|
thanks i will take a look into it
|
|
|
|
|
I have a base-class B where I put all my slowly changing, somewhat generic stuff. On top of that I intend to have a class C : B; in words, C inherits from B.
What's the best way to build the interface(s)? I can imagine IB, so B : IB. How do I structure an interface for C? Do I build one global interface for (C : B)? or perhaps C : IC, B (but I don't really know that means, well, I could guess).
Please advise.
(Also, I suppose I could use composition, but I'm not yet fluent with that design pattern).
Thx.
|
|
|
|
|
That depends on how you want to use it. Are the functionalities of B and c good seperated? Do you always when you work on C also need the base functionality from B?
If both contents are totally seperated I would use the following:
B : IB; C: IC, B
If not:
B : IB; IBC : IB, IC; C : IBC
But again: It greatly depends on what your are actually trying to do and how the classes are logically bound together.
|
|
|
|
|
You could try reading the article Why Extends is Evil[^] by Allen Holub. It discusses a situation similar to yours. The article deals specifically with Java, but pertains to all object-oriented languages with single inheritance and multiple "interface" implementations.
In short, Holub's answer would consist of the following:
Create an interface IB .
Create a class B implementing interface IB .
Create an interface IC .
Create a class C implementing interfaces IB and IC .
Create a private member of C of type B and, in all the functions from IB , pass those requests through to B .
As an alternative, you could modify the third and fourth items in the above list to read like this:
Create an interface IC inheriting from IB .
Create a class C implementing interface IC .
I hope that helps.
|
|
|
|
|
In case I, do I ever inherit B to C (C : B), or does the private member B of C act as a proxy to inheritance?
In case II, C has to implement IB and IC, but my purpose is to code the implementation of IB in B.
Please advise.
Thx.
|
|
|
|