Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        /// <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()
            };
        }
Exemplo n.º 3
0
        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()
            };
        }
Exemplo n.º 4
0
        /// <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(),
            };
        }