How to convert JSON data to Class Object - string

JS Code.
// this is person class constructor.
function personClass(id, name, address, phone) {
this.Id = id;
this.Name = name;
this.Address = address;
this.Phone = phone;
}
var person = new Array();
person.push(new personClass("101", $('#txtName').val(), $('#txtAddress').val(), $('#txtPhone').val());
AjaxRequest = function ("PersonInfo.asmx/AddNewPerson", "{'person[]':'" + JSON.stringify(person) + "'}", successcallback, errorcallback) {
$.ajax({
type: "POST",
url: url,
data: param,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: successcallback,
error: errorcallback
});
}
C# Code.
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
[WebMethod(EnableSession = true)]
public string AddProduct(Person[] person)
{
return person[0].Id;
}
public class Person
{
private string _id = String.Empty;
private string Id
{
get { return _id; }
set { _id = value; }
}
private string _name = String.Empty;
private string Name
{
get { return _name; }
set { _name = value; }
}
private string _address = String.Empty;
private string Address
{
get { return _address; }
set { _address = value; }
}
private string _phone = String.Empty;
private string Id
{
get { return _phone; }
set { _phone = value; }
}
}
Problem is that : show response error message following -:
{"Message":"Invalid web service call,
missing value for parameter:
\u0027person\u0027.","StackTrace":" at
System.Web.Script.Services.WebServiceMethodData.CallMethod(Object
target, IDictionary2 parameters)\r\n
at
System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object
target, IDictionary2 parameters)\r\n
at
System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext
context, WebServiceMethodData
methodData, IDictionary`2
rawParams)\r\n at
System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext
context, WebServiceMethodData
methodData)","ExceptionType":"System.InvalidOperationException"}
Please suggest the solution.

Try:
"{'person':" + JSON.stringify(person) + "}"
It differs from your code in two places:
person instead of person[]
No quotes around person object

Related

How to Insert Data in a SharePoint List via GraphAPI?

I have SharePoint List which content a Reference No. It'd URL look like this:
https://xyz.sharepoint.com/sites/site_name/Lists/List_name/AllItems.aspx
This List content ref no. I am trying to insert this data in the list.
{
"Optimum_x0020_Case_x0020_Reference": "000777"
}
This is url I am posting the data.
https://graph.microsoft.com/v1.0/sites/xyz.sharepoint.com:/sites/site_name:/lists/List_names/items
But I am getting this error:
error": {
"code": "accessDenied",
"message": "The caller does not have permission to perform the action.",
How to solve this? Using the access I am able to create folder, sub folder and Update meta data for other document.
What is the context of what you are doing this with? Is it an app that you are using? Are you inserting data on a already existing listitem or a new item?
This is the code I had to use for my UWP App. I'm not sure if this will help you or not, but it should give you a little guidance I hope. Creating the dictionary and figuring out the XML structure were the keys things I had to piece together to get my code to work.
I declared my scopes in my App.xaml.cs
public static string[] scopes = new string[] { "user.ReadWrite", "Sites.ReadWrite.All", "Files.ReadWrite.All" };
I have a submit button that I use on my MainPage
private async void SubmitButton_Click(object sender, RoutedEventArgs e)
{
var (authResult, message) = await Authentication.AquireTokenAsync();
if (authResult != null)
{
await SubmitDataWithTokenAsync(submiturl, authResult.AccessToken);
}
}
This calls the AquireToken which I have in a class file:
public static async Task<(AuthenticationResult authResult, string message)> AquireTokenAsync()
{
string message = String.Empty;
string[] scopes = App.scopes;
AuthenticationResult authResult = null;
message = string.Empty;
//TokenInfoText.Text = string.Empty;
IEnumerable<IAccount> accounts = await App.PublicClientApp.GetAccountsAsync();
IAccount firstAccount = accounts.FirstOrDefault();
try
{
authResult = await App.PublicClientApp.AcquireTokenSilentAsync(scopes, firstAccount);
}
catch (MsalUiRequiredException ex)
{
// A MsalUiRequiredException happened on AcquireTokenSilentAsync. This indicates you need to call AcquireTokenAsync to acquire a token
System.Diagnostics.Debug.WriteLine($"MsalUiRequiredException: {ex.Message}");
try
{
authResult = await App.PublicClientApp.AcquireTokenAsync(scopes);
}
catch (MsalException msalex)
{
message = $"Error Acquiring Token:{System.Environment.NewLine}{msalex}";
}
}
catch (Exception ex)
{
message = $"Error Acquiring Token Silently:{System.Environment.NewLine}{ex}";
}
return (authResult,message);
}
I had created another class for my SharePointList
public class SharePointListItems
{
public class Lookup
{
public string SerialNumber { get; set; }
public string id { get; set; }
public override string ToString()
{
return SerialNumber;
}
}
public class Value
{
public Lookup fields { get; set; }
}
public class Fields
{
[JsonProperty("#odata.etag")]
public string ODataETag { get; set; }
public string ParameterA { get; set; }
public string ParameterB { get; set; }
public string ParameterC { get; set; }
}
public class RootObject
{
[JsonProperty("#odata.context")]
public string ODataContext { get; set; }
[JsonProperty("#odata.etag")]
public string ODataETag { get; set; }
[JsonProperty("fields#odata.context")]
public string FieldsODataContext { get; set; }
public Fields Fields { get; set; }
}
}
I used this class to create a dictionary for submitting my data to SharePoint.
public async Task<string> SubmitDataWithTokenAsync(string url, string token)
{
var httpClient = new HttpClient();
HttpResponseMessage response;
try
{
var root = new
{
fields = new Dictionary<string, string>
{
// The second string are public static strings that I
// I declared in my App.xaml.cs because of the way my app
// is set up.
{ "ParameterA", App.ParameterA },
{ "ParameterB", App.ParameterB },
{ "ParameterC", App.ParameterC },
}
};
var s = new JsonSerializerSettings { DateFormatHandling = DateFormatHandling.MicrosoftDateFormat };
var content = JsonConvert.SerializeObject(root, s);
var request = new HttpRequestMessage(HttpMethod.Post, url);
//Add the token in Authorization header
request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);
request.Content = new StringContent(content, Encoding.UTF8, "application/json");
response = await httpClient.SendAsync(request);
var responseString = await response.Content.ReadAsStringAsync();
return responseString;
}
catch (Exception ex)
{
return ex.ToString();
}
}
And my submiturl is defined:
public static string rooturl = "https://graph.microsoft.com/v1.0/sites/xxxxxx.sharepoint.com,495435b4-60c3-49b7-8f6e-1d262a120ae5,0fad9f67-35a8-4c0b-892e-113084058c0a/";
string submiturl = rooturl + "lists/18a725ac-83ef-48fb-a5cb-950ca2378fd0/items";
You can also look at my posted question on a similar topic here.

response.body returns null using retrofit:2.3.0

my json data is this
{
"data":[
{
"id":"4",
"totalOpns":"40000",
"killedDrugPer":"320",
"arrestedDrugPer":"17683",
"houseVisited":"4000",
"userSurrenderers":"45000",
"pusherSurrenderers":"15000",
"totalSurrenderers":"60000",
"killedPNPPerOpns":"40",
"woundedPNPPerOpns":"70",
"killedAFPPerOpns":"100",
"woundedAFPPerOpns":"10",
"date":"2017-07-12 13:57:34.000"
}
]
}
and my data model is this
package com.androidtutorialpoint.retrofitandroid;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
public class Student implements Serializable {
//Variables that are in our json
#SerializedName("id")
#Expose
private String id;
#SerializedName("totalOpns")
#Expose
private String totalOpns;
#SerializedName("killedDrugPer")
#Expose
private String killedDrugPer;
#SerializedName("arrestedDrugPer")
#Expose
private String arrestedDrugPer;
#SerializedName("houseVisited")
#Expose
private String houseVisited;
#SerializedName("userSurrenderers")
#Expose
private String userSurrenderers;
#SerializedName("pusherSurrenderers")
#Expose
private String pusherSurrenderers;
#SerializedName("totalSurrenderers")
#Expose
private String totalSurrenderers;
#SerializedName("killedPNPPerOpns")
#Expose
private String killedPNPPerOpns;
#SerializedName("woundedPNPPerOpns")
#Expose
private String woundedPNPPerOpns;
#SerializedName("killedAFPPerOpns")
#Expose
private String killedAFPPerOpns;
#SerializedName("woundedAFPPerOpns")
#Expose
private String woundedAFPPerOpns;
#SerializedName("date")
#Expose
private String date;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTotalOpns() {
return totalOpns;
}
public void setTotalOpns(String totalOpns) {
this.totalOpns = totalOpns;
}
public String getKilledDrugPer() {
return killedDrugPer;
}
public void setKilledDrugPer(String killedDrugPer) {
this.killedDrugPer = killedDrugPer;
}
public String getArrestedDrugPer() {
return arrestedDrugPer;
}
public void setArrestedDrugPer(String arrestedDrugPer) {
this.arrestedDrugPer = arrestedDrugPer;
}
public String getHouseVisited() {
return houseVisited;
}
public void setHouseVisited(String houseVisited) {
this.houseVisited = houseVisited;
}
public String getUserSurrenderers() {
return userSurrenderers;
}
public void setUserSurrenderers(String userSurrenderers) {
this.userSurrenderers = userSurrenderers;
}
public String getPusherSurrenderers() {
return pusherSurrenderers;
}
public void setPusherSurrenderers(String pusherSurrenderers) {
this.pusherSurrenderers = pusherSurrenderers;
}
public String getTotalSurrenderers() {
return totalSurrenderers;
}
public void setTotalSurrenderers(String totalSurrenderers) {
this.totalSurrenderers = totalSurrenderers;
}
public String getKilledPNPPerOpns() {
return killedPNPPerOpns;
}
public void setKilledPNPPerOpns(String killedPNPPerOpns) {
this.killedPNPPerOpns = killedPNPPerOpns;
}
public String getWoundedPNPPerOpns() {
return woundedPNPPerOpns;
}
public void setWoundedPNPPerOpns(String woundedPNPPerOpns) {
this.woundedPNPPerOpns = woundedPNPPerOpns;
}
public String getKilledAFPPerOpns() {
return killedAFPPerOpns;
}
public void setKilledAFPPerOpns(String killedAFPPerOpns) {
this.killedAFPPerOpns = killedAFPPerOpns;
}
public String getWoundedAFPPerOpns() {
return woundedAFPPerOpns;
}
public void setWoundedAFPPerOpns(String woundedAFPPerOpns) {
this.woundedAFPPerOpns = woundedAFPPerOpns;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
}
and the interface is this
package com.androidtutorialpoint.retrofitandroid;
import retrofit2.Call;
import retrofit2.http.GET;
public interface RetrofitObjectAPI {
/*
* Retrofit get annotation with our URL
* And our method that will return us details of student.
*/
// #GET("JSONTESTING/index.php")
#GET("getJson")
Call<Student> getStudentDetails();
}
and in my main is this
private void getRetrofitObject() {
HttpLoggingInterceptor.Level logLevel = HttpLoggingInterceptor.Level.BODY;
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
// set your desired log level
logging.setLevel(logLevel);
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
// add your other interceptors …
// add logging as last interceptor
httpClient.addInterceptor(logging); // <-- this is the important line!
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(url)
.addConverterFactory(GsonConverterFactory.create())
.client(httpClient.build())
.build();
RetrofitObjectAPI service = retrofit.create(RetrofitObjectAPI.class);
Call<Student> call = service.getStudentDetails();
call.enqueue(new Callback<Student>() {
#Override
public void onResponse(Call<Student> call, Response<Student> response) {
try {
if (response.isSuccessful()) {
text_id_1.setText("StudentId : " + response.body().getId());
text_name_1.setText("StudentName : " + response.body().getTotalOpns());
text_marks_1.setText("StudentMarks : " + response.body().getArrestedDrugPer());
} else {
//unsuccessful response
}
} catch (Exception e) {
Log.d("onResponse", "There is an error");
e.printStackTrace();
}
}
#Override
public void onFailure(Call<Student> call, Throwable t) {
Log.d("onFailure", t.toString());
}
});
}
and in my logcat is this, i can see the json data but on my response.body returns null.
logcat
What should I do?
You are getting a response but there is issue in deserialization.
Reason being the Call<Student> is not the type it will be serialized to becuase you are getting a List of Students(JSONArray).
add this class
MyResponse
public class MyResponse {
#SerializedName("data")
#Expose
private List<Student> data = null;
public List<Student> getData() {
return data;
}
public void setData(List<Student> data) {
this.data = data;
}
}
and change your call to:
#GET("getJson")
Call<MyResponse> getStudentDetails();
Now you will get response body
and how to retrive?
List<Student> students = response.body().getData();
This will do..:)

How to get values of passed in object using C#

I have a following code
public void ShowForm(String EName, String phoneNumber, String dnis, String mode, String callid)
{
objCallParams.EventName = EName;
objCallParams.ANI = phoneNumber;
objCallParams.DNIS = dnis;
objCallParams.Mode = mode;
objCallParams.CallId = callid;
UIThreadContext.Post(InComing_Callback, (object)objCallParams);
}
private void InComing_Callback(object objCallParams)
{
/*want to access phone number i.e.objCallParams.ANI*/
}
How do I access phoneNumber in InComing_Callback(object objCallParams) method?
If you know the type of the object you can use casting
private void InComing_Callback(object objCallParams)
{
// If you know that objCallParams will always be of the type FormParameters:
var params = (FormParameters)objCallParams;
// if you are not so sure about that
var notSoSureParams = objCallParams as FormParameters;
if (notSoSureParams != null)
{
}
}

reading an object from stream

I'm trying to read an object ChatMassage from the stream and to print a message (which this object contains) with its method getMassage(). It prints a message the first time but next time it always prints the first message. What is wrong?
Here is an example of the code:
while(keepGoing){
System.out.println("Client: " + ((ChatMassage) in.readObject()).getMassage() + "\n" );
}
ChatMassage class:
public class ChatMassage implements Serializable {
String msg, recipientName = null;
String senderName = "None";
public void setMassage(String msg) {
this.msg = msg;
}
public void setRecipientName(String recName) {
recipientName = recName;
}
public String getMassage() {
return msg;
}
public String getRecipientName() {
return recipientName;
}
public void setSenderName(String name) {
senderName = name;
}
public String getSenderName() {
return senderName;
}
}
I think the problem lies in this method:
public void setMassage(String msg) {
this.msg = msg;
}
I don't know if that can be a problem, but try changing the parameter to something like "new_msg". I think it confuses the "this.msg" with "msg".

How to get ACS token out from raw token we get Identity Provider

I am getting the token from acs as describe in this post Validating a SWT Token REST WCF Service
But i was not able to extract the ACS token.
Could you please help me in that.
Actually the class the extract the acs token "JsonNotifyRequestSecurityTokenResponse.FromJson"
I was not able to get that as the class as the link provided is not working.
I think you posted this question as an answer at my question some hours ago and then deleted it. So i looked up my old project and found the code you need:
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IdentityModel.Policy;
using System.IdentityModel.Tokens;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Web;
using System.Xml.Linq;
using Thinktecture.IdentityModel.Extensions;
namespace Security {
[DataContract]
public class JsonNotifyRequestSecurityTokenResponse {
[DataMember(Name = "appliesTo", Order = 1)]
public string AppliesTo { get; set; }
[DataMember(Name = "context", Order = 2)]
public string Context { get; set; }
[DataMember(Name = "created", Order = 3)]
public string Created { get; set; }
[DataMember(Name = "expires", Order = 4)]
public string Expires { get; set; }
[DataMember(Name = "securityToken", Order = 5)]
public string SecurityTokenString { get; set; }
[DataMember(Name = "tokenType", Order = 6)]
public string TokenType { get; set; }
public DateTime ValidFrom { get; set; }
public DateTime ValidTo { get; set; }
public GenericXmlSecurityToken SecurityToken { get; set; }
public static JsonNotifyRequestSecurityTokenResponse FromJson(string jsonString) {
JsonNotifyRequestSecurityTokenResponse rstr;
var memoryStream = new MemoryStream(Encoding.Unicode.GetBytes(jsonString));
var serializer = new DataContractJsonSerializer(typeof(JsonNotifyRequestSecurityTokenResponse));
rstr = serializer.ReadObject(memoryStream) as JsonNotifyRequestSecurityTokenResponse;
memoryStream.Close();
ParseValues(rstr);
return rstr;
}
private static void ParseValues(JsonNotifyRequestSecurityTokenResponse rstr) {
rstr.ValidFrom = ulong.Parse(rstr.Created).ToDateTimeFromEpoch();
rstr.ValidTo = ulong.Parse(rstr.Expires).ToDateTimeFromEpoch();
rstr.SecurityTokenString = HttpUtility.HtmlDecode(rstr.SecurityTokenString);
var xml = XElement.Parse(rstr.SecurityTokenString);
string idAttribute = "";
string tokenType = "";
switch (rstr.TokenType) {
case SecurityTokenTypes.Saml11:
idAttribute = "AssertionID";
tokenType = SecurityTokenTypes.Saml11;
break;
case SecurityTokenTypes.Saml2:
idAttribute = "ID";
tokenType = SecurityTokenTypes.Saml2;
break;
case SecurityTokenTypes.SWT:
idAttribute = "Id";
tokenType = SecurityTokenTypes.SWT;
break;
}
if (tokenType == SecurityTokenTypes.Saml11 || tokenType == SecurityTokenTypes.Saml2) {
var tokenId = xml.Attribute(idAttribute);
var xmlElement = xml.ToXmlElement();
SecurityKeyIdentifierClause clause = null;
if (tokenId != null) {
clause = new SamlAssertionKeyIdentifierClause(tokenId.Value);
}
rstr.SecurityToken = new GenericXmlSecurityToken(
xmlElement,
null,
rstr.ValidFrom,
rstr.ValidTo,
clause,
clause,
new ReadOnlyCollection<IAuthorizationPolicy>(new List<IAuthorizationPolicy>()));
}
}
private class SecurityTokenTypes {
public const string Saml2 = "urn:oasis:names:tc:SAML:2.0:assertion";
public const string Saml11 = "urn:oasis:names:tc:SAML:1.0:assertion";
public const string SWT = "http://schemas.xmlsoap.org/ws/2009/11/swt-token-profile-1.0";
}
}
}
You should get the Thinktecture.IdentityModel.Extensions assembly from: http://identitymodel.codeplex.com/
I hope this helps.
EDIT - SWT token handling
I don't know if it helps, but I've found a SWTModule which should handle a SWT token.
public class SWTModule : IHttpModule {
void IHttpModule.Dispose() {
}
void IHttpModule.Init(HttpApplication context) {
context.BeginRequest += new EventHandler(context_BeginRequest);
}
void context_BeginRequest(object sender, EventArgs e) {
//HANDLE SWT TOKEN VALIDATION
// get the authorization header
string headerValue = HttpContext.Current.Request.Headers.Get("Authorization");
// check that a value is there
if (string.IsNullOrEmpty(headerValue)) {
throw new ApplicationException("unauthorized");
}
// check that it starts with 'WRAP'
if (!headerValue.StartsWith("WRAP ")) {
throw new ApplicationException("unauthorized");
}
string[] nameValuePair = headerValue.Substring("WRAP ".Length).Split(new char[] { '=' }, 2);
if (nameValuePair.Length != 2 ||
nameValuePair[0] != "access_token" ||
!nameValuePair[1].StartsWith("\"") ||
!nameValuePair[1].EndsWith("\"")) {
throw new ApplicationException("unauthorized");
}
// trim off the leading and trailing double-quotes
string token = nameValuePair[1].Substring(1, nameValuePair[1].Length - 2);
// create a token validator
TokenValidator validator = new TokenValidator(
this.acsHostName,
this.serviceNamespace,
this.trustedAudience,
this.trustedTokenPolicyKey);
// validate the token
if (!validator.Validate(token)) {
throw new ApplicationException("unauthorized");
}
}
}
And you also need the TokenValidator:
public class TokenValidator {
private string issuerLabel = "Issuer";
private string expiresLabel = "ExpiresOn";
private string audienceLabel = "Audience";
private string hmacSHA256Label = "HMACSHA256";
private string acsHostName;
private string trustedSigningKey;
private string trustedTokenIssuer;
private string trustedAudienceValue;
public TokenValidator(string acsHostName, string serviceNamespace, string trustedAudienceValue, string trustedSigningKey) {
this.trustedSigningKey = trustedSigningKey;
this.trustedTokenIssuer = String.Format("https://{0}.{1}/",
serviceNamespace.ToLowerInvariant(),
acsHostName.ToLowerInvariant());
this.trustedAudienceValue = trustedAudienceValue;
}
public bool Validate(string token) {
if (!this.IsHMACValid(token, Convert.FromBase64String(this.trustedSigningKey))) {
return false;
}
if (this.IsExpired(token)) {
return false;
}
if (!this.IsIssuerTrusted(token)) {
return false;
}
if (!this.IsAudienceTrusted(token)) {
return false;
}
return true;
}
public Dictionary<string, string> GetNameValues(string token) {
if (string.IsNullOrEmpty(token)) {
throw new ArgumentException();
}
return
token
.Split('&')
.Aggregate(
new Dictionary<string, string>(),
(dict, rawNameValue) => {
if (rawNameValue == string.Empty) {
return dict;
}
string[] nameValue = rawNameValue.Split('=');
if (nameValue.Length != 2) {
throw new ArgumentException("Invalid formEncodedstring - contains a name/value pair missing an = character");
}
if (dict.ContainsKey(nameValue[0]) == true) {
throw new ArgumentException("Repeated name/value pair in form");
}
dict.Add(HttpUtility.UrlDecode(nameValue[0]), HttpUtility.UrlDecode(nameValue[1]));
return dict;
});
}
private static ulong GenerateTimeStamp() {
// Default implementation of epoch time
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToUInt64(ts.TotalSeconds);
}
private bool IsAudienceTrusted(string token) {
Dictionary<string, string> tokenValues = this.GetNameValues(token);
string audienceValue;
tokenValues.TryGetValue(this.audienceLabel, out audienceValue);
if (!string.IsNullOrEmpty(audienceValue)) {
if (audienceValue.Equals(this.trustedAudienceValue, StringComparison.Ordinal)) {
return true;
}
}
return false;
}
private bool IsIssuerTrusted(string token) {
Dictionary<string, string> tokenValues = this.GetNameValues(token);
string issuerName;
tokenValues.TryGetValue(this.issuerLabel, out issuerName);
if (!string.IsNullOrEmpty(issuerName)) {
if (issuerName.Equals(this.trustedTokenIssuer)) {
return true;
}
}
return false;
}
private bool IsHMACValid(string swt, byte[] sha256HMACKey) {
string[] swtWithSignature = swt.Split(new string[] { "&" + this.hmacSHA256Label + "=" }, StringSplitOptions.None);
if ((swtWithSignature == null) || (swtWithSignature.Length != 2)) {
return false;
}
HMACSHA256 hmac = new HMACSHA256(sha256HMACKey);
byte[] locallyGeneratedSignatureInBytes = hmac.ComputeHash(Encoding.ASCII.GetBytes(swtWithSignature[0]));
string locallyGeneratedSignature = HttpUtility.UrlEncode(Convert.ToBase64String(locallyGeneratedSignatureInBytes));
return locallyGeneratedSignature == swtWithSignature[1];
}
private bool IsExpired(string swt) {
try {
Dictionary<string, string> nameValues = this.GetNameValues(swt);
string expiresOnValue = nameValues[this.expiresLabel];
ulong expiresOn = Convert.ToUInt64(expiresOnValue);
ulong currentTime = Convert.ToUInt64(GenerateTimeStamp());
if (currentTime > expiresOn) {
return true;
}
return false;
} catch (KeyNotFoundException) {
throw new ArgumentException();
}
}
}

Resources