コード例 #1
0
ファイル: Runtime.cs プロジェクト: toddcoder/Orange
 public Runtime(string text = "", IFileCache fileCache = null)
 {
     Sys                   = new Sys();
     stack                 = new ValueStack();
     blockManager          = new BlockManager();
     printBuffer           = new Buffer();
     patternManager        = new PatternManager();
     Regions               = new RegionManager(Sys, text);
     expressionManager     = new ExpressionManager();
     FieldPattern          = (Pattern)(STRING_BEGIN_PATTERN + "+" + STRING_END_PATTERN);
     RecordPattern         = (Pattern)(STRING_BEGIN_PATTERN + "'`r`n' | '`r' | '`n'" + STRING_END_PATTERN);
     FieldSeparator        = (String)" ";
     RecordSeparator       = (String)"\r\n";
     seed                  = DateTime.Now.Millisecond;
     random                = new Random(seed);
     valueStacks           = new Stack <ValueStack>();
     FileCache             = fileCache ?? new StandardFileCache();
     takeArray             = new Array();
     defaultParameterNames = new Stack <DefaultParameterNames>();
     defaultParameterNames.Push(new DefaultParameterNames(true));
     buffer                   = new Buffer();
     ArgumentDepth            = 0;
     invokeables              = new Hash <string, IInvokeable>();
     extenders                = new Hash <string, InvokeableReference>();
     Parser.InClassDefinition = false;
     consoleManager           = new ConsoleManager();
     indent                   = "";
 }
コード例 #2
0
        private void GetFileCaches(ICondition condition, IFieldSource[] fieldSources, FileInfo file,
                                   Dictionary <Type, IFileCache> cacheLookup, IProgress <IEnumerable <ExceptionInfo> > exceptionProgress)
        {
            List <Type> cacheTypes = new List <Type>();

            cacheTypes.AddRange(condition.CacheTypes);
            foreach (IFieldSource fieldSource in fieldSources)
            {
                cacheTypes.AddRange(fieldSource.CacheTypes);
            }
            List <ExceptionInfo> exinfos = new List <ExceptionInfo>();

            foreach (Type type in cacheTypes)
            {
                Type[] interfaces = type.GetInterfaces();
                if (type == null || !interfaces.Contains(typeof(IFileCache)))
                {
                    continue;
                }
                try
                {
                    if (!cacheLookup.ContainsKey(type))
                    {
                        IFileCache cache = (IFileCache)Activator.CreateInstance(type);
                        cache.Load(file);
                        cacheLookup[type] = cache;
                    }
                }
                catch (Exception ex) when(!(ex is OperationCanceledException))
                {
                    RunInfo.ExceptionInfos.Enqueue(new ExceptionInfo(ex, file));
                }
            }
        }
コード例 #3
0
 public BannerDownloader(IFileCache fileCache, BannerOptions options, IHashUtil hashUtil, IDownloader downloader)
 {
     _fileCache  = fileCache;
     _options    = options;
     _hashUtil   = hashUtil;
     _downloader = downloader;
 }
コード例 #4
0
 protected void SetUp()
 {
     Config  = new TestConfiguration();
     WebApi  = new TestWebApi(Config);
     Cache   = new TestFileCache();
     Storage = new PictureStorageImpl(WebApi, Cache);
 }
コード例 #5
0
 public BannerLoader(IDirectory directory, IFileCache fileCache, IWebLinkLauncher webLinkLauncher, IUsageStatisticsSender usageStatisticsSender, IBannerMetricFactory bannerMetricFactory)
 {
     _directory             = directory;
     _fileCache             = fileCache;
     _webLinkLauncher       = webLinkLauncher;
     _usageStatisticsSender = usageStatisticsSender;
     _bannerMetricFactory   = bannerMetricFactory;
 }
コード例 #6
0
        public GitHubAdapter(IGitHubClientFactory clientFactory, IConfiguration configuration, IFileCache cache, Options options)
        {
            _clientFactory = clientFactory;
            _configuration = configuration;
            _cache         = cache;

            this.options = options;
        }
コード例 #7
0
ファイル: BannerLoader.cs プロジェクト: wholesky/PDFCreator
 public BannerLoader(IDirectory directory, IFileCache fileCache, IProcessStarter processStarter, IUsageStatisticsSender usageStatisticsSender, IBannerMetricFactory bannerMetricFactory)
 {
     _directory             = directory;
     _fileCache             = fileCache;
     _processStarter        = processStarter;
     _usageStatisticsSender = usageStatisticsSender;
     _bannerMetricFactory   = bannerMetricFactory;
 }
