Esempio n. 1
0
        private void CreateNewData(InternalReferenceObject internalReferenceObject)
        {
            var data = new Data();

            SetDataMessage(internalReferenceObject, data);

            m_Data.Add(internalReferenceObject.Id, data);
        }
Esempio n. 2
0
        private void ModifyData(InternalReferenceObject internalReferenceObject)
        {
            var data = m_Data[internalReferenceObject.Id];

            SetDataMessage(internalReferenceObject, data);

            m_Data.Remove(internalReferenceObject.Id);
            m_Data.Add(internalReferenceObject.Id, data);
        }
Esempio n. 3
0
        private static void SetDataMessage(InternalReferenceObject internalReferenceObject, Data data)
        {
            var message = new Message {
                data = GetJsonData(internalReferenceObject.Body)
            };

            switch (internalReferenceObject.Relation)
            {
            case "left":
                data.DataLeft = message;
                break;

            case "right":
                data.DataRight = message;
                break;
            }
        }
Esempio n. 4
0
        public bool StoreData(string id, string relation, Stream bodyStream)
        {
            var body = bodyStream.ConvertToString();
            var internalReferenceObject = new InternalReferenceObject {
                Id = id, Relation = relation, Body = body
            };

            if (!supportedRelation.Contains(relation) || !ValidInput(body))
            {
                return(false);
            }

            if (IsExists(id))
            {
                ModifyData(internalReferenceObject);
            }
            else
            {
                CreateNewData(internalReferenceObject);
            }

            return(true);
        }