示例#1
0
        public string DehydrateValue(object obj, IGraph uow)
        {
            Condition.Requires(obj).IsNotNull();
            var name = obj.GetType().AssemblyQualifiedName;
            var data = BinarySerializationUtil.Serialize(obj);

            return(LengthEncoder.LengthEncodeList(name, data));
        }
示例#2
0
 public string DehydrateValue(object obj, IGraph uow)
 {
     var ser = new BinarySerializationUtil();
     var data = ser.Serialize(obj);
     //prepend the assembly qualified type name
     data = obj.GetType().AssemblyQualifiedName + GraphingDelimiters.DELIM_LEVEL1 + data;
     
     return data;
 }
示例#3
0
        public string DehydrateValue(object obj, IGraph uow)
        {
            var ser  = new BinarySerializationUtil();
            var data = ser.Serialize(obj);

            //prepend the assembly qualified type name
            data = obj.GetType().AssemblyQualifiedName + GraphingDelimiters.DELIM_LEVEL1 + data;

            return(data);
        }
示例#4
0
        public object HydrateValue(string nodeText, IGraph uow)
        {
            var list = LengthEncoder.LengthDecodeList(nodeText);

            Condition.Requires(list).HasLength(2);
            var  typeName = list.ElementAt(0);
            var  serData  = list.ElementAt(1);
            Type type     = TheTypeLocator.Instance.Locator.FindAssemblyQualifiedType(typeName);
            var  obj      = BinarySerializationUtil.Deserialize(type, serData);

            return(obj);
        }
示例#5
0
        public object HydrateValue(string nodeText, IGraph uow)
        {
            var ser = new BinarySerializationUtil();
            string[] split = new string[] { GraphingDelimiters.DELIM_LEVEL1 };
            var arr = nodeText.Split(split, StringSplitOptions.None);
            Condition.Requires(arr).IsNotNull();
            Condition.Requires(arr).HasLength(2);
            var typeName = arr[0];
            var serData = arr[1];

            Type type = Util.FindAssemblyQualifiedType(typeName);
            var obj = ser.Deserialize(type, serData);
            return obj;
        }
示例#6
0
        public object HydrateValue(string nodeText, IGraph uow)
        {
            var ser = new BinarySerializationUtil();

            string[] split = new string[] { GraphingDelimiters.DELIM_LEVEL1 };
            var      arr   = nodeText.Split(split, StringSplitOptions.None);

            Condition.Requires(arr).IsNotNull();
            Condition.Requires(arr).HasLength(2);
            var typeName = arr[0];
            var serData  = arr[1];

            Type type = Util.FindAssemblyQualifiedType(typeName);
            var  obj  = ser.Deserialize(type, serData);

            return(obj);
        }
示例#7
0
 public override string ToString()
 {
     return(BinarySerializationUtil.Serialize(this));
 }
 /// <summary>
 /// 自动反序列化
 /// </summary>
 /// <typeparam name="T">对象类型</typeparam>
 /// <param name="bytes">字节数组</param>
 /// <returns></returns>
 protected virtual T AutoDeserialize <T>(byte[] bytes)
 {
     return((T)BinarySerializationUtil.DeserializeExtended(bytes));
 }
 /// <summary>
 /// 自动序列化
 /// </summary>
 /// <typeparam name="T">对象类型</typeparam>
 /// <param name="obj">对象</param>
 /// <returns></returns>
 protected virtual byte[] AutoSerialize <T>(T obj)
 {
     return(BinarySerializationUtil.Serialize(obj));
 }