To the person who wrote on Sunday-
I finally got the C# answer to returning a vector of Strings from a WSDL created by Axis:
Basically you have to return a struct Vector of IEnumerable objects..
//here is a Main method to make everything work
static void Main()
{
strings[] = {"Tom","Dick","Harry"};
Vector f = new Vector(); //instantiate the struct
foreach (string item in f) //there are many strings within Vector
{
f.push(item); //push the values into the Vector
Console.WriteLine(item); //write one string out at a time
}
}
struct Vector
{
String s[]; //array of strings within vector..
static int ctr=0;
//make a class that will push the strings into the vector
push(str) { s[ctr++]=str; Tokens =new Tokens(s[ctr],',');}
};
// tokens2.cs
using System;
using System.Collections;
public class Tokens: IEnumerable
{
static int ctr=0;
private string[] elements; //contained in here are all the IEnumerable elements
// Test Method for Tokens, TokenEnumerator
static void Main(string[] args)
{
Tokens f = new Tokens(args,
new char [] = {' ','-',','}); //delimiters
foreach (string item in f)
{
Console.WriteLine(item);
}
}
Tokens(string source, char[] delimiters)
{ //split the source by delimiters
elements[ctr++] = source.Split(delimiters);
}
//get the IEnumerable Interface Implementation (TokenEnumerator):
public TokenEnumerator GetEnumerator() // non-IEnumerable version
{
return new TokenEnumerator(this);
}
IEnumerator IEnumerable.GetEnumerator() // IEnumerable version
{
return (IEnumerator) new TokenEnumerator(this);
}
// Inner class implements IEnumerator interface:
public class TokenEnumerator: IEnumerator
{ //this inner class handles Enumerator positioning
private int position = -1;
private Tokens t; //Parent Class Tokens
//Constructor for Enumerator for Tokens
public TokenEnumerator(Tokens t)
{
this.t = t;
}
//Move position to next object
public bool MoveNext()
{
if (position < t.elements.Length - 1)
{
position++;
return true;
}
else
{
return false;
}
}
//move position to default -1
public void Reset()
{
position = -1;
}
//return the String value of the element located at Current position
public string Current // non-IEnumerator version: type-safe
{
get
{
return t.elements[position];
}
}
//return the object of the element located at Current Position
object IEnumerator.Current // IEnumerator version: returns object
{
get
{
return t.elements[position];
}
}
}
}
I am not a C# expert and this needs ALOT OF WORK but you get the gist of how to handle a vector of strings in C#
hth,
______________________________________________
Disclaimer and confidentiality note
Everything in this e-mail and any attachments relating to the official business of Laconia Data Systems (LDS) is proprietary to the company. It is confidential, legally privileged and protected by law. LDS does not own and endorse any other content.
STOP MORE SPAM with the new MSN 8 and get 2 months FREE*
