コード例 #1
0
        internal virtual void Scalar(IIonHashValue ionValue)
        {
            this.HandleAnnotationsBegin(ionValue);
            this.BeginMarker();

            dynamic ionValueValue = ionValue.CurrentIsNull ? null : ionValue.CurrentValue;
            IonType ionType       = ionValue.CurrentIsNull ? IonType.None : ionValue.CurrentType;

            byte[] scalarBytes = this.GetBytes(ionValue.CurrentType, ionValueValue, ionValue.CurrentIsNull);
            ionValueValue = ionValue.CurrentType == IonType.Symbol ? ionValueValue : null;
            (byte tq, byte[] representation) = ((byte, byte[])) this.ScalarOrNullSplitParts(
                ionType,
                ionValueValue,
                ionValue.CurrentIsNull,
                scalarBytes);

            this.Update(new byte[] { tq });
            if (representation.Length > 0)
            {
                this.Update(Escape(representation));
            }

            this.EndMarker();
            this.HandleAnnotationsEnd(ionValue);
        }
コード例 #2
0
 internal override void Scalar(IIonHashValue value)
 {
     this.scalarSerializer.HandleFieldName(value.CurrentFieldName);
     this.scalarSerializer.Scalar(value);
     byte[] digest = this.scalarSerializer.Digest();
     this.AppendFieldHash(digest);
 }
コード例 #3
0
 private void HandleAnnotationsEnd(IIonHashValue ionValue, bool isContainer = false)
 {
     if ((ionValue != null && ionValue.Annotations.Count > 0) || (isContainer && this.hasContainerAnnotation))
     {
         this.EndMarker();
         if (isContainer)
         {
             this.hasContainerAnnotation = false;
         }
     }
 }
コード例 #4
0
        internal void HandleFieldName(IIonHashValue ionValue)
        {
            if (this.depth > 0 && ionValue.IsInStruct)
            {
                if (ionValue.CurrentFieldNameSymbol.Text == null &&
                    ionValue.CurrentFieldNameSymbol.Sid != 0)
                {
                    throw new UnknownSymbolException(ionValue.CurrentFieldNameSymbol.Sid);
                }

                this.WriteSymbol(ionValue.CurrentFieldNameSymbol.Text);
            }
        }
コード例 #5
0
        internal void StepIn(IIonHashValue ionValue)
        {
            this.HandleFieldName(ionValue);
            this.HandleAnnotationsBegin(ionValue, true);
            this.BeginMarker();
            byte tq = TQ(ionValue);

            if (ionValue.CurrentIsNull)
            {
                tq |= 0x0F;
            }

            this.Update(new byte[] { tq });
        }
コード例 #6
0
        private void HandleAnnotationsBegin(IIonHashValue ionValue, bool isContainer = false)
        {
            IList <SymbolToken> annotations = ionValue.Annotations;

            if (annotations.Count > 0)
            {
                this.BeginMarker();
                this.Update(Constants.TqAnnotatedValue);
                foreach (var annotation in annotations)
                {
                    this.WriteSymbol(annotation.Text);
                }

                if (isContainer)
                {
                    this.hasContainerAnnotation = true;
                }
            }
        }
コード例 #7
0
        internal void StepIn(IIonHashValue ionValue)
        {
            IIonHasher hashFunction = this.currentHasher.HashFunction;

            if (this.currentHasher is StructSerializer)
            {
                hashFunction = this.hasherProvider.NewHasher();
            }

            if (ionValue.CurrentType == IonType.Struct)
            {
                this.currentHasher = new StructSerializer(hashFunction, this.Depth(), this.hasherProvider);
            }
            else
            {
                this.currentHasher = new Serializer(hashFunction, this.Depth());
            }

            this.hasherStack.Push(this.currentHasher);
            this.currentHasher.StepIn(ionValue);
        }
コード例 #8
0
 internal void Scalar(IIonHashValue ionValue)
 {
     this.currentHasher.Scalar(ionValue);
 }
コード例 #9
0
        private static byte TQ(IIonHashValue ionValue)
        {
            byte typeCode = (byte)ionValue.CurrentType;

            return((byte)(typeCode << 4));
        }