/// <summary> /// Inlines type value instead of pointer handle /// </summary> public static MetaHandle InlineTypeValue(string inlinedTypeValue) { var result = new MetaHandle(); result.m_Handle = INLINED_TYPEVAL_HANDLE; result.m_Metadata = inlinedTypeValue; return(result); }
/// <summary> /// Inlines value type instead of pointer handle /// </summary> public static MetaHandle InlineValueType(string inlinedValueType) { var result = new MetaHandle(); result.m_Handle = INLINED_VALUETYPE_HANDLE; result.m_Metadata = inlinedValueType; return(result); }
/// <summary> /// Inlines ref type instead of pointer handle /// </summary> public static MetaHandle InlineRefType(string inlinedRefType) { var result = new MetaHandle(); result.m_Handle = INLINED_REFTYPE_HANDLE; result.m_Metadata = inlinedRefType; return(result); }
/// <summary> /// Inlines string instance instead of pointer handle /// </summary> public static MetaHandle InlineString(string inlinedString) { var result = new MetaHandle(); result.m_Handle = INLINED_STRING_HANDLE; result.m_Metadata = inlinedString; return(result); }
public override void Write(MetaHandle value) { var meta = value.Metadata.HasValue; var handle = value.m_Handle; byte b = 0; if (meta) { b = 1; } b = (byte)(b | ((handle & 0x3f) << 1)); handle = (handle >> 6); var has = handle != 0; if (has) { b = (byte)(b | 0x80); } m_Stream.WriteByte(b); while (has) { b = (byte)(handle & 0x7f); handle = (handle >> 7); has = handle != 0; if (has) { b = (byte)(b | 0x80); } m_Stream.WriteByte(b); } if (meta) { var vis = value.Metadata.Value; this.Write(vis.StringValue); if (vis.StringValue == null) { this.Write(vis.IntValue); } } }
public override void Write(MetaHandle value) { var meta = !string.IsNullOrEmpty(value.Metadata); var handle = value.m_Handle; byte b = 0; if (meta) { b = 1; } b = (byte)(b | ((handle & 0x3f) << 1)); handle = (handle >> 6); var has = handle != 0; if (has) { b = (byte)(b | 0x80); } m_Stream.WriteByte(b); while (has) { b = (byte)(handle & 0x7f); handle = (handle >> 7); has = handle != 0; if (has) { b = (byte)(b | 0x80); } m_Stream.WriteByte(b); } if (meta) { this.Write(value.Metadata); } }
public abstract void Write(MetaHandle? value);
/// <summary> /// Inlines value type instead of pointer handle /// </summary> public static MetaHandle InlineValueType(string inlinedValueType) { var result = new MetaHandle(); result.m_Handle = INLINED_VALUETYPE_HANDLE; result.m_Metadata = inlinedValueType; return result; }
/// <summary> /// Inlines type value instead of pointer handle /// </summary> public static MetaHandle InlineTypeValue(string inlinedTypeValue) { var result = new MetaHandle(); result.m_Handle = INLINED_TYPEVAL_HANDLE; result.m_Metadata = inlinedTypeValue; return result; }
/// <summary> /// Inlines string instance instead of pointer handle /// </summary> public static MetaHandle InlineString(string inlinedString) { var result = new MetaHandle(); result.m_Handle = INLINED_STRING_HANDLE; result.m_Metadata = inlinedString; return result; }
/// <summary> /// Inlines ref type instead of pointer handle /// </summary> public static MetaHandle InlineRefType(string inlinedRefType) { var result = new MetaHandle(); result.m_Handle = INLINED_REFTYPE_HANDLE; result.m_Metadata = inlinedRefType; return result; }
public override void Write(MetaHandle? value) { if (value.HasValue) { this.Write(true); Write(value.Value); return; } this.Write(false); }
public override void Write(MetaHandle value) { var meta = !string.IsNullOrEmpty(value.Metadata); var handle = value.m_Handle; byte b = 0; if (meta) b = 1; b = (byte)(b | ((handle & 0x3f) << 1)); handle = (handle >> 6); var has = handle != 0; if (has) b = (byte)(b | 0x80); m_Stream.WriteByte(b); while(has) { b = (byte)(handle & 0x7f); handle = (handle >> 7); has = handle != 0; if (has) b = (byte)(b | 0x80); m_Stream.WriteByte(b); } if (meta) this.Write(value.Metadata); }
/// <summary> /// Returns object reference for supplied metahandle /// </summary> public object HandleToReference(MetaHandle handle, TypeRegistry treg, SlimFormat format, SlimReader reader) { if (handle.IsInlinedString) return handle.Metadata; if (handle.IsInlinedTypeValue) { var tref = treg.GetByHandle(handle.Metadata);//adding this type to registry if it is not there yet return tref; } if (handle.IsInlinedRefType) { var tref = treg.GetByHandle(handle.Metadata);//adding this type to registry if it is not there yet var ra = format.GetReadActionForRefType(tref); if (ra!=null) { var inst = ra(reader); m_List.Add(inst); m_Dict.Add(inst, m_List.Count - 1); return inst; } else throw new SlimDeserializationException("Internal error HandleToReference: no read action for ref type, but ref mhandle is inlined"); } int idx = (int)handle.Handle; if (idx<m_List.Count) return m_List[idx]; if (string.IsNullOrEmpty(handle.Metadata)) throw new SlimDeserializationException(StringConsts.SLIM_HNDLTOREF_MISSING_TYPE_NAME_ERROR + handle.ToString()); var metadata = handle.Metadata; var ip = metadata.IndexOf('|'); //var segments = metadata.Split('|'); var th = ip>0 ? metadata.Substring(0, ip) : metadata; //20140701 DKh var type = treg[th];//segments[0]]; object instance = null; if (type.IsArray) //DKh 20130712 Removed repetitive code that was refactored into Arrays class instance = Arrays.DescriptorToArray(metadata, treg, type); else //20130715 DKh instance = SerializationUtils.MakeNewObjectInstance(type); m_List.Add(instance); m_Dict.Add(instance, m_List.Count - 1); return instance; }
public abstract void Write(MetaHandle value);
/// <summary> /// Returns object reference for supplied metahandle /// </summary> public object HandleToReference(MetaHandle handle, TypeRegistry treg, SlimFormat format, SlimReader reader) { Debug.Assert(m_Mode == SerializationOperation.Deserializing, "HandleToReference() called while serializing", DebugAction.Throw); if (handle.IsInlinedString) return handle.Metadata.Value.StringValue; if (handle.IsInlinedTypeValue) { var tref = treg[ handle.Metadata.Value ];//adding this type to registry if it is not there yet return tref; } if (handle.IsInlinedRefType) { var tref = treg[ handle.Metadata.Value ];//adding this type to registry if it is not there yet var ra = format.GetReadActionForRefType(tref); if (ra!=null) { var inst = ra(reader); m_List.Add(inst); return inst; } else throw new SlimDeserializationException("Internal error HandleToReference: no read action for ref type, but ref mhandle is inlined"); } int idx = (int)handle.Handle; if (idx<m_List.Count) return m_List[idx]; if (!handle.Metadata.HasValue) throw new SlimDeserializationException(StringConsts.SLIM_HNDLTOREF_MISSING_TYPE_NAME_ERROR + handle.ToString()); Type type; var metadata = handle.Metadata.Value; if (metadata.StringValue!=null)//need to search for possible array descriptor { var ip = metadata.StringValue.IndexOf('|');//array descriptor start if (ip>0) { var tname = metadata.StringValue.Substring(0, ip); if (TypeRegistry.IsNullHandle(tname)) return null; type = treg[ tname ]; } else { if (TypeRegistry.IsNullHandle(metadata)) return null; type = treg[ metadata ]; } } else { if (TypeRegistry.IsNullHandle(metadata)) return null; type = treg[ metadata ]; } object instance = null; if (type.IsArray) //DKh 20130712 Removed repetitive code that was refactored into Arrays class instance = Arrays.DescriptorToArray(metadata.StringValue, type); else //20130715 DKh instance = SerializationUtils.MakeNewObjectInstance(type); m_List.Add(instance); return instance; }
public override void Write(MetaHandle value) { var meta = value.Metadata.HasValue; var handle = value.m_Handle; byte b = 0; if (meta) b = 1; b = (byte)(b | ((handle & 0x3f) << 1)); handle = (handle >> 6); var has = handle != 0; if (has) b = (byte)(b | 0x80); m_Stream.WriteByte(b); while(has) { b = (byte)(handle & 0x7f); handle = (handle >> 7); has = handle != 0; if (has) b = (byte)(b | 0x80); m_Stream.WriteByte(b); } if (meta) { var vis = value.Metadata.Value; this.Write( vis.StringValue ); if (vis.StringValue==null) this.Write( vis.IntValue ); } }