예제 #1
0
        /// <summary>
        /// Checks the validity of a given STON reference address.
        /// </summary>
        /// <param name="address">The reference address to check the validity of.</param>
        public static void ValidateAddress(IStonAddress address)
        {
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }
            if (address.InitialContext == null)
            {
                throw new StonException("A reference address cannot have a non-existing initial context.");
            }
            if (address.RelativePath == null)
            {
                throw new StonException("A reference address cannot have a non-existing relative path.");
            }

            ValidateInitialContext(address.InitialContext);
            foreach (var segment in address.RelativePath)
            {
                if (segment == null)
                {
                    throw new StonException("A reference address relative path cannot have non-existing path segments.");
                }
                ValidatePathSegment(segment);
            }
        }
예제 #2
0
 /// <summary>
 /// Creates a structurally equivalent STON address from a given address.
 /// </summary>
 /// <param name="address">The address to copy the structure of.</param>
 /// <returns>A structurally equivalent copy of the given address.</returns>
 public static IStonAddress Copy(IStonAddress address)
 {
     if (address == null)
     {
         throw new ArgumentNullException("address");
     }
     return(new StonAddress(address));
 }
예제 #3
0
        /// <summary>
        /// Creates a new reference entity, with a given reference address and optional global identifier.
        /// </summary>
        /// <param name="address">The address of the referenced value.</param>
        /// <param name="globalIdentifier">The global identifier of the entity.</param>
        public StonReferenceEntity(IStonAddress address, string globalIdentifier = null)
            : base(globalIdentifier)
        {
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }
            Address = StonAddress.Copy(address);

            Helpers.Validator.ValidateEntity(this);
        }
예제 #4
0
        // writes a reference address
        private void WriteReferenceAddress(StonTokenWriter writer, IStonAddress address)
        {
            if (address.InitialContext == null)
            {
                throw new StonException("A reference address cannot have a non-existing initial context.");
            }
            if (address.RelativePath == null)
            {
                throw new StonException("A reference address cannot have a non-existing relative path.");
            }

            WriteInitialContext(writer, address.InitialContext);
            foreach (var segment in address.RelativePath)
            {
                WritePathSegment(writer, segment);
            }
        }
예제 #5
0
 /// <summary>
 /// Creates a new reference entity, with a given reference address and optional global identifier.
 /// </summary>
 /// <param name="address">The address of the referenced value.</param>
 /// <param name="globalIdentifier">The global identifier of the entity.</param>
 /// <returns>The new STON entity.</returns>
 public IStonReferenceEntity CreateReferenceEntity(IStonAddress address, string globalIdentifier = null)
 => new StonReferenceEntity(address, globalIdentifier);
예제 #6
0
 /// <summary>
 /// Creates a structurally equivalent STON address from a given address.
 /// </summary>
 /// <param name="address">The address to copy the structure from.</param>
 public StonAddress(IStonAddress address)
     : this(address.InitialContext, address.RelativePath)
 {
 }
예제 #7
0
 public AReferenceEntity(IStonAddress address, string globalIdentifier = null)
 {
     Address          = address;
     GlobalIdentifier = globalIdentifier;
 }