Esempio n. 1
0
        /// <summary>
        /// Checks the validity of a given STON collection element path segment.
        /// </summary>
        /// <param name="segment">The path segment to check the validity of.</param>
        public static void ValidatePathSegment(IStonCollectionElementPathSegment segment)
        {
            if (segment == null)
            {
                throw new ArgumentNullException("segment");
            }
            if (segment.ElementIndex == null)
            {
                throw new StonException("A collection element path segment cannot have a non-existing element index.");
            }

            if (segment.ElementIndex.GlobalIdentifier != null)
            {
                throw new StonException("A collection element path segment index cannot declare a global identifier.");
            }
            if (segment.ElementIndex is IStonComplexEntity)
            {
                throw new StonException("A collection element path segment index cannot be a complex-valued entity.");
            }
            else if (segment.ElementIndex is IStonSimpleEntity)
            {
                if ((segment.ElementIndex as IStonSimpleEntity).Type != null)
                {
                    throw new StonException("A collection element path segment index must be implicitly typed.");
                }
                var value = (segment.ElementIndex as IStonSimpleEntity).Value;
                if (value.DataType != StonDataType.Binary && value.DataType != StonDataType.Number)
                {
                    throw new StonException("A collection element path segment index must have a number or binary value.");
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Creates a structurally equivalent collection element path segment from a given segment.
 /// </summary>
 /// <param name="segment">The segment to copy the structure from.</param>
 /// <returns>A structurally equivalent copy of the given segment.</returns>
 public static IStonCollectionElementPathSegment Copy(IStonCollectionElementPathSegment segment)
 {
     if (segment == null)
     {
         throw new ArgumentNullException("segment");
     }
     return(new StonCollectionElementPathSegment(segment));
 }
Esempio n. 3
0
 // writes a collection element access path segment
 private void WritePathSegment(StonTokenWriter writer, IStonCollectionElementPathSegment segment)
 {
     writer.Write("[#");
     WriteEntity(writer, segment.ElementIndex);
     writer.Write(']');
 }
Esempio n. 4
0
 /// <summary>
 /// Creates a structurally equivalent collection element path segment from a given segment.
 /// </summary>
 /// <param name="segment">The segment to copy the structure from.</param>
 public StonCollectionElementPathSegment(IStonCollectionElementPathSegment segment)
     : this(segment.ElementIndex)
 {
 }