コード例 #1
0
        public static Validation.ValidationResult Validate(string filePath)
        {
            Guard.NotNull(filePath, nameof(filePath));
            Guard.FilePathMustExist(filePath, nameof(filePath));

            var dir = Path.GetDirectoryName(filePath);
            filePath = System.IO.Path.GetFileName(filePath);

            var context = ReadContext.CreateFromDirectory(dir);

            return context.Validate(filePath);
        }
コード例 #2
0
        /// <summary>
        /// Reads a <see cref="MODEL"/> instance from a path pointing to a GLB or a GLTF file
        /// </summary>
        /// <param name="filePath">A valid file path.</param>
        /// <param name="settings">Optional settings.</param>
        /// <returns>A <see cref="MODEL"/> instance.</returns>
        /// <remarks>
        /// <paramref name="settings"/> can be either a plain <see cref="ReadSettings"/> instance,
        /// or a <see cref="ReadContext"/>, in which case, the context will be used to read the
        /// files from it.
        /// </remarks>
        public static MODEL Load(string filePath, ReadSettings settings = null)
        {
            Guard.NotNull(filePath, nameof(filePath));

            if (!(settings is ReadContext context))
            {
                Guard.FilePathMustExist(filePath, nameof(filePath));

                var dir = Path.GetDirectoryName(filePath);
                filePath = System.IO.Path.GetFileName(filePath);

                context = ReadContext
                    .CreateFromDirectory(dir)
                    .WithSettingsFrom(settings);
            }

            return context.ReadSchema2(filePath);
        }