Пример #1
0
        private string CreateTempFile()
        {
            var target     = SourceLocator.GetTargetLocation(Location);
            var fileEntity = Context.Default.EmbeddedBlobs.FirstOrDefault(f => f.Name == target);

            if (fileEntity == null)
            {
                throw new FileNotFoundException();
            }

            var tempFilePath = Path.GetTempFileName();

            System.IO.File.WriteAllBytes(tempFilePath, fileEntity.Data);

            return(tempFilePath);
        }
Пример #2
0
        public bool IsInvokable(ISource source, string arguments)
        {
            var sourcePath = SourceLocator.GetTargetLocation(source.Location);

            if (SourceLocator.IsLocalPathLocation(source.Location))
            {
                return(File.Exists(sourcePath));
            }

            if (SourceLocator.IsFileEntityLocation(source.Location))
            {
                using (var context = new Context())
                {
                    return(context.EmbeddedBlobs.Any(b => b.Name == sourcePath));
                }
            }

            throw new NotImplementedException(@"Source location " + source.Location + " not implemented yet.");
        }