コード例 #8
0
        public MappingList(IApplicationPaths applicationPaths, IFileCache fileCache)
        {
            _mappingsFileSpec = new MappingsFileSpec(applicationPaths.CachePath);
            _fileCache        = fileCache;

            _mappingListTaskLazy =
                new Lazy <Task <IEnumerable <SeriesMapping> > >(() => CreateMappingListAsync(CancellationToken.None));
        }
コード例 #9
0
 public OrangeRuntime(Block block, string text = "", IFileCache fileCache = null, IConsole console = null)
 {
     this.block = block;
     Block.ClearResults();
     this.text      = text;
     this.fileCache = fileCache;
     this.console   = console;
 }
コード例 #10
0
 public BackgroundController(ProductJsonConverter productJsonConverter, IFileCache fileCache, IConfiguration configuration, ImageLoader imageLoader)
 {
     _productJsonConverter = productJsonConverter;
     _fileCache            = fileCache;
     _configuration        = configuration;
     _imageLoader          = imageLoader;
     _itemHandlerFactory   = new ItemHandlerFactory(_configuration, _fileCache, null, _imageLoader, null, null);
 }
コード例 #11
0
        public static TSFileAdditionalInfo AutodetectAndAddDependencyCore(ProjectOptions projectOptions, string depName,
                                                                          IFileCache usedFrom)
        {
            var dc        = projectOptions.Owner.DiskCache;
            var extension = PathUtils.GetExtension(depName);
            var depFile   = dc.TryGetItem(depName) as IFileCache;

            if (depFile == null)
            {
                if (usedFrom != null)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("In " + usedFrom.FullPath + " missing dependency " + depName);
                    Console.ForegroundColor = ConsoleColor.Gray;
                    TSFileAdditionalInfo.Get(usedFrom, dc)
                    .ReportDiag(true, -3, "Missing dependency " + depName, 0, 0, 0, 0);
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Somethere missing dependency " + depName);
                    Console.ForegroundColor = ConsoleColor.Gray;
                }

                return(null);
            }

            var assetFileInfo = TSFileAdditionalInfo.Get(depFile, dc);

            if (projectOptions.BundleCss && extension == "css")
            {
                assetFileInfo.Type = FileCompilationType.Css;
                return(assetFileInfo);
            }

            if (assetFileInfo.OutputUrl == null)
            {
                assetFileInfo.OutputUrl =
                    projectOptions.AllocateName(PathUtils.Subtract(depFile.FullPath,
                                                                   projectOptions.Owner.Owner.FullPath));
            }
            switch (extension)
            {
            case "css":
                assetFileInfo.Type = FileCompilationType.Css;
                break;

            case "js":
                assetFileInfo.Type = FileCompilationType.JavaScriptAsset;
                break;

            default:
                assetFileInfo.Type = FileCompilationType.Resource;
                break;
            }

            return(assetFileInfo);
        }
コード例 #12
0
ファイル: OrangeRuntime.cs プロジェクト: toddcoder/Orange
 public OrangeRuntime(Block block, string text = "", IFileCache fileCache = null, IConsole console = null)
 {
     this.block = block;
     //this.block.Statement += (sender, e) => Statement?.Invoke(this, e);
     Block.ClearResults();
     this.text      = text;
     this.fileCache = fileCache;
     this.console   = console;
 }
