コード例 #1
0
        public static InspectionSchema LoadFromFile(this string fileName)
        {
            if (!File.Exists(fileName))
            {
                var ds = InspectionSchemaFactory.CreateDefaultSchema();
                ds.SerializeToXamlFile(fileName);
            }
            var schema = fileName.DeserializeFromXamlFile <InspectionSchema>();

            return(schema);
        }
コード例 #2
0
        public static InspectionSchema LoadFromAssemblyDir(this string shortFileName)
        {
            var dir      = typeof(InspectionSchemaExtensions).Assembly.GetAssemblyDirectoryPath();
            var fileName = Path.Combine(dir, shortFileName);

            if (!File.Exists(fileName))
            {
                var ds = InspectionSchemaFactory.CreateDefaultSchema();
                ds.SerializeToXamlFile(fileName);
            }
            var schema = fileName.DeserializeFromXamlFile <InspectionSchema>();

            return(schema);
        }
コード例 #3
0
        public static InspectionSchema GetInspectionSchema()
        {
            var dir = typeof(InspectionController).Assembly.GetAssemblyDirectoryPath();

            var inspectionSchemaDirPath  = dir + "\\InspectionSchema";
            var inspectionSchemaFilePath = dir + "\\InspectionSchema\\InspectionSchema.xaml";

            if (!Directory.Exists(inspectionSchemaDirPath))
            {
                Directory.CreateDirectory(inspectionSchemaDirPath);
            }

            if (!File.Exists(inspectionSchemaFilePath))
            {
                var ds = InspectionSchemaFactory.CreateDefaultSchema();
                ds.SerializeToXamlFile(inspectionSchemaFilePath);
            }


            InspectionSchema schema;

            try
            {
                schema = inspectionSchemaFilePath.DeserializeFromXamlFile <InspectionSchema>();
            }
            catch (Exception e)
            {
                throw;
            }

            var files = Directory.GetFiles(inspectionSchemaDirPath);

            foreach (var file in files)
            {
                if (file == inspectionSchemaFilePath)
                {
                    continue;
                }

                var slaveSchema = file.DeserializeFromXamlFile <InspectionSchema>();
                if (!slaveSchema.Disabled)
                {
                    schema.Merge(slaveSchema);
                }
            }

            return(schema);
        }