Hallo *,
ich schlage mich jetzt schon ein bisschen mit C# rum, komme aber überhaupt nicht weiter (auch nach 2 Tagen rumgegoogle).
(Beide im gleichen Namespace)
Aufrufende Methode in Klasse Page :
C#-Quelltext
1: 2: 3: 4: 5: 6:
| public partial class Page : UserControl { Parser prs1; private XDocument ser_XMLFile_systems = new XDocument(); prs1 = new Parser("systems.xml", ser_XMLFile_systems); } |
Aufzurufenden Methoden in Klasse Parser:
C#-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26:
| public class Parser { private XDocument in_target;
public Parser (string uri_xml_file, XDocument target) { WebClient wc = new WebClient(); wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted); wc.DownloadStringAsync(new Uri(uri_xml_file, UriKind.RelativeOrAbsolute)); count_instances++; target = in_target; }
private void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { if (e.Error == null) { in_target = System.Xml.Linq.XDocument.Parse(e.Result); } count_instances--; if (count_instances == 0) { OnAllFilesDownloaded(this, new EventArgs()); } } } |
Wie bekomme ich jetzt die Referenz in target nach in_target, sodass sich das Objekt, das hinter target steckt durch die Methode wc_DownloadStringCompleted verändert werden kann?
Stichworte, wie Boxing und Unboxing und Regel der OO habe ich schon gehört, finde aber, dass mein Problem in eines dieser Raster fällt...