public void Go(ExecutionPoint point)
        {
            var p = point.PathToTheHeadlockFile;

            VerifyFile(p);
            VerifyEntries(new FileInfo(p));
        }
        public void Go(ExecutionPoint point)
        {
            var p = point.PathToTheHeadlockFile;

            VerifyFile(p);
            VerifyEntries(new FileInfo(p));
        }
예제 #3
0
 public void Sign()
 {
     var p = new ProcessToPutInHeadlock();
     var ep = new ExecutionPoint(@".\test_folder");
     p.Go(ep);
     //assert file exists
 }
예제 #4
0
파일: AsyncFlow.cs 프로젝트: mamasha/tests
        private void enqueue(ExecutionPoint point, OnReady <T> onReady)
        {
            T         value;
            Exception error;

            for (;;)
            {
                lock (point)
                {
                    value = point.Value;
                    error = point.Error;

                    if (value != null)
                    {
                        break;
                    }

                    if (error != null)
                    {
                        break;
                    }

                    point.Que.Enqueue(onReady);
                    return;
                }
            }

            invoke(onReady, value, error);
        }
예제 #5
0
 public void Verify()
 {
     var p = new ProcessToVerifyHeadlock();
     var ep = new ExecutionPoint(@".\test_folder");
     //sign it?
     //run process
     p.Go(ep);
 }
예제 #6
0
        public void Sign()
        {
            var p  = new ProcessToPutInHeadlock();
            var ep = new ExecutionPoint(@".\test_folder");

            p.Go(ep);
            //assert file exists
        }
예제 #7
0
        public MsdnTocBuilder()
        {
            var executeBefore = new ExecutionPoint(BuildStep.BuildConceptualTopics, ExecutionBehaviors.Before);

            executionPoints = new ExecutionPointCollection()
            {
                executeBefore
            };
        }
예제 #8
0
        public void Verify()
        {
            var p  = new ProcessToVerifyHeadlock();
            var ep = new ExecutionPoint(@".\test_folder");

            //sign it?
            //run process
            p.Go(ep);
        }
예제 #9
0
        public CopyMsdn2010BrandingContent()
        {
            var executeAfter        = new ExecutionPoint(BuildStep.CopyStandardContent, ExecutionBehaviors.After);
            var executeAfterWebsite = new ExecutionPoint(BuildStep.CopyingWebsiteFiles, ExecutionBehaviors.After);
            var executeBeforeProjet = new ExecutionPoint(BuildStep.BuildConceptualTopics, ExecutionBehaviors.After);

            executionPoints = new ExecutionPointCollection()
            {
                executeAfter, executeAfterWebsite,                                                /*executeBeforeProjet*/
            };
        }
예제 #10
0
        public void Go(ExecutionPoint point)
        {
            var files = _fileSystem.GetAllFilesInDir(point.PathToPutInAHeadlock);
            var entries = new List<Entry>();

            foreach (var file in files)
            {
                var e = new Entry {File = file.Name, FingerPrint = _hasher.Hash(_fileSystem.ReadBytes(file.FullName))};
                entries.Add(e);
            }

            _fileSystem.WriteEntriesToFile(point.PathToPutInAHeadlock, entries);
            _fileSystem.AttachFingerprintToHeadlockFile(point.PathToTheHeadlockFile, _hasher.Hash(_fileSystem.ReadBytes(point.PathToTheHeadlockFile)));
        }
예제 #11
0
        public void Go(ExecutionPoint point)
        {
            var files   = _fileSystem.GetAllFilesInDir(point.PathToPutInAHeadlock);
            var entries = new List <Entry>();

            foreach (var file in files)
            {
                var e = new Entry {
                    File = file.Name, FingerPrint = _hasher.Hash(_fileSystem.ReadBytes(file.FullName))
                };
                entries.Add(e);
            }

            _fileSystem.WriteEntriesToFile(point.PathToPutInAHeadlock, entries);
            _fileSystem.AttachFingerprintToHeadlockFile(point.PathToTheHeadlockFile, _hasher.Hash(_fileSystem.ReadBytes(point.PathToTheHeadlockFile)));
        }
예제 #12
0
파일: AsyncFlow.cs 프로젝트: mamasha/tests
        private ExecutionPoint getMyPoint(string key)
        {
            lock (_db)
            {
                if (_db.TryGetValue(key, out var point))
                {
                    return(point);
                }

                point = new ExecutionPoint {
                    Que = new Queue <OnReady <T> >()
                };

                _db.Add(key, point);

                return(point);
            }
        }
