public RequestMessageBody DeepCopy() { RequestMessageBody newRequestMessageBody = new RequestMessageBody(); foreach (PropertyInfo propInfo in newRequestMessageBody.GetType().GetProperties()) { if (propInfo.CanWrite) { propInfo.SetValue(newRequestMessageBody, propInfo.GetValue(this)); } } var notificationTypeInstance = (INotification)Activator.CreateInstance(this.Notification.GetType()); foreach (PropertyInfo propInfo in notificationTypeInstance.GetType().GetProperties()) { if (propInfo.CanWrite) { propInfo.SetValue(notificationTypeInstance, propInfo.GetValue(this.Notification)); } } newRequestMessageBody.Notification = notificationTypeInstance; Dictionary <string, string> payLoad = (Dictionary <string, string>) this.Data; Payload newPayload = new Payload(); foreach (var key in payLoad.Keys) { newPayload.Add(key, payLoad[key]); } newRequestMessageBody.Data = newPayload; return(newRequestMessageBody); }
/// <summary> /// Default constructor /// </summary> public RequestMessage() { ConnectionProtocol = FirebaseProtocol.HTTP; Header = new RequestMessageHeader("application/json"); Body = new RequestMessageBody(); _jsonSerializerSettings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, ContractResolver = new PropertyNameResolver() }; }
public RequestMessage(RequestMessageHeader header, RequestMessageBody body, FirebaseProtocol protocol = FirebaseProtocol.HTTP) { ConnectionProtocol = protocol; Header = header; Body = body; _jsonSerializerSettings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, ContractResolver = new PropertyNameResolver() }; }
/// <summary> /// All parameters are optional, every parameter will be initialized: /// Header will be ready and only Body needs to be filled with neccessary data /// </summary> /// <param name="body"></param> /// <param name="content_type">Default is 'application/json'</param> /// <param name="protocol">Default is HTTP</param> public RequestMessage(RequestMessageBody body = null, string content_type = "application/json", FirebaseProtocol protocol = FirebaseProtocol.HTTP) { ConnectionProtocol = protocol; Header = new RequestMessageHeader(content_type); Body = (body == null ? new RequestMessageBody() : body); _jsonSerializerSettings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, ContractResolver = new PropertyNameResolver(), }; }