private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "") { return; } textBox2.Text = PFunc.SetKey(textBox1.Text); }
public Boolean ParseMandatory <T>(String PropertyName, String PropertyDescription, String DefaultServerName, PFunc <T> Parser, out T Value, HTTPRequest HTTPRequest, out HTTPResponse HTTPResponse) { Object JSONToken = null; if (!TryGetValue(PropertyName, out JSONToken)) { HTTPResponse = new HTTPResponseBuilder(HTTPRequest) { HTTPStatusCode = HTTPStatusCode.BadRequest, Server = DefaultServerName, Date = DateTime.Now, ContentType = HTTPContentType.JSON_UTF8, Content = JSONObject.Create( new JProperty("description", "Missing JSON property '" + PropertyName + "'!") ).ToUTF8Bytes() }; Value = default(T); return(false); } if (JSONToken != null) { if (!Parser(JSONToken.ToString(), out Value)) { HTTPResponse = new HTTPResponseBuilder(HTTPRequest) { HTTPStatusCode = HTTPStatusCode.BadRequest, Server = DefaultServerName, Date = DateTime.Now, ContentType = HTTPContentType.JSON_UTF8, Content = JSONObject.Create( new JProperty("description", "Unknown " + PropertyDescription + "!") ).ToUTF8Bytes() }; Value = default(T); return(false); } HTTPResponse = null; return(true); } Value = default(T); HTTPResponse = null; return(true); }
public Boolean ParseOptionalN <T>(String PropertyName, String PropertyDescription, String DefaultServerName, PFunc <T> Parser, out T?Value, HTTPRequest HTTPRequest, out HTTPResponse HTTPResponse) where T : struct { Object JSONToken = null; Value = new T?(); if (TryGetValue(PropertyName, out JSONToken)) { if (JSONToken != null) { var JSONValue = JSONToken.ToString(); T _Value = default(T); if (JSONValue != null && !Parser(JSONValue, out _Value)) { HTTPResponse = new HTTPResponseBuilder(HTTPRequest) { HTTPStatusCode = HTTPStatusCode.BadRequest, Server = DefaultServerName, Date = DateTime.Now, ContentType = HTTPContentType.JSON_UTF8, Content = JSONObject.Create( new JProperty("description", "Unknown " + PropertyDescription + "!") ).ToUTF8Bytes() }; Value = new T?(); return(false); } Value = new T?(_Value); } } HTTPResponse = null; return(true); }
public Accessor(Type type, string propertyName) { var propertyInfo = type.GetProperty(propertyName); if (propertyInfo != null) { var gm = propertyInfo.GetGetMethod(); var sm = propertyInfo.GetSetMethod(); if (propertyInfo.CanRead && gm != null) { GetValueDelegate = (PFunc <T, P>)Delegate.CreateDelegate(PFuncType, gm); } if (propertyInfo.CanWrite && sm != null) { SetValueDelegate = (PAction <T, P>)Delegate.CreateDelegate(PActionType, sm); } } this.propertyInfo = propertyInfo; }