This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
LETSIRTE_Client_extended.cs
181 lines (155 loc) · 5.38 KB
/
LETSIRTE_Client_extended.cs
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Xml.Serialization;
using System.Xml;
using System.Web.Services.Protocols;
using System.Collections;
using Rustici.LETSI.rtws;
using Microsoft.Web.Services3.Security.Tokens;
//using Microsoft.Web.Services3.Security.Tokens;
namespace Rustici.LETSI.rtws.client
{
public partial class LETSIRTE_Service
{
public LETSIRTE_Service(string sessionID, string secret)
: base()
{
UsernameToken token = new UsernameToken(sessionID, secret,
PasswordOption.SendHashed);
// make credentials available to send with the request
SetClientCredential(token);
// indicate that credentials should be sent with the request
SetPolicy("Client");
}
public cocdType Get()
{
return Get(new Get()).cocd;
}
public attemptSummary[] GetAttemptList()
{
return GetAttemptList(new GetAttemptList());
}
public void Set(cocdType cmi)
{
Set sr = new Set();
sr.cocd = cmi;
Set(sr);
}
public cocdType GetAttempt(int attemptNumber)
{
GetAttempt gar = new GetAttempt();
gar.attemptNumber = attemptNumber;
return GetAttempt(gar).cocd;
}
}
public interface IIdentified
{
string identifier {
get;
set;
}
}
public partial class correctResponsesTypeCorrectResponsePerformanceStep
{
public correctResponsesTypeCorrectResponsePerformanceStep() { }
public correctResponsesTypeCorrectResponsePerformanceStep(string stepName, string stepAnswer)
{
this.stepName = stepName;
this.stepAnswer = new correctResponsesTypeCorrectResponsePerformanceStepStepAnswer();
this.stepAnswer.Item = stepAnswer;
}
public correctResponsesTypeCorrectResponsePerformanceStep(string stepName, Decimal? min, Decimal? max)
{
this.stepName = stepName;
this.stepAnswer = new correctResponsesTypeCorrectResponsePerformanceStepStepAnswer();
correctResponsesTypeCorrectResponsePerformanceStepStepAnswerNumeric numAnswer = new correctResponsesTypeCorrectResponsePerformanceStepStepAnswerNumeric();
if (!(min == null))
{
numAnswer.minSpecified = true;
numAnswer.min = min.Value;
}
if (!(max == null))
{
numAnswer.maxSpecified= true;
numAnswer.max = max.Value;
}
this.stepAnswer.Item = numAnswer;
}
}
public partial class interactionType : IIdentified { }
public partial class objectiveType : IIdentified { }
public partial class attemptSummary
{
public override string ToString()
{
return cocdType.Serialize(this);
}
}
public partial class cocdType
{
/// <summary>
/// returns XML serialization
/// </summary>
public override string ToString()
{
XmlSerializer serializer = new XmlSerializer(this.GetType(),"http://ltsc.ieee.org/xsd/1484_11_3");
StringWriter sw = new StringWriter();
serializer.Serialize(sw, this);
return sw.ToString();
}
// code in this region is identical between server and client
// TODO: DRY
#region SERVER_AND_CLIENT
public static string Serialize(object obj)
{
XmlSerializer serializer = new XmlSerializer(obj.GetType(), "http://ltsc.ieee.org/xsd/1484_11_3");
StringWriter sw = new StringWriter();
serializer.Serialize(sw, obj);
return sw.ToString();
}
public objectiveType GetObjective(string id, bool createIfNotFound)
{
return GetItem<objectiveType>(id, createIfNotFound, ref objectivesField);
}
public interactionType GetInteraction(string id, bool createIfNotFound)
{
return GetItem<interactionType>(id, createIfNotFound, ref interactionsField);
}
private T GetItem<T>(string id, bool createIfNotFound,ref T[] list) where T : class,IIdentified,new()
{
if (list == null) {
list = new T[0];
}
foreach (T itm in list)
{
if (((IIdentified)itm).identifier == id)
{
return itm;
}
}
if (createIfNotFound)
{
// not found, create
T newItm = new T();
((IIdentified)newItm).identifier = id;
AddItem<T>(newItm,ref list);
return newItm;
}
else
{
// not found, not createIfNotFound
return null;
}
}
public void AddItem<T>(T obj,ref T[] list)
{
int index = 0;
index = list.Length;
Array.Resize<T>(ref list, index + 1);
list[index] = obj;
}
#endregion
}
}