예제 #1
0
 private bool VerifyObject(KyruObject o)
 {
     if (!o.VerifyData())
     {
         this.Warn("Object failed verification; it will not be stored. ID: {0}", o.ObjectId);
         return false;
     }
     return true;
 }
예제 #2
0
        /// <summary>
        /// Stores an object on this or another node
        /// </summary>
        /// <param name="o">the object</param>
        internal void StoreObject(KyruObject o, bool replicate)
        {
            if (o is User)
            {
                var oldUser = GetObject(o.ObjectId);
                if (oldUser is User)
                {
                    var user = o as User;
                    if (!user.Merge(oldUser as User))
                        return;
                }
            }

            if (!VerifyObject(o)) return;

            using (var stream = new MemoryStream())
            {
                Serializer.Serialize(stream, o);
                Store(o.ObjectId, stream.ToArray(), replicate);
            }

            if (o is User && OnUserUpdated != null)
            {
                OnUserUpdated(o as User);
            }
        }