コード例 #13
0
        internal void Collect(string sourceDir, string dstDir)
        {
            if (sourceDir == null || dstDir == null)
            {
                return;
            }

            IFileCache fileCache = InitFileCache(dstDir);

            if (Directory.Exists(sourceDir))
            {
                string   fileName;
                string   destFile;
                string[] files = Directory.GetFiles(sourceDir);

                foreach (string sourceFile in files)
                {
                    using (FileStream sourceFileStream = new FileStream(sourceFile, FileMode.Open, FileAccess.Read))
                    {
                        if (fileCache.Contains(sourceFileStream))
                        {
                            continue;
                        }

                        try
                        {
                            using (Image img = Image.FromStream(sourceFileStream))
                            {
                                // Use static Path methods to extract only the file name from the path.
                                fileName = Path.GetFileName(sourceFile) + _fileType;
                                destFile = Path.Combine(dstDir, fileName);

                                if (CanCopy(img))
                                {
                                    File.Copy(sourceFile, destFile, false);

                                    fileCache.AddEntry(sourceFileStream.Length);

                                    _logger.Add($"File Added: {fileName}");
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                    }
                }
            }
            else
            {
                Console.WriteLine("Source path does not exist!");
            }

            fileCache.Dispose();
            _logger.Dispose();
        }
コード例 #14
0
ファイル: Orange.cs プロジェクト: toddcoder/Orange
 public Orange(string source, IColorizer colorizer = null, IFileCache fileCache = null, IConsole console = null)
 {
     this.source    = source.Trim();
     this.colorizer = colorizer;
     this.fileCache = fileCache;
     this.console   = console;
     verboseText    = "";
     block          = null;
 }
コード例 #15
0
ファイル: FaviconCommand.cs プロジェクト: breki/syborg
 public FaviconCommand(
     string faviconsDirectory,
     IFileSystem fileSystem,
     IFileCache fileCache)
 {
     this.faviconsDirectory = faviconsDirectory;
     this.fileSystem        = fileSystem;
     this.fileCache         = fileCache;
 }
コード例 #16
0
        bool MatchingTranspilationDendencies(IFileCache owner, List <DependencyTriplet> transpilationDependencies)
        {
            if (transpilationDependencies == null)
            {
                return(true);
            }
            var hashToName = new Dictionary <byte[], string>(StructuralEqualityComparer <byte[]> .Default);

            hashToName.Add(owner.HashOfContent, owner.FullPath);
            var processed = new StructList <bool>();

            processed.RepeatAdd(false, (uint)transpilationDependencies.Count);
            bool somethingFailed;

            do
            {
                var somethingProcessed = false;
                somethingFailed = false;
                for (var i = 0u; i < processed.Count; i++)
                {
                    if (processed[i])
                    {
                        continue;
                    }
                    var dep = transpilationDependencies[(int)i];
                    if (!hashToName.TryGetValue(dep.SourceHash, out var sourceName))
                    {
                        somethingFailed = true;
                        continue;
                    }

                    somethingProcessed = true;
                    processed[i]       = true;
                    var targetName = ResolveImport(sourceName, dep.Import);
                    if (targetName == "?")
                    {
                        return(false);
                    }

                    Result.Path2FileInfo.TryGetValue(targetName, out var targetInfo);
                    if (!dep.TargetHash.AsSpan().SequenceEqual(targetInfo.Owner.HashOfContent))
                    {
                        return(false);
                    }

                    hashToName.TryAdd(targetInfo.Owner.HashOfContent, targetInfo.Owner.FullPath);
                }

                if (!somethingProcessed)
                {
                    return(!somethingFailed);
                }
            } while (somethingFailed);

            return(true);
        }
コード例 #17
0
 public TvDbClient(IJsonConnection jsonConnection, IFileCache fileCache, IApplicationPaths applicationPaths,
                   ILogManager logManager, ICustomJsonSerialiser jsonSerialiser, PluginConfiguration configuration)
 {
     _log              = logManager.GetLogger(nameof(TvDbClient));
     _jsonConnection   = jsonConnection;
     _fileCache        = fileCache;
     _applicationPaths = applicationPaths;
     _jsonSerialiser   = jsonSerialiser;
     _token            = new TvDbToken(_jsonConnection, configuration.TvDbApiKey, logManager);
 }
コード例 #18
0
        /// <summary>
        /// Gets the main file cache.
        /// </summary>
        public IFileCache GetMainFileCache()
        {
            if (_mainFileCache == null)
            {
                DiskCacheConfig diskCacheConfig = _config.MainDiskCacheConfig;
                _mainFileCache = _config.FileCacheFactory.Get(diskCacheConfig);
            }

            return(_mainFileCache);
        }
コード例 #19
0
        /// <summary>
        /// Gets the small image file cache.
        /// </summary>
        public IFileCache GetSmallImageFileCache()
        {
            if (_smallImageFileCache == null)
            {
                DiskCacheConfig diskCacheConfig = _config.SmallImageDiskCacheConfig;
                _smallImageFileCache = _config.FileCacheFactory.Get(diskCacheConfig);
            }

            return(_smallImageFileCache);
        }
コード例 #20
0
 public static TSFileAdditionalInfo Create(IFileCache file, IDiskCache diskCache)
 {
     if (file == null)
     {
         return(null);
     }
     return(new TSFileAdditionalInfo {
         Owner = file, DiskCache = diskCache
     });
 }
コード例 #21
0
        TSFileAdditionalInfo AutodetectAndAddDependency(string depName, IFileCache usedFrom)
        {
            var fai = AutodetectAndAddDependencyCore(_owner.ProjectOptions, depName, usedFrom);

            if (fai != null)
            {
                CheckAdd(depName);
            }
            return(fai);
        }
コード例 #22
0
 public TvDbClientV2(IJsonConnection jsonConnection, IFileCache fileCache, IApplicationPaths applicationPaths,
                     ILogManager logManager, ICustomJsonSerialiser jsonSerialiser, PluginConfiguration configuration)
 {
     this.log              = logManager.GetLogger(nameof(TvDbClientV2));
     this.jsonConnection   = jsonConnection;
     this.fileCache        = fileCache;
     this.applicationPaths = applicationPaths;
     this.jsonSerialiser   = jsonSerialiser;
     this.token            = new TvDbToken(this.jsonConnection, configuration.TvDbApiKey, logManager);
 }
コード例 #23
0
        private ContentCommand RegisterWebContent(string webAppRootDir, IFileCache fileCache, IWebServerConfiguration config)
        {
            string contentRootDirectory = Path.GetFullPath(Path.Combine(webAppRootDir, "Content"));

            ContentCommand contentCommand = new ContentCommand(contentRootDirectory, FileSystem, fileCache);

            contentCommand.CacheByMaxAge(@"cached-by-max-age.txt", TimeSpan.FromDays(30));
            contentCommand.CacheByETag(@"cached-by-etag.txt", TimeSpan.FromDays(10), () => GenerateContentETag(config));
            return(contentCommand);
        }
コード例 #24
0
 public TvDbClientV3(IJsonConnection jsonConnection, IFileCache fileCache, IApplicationPaths applicationPaths,
                     ILogManager logManager, ICustomJsonSerialiser jsonSerialiser, PluginConfiguration configuration)
 {
     this.log              = logManager.GetLogger(nameof(TvDbClientV2));
     this.fileCache        = fileCache;
     this.applicationPaths = applicationPaths;
     this.jsonSerialiser   = jsonSerialiser;
     this.tvDbClient       = new TvDbClient();
     this.tvDbClient.Authentication.AuthenticateAsync(configuration.TvDbApiKey).GetAwaiter().GetResult();
     this.dataMapper = this.CreateDataMapper();
 }
コード例 #25
0
 public NVelocityHtmlRenderHelper(
     IHttpContext httpContext,
     XhtmlTextWriter writer,
     IApplicationInfo applicationInfo,
     IFileCache fileCache)
 {
     this.httpContext     = httpContext;
     this.fileCache       = fileCache;
     this.applicationInfo = applicationInfo;
     this.writer          = writer;
 }
コード例 #26
0
ファイル: CachedFileResponse.cs プロジェクト: Ryks/detergent
 public CachedFileResponse(
     string fileName,
     IFileCache fileCache,
     string contentType,
     Encoding encoding)
 {
     this.fileName = fileName;
     this.fileCache = fileCache;
     this.contentType = contentType;
     this.encoding = encoding;
 }
コード例 #27
0
 public CachedFileResponse(
     string fileName,
     IFileCache fileCache,
     string contentType,
     Encoding encoding)
 {
     this.fileName    = fileName;
     this.fileCache   = fileCache;
     this.contentType = contentType;
     this.encoding    = encoding;
 }
コード例 #28
0
 public NVelocityHtmlRenderHelper(
     IHttpContext httpContext,
     XhtmlTextWriter writer,
     IApplicationInfo applicationInfo,
     IFileCache fileCache)
 {
     this.httpContext = httpContext;
     this.fileCache = fileCache;
     this.applicationInfo = applicationInfo;
     this.writer = writer;
 }
コード例 #29
0
        public AgentCommunicator(Stream stream, IFormatter formatter, IJobWorker jobWorker, IFileCache fileCache, ILog logger)
        {
            logger.Info("AgentCommunicator initializing...");

            this.stream    = stream;
            this.formatter = formatter;
            this.jobWorker = jobWorker;
            this.fileCache = fileCache;
            this.logger    = logger;

            logger.Info("AgentCommunicator initialized.");
        }
コード例 #30
0
        public AgentCommunicator(Stream stream, IFormatter formatter, IJobWorker jobWorker, IFileCache fileCache, ILog logger)
        {
            logger.Info("AgentCommunicator initializing...");

            this.stream = stream;
            this.formatter = formatter;
            this.jobWorker = jobWorker;
            this.fileCache = fileCache;
            this.logger = logger;

            logger.Info("AgentCommunicator initialized.");
        }
コード例 #31
0
ファイル: ContentCommand.cs プロジェクト: breki/syborg
        /// <summary>
        /// Initializes a new instance of the <see cref="ContentCommand"/> class.
        /// </summary>
        /// <param name="contentRootDirectory">
        /// The path to the root content directory.
        /// </param>
        /// <param name="fileSystem">
        /// Instance of the <see cref="IFileSystem"/> service.
        /// </param>
        /// <param name="fileCache">
        /// Instance of the <see cref="IFileCache"/> service. If <c>null</c>, no file caching will be performed.
        /// </param>
        public ContentCommand(
            string contentRootDirectory,
            IFileSystem fileSystem,
            IFileCache fileCache)
        {
            Contract.Requires(contentRootDirectory != null);
            Contract.Requires(fileSystem != null);

            this.contentRootDirectory = contentRootDirectory;
            this.fileSystem           = fileSystem;
            this.fileCache            = fileCache;
        }
コード例 #32
0
 public MappingList(IApplicationPaths applicationPaths, IFileCache fileCache, IApiClient xemApiClient, ICustomJsonSerialiser jsonSerialiser, IXmlSerialiser xmlSerializer)
 {
     this.mappingsFileSpec         = new MappingsFileSpec(applicationPaths.CachePath, xmlSerializer);
     this.mappingsAniDbXemFileSpec = new XemAniDbMappingsFileSpec(applicationPaths.CachePath, xemApiClient, jsonSerialiser);
     this.mappingsTvDbXemFileSpec  = new XemTvDbMappingsFileSpec(applicationPaths.CachePath, xemApiClient, jsonSerialiser);
     this.fileCache           = fileCache;
     this.mappingListTaskLazy =
         new Lazy <Task <IEnumerable <SeriesMapping> > >(() => this.CreateMappingListAsync(CancellationToken.None));
     this.xemAniDbMappingListTaskLazy =
         new Lazy <Task <IEnumerable <SeriesMapping> > >(() => this.CreateXemAniDbMappingListAsync(CancellationToken.None));
     this.xemTvDbMappingListTaskLazy =
         new Lazy <Task <IEnumerable <SeriesMapping> > >(() => this.CreateXemTvDbMappingListAsync(CancellationToken.None));
 }
コード例 #33
0
        public static MvcTemplateHttpResponse ReturnHtml(
            string htmlTemplateFileName,
            IFileCache fileCache,
            IDictionary properties)
        {
            ITemplateSource template = new CacheableFileTemplate(
                htmlTemplateFileName,
                fileCache);

            return(new MvcTemplateHttpResponse(
                       template,
                       HttpConstants.ContentTypeHtml,
                       properties));
        }
コード例 #34
0
ファイル: Wiki2Html.cs プロジェクト: Ashod/WikiDesk
        public Wiki2Html(Configuration config,
            ResolveWikiLink resolveWikiLinkDel,
            RetrievePage retrievePageDel,
            IFileCache fileCache)
        {
            config_ = config;
            resolveWikiLinkDel_ = resolveWikiLinkDel;
            retrievePageDel_ = retrievePageDel;
            fileCache_ = fileCache;

            commonImagesPath_ = Path.Combine(config.SkinsPath, config.CommonImagesPath);
            commonImagesPath_ = commonImagesPath_.Replace('\\', '/');
            commonImagesPath_ = "file:///" + commonImagesPath_;
            commonImagesPath_ = commonImagesPath_.TrimEnd('/') + '/';

            magicWordProcessor_ = new MagicWordProcessor(ProcessMagicWords);
            parserFunctionsProcessor_ = new ParserFunctionProcessor(ProcessMagicWords);

            logger_ = LogManager.CreateLoger(typeof(Wiki2Html).FullName);
            logger_.Trace = true;
        }
コード例 #35
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FileTransferServiceClient"/> class.
 /// </summary>
 public FileTransferServiceClient()
 {
     _fileCache = new DefaultFileCache();
 }
コード例 #36
0
 public StaticFileController(IFileCache fileCache)
     : base(fileCache)
 {
 }
コード例 #37
0
ファイル: ControllerBase.cs プロジェクト: Ryks/detergent
 protected ControllerBase(IFileCache fileCache)
 {
     this.fileCache = fileCache;
 }
コード例 #38
0
 public CacheableFileTemplate(string templateFileName, IFileCache fileCache)
 {
     this.templateFileName = templateFileName;
     this.fileCache = fileCache;
 }