Ejemplo n.º 1
0
 public virtual void Draw(IOutputProvider provider, Point startPosition)
 {
     provider.SetPosition(startPosition);
     provider.SetForegroundColor(color);
     provider.Draw(Symbol);
     provider.ResetColor();
 }
Ejemplo n.º 2
0
 public Calculator(IInputProvider inputProvider, IOutputProvider outputProvider, IParseProvider parseProvider, IMathProvider mathProvider)
 {
     _inputProvider = inputProvider;
     _outputProvider = outputProvider;
     _parseProvider = parseProvider;
     _mathProvider = mathProvider;
 }
Ejemplo n.º 3
0
 public AppLogic(IOutputProvider output, IInputProvider input, ICredentialManager credentialManager, IDataManager inventoryManager)
 {
     _output            = output;
     _input             = input;
     _credentialManager = credentialManager;
     _inventoryManager  = inventoryManager;
 }
Ejemplo n.º 4
0
        private void OutputProfileSignInResult(IOutputProvider outputProvider, HttpContext context, APIRequestParams filter)
        {
            var    sr          = new System.IO.StreamReader(context.Request.InputStream);
            string jsonContent = sr.ReadToEnd();
            var    loginModel  = JsonConvert.DeserializeObject <LoginModel>(jsonContent);

            User   user             = new OCM.API.Common.UserManager().GetUser(loginModel);
            string access_token     = null;
            var    responseEnvelope = new APIResponseEnvelope();

            if (user == null)
            {
                context.Response.StatusCode = 401;
                context.Response.Flush();
                return;
            }
            else
            {
                access_token = Security.JWTAuth.GenerateEncodedJWT(user);

                /*
                 * var validatedToken = Security.JWTAuthTicket.ValidateJWTForUser(testTicket, user);
                 */
            }

            responseEnvelope.Data = new { UserProfile = user, access_token = access_token };

            outputProvider.GetOutput(context.Response.OutputStream, responseEnvelope, filter);
        }
