Пример #1
0
        public void ProcessPriceUpdates(string productCode)
        {
            // get the necessary dependencies
            IWebPageEngine       pageEngine      = EngineLocator.CreateEngine <IWebPageEngine>();
            IProductParserEngine priceEngine     = EngineLocator.CreateEngine <IProductParserEngine>();
            IProductAccessor     productAccessor = AccessorLocator.CreateAccessor <IProductAccessor>();
            IEmailAccessor       emailAccessor   = AccessorLocator.CreateAccessor <IEmailAccessor>();

            // build the url
            string url = pageEngine.BuildUrl(productCode);
            // get the page contents
            string contents = pageEngine.GetWebPageContents(url);
            // get the stored product information
            var product = productAccessor.FindByCode(productCode);
            // get the current price
            decimal currentPrice = priceEngine.GetProductPrice(contents, productCode);

            // if the current price is different from the price threshold then send an email
            if (currentPrice > 0)
            {
                if (product.PriceThreshold != currentPrice)
                {
                    emailAccessor.SendPriceNotice(product, currentPrice);
                }
            }
        }
Пример #2
0
 public void Setup()
 {
     _client  = MockRepository.GenerateMock <IClient>();
     _fs      = MockRepository.GenerateMock <IFS>();
     _locator = new EngineLocator(_fs);
     _locator.ClientFactory = () => { return(_client); };
 }
Пример #3
0
        public void Setup()
        {
            var user = System.Security.Principal.WindowsIdentity.GetCurrent().Name.Replace(Path.DirectorySeparatorChar.ToString(), "-");

            _filepattern           = string.Format("*.EditorEngine.{0}.pid", user);
            _client                = MockRepository.GenerateMock <IClient>();
            _fs                    = MockRepository.GenerateMock <IFS>();
            _locator               = new EngineLocator(_fs);
            _locator.ClientFactory = () => { return(_client); };
        }
        public void Execute(IResponseWriter writer, string[] args)
        {
            if (args.Length != 1)
            {
                return;
            }
            var chunks = args[0].Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries);

            if (chunks.Length != 3)
            {
                return;
            }
            try {
                var file   = chunks[0];
                var line   = int.Parse(chunks[1]);
                var column = int.Parse(chunks[2]);

                var cache =
                    new DirtyFileParser(
                        _globalCache,
                        (fileName) => File.ReadAllText(fileName),
                        (fileName) => File.Delete(fileName),
                        (fileName) => {
                    var instance = new EngineLocator(new FS()).GetInstance(Environment.CurrentDirectory);
                    if (instance != null)
                    {
                        return(instance.GetDirtyFiles(fileName));
                    }
                    return("");
                }).Parse(file);

                var name = new TypeUnderPositionResolver()
                           .GetTypeName(file, File.ReadAllText(file), line, column);
                writer.Write("comment|Found name {0}", name);
                var signature = new FileContextAnalyzer(_globalCache, cache)
                                .GetSignatureFromNameAndPosition(file, name, line, column);
                writer.Write("comment|Found signature {0}", signature);
                var pos = cache.PositionFromSignature(signature);
                if (pos != null)
                {
                    writer.Write("editor goto {0}|{1}|{2}", pos.Fullpath, pos.Line, pos.Column);
                    return;
                }
                writer.Write("comment|Looking in global cache");
                pos = _globalCache.PositionFromSignature(signature);
                if (pos != null)
                {
                    writer.Write("editor goto {0}|{1}|{2}", pos.Fullpath, pos.Line, pos.Column);
                }
            } catch (Exception ex) {
                writer.Write(ex.ToString());
            }
        }
Пример #5
0
        public void Execute(IResponseWriter writer, string[] args)
        {
            if (args.Length != 1)
            {
                return;
            }
            var chunks = args[0].Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries);

            if (chunks.Length != 3)
            {
                return;
            }
            try {
                var file   = chunks[0];
                var line   = int.Parse(chunks[1]);
                var column = int.Parse(chunks[2]);

                var signatureFetcher =
                    new EnclosingSignatureFromPosition(
                        _globalCache,
                        (fileName) => File.ReadAllText(fileName),
                        (fileName) => File.Delete(fileName),
                        (fileName) => {
                    var instance = new EngineLocator(new FS()).GetInstance(Environment.CurrentDirectory);
                    if (instance != null)
                    {
                        return(instance.GetDirtyFiles(fileName));
                    }
                    return("");
                });
                var signature = signatureFetcher.GetSignature(file, line, column);
                writer.Write(signature);
            } catch (Exception ex) {
                writer.Write(ex.ToString());
            }
        }
Пример #6
0
 protected ManagerBase()
 {
     EngineLocator   = new EngineLocator();
     AccessorLocator = new AccessorLocator();
 }