コード例 #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
ファイル: WritingStreamer.cs プロジェクト: yhhno/nfx
 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
ファイル: SlimSerializer.cs プロジェクト: cole2295/nfx
        /// <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
ファイル: WritingStreamer.cs プロジェクト: dotnetchris/nfx
 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 );
            }
        }