예제 #1
0
파일: MetaHandle.cs 프로젝트: ame89/nfx
        /// <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);
        }
예제 #2
0
파일: MetaHandle.cs 프로젝트: ame89/nfx
        /// <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);
        }
예제 #3
0
파일: MetaHandle.cs 프로젝트: ame89/nfx
        /// <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);
        }
예제 #4
0
파일: MetaHandle.cs 프로젝트: ame89/nfx
        /// <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);
        }
예제 #5
0
파일: SlimWriter.cs 프로젝트: filmor/nfx
        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);
                }
            }
        }
예제 #6
0
파일: SlimWriter.cs 프로젝트: ame89/nfx
        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);
            }
        }
예제 #7
0
 public abstract void Write(MetaHandle? value);
예제 #8
0
파일: MetaHandle.cs 프로젝트: cole2295/nfx
 /// <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;
 }
예제 #9
0
파일: MetaHandle.cs 프로젝트: cole2295/nfx
 /// <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;
 }
예제 #10
0
파일: MetaHandle.cs 프로젝트: cole2295/nfx
 /// <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;
 }
예제 #11
0
파일: MetaHandle.cs 프로젝트: cole2295/nfx
 /// <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;
 }
예제 #12
0
파일: SlimWriter.cs 프로젝트: itadapter/nfx
 public override void Write(MetaHandle? value)
 {
     if (value.HasValue)
         {
           this.Write(true);
           Write(value.Value);
           return;
         }
         this.Write(false);
 }
예제 #13
0
파일: SlimWriter.cs 프로젝트: cole2295/nfx
        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);
        }
예제 #14
0
        /// <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;
        }
예제 #15
0
 public abstract void Write(MetaHandle value);
예제 #16
0
파일: RefPool.cs 프로젝트: itadapter/nfx
        /// <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;
        }
예제 #17
0
파일: SlimWriter.cs 프로젝트: itadapter/nfx
        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 );
            }
        }