/// <summary>
        /// Returns a collection with items matching the specified identifier.
        /// </summary>
        /// <param name="identifier">The identifier.</param>
        /// <returns>A collection containing the items that match the specified identifier.</returns>
        /// <exception cref="System.ArgumentNullException">The identifier is null.</exception>
        public IEnumerable <ReferenceType> WithIdentifier(String identifier)
        {
            if (identifier == null)
            {
                throw new ArgumentNullException(nameof(identifier));
            }

            this.EnsureAliases();
            this.EnsureReferences();

            // match exact code
            String authority = IdentifiedObject.GetAuthority(identifier);
            Int32  code      = IdentifiedObject.GetCode(identifier);

            if (authority == Authority && this.referenceDictionary.ContainsKey(code))
            {
                yield return(this.referenceDictionary[code]);
            }

            // match contained code
            foreach (ReferenceType reference in this.referenceDictionary.Values.Where(reference => reference.Identifier.IndexOf(identifier, StringComparison.OrdinalIgnoreCase) >= 0))
            {
                yield return(reference);
            }
        }
        /// <summary>
        /// Ensures that all operation types are available.
        /// </summary>
        private void EnsureOperationTypes()
        {
            if (this.transformationTypes != null)
            {
                return;
            }

            this.transformationTypes = new Dictionary <Int32, Type>();

            foreach (TypeInfo type in this.GetType().GetTypeInfo().Assembly.DefinedTypes.Where(type => type.IsClass && type.CustomAttributes.Any(attribute => attribute.AttributeType.Equals(typeof(IdentifiedObjectAttribute)) && type.IsSubclassOf(typeof(CoordinateTransformation <CoordinateType>)))))
            {
                this.transformationTypes.Add(IdentifiedObject.GetCode(type.GetCustomAttribute <IdentifiedObjectAttribute>().Identifier), type.AsType());
            }
        }
Example #3
0
        /// <summary>
        /// Ensures that all operation types are available.
        /// </summary>
        private void EnsureOperationTypes()
        {
            if (this.projectionTypes != null)
            {
                return;
            }

            this.projectionTypes = new Dictionary <Int32, Type>();

            foreach (TypeInfo type in this.GetType().GetTypeInfo().Assembly.DefinedTypes.Where(type => type.IsClass && type.CustomAttributes.Any(attribute => attribute.AttributeType.Equals(typeof(IdentifiedObjectAttribute)) && type.IsSubclassOf(typeof(CoordinateProjection)))))
            {
                this.projectionTypes.Add(IdentifiedObject.GetCode(type.GetCustomAttribute <IdentifiedObjectAttribute>().Identifier), type.AsType());
            }

            this.defaultEllipsoid = this.ellipsoidCollection.WithIdentifier(DefaultEllipsoidIdentifier).FirstOrDefault();
        }
        /// <summary>
        /// Gets the item with the specified identifier.
        /// </summary>
        /// <param name="identifier">The identifier.</param>
        /// <returns>The item with the specified identifier.</returns>
        public ReferenceType this[String identifier]
        {
            get
            {
                if (identifier == null)
                {
                    return(null);
                }

                String authority = IdentifiedObject.GetAuthority(identifier);
                Int32  code      = IdentifiedObject.GetCode(identifier);

                if (!String.IsNullOrEmpty(authority) && authority != Authority)
                {
                    return(null);
                }

                return(this.GetReference(code));
            }
        }