예제 #1
0
        /// <summary>
        /// Attempts to retrieve the class of a specified shape.
        /// The shape will be searched in both internal and query directories
        /// starting in the specified directory for speed.
        /// </summary>
        /// <param name="shapeName">The name of the shape which needs to be retrieved.
        /// </param>
        /// <param name="queryShape">If the shape is present in the query directory.
        /// This is used to speed up retrieval by using extra knowledge.</param>
        /// <returns>The name of the class of the specified shape if it could be found,
        /// otherwise it returns <see langword="null"/>.</returns>
        public string ClassByShapeName(string shapeName, bool queryShape = true)
        {
            if (string.IsNullOrEmpty(shapeName))
            {
                throw new ArgumentNullException(nameof(shapeName));
            }

            MeshLibrary library = queryShape ? QueryMeshes : ProcessedMeshes;

            foreach (MeshEntry mesh in library)
            {
                if (string.Equals(mesh.Name, shapeName,
                                  StringComparison.InvariantCultureIgnoreCase))
                {
                    return(mesh.Class);
                }
            }
            MeshLibrary other = queryShape ? ProcessedMeshes : QueryMeshes;

            foreach (MeshEntry mesh in other)
            {
                if (string.Equals(mesh.Name, shapeName,
                                  StringComparison.InvariantCultureIgnoreCase))
                {
                    return(mesh.Class);
                }
            }
            return(null);
        }
예제 #2
0
 /// <summary>
 /// Adds the given file to the specified library, creating the correct
 /// entry for easier access.
 /// </summary>
 /// <param name="file">The file, assumed not <see langword="null"/>, which
 /// will contain the shape to add to the library.</param>
 /// <param name="library">The collection of shapes which will get a new
 /// shape present in the previous file.</param>
 private static void Add(FileInfo file, MeshLibrary library) =>
 library.Add(new MeshEntry(file));