Ejemplo n.º 5
0
 private static void OnProviderDetatched(IOutputProvider sender)
 {
     if (ProviderDetached != null)
     {
         ProviderDetached(sender, EventArgs.Empty);
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Method returns a list of blocks since a specified datetime.
        /// </summary>
        /// <param name="datapath">Path to blockchain files.</param>
        /// <param name="fromDate">Date used to filter blocks.</param>
        /// <param name="outputProvider">Output handler type - CSV file or console.</param>
        public void GetBlocks(string datapath, DateTime fromDate, IOutputProvider outputProvider)
        {
            ConcurrentDictionary <uint256, bool> check = new ConcurrentDictionary <uint256, bool>();

            Action <StoredBlock, Transaction> callback = (block, transaction) => {
                if (!check.ContainsKey(block.Item.GetHash()) && block.Item.Header.BlockTime.DateTime.Date >= fromDate.Date)
                {
                    check[block.Item.GetHash()] = true;

                    string[] message = new string[4];
                    message[0] = "";
                    message[1] = block.Item.GetHash().ToString();
                    message[2] = String.Format("{0} {1}", block.Item.Header.BlockTime.DateTime.ToShortDateString(), block.Item.Header.BlockTime.DateTime.ToShortTimeString());
                    message[3] = block.Item.Transactions.Count.ToString();
                    outputProvider.WriteLine(message);
                }
            };
            Thread queueThread = new Thread(() => {
                WatchQueue();
            });
            Thread runnerThread = new Thread(() =>
            {
                Runner(datapath, callback);
            });

            runnerThread.Start();
            queueThread.Start();
            runnerThread.Join();
            queueThread.Join();
        }
Ejemplo n.º 7
0
        private void OutputGeocodingResult(IOutputProvider outputProvider, HttpContext context, APIRequestParams filter)
        {
            GeocodingResult result = null;

            //get or get and cache result
            if (HttpContext.Current.Cache["Geocoding_" + filter.HashKey] != null && filter.EnableCaching)
            {
                result = (GeocodingResult)HttpContext.Current.Cache["Geocoding_" + filter.HashKey];
            }
            else
            {
                var geocoder = new GeocodingHelper();
                geocoder.IncludeExtendedData = true;

                //result = geocoder.GeolocateAddressInfo_OSM(filter.Address);
                result = geocoder.GeolocateAddressInfo_Google(filter.Address);

                HttpContext.Current.Cache.Add("Geocoding_" + filter.HashKey, result, null, Cache.NoAbsoluteExpiration, new TimeSpan(1, 0, 0), CacheItemPriority.Normal, null);
            }

            //send API response
            if (filter.IsEnvelopedResponse)
            {
                var responseEnvelope = new APIResponseEnvelope();
                responseEnvelope.Data = result;
                outputProvider.GetOutput(context.Response.OutputStream, responseEnvelope, filter);
            }
            else
            {
                outputProvider.GetOutput(context.Response.OutputStream, result, filter);
            }
        }
Ejemplo n.º 8
0
 public Calculator(IInputProvider inputProvider, IOutputProvider outputProvider, IParseProvider parseProvider, IMathProvider mathProvider)
 {
     _inputProvider  = inputProvider;
     _outputProvider = outputProvider;
     _parseProvider  = parseProvider;
     _mathProvider   = mathProvider;
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Game"/> class.
        /// </summary>
        /// <param name="inputProvider">The input provider.</param>
        /// <param name="outputProvider">The output provider.</param>
        /// <param name="stateFactory">The factory that creates the game states.</param>
        public Game(IInputProvider inputProvider, IOutputProvider outputProvider, IStateFactory stateFactory)
        {
            this.InputProvider  = inputProvider;
            this.OutputProvider = outputProvider;
            this.StateFactory   = stateFactory;

            this.State = stateFactory.GetStartMenuState(this);
        }
Ejemplo n.º 10
0
        public IntcodeVirtualMachine(List <int> program, IInputProvider inputProvider = null, IOutputProvider outputProvider = null)
        {
            this._program = program.Select(x => (long)x).ToList();
            _vmstate      = new VirtualMachineState();

            this._inputProvider  = inputProvider ?? new ConsoleInputProvider();
            this._outputProvider = outputProvider ?? new ConsoleOutputProvider();
        }
Ejemplo n.º 11
0
 public static void Detach(IOutputProvider output)
 {
     if (providers.Contains(output))
     {
         providers.Remove(output);
         OnProviderDetatched(output);
     }
 }
 public SSASOutputController(
     OutputContext context,
     IAction initializer,
     IInputProvider inputProvider,
     IOutputProvider outputProvider
     ) : base(context, initializer, inputProvider, outputProvider)
 {
 }
Ejemplo n.º 13
0
 public void Register(IOutputProvider output)
 {
     if (output != null)
     {
         Context.Debug(() => $"Registering {output.GetType().Name}.");
     }
     OutputProvider = output;
 }
Ejemplo n.º 14
0
 public void Draw(IOutputProvider provider, Point startPosition)
 {
     provider.SetPosition(startPosition);
     provider.Draw("Generation: ");
     provider.SetForegroundColor(Color.Green);
     provider.Draw(count);
     provider.DrawEmptyLine();
     provider.ResetColor();
 }
Ejemplo n.º 15
0
        public IntcodeVirtualMachine(List <long> program, IInputProvider inputProvider = null, IOutputProvider outputProvider = null)
        {
            this._program = program;

            _vmstate = new VirtualMachineState();

            this._inputProvider  = inputProvider ?? new ConsoleInputProvider();
            this._outputProvider = outputProvider ?? new ConsoleOutputProvider();
        }
 public RethinkDbOutputController(
     OutputContext context,
     IAction initializer,
     IInputProvider inputProvider,
     IOutputProvider outputProvider,
     IConnectionFactory factory
     ) : base(context, initializer, inputProvider, outputProvider)
 {
     _factory = factory;
 }
Ejemplo n.º 17
0
        public DeliveryCodeGenerator(IOptions <CodeGeneratorOptions> options, IOutputProvider outputProvider, IDeliveryClient deliveryClient)
            : base(options, outputProvider)
        {
            if (options.Value.ManagementApi)
            {
                throw new InvalidOperationException("Cannot create Delivery models with Management API options.");
            }

            _deliveryClient = deliveryClient;
        }
Ejemplo n.º 18
0
        void OutputPad_ProviderAttached(object sender, EventArgs e)
        {
            IOutputProvider p = sender as IOutputProvider;

            if (p != null)
            {
                this.ItemBox.Items.Add(p);
                this.ItemBox.SelectedIndex = this.ItemBox.Items.Count - 1;
            }
        }
Ejemplo n.º 19
0
        public ManagementCodeGenerator(IOptions <CodeGeneratorOptions> options, IOutputProvider outputProvider, IManagementClient managementClient)
            : base(options, outputProvider)
        {
            if (!options.Value.ManagementApi)
            {
                throw new InvalidOperationException("Cannot create Management models with Delivery API options.");
            }

            _managementClient = managementClient;
        }
Ejemplo n.º 20
0
 public AdoOutputController(
     OutputContext context,
     IAction initializer,
     IInputProvider inputProvider,
     IOutputProvider outputProvider,
     IConnectionFactory cf) : base(context, initializer, inputProvider, outputProvider)
 {
     _cf        = cf;
     _stopWatch = new Stopwatch();
 }
 protected BaseOutputController(
     OutputContext context,
     IAction initializer,
     IInputProvider inputProvider,
     IOutputProvider outputProvider)
 {
     Context        = context;
     Initializer    = initializer;
     InputProvider  = inputProvider;
     OutputProvider = outputProvider;
 }
Ejemplo n.º 22
0
        public GameApp(IInputProvider inputProvider, IOutputProvider outputProvider, IMessageProvider mp, IDeck deck)
        {
            this.inputProvider   = inputProvider;
            this.outputProvider  = outputProvider;
            this.deck            = deck;
            players              = new List <IPlayer>();
            GameState            = GameState.Running;
            this.messageProvider = mp;

            Welcome();
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Render output in required format using available providers
        /// </summary>
        /// <param name="data">Output data in byte[]</param>
        /// <param name="format">Output format</param>
        /// <returns></returns>
        public bool Output(byte[] data, string format)
        {
            _data = data;

            outputProvider = GetOutputProvider(format);

            var result = outputProvider.Output(data);

            outputProvider = null;

            return result;
        }
Ejemplo n.º 24
0
 public RollingFileReaderManager(string pattern, IFilePositionStore store, ReadBehaviour readBehaviour, IOutputProvider outputProvider)
 {
     _positionStore  = store;
     _knownFiles     = new Dictionary <string, TimeBasedPoller>();
     _readBehaviour  = readBehaviour;
     _outputProvider = outputProvider;
     _fileWatcher    = new FileWatcher(pattern, OnNewFile);
     foreach (var file in Search.FindFiles(pattern))
     {
         OnNewFile(file);
     }
 }
Ejemplo n.º 25
0
        /// <summary>
        /// Output standard POI List results
        /// </summary>
        /// <param name="outputProvider"></param>
        /// <param name="context"></param>
        /// <param name="filter"></param>
        private void OutputPOIList(IOutputProvider outputProvider, HttpContext context, APIRequestSettings filter)
        {
            List <OCM.API.Common.Model.ChargePoint> dataList = null;

            //get list of charge points for output:
            dataList = new POIManager().GetChargePoints(filter);

            int numResults = dataList.Count;

            //send response
            outputProvider.GetOutput(context.Response.OutputStream, dataList, filter);
        }
Ejemplo n.º 26
0
 //this is for testing
 public Game(
     IInputProvider inputProvider,
     IOutputProvider outputProvider,
     ISnake snake,
     IBoard board
     )
 {
     this.inputProvider  = inputProvider;
     this.outputProvider = outputProvider;
     this.snake          = snake != null ? snake : null;
     this.board          = board;
 }
Ejemplo n.º 27
0
        void OutputPad_ProviderDetached(object sender, EventArgs e)
        {
            IOutputProvider p = sender as IOutputProvider;

            if (p != null)
            {
                this.ItemBox.Items.Remove(p);
                if (CurrentProvider == p)
                {
                    this.ItemBox.SelectedItem = this.ItemBox.Items.Count > 0 ? this.ItemBox.Items[this.ItemBox.Items.Count - 1] : null;
                }
            }
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Constructor used for unit testing
        /// </summary>
        /// <param name="board">The board</param>
        /// <param name="renderer">The board renderer</param>
        /// <param name="inputprovider">The input provider</param>
        /// <param name="outputProvider">The output provider</param>
        public GameManager(IBoard board, IBoardRenderer renderer, IInputProvider inputProvider, IOutputProvider outputProvider)
        {
            // validate the inputs

            this.board          = board;
            this.renderer       = renderer;
            this.inputProvider  = inputProvider;
            this.outputProvider = outputProvider;

            // initialize the players list

            // set the game state to waiting to start
        }
Ejemplo n.º 29
0
 public StandardOnePlayerEngine(IInputProvider inputProvider, IOutputProvider outputProvider, IRenderer renderer, IData data)
 {
     this.players         = new List <IPlayer>();
     snake                = new Snake();
     this.inputProvider   = inputProvider;
     this.outputProvider  = outputProvider;
     this.direction       = new Direction();
     this.randomGenerator = new RandomGenerator();
     this.RandomPosition  = this.randomGenerator.GetRandomPosition();
     this.sleepTime       = 100;
     this.data            = data;
     this.renderer        = renderer;
 }
Ejemplo n.º 30
0
 public Program
     (IDataInteraction dataInteraction,
     ISimulation simulation,
     IOutputProvider outputProvider,
     IContextProvider contextProvider,
     ILogger logger)
 {
     this.dataInteraction = dataInteraction;
     this.simulation      = simulation;
     this.outputProvider  = outputProvider;
     this.contextProvider = contextProvider;
     this.dataInteraction = dataInteraction;
     this.logger          = logger;
 }
Ejemplo n.º 31
0
 public LuceneOutputController(
     OutputContext context,
     IAction initializer,
     IInputProvider inputProvider,
     IOutputProvider outputProvider
     ) : base(
         context,
         initializer,
         inputProvider,
         outputProvider
         )
 {
     _stopWatch = new Stopwatch();
 }
 public SolrOutputController(
     OutputContext context,
     IAction initializer,
     IInputProvider inputProvider,
     IOutputProvider outputProvider,
     ISolrReadOnlyOperations <Dictionary <string, object> > solr
     ) : base(
         context,
         initializer,
         inputProvider,
         outputProvider
         )
 {
     _solr = solr;
 }
Ejemplo n.º 33
0
        /// <summary>
        /// Constructor with which you can supply the input and the output provider independently
        /// </summary>
        /// <param name="input">The input provider</param>
        /// <param name="output">The output provider</param>
        public Interpreter(IInputProvider input, IOutputProvider output, String program = "")
        {
            if (input == null) throw new ArgumentNullException("input");
            if (output == null) throw new ArgumentNullException("output");

            this.inputProvider = input;
            this.outputDestination = output;

            InitializeActionList(input, output);

            ValidateSourceFile(program);

            ProgramString = program;
            PointerPosition = 0;
            loopIndexes = new Stack<Int32>();
            MemoryCells = new List<Int32>();
            MemoryCells.Add(0);
        }
Ejemplo n.º 34
0
        /// <summary>
        /// Output Core Reference Data (lookup lists, default objects)
        /// </summary>
        /// <param name="outputProvider"></param>
        /// <param name="context"></param>
        /// <param name="filter"></param>
        private void OutputCoreReferenceData(IOutputProvider outputProvider, HttpContext context, APIRequestParams filter)
        {
            //get core reference data
            var refDataManager = new ReferenceDataManager();
            CoreReferenceData data = null;

            //cache result
            if (HttpContext.Current.Cache["CoreRefData"] != null && filter.EnableCaching)
            {
                data = (CoreReferenceData)HttpContext.Current.Cache["CoreRefData"];
            }
            else
            {
                data = refDataManager.GetCoreReferenceData();

                HttpContext.Current.Cache.Add("CoreRefData", data, null, Cache.NoAbsoluteExpiration, new TimeSpan(1, 0, 0), CacheItemPriority.Normal, null);
            }

            //populate non-cached fragments (user profile)
            data.UserProfile = new InputProviderBase().GetUserFromAPICall(context);

            //send response
            outputProvider.GetOutput(context.Response.OutputStream, data, filter);
        }
Ejemplo n.º 35
0
        void ItemBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (CurrentControl != null)
            {
                ViewPanel.Controls.Remove(CurrentControl);
                CurrentControl = null;
            }

            if (CurrentProvider != null)
            {
                CurrentProvider = null;
            }

            if (this.ItemBox.SelectedItem != null)
            {
                CurrentProvider = this.ItemBox.SelectedItem as IOutputProvider;
                CurrentControl = CurrentProvider.OutputViewContent;

                CurrentControl.Dock = DockStyle.Fill;
                ViewPanel.Controls.Add(CurrentControl);
            }
        }
Ejemplo n.º 36
0
 private static void OnProviderDetatched(IOutputProvider sender)
 {
     if (ProviderDetached != null)
         ProviderDetached(sender, EventArgs.Empty);
 }
Ejemplo n.º 37
0
 public static void Detach(IOutputProvider output)
 {
     if (providers.Contains(output))
     {
         providers.Remove(output);
         OnProviderDetatched(output);
     }
 }
Ejemplo n.º 38
0
 public static void Attach(IOutputProvider output)
 {
     providers.Add(output);
     OnProviderAttached(output);
 }
Ejemplo n.º 39
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            dte = GetService(typeof (DTE)) as DTE;

            if (null == dte)
            {
                throw new ArgumentNullException(nameof(dte));
            }

            var pane = GetService(typeof(SVsGeneralOutputWindowPane)) as IVsOutputWindowPane;

            if (null == pane)
            {
                throw new ArgumentNullException(nameof(pane));
            }

            output = new VisualStudioOutputPaneProvider(pane);

            formatDocumentEvent = dte.Events.CommandEvents[VsStd2KCmdIdGuid, (int) VSConstants.VSStd2KCmdID.FORMATDOCUMENT];
            saveProjectItemEvent = dte.Events.CommandEvents[VsStd97CmdIdGuid, (int) VSConstants.VSStd97CmdID.SaveProjectItem];

            factory = new CommandFactory(dte, output);

            formatDocumentEvent.BeforeExecute += OnFormatDocumentBeforeExecute;
            saveProjectItemEvent.BeforeExecute += OnSaveProjectItemBeforeExecute;
        }
Ejemplo n.º 40
0
        private void InitializeActionList(IInputProvider input, IOutputProvider output)
        {
            actions = new Dictionary<char, Action>();

            //Pointer manipulation
            actions.Add('>', () =>
            {
                PointerPosition++;

                //Allocate new memory cells as we go
                if (MemoryCells.Count <= PointerPosition)
                    MemoryCells.Add(0);
            });

            actions.Add('<', () =>
            {
                PointerPosition--;

                if (PointerPosition < 0)
                    PointerPosition = 0;
            });

            //Current cell manipulation
            actions.Add('+', () => MemoryCells[PointerPosition]++);
            actions.Add('-', () => MemoryCells[PointerPosition]--);

            //Input and output
            actions.Add(',', () => MemoryCells[PointerPosition] = Convert.ToInt32(input.Get()));
            actions.Add('.', () => output.Write(MemoryCells[PointerPosition].ToString()));

            actions.Add('[', () =>
            {
                loopIndexes.Push(currentProgramStringIndex);

                //Enter the loop if the current memory cell is different than zero
                if (MemoryCells[PointerPosition] != 0)
                    return;

                //Else we skip until the end of that loop
                do
                {
                    currentProgramStringIndex++;

                    //Stack-based logic in case we encounter any inner loops
                    if (ProgramString[currentProgramStringIndex] == '[')
                    {
                        loopIndexes.Push(currentProgramStringIndex);
                    }
                    else if (ProgramString[currentProgramStringIndex] == ']')
                    {
                        loopIndexes.Pop();
                    }
                //FIXME: Potential bug here if we are already in a loop
                } while (loopIndexes.Count > 0);
            });

            actions.Add(']', () =>
            {
                //Go back to the start of the loop
                if (MemoryCells[PointerPosition] != 0)
                    currentProgramStringIndex = loopIndexes.Peek();
                else
                    loopIndexes.Pop();
            });
        }
Ejemplo n.º 41
0
 /// <summary>
 /// Инициализирует новый экземпляр класса <see cref="T:System.Object"/>.
 /// </summary>
 public CommandFactory(DTE dte, IOutputProvider output)
 {
     this.dte = dte;
     this.output = output;
 }
Ejemplo n.º 42
0
 public TestRunner(IOutputProvider outputProvider)
 {
     _output = outputProvider;
 }
 /// <summary>
 /// Инициализирует новый экземпляр класса <see cref="T:System.Object"/>.
 /// </summary>
 public FormatDocumentCommand(DTE dte, IOutputProvider output)
 {
     this.dte = dte;
     this.output = output;
 }
Ejemplo n.º 44
0
        private void OutputAvailabilityResult(IOutputProvider outputProvider, HttpContext context, APIRequestParams filter)
        {
            //TODO: provider specific availability check with result caching
            var results = new List<object>();

            foreach (var poiId in filter.ChargePointIDs)
            {
                results.Add(new { id = filter.ChargePointIDs, status = StandardStatusTypes.Unknown, timestamp = DateTime.UtcNow });
            }
            //send API response
            if (filter.IsEnvelopedResponse)
            {
                var responseEnvelope = new APIResponseEnvelope();
                responseEnvelope.Data = results;
                outputProvider.GetOutput(context.Response.OutputStream, responseEnvelope, filter);
            }
            else
            {
                outputProvider.GetOutput(context.Response.OutputStream, results, filter);
            }
        }
Ejemplo n.º 45
0
        private void OutputGeocodingResult(IOutputProvider outputProvider, HttpContext context, APIRequestParams filter)
        {
            GeocodingResult result = null;

            //get or get and cache result
            if (HttpContext.Current.Cache["Geocoding_" + filter.HashKey] != null && filter.EnableCaching)
            {
                result = (GeocodingResult)HttpContext.Current.Cache["Geocoding_" + filter.HashKey];
            }
            else
            {
                var geocoder = new GeocodingHelper();
                geocoder.IncludeExtendedData = true;

                //result = geocoder.GeolocateAddressInfo_OSM(filter.Address);
                result = geocoder.GeolocateAddressInfo_Google(filter.Address);

                HttpContext.Current.Cache.Add("Geocoding_" + filter.HashKey, result, null, Cache.NoAbsoluteExpiration, new TimeSpan(1, 0, 0), CacheItemPriority.Normal, null);
            }

            //send API response
            if (filter.IsEnvelopedResponse)
            {
                var responseEnvelope = new APIResponseEnvelope();
                responseEnvelope.Data = result;
                outputProvider.GetOutput(context.Response.OutputStream, responseEnvelope, filter);
            }
            else
            {
                outputProvider.GetOutput(context.Response.OutputStream, result, filter);
            }
        }
Ejemplo n.º 46
0
        /// <summary>
        /// Output standard POI List results
        /// </summary>
        /// <param name="outputProvider"></param>
        /// <param name="context"></param>
        /// <param name="filter"></param>
        private void OutputPOIList(IOutputProvider outputProvider, HttpContext context, APIRequestParams filter)
        {
            List<OCM.API.Common.Model.ChargePoint> dataList = null;

            //get list of charge points for output:
            dataList = new POIManager().GetChargePoints(filter);

            int numResults = dataList.Count;

            //send response
            outputProvider.GetOutput(context.Response.OutputStream, dataList, filter);
        }
Ejemplo n.º 47
0
 public PathFinder(IDictionaryProvider dictionaryProvider, IOutputProvider outputProvider)
 {
     _dictionaryProvider = dictionaryProvider;
     _outputProvider = outputProvider;
 }