Пример #1
0
        /// <summary>
        /// Routine used to load a set of CIM instances from a .mof file using the
        /// current set of cached classes for schema validation.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="schemaValidationOption"></param>
        /// <returns></returns>
        public static List<CimInstance> ImportInstances(string path, int schemaValidationOption)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw PSTraceSource.NewArgumentNullException("path");
                throw new ArgumentNullException("path");
            }
            if (schemaValidationOption < (int)Microsoft.Management.Infrastructure.Serialization.MofDeserializerSchemaValidationOption.Default ||
                schemaValidationOption > (int)Microsoft.Management.Infrastructure.Serialization.MofDeserializerSchemaValidationOption.Ignore)
            {
                throw new IndexOutOfRangeException("schemaValidationOption");
            }

            var parser = new Microsoft.PowerShell.DesiredStateConfiguration.CimDSCParser(MyClassCallback, (Microsoft.Management.Infrastructure.Serialization.MofDeserializerSchemaValidationOption)schemaValidationOption);

            return parser.ParseInstanceMof(path);
        }
Пример #2
0
        /// <summary>
        /// Routine used to load a set of CIM instances from a .mof file using the
        /// current set of cached classes for schema validation.
        /// </summary>
        /// <param name="path">The file to load the classes from.</param>
        /// <returns></returns>
        public static List<CimInstance> ImportInstances(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw PSTraceSource.NewArgumentNullException("path");
            }

            var parser = new Microsoft.PowerShell.DesiredStateConfiguration.CimDSCParser(MyClassCallback);

            return parser.ParseInstanceMof(path);
        }