Пример #1
0
        public bool TryResolveContent(string fileName, IServiceProvider serviceProvider, out Stream stream, out IContentImporter contentImporter)
        {
            stream          = null;
            contentImporter = null;

            if (!File.Exists(fileName))
            {
                return(false);
            }

            stream = File.OpenRead(fileName);

            var importerFile = fileName + ".importer";

            if (File.Exists(importerFile))
            {
                contentImporter = xaml.Load <IContentImporter>(importerFile, serviceProvider);
            }
            else if (!importers.TryGetValue(Path.GetExtension(fileName), out contentImporter))
            {
                throw new InvalidOperationException("Cannot find importer for file: " + fileName);
            }

            return(true);
        }