Ejemplo n.º 1
0
 public object DeserializeFrom(Type type, byte[] bytes, int index, int count)
 {
     return(MongoHelper.FromBson(type, bytes, index, count));
 }
Ejemplo n.º 2
0
 public object DeserializeFrom(object instance, byte[] bytes, int index, int count)
 {
     return(MongoHelper.FromBson(instance, bytes, index, count));
 }
Ejemplo n.º 3
0
 public object DeserializeFrom(object instance, MemoryStream stream)
 {
     return(MongoHelper.FromBson(instance, stream));
 }
Ejemplo n.º 4
0
        public void SetPropertyValue(int propertyId, byte[] valueBytes)
        {
            var server = false;

#if SERVER
            server = true;
#endif
            var propertyCollection      = EntityDefine.PropertyCollectionMap[EntityDefine.GetTypeId(GetType())];
            var reactPropertyCollection = EntityDefine.ReactPropertyCollectionMap[EntityDefine.GetTypeId(GetType())];
            var propertyInfo            = propertyCollection[propertyId];
            var reactPropertyInfo       = reactPropertyCollection[propertyId];
            if (propertyInfo == null)
            {
                Log.Error($"Error {propertyId} propertyInfo == null {propertyInfo}");
                return;
            }
            if (propertyInfo.PropertyType == typeof(int))
            {
                if (server)
                {
                    propertyInfo.SetValue(this, MongoHelper.ToInt(valueBytes));
                }
                else
                {
                    typeof(ReactProperty <int>).GetProperty("Value").SetValue(reactPropertyInfo.GetValue(this), MongoHelper.ToInt(valueBytes));
                }
            }
            if (propertyInfo.PropertyType == typeof(float))
            {
                if (server)
                {
                    propertyInfo.SetValue(this, MongoHelper.ToFloat(valueBytes));
                }
                else
                {
                    typeof(ReactProperty <float>).GetProperty("Value").SetValue(reactPropertyInfo.GetValue(this), MongoHelper.ToFloat(valueBytes));
                }
            }
            if (propertyInfo.PropertyType == typeof(string))
            {
                if (server)
                {
                    propertyInfo.SetValue(this, MongoHelper.ToString(valueBytes));
                }
                else
                {
                    typeof(ReactProperty <string>).GetProperty("Value").SetValue(reactPropertyInfo.GetValue(this), MongoHelper.ToString(valueBytes));
                }
            }
            if (propertyInfo.PropertyType == typeof(Vector3))
            {
                if (server)
                {
                    propertyInfo.SetValue(this, MongoHelper.FromBson <Vector3>(valueBytes));
                }
                else
                {
                    typeof(ReactProperty <Vector3>).GetProperty("Value").SetValue(reactPropertyInfo.GetValue(this), MongoHelper.FromBson <Vector3>(valueBytes));
                }
            }
        }
Ejemplo n.º 5
0
 public T DeserializeFrom <T>(byte[] bytes, int index, int count)
 {
     return(MongoHelper.FromBson <T>(bytes, index, count));
 }
Ejemplo n.º 6
0
 public T DeserializeFrom <T>(byte[] bytes)
 {
     return(MongoHelper.FromBson <T>(bytes));
 }
Ejemplo n.º 7
0
 public object DeserializeFrom(Type type, byte[] bytes)
 {
     return(MongoHelper.FromBson(type, bytes));
 }