示例#1
0
        internal static LCObjectData Decode(IDictionary dict)
        {
            if (dict == null)
            {
                return(null);
            }
            LCObjectData objectData = new LCObjectData();

            foreach (DictionaryEntry kv in dict)
            {
                string key   = kv.Key.ToString();
                object value = kv.Value;
                if (key == "className")
                {
                    objectData.ClassName = value.ToString();
                }
                else if (key == "objectId")
                {
                    objectData.ObjectId = value.ToString();
                }
                else if (key == "createdAt" && DateTime.TryParse(value.ToString(), out DateTime createdAt))
                {
                    objectData.CreatedAt = createdAt;
                }
                else if (key == "updatedAt" && DateTime.TryParse(value.ToString(), out DateTime updatedAt))
                {
                    objectData.UpdatedAt = updatedAt;
                }
                else
                {
                    objectData.CustomPropertyDict[key] = LCDecoder.Decode(value);
                }
            }
            return(objectData);
        }
示例#2
0
        public static Dictionary <string, object> Encode(LCObjectData objectData)
        {
            if (objectData == null)
            {
                return(null);
            }
            Dictionary <string, object> dict = new Dictionary <string, object> {
                { "className", objectData.ClassName }
            };

            if (!string.IsNullOrEmpty(objectData.ObjectId))
            {
                dict["objectId"] = objectData.ObjectId;
            }
            if (!objectData.CreatedAt.Equals(default))
示例#3
0
        internal static Dictionary <string, object> Encode(LCObjectData objectData)
        {
            if (objectData == null)
            {
                return(null);
            }
            Dictionary <string, object> dict = new Dictionary <string, object> {
                { "className", objectData.ClassName },
                { "objectId", objectData.ObjectId },
                { "createdAt", objectData.CreatedAt },
                { "updatedAt", objectData.UpdatedAt },
            };

            if (objectData.CustomPropertyDict != null)
            {
                foreach (KeyValuePair <string, object> kv in objectData.CustomPropertyDict)
                {
                    string key   = kv.Key;
                    object value = kv.Value;
                    dict[key] = LCEncoder.Encode(value);
                }
            }
            return(dict);
        }