예제 #13
0
파일: AsyncFlow.cs 프로젝트: mamasha/tests
        private void complete(ExecutionPoint point, T value, Exception error)
        {
            Trace.Assert(value != null || error != null);

            OnReady <T>[] handlers;

            lock (point)
            {
                point.Value = value;
                point.Error = error;

                handlers = point.Que.ToArray();
                point.Que.Clear();
            }

            foreach (var onReady in handlers)
            {
                invoke(onReady, value, error);
            }
        }
예제 #14
0
        public ExecutionResult Run(
            PolishResult polishResult,
            ExecutionPoint executionPoint = default,
            decimal input = default)
        {
            var outputBuilder = new StringBuilder();

            _stack.Clear();
            _declaredIdentifiers.Clear();
            _identifiersValues.Clear();
            int i = 0;

            if (executionPoint != default)
            {
                _stack = executionPoint.Stack;
                _declaredIdentifiers = executionPoint.DeclaredIdentifiers;
                _identifiersValues   = executionPoint.IdentifiersValues;
                i = executionPoint.PolishNotationIndex;

                _stack.Push(input.ToString(CultureInfo.InvariantCulture));
                HandleSet();
            }

            try
            {
                while (i < polishResult.ReversePolishNotation.Count)
                {
                    PolishNotation element = polishResult.ReversePolishNotation[i];

                    switch (element.Type)
                    {
                    case PolishNotationTokenType.Identifier:
                        _stack.Push(_identifiersValues.ContainsKey(element.Token) &&
                                    !element.IsAssignmentToThisIdentifier
                                                                ? _identifiersValues[element.Token].ToString(CultureInfo.InvariantCulture)
                                                                : element.Token); // only for declaration or assignment
                        break;

                    case PolishNotationTokenType.Literal:
                        _stack.Push(element.Token);
                        break;

                    case PolishNotationTokenType.Operator:
                        switch (element.Token)
                        {
                        case "@+":
                        case "@-":
                            HandleArithmeticUnary(element);
                            break;

                        case "+":
                        case "-":
                        case "*":
                        case "/":
                            HandleArithmeticBinary(element);
                            break;

                        case "var":
                            HandleVar();
                            break;

                        case "set":
                            HandleSet();
                            break;

                        case "write":
                            string head = _stack.Pop();
                            if (head.StartsWith("@"))
                            {
                                throw new RuntimeException($"{head} is not declared");
                            }

                            outputBuilder.AppendLine(head.ToString(CultureInfo.InvariantCulture));
                            break;

                        case "read":
                            return(new ExecutionResult
                            {
                                Type = ExecutionResultType.InputRequired,
                                Output = outputBuilder.ToString(),
                                ExecutionPoint = new ExecutionPoint
                                {
                                    PolishNotationIndex = i + 1,
                                    Stack = _stack,
                                    DeclaredIdentifiers = _declaredIdentifiers,
                                    IdentifiersValues = _identifiersValues,
                                    PolishResult = polishResult
                                }
                            });

                        case "equals":
                        case "greaterthn":
                        case "lessthn":
                            HandleConditional(element);
                            break;
                        }
                        break;

                    case PolishNotationTokenType.Delimiter:
                        break;

                    case PolishNotationTokenType.If:
                        break;

                    case PolishNotationTokenType.Then:
                        break;

                    case PolishNotationTokenType.Fi:
                        break;

                    case PolishNotationTokenType.While:
                        break;

                    case PolishNotationTokenType.TechnicalDo:
                        break;

                    case PolishNotationTokenType.Enddo:
                        break;

                    case PolishNotationTokenType.Label:
                        PolishNotation nextElement = polishResult.ReversePolishNotation[i + 1];
                        switch (nextElement.Token)
                        {
                        case "УПХ":
                            bool operand = Convert.ToBoolean(_stack.Pop());
                            if (!operand)
                            {
                                i = polishResult.LabelAddresses[element.Token];
                                continue;
                            }

                            break;

                        case "БП":
                            i = polishResult.LabelAddresses[element.Token];
                            continue;
                        }
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }

                    i++;
                }
            }
            catch (RuntimeException e)
            {
                outputBuilder.AppendLine(e.Message);
            }

            return(new ExecutionResult
            {
                Type = ExecutionResultType.Completed,
                Output = outputBuilder.ToString()
            });
        }