Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added AddSeries function

  • Loading branch information...
commit b53f1e264cf20941e89397f48fbc9a18538c7b64 1 parent 9528f6b
unknown authored
View
17 SilverlightCalculator/Calculator.cs
@@ -40,8 +40,7 @@ public string Divide(string value1, string value2)
return (decimal_1/decimal_2).ToString();
}
- [
- ScriptableMember]
+ [ScriptableMember]
public string Subtract(string value1, string value2)
{
var decimal_1 = System.Convert.ToDecimal(value1);
@@ -50,5 +49,19 @@ public string Subtract(string value1, string value2)
return (decimal_1 - decimal_2).ToString();
}
+
+ [ScriptableMember]
+ public string AddSeries(string series)
+ {
+ var returnValue = 0.0m;
+
+ var parts = series.Split(System.Convert.ToChar(","));
+ foreach(string part in parts)
+ {
+ returnValue += System.Convert.ToDecimal(part);
+ }
+ return returnValue.ToString();
+ }
+
}
}
View
BIN  WebSample/Silverlight/SilverlightCalculator.xap
Binary file not shown
View
6 WebSample/index.htm
@@ -33,6 +33,12 @@
<td><input type="button" id="cmdDivideNumbers" value="Divide Values"/>
<td><input type="button" id="cmdSubtractNumbers" value="Subtract Values"/>
</tr>
+ <tr>
+ <td>Add Series</td>
+ <td>&nbsp;</td>
+ <td><input type="text" id="txtSeries" value=".1,.2,.3"/></td>
+ <td><input type="button" id="cmdAddSeries" value="Add Series"/>
+ </tr>
</table>
</body>
View
6 WebSample/main.js
@@ -3,6 +3,7 @@ function main(){
$("#cmdMultiplyNumbers").click(multiplyNumbers);
$("#cmdDivideNumbers").click(divideNumbers);
$("#cmdSubtractNumbers").click(subtractNumbers);
+ $("#cmdAddSeries").click(addSeries);
}
function getCalculatorHandle() {
@@ -18,6 +19,11 @@ function addNumbers(){
alert(calc);
}
+function addSeries() {
+ var seriesString = $("#txtSeries").val();
+ var calc = getCalculatorHandle().AddSeries(seriesString);
+ alert(calc);
+}
function multiplyNumbers(){
var factor_1 = $("#addNumber1").val();
Please sign in to comment.
Something went wrong with that request. Please try again.