Changeset 4699
- Timestamp:
- 06/12/08 11:26:46 (6 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/nuxleus/Source/CodeSamples/AwsSdbSOAP_Test/Program.cs
r4697 r4699 12 12 using System.Xml.Linq; 13 13 using VVMF.SOA.Common; 14 using System.Collections; 14 15 15 16 namespace AwsSdbSOAP_Test { … … 31 32 scope += exShield.Scope; 32 33 33 logger.Message = " DoSomething()";34 logger.Message = "Processing SOAP requests"; 34 35 35 36 // Inject code to scope 36 37 scope.Begin = () => { 37 PutAttributes( ).ExecuteAndWait();38 PutAttributes(scope).ExecuteAndWait(); 38 39 }; 39 40 … … 58 59 } 59 60 60 static IEnumerable<IAsync> PutAttributes( ) {61 static IEnumerable<IAsync> PutAttributes(Scope scope) { 61 62 62 List<XElement> responseList = new List<XElement>();63 Dictionary<XElement, XElement> responseList = new Dictionary<XElement, XElement>(); 63 64 64 65 SimpleDBService service = new SimpleDBService(); … … 84 85 85 86 Console.WriteLine("Completed all in:\t {0}ms", stopwatch.ElapsedMilliseconds); 86 Console.WriteLine("There are a total of {0} XElement objects in the result list", responseList.Count); 87 Console.WriteLine("There are a total of {0} result objects in the result dictionary", responseList.Count); 88 89 int c = 1; 90 IEnumerator responseEnumerator = responseList.GetEnumerator(); 91 92 while (responseEnumerator.MoveNext()){ 93 KeyValuePair<XElement,XElement> responseItem = (KeyValuePair<XElement,XElement>)responseEnumerator.Current; 94 Console.WriteLine(".......................... Begin Message {0} ............................", c); 95 Console.WriteLine("\n"); 96 Console.WriteLine("[Message {0} Sent]", c); 97 responseItem.Key.Save(Console.Out); 98 Console.WriteLine("\n"); 99 Console.WriteLine("[Message {0} Received]", c); 100 responseItem.Value.Save(Console.Out); 101 Console.WriteLine("\n"); 102 Console.WriteLine(".......................... End Message {0} ............................", c); 103 c++; 104 } 87 105 } 88 106 } trunk/nuxleus/Source/Dependencies/Scope/Scope/Scope.cs
r4696 r4699 4 4 using System.Text; 5 5 6 namespace VVMF.SOA.Common 7 { 8 public struct Scope 9 { 6 namespace VVMF.SOA.Common { 7 public struct Scope { 10 8 public delegate Chain Chain(Chain code); 11 9 12 10 public delegate void Block(); 13 11 14 public Scope(params Chain[] codes) 15 { 12 public Scope(params Chain[] codes) { 16 13 this.code = null; 17 if (codes != null) 18 { 19 foreach (Chain code in codes) 20 { 14 if (codes != null) { 15 foreach (Chain code in codes) { 21 16 AddCode(code); 22 17 } … … 24 19 } 25 20 26 public Scope(params Scope[] others) 27 { 21 public Scope(params Scope[] others) { 28 22 this.code = null; 29 if (others != null) 30 { 31 foreach (Scope other in others) 32 { 23 if (others != null) { 24 foreach (Scope other in others) { 33 25 AddCode(other.code); 34 26 } … … 38 30 Chain code; 39 31 40 private static Chain BlockToChain(Block code) 41 { 42 return c => 43 { 32 private static Chain BlockToChain(Block code) { 33 return c => { 44 34 code(); 45 35 return null; … … 47 37 } 48 38 49 private void AddCode(Chain otherCode) 50 { 51 if (otherCode != null) 52 { 39 private void AddCode(Chain otherCode) { 40 if (otherCode != null) { 53 41 Chain thisCode = this.code; 54 if (thisCode == null) 55 { 42 if (thisCode == null) { 56 43 this.code = otherCode; 57 } 58 else 59 { 44 } else { 60 45 this.code = (c) => otherCode(thisCode(c)); 61 46 } … … 63 48 } 64 49 65 public Block Begin 66 { 67 set 68 { 69 if (value == null) throw new ArgumentNullException("value"); 70 if (code != null) 71 { 50 public Block Begin { 51 set { 52 if (value == null) 53 throw new ArgumentNullException("value"); 54 if (code != null) { 72 55 code(BlockToChain(value))(null); 73 56 } … … 75 58 } 76 59 77 public static Scope operator +(Scope scope1, Scope scope2) 78 { 60 public static Scope operator +(Scope scope1, Scope scope2) { 79 61 Scope result = new Scope(scope1); 80 62 result.AddCode(scope2.code); … … 82 64 } 83 65 84 public static Scope operator +(Scope scope, Chain code) 85 { 66 public static Scope operator +(Scope scope, Chain code) { 86 67 Scope result = new Scope(scope); 87 68 result.AddCode(code); … … 89 70 } 90 71 91 public static implicit operator Scope(Chain code) 92 { 72 public static implicit operator Scope(Chain code) { 93 73 return new Scope(code); 94 74 } 95 75 96 public static implicit operator Chain(Scope scope) 97 { 76 public static implicit operator Chain(Scope scope) { 98 77 return scope.code; 99 78 } trunk/nuxleus/Source/Nuxleus.Extension.Aws/SimpleDB/SimpleDBService.cs
r4698 r4699 21 21 public struct SimpleDBService { 22 22 23 public X ContainerGetMessage(RequestType requestType, params string[] paramArray) {23 public XElement GetMessage(RequestType requestType, params string[] paramArray) { 24 24 25 25 XNamespace s = "http://schemas.xmlsoap.org/soap/envelope/"; 26 26 27 X ContainerawsSOAPMessage =27 XElement awsSOAPMessage = 28 28 new XElement(s + "Envelope", 29 29 new XElement(s + "Body", … … 86 86 } 87 87 88 public StreamReader MakeRequest(RequestType requestType, X Containermessage) {88 public StreamReader MakeRequest(RequestType requestType, XElement message) { 89 89 90 90 string rType = LabelAttribute.FromMember(requestType); … … 128 128 } 129 129 130 public static IEnumerable<IAsync> MakeSoapRequestAsync<T>(RequestType requestType, X Container message, List<T> responseList) {130 public static IEnumerable<IAsync> MakeSoapRequestAsync<T>(RequestType requestType, XElement message, Dictionary<XElement,T> responseList) { 131 131 132 132 string rType = LabelAttribute.FromMember(requestType); … … 148 148 if (xreader.IsStartElement()) { 149 149 output.Append(xreader.ReadOuterXml()); 150 Console.WriteLine("Output: {0} :/Output", output.ToString());151 150 buffer = encoding.GetBytes(output.ToString()); 152 151 } … … 166 165 167 166 using (Stream newStream = request.GetRequestStream()) { 168 try { 167 169 168 newStream.Write(buffer, 0, contentLength); 170 169 Async<WebResponse> response = request.GetResponseAsync(); … … 174 173 Async<T> responseObject = stream.ReadToEndAsync<T>().ExecuteAsync<T>(); 175 174 yield return responseObject; 176 responseList.Add(responseObject.Result); 177 //} finally (System.Net.WebException e) { 178 // Console.WriteLine("Failed! Reason: {0}, Message: {1}", e.Response, e.Message); 179 // return new StreamReader(e.Response.GetResponseStream()); 180 //} 181 } finally { 182 183 } 175 responseList.Add(message, responseObject.Result); 184 176 } 185 177
