コード例 #1
0
        public static DataNode Create(Stream source, IEnumerable <Type> typesToCheck, string fileName = null)
        {
            var module = FormatModuleUtilities.GetModuleForImport(source, typesToCheck, fileName);

            if (module != null && DataNodeTypes.ContainsKey(module.ModelType))
            {
                return(Create(module.ModelType, fileName, module.Import(source, fileName)));
            }

            return(new StreamNode(fileName, source));
        }
コード例 #2
0
        public static DataNode Create(string filePath, IEnumerable <Type> typesToCheck)
        {
            IFormatModule module;

            using (var stream = File.OpenRead(filePath))
                module = FormatModuleUtilities.GetModuleForImport(stream, typesToCheck, Path.GetFileName(filePath));

            if (module != null && DataNodeTypes.ContainsKey(module.ModelType))
            {
                return(Create(module.ModelType, Path.GetFileName(filePath), module.Import(filePath)));
            }

            return(new StreamNode(Path.GetFileName(filePath), File.OpenRead(filePath)));
        }