Ejemplo n.º 1
0
        public override void Invoke(Touch touch)
        {
            if (touch.State == TouchState.Begin)
            {
                Input.Value = GetText();
            }
            if (touch.State == TouchState.End || touch.State == TouchState.Moving)
            {
                List <char> charShift = InputLabelStyle.Type == InputLabelType.Digits
                    ? Digits
                    : (InputLabelStyle.Type == InputLabelType.Characters ? Characters : All);
                string newValue = Input.Temp;
                int    delta    = touch.Session.PreviousTouch.AbsoluteY - touch.AbsoluteY;
                if (delta % charShift.Count != 0)
                {
                    int  charPosition = touch.Session.BeginTouch.X / 2;
                    int  charIndex    = charShift.IndexOf(RawText[charPosition]);
                    char newChar      = charShift[((charIndex + delta) % charShift.Count + charShift.Count) % charShift.Count];
                    newValue = $"{RawText.Substring(0, charPosition)}{newChar}{RawText.Substring(charPosition + 1, (RawText.Length - charPosition - 1))}";
                }

                if (touch.State == TouchState.End || InputLabelStyle.TriggerInRuntime)
                {
                    SetValue(newValue, true, touch.Session.PlayerIndex);
                }
                else
                {
                    SetTempValue(newValue, true);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// New position in stream.
        /// </summary>
        /// <param name="svc"></param>
        /// <param name="line">Received line.</param>
        /// <returns>true if it was processed by current handler, otherwise it means ignoring.</returns>
        public override bool Positioned(ISvc svc, RawText line)
        {
            if (svc.Sln.ExtItems == null)
            {
                svc.Sln.ExtItems = new Dictionary <string, string>();
            }

            string _line;

            while ((_line = svc.ReadLine(this)) != null && _line.Trim() != "EndGlobalSection")
            {
                int pos = _line.IndexOf('=');
                if (pos < 0) // we will use non-strict processing
                {
                    svc.Sln.ExtItems[_line.Trim()] = null;
                    LSender.Send(this, $"Found extensible null record:{_line}", Message.Level.Info);
                    continue;
                }

                string key = _line.Substring(0, pos).Trim();
                string val = _line.Substring(pos + 1).Trim();

                svc.Sln.ExtItems[key] = val;
                LSender.Send(this, $"Found extensible key-value: `{key}` = `{val}`", Message.Level.Info);
            }

            return(true);
        }
Ejemplo n.º 3
0
        private bool IsNoNewlineAtEndOfFile(FileHeader fh)
        {
            HunkHeader lastHunk = fh.GetHunks()[fh.GetHunks().Count - 1];
            RawText    lhrt     = new RawText(lastHunk.GetBuffer());

            return(lhrt.GetString(lhrt.Size() - 1).Equals("\\ No newline at end of file"));
        }
 // RZ: 5.6.2012
 /// <summary>
 ///  Loads the properties of the FreeMarker 'ftl' directive.
 /// </summary>
 private void loadTemplateProperties()
 {
     _StriptWhiteSpaces = false;
     try {
         if (RawText != string.Empty)
         {
             String startingTag      = FTL_START_TAG;
             String endingTag        = FTL_END_TAG;
             int    startingPosition = 0;
             int    endingPosition   = 0;
             startingPosition = RawText.IndexOf(startingTag) + startingTag.Length;
             endingPosition   = RawText.IndexOf(endingTag);
             String templateProperties = RawText.Substring(startingPosition, endingPosition - startingPosition);
             if (!String.IsNullOrEmpty(templateProperties))
             {
                 string[] pairs = templateProperties.Trim().Split(' ');
                 foreach (String pair in pairs)
                 {
                     String[] value = pair.Split('=');
                     value[0] = value[0].Trim();
                     if (value.Length == 2)
                     {
                         if (value[0].ToLower() == FTL_STRIP_WHITESPACE)
                         {
                             Boolean result = false;
                             Boolean.TryParse(removeQuotes(value[1].Trim()), out result);
                             _StriptWhiteSpaces = result;
                         }
                     }
                 }
             }
         }
     } catch (Exception e) {
     }
 }
Ejemplo n.º 5
0
 public void SetDataText(string newData)
 {
     RawText =
         RawText.Substring(0, DataStartIndex)                              // add preceding whitespace
         + newData.Replace("#", "\\#")                                     // escape comments
         + RawText.Substring(DataEndIndex, RawText.Length - DataEndIndex); // add any following whitespace or comments
 }
        public IEnumerable<HunkRangeInfo> GetGitDiffFor(ITextDocument textDocument, ITextSnapshot snapshot)
        {
            string fileName = textDocument.FilePath;
            GitFileStatusTracker tracker = new GitFileStatusTracker(Path.GetDirectoryName(fileName));
            if (!tracker.IsGit)
                yield break;

            GitFileStatus status = tracker.GetFileStatus(fileName);
            if (status == GitFileStatus.New || status == GitFileStatus.Added)
                yield break;

            HistogramDiff diff = new HistogramDiff();
            diff.SetFallbackAlgorithm(null);
            string currentText = snapshot.GetText();

            byte[] preamble = textDocument.Encoding.GetPreamble();
            byte[] content = textDocument.Encoding.GetBytes(currentText);
            if (preamble.Length > 0)
            {
                byte[] completeContent = new byte[preamble.Length + content.Length];
                Buffer.BlockCopy(preamble, 0, completeContent, 0, preamble.Length);
                Buffer.BlockCopy(content, 0, completeContent, preamble.Length, content.Length);
                content = completeContent;
            }

            byte[] previousContent = null; //GetPreviousRevision(tracker, fileName);
            RawText b = new RawText(content);
            RawText a = new RawText(previousContent ?? new byte[0]);
            EditList edits = diff.Diff(RawTextComparator.DEFAULT, a, b);
            foreach (Edit edit in edits)
                yield return new HunkRangeInfo(snapshot, edit, a, b);
        }
Ejemplo n.º 7
0
        private IEnumerable <InputValue> GetInputValues(string delimiterPattern)
        {
            var startIndex = 0;
            var delimiters = GetDelimiters(delimiterPattern);

            if (!delimiters.Any())
            {
                yield return(new InputValue(RawText, Bias(startIndex)));

                yield break;
            }
            foreach (var delimiterMatch in delimiters)
            {
                yield return(new InputValue(RawText.Substring(startIndex, delimiterMatch.Index - startIndex), Bias(startIndex)));

                startIndex = delimiterMatch.Index + delimiterMatch.Length;
            }

            var last = delimiters.LastOrDefault();

            if (last != null)
            {
                yield return(new InputValue(RawText.Substring(startIndex, RawText.Length - startIndex), Bias(startIndex)));
            }
        }
Ejemplo n.º 8
0
 /// <param name="type">Allowed type of operations.</param>
 /// <param name="raw">Solution raw data.</param>
 /// <param name="projects">Dictionary of raw xml projects by Guid.</param>
 public Sln(SlnItems type, RawText raw, IDictionary <string, RawText> projects)
 {
     parser.RawXmlProjects = projects;
     using (var reader = new StreamReader(raw.data.GetStream(raw.encoding), raw.encoding)) {
         Result = parser.Parse(reader, type);
     }
 }
Ejemplo n.º 9
0
        public IActionResult CreatePostVersion([FromBody] CreatePostVersionViewModel model)
        {
            var user = userRepository.GetApplicationUserByUsername(User.Identity.Name, true);

            if (user == null)
            {
                return(Unauthorized());
            }
            var rawText = new RawText()
            {
                Text = ""
            };
            var postVersion = new PostVersion()
            {
                Title       = model.Title,
                RawText     = rawText,
                PostId      = model.PostId,
                PreviewText = ""
            };

            try {
                postVersion = postRepository.CreatePostVersion(postVersion);
                return(Ok(Conversions.PostVersionViewModelFromPostVersion(postVersion)));
            }
            catch (Exception) {
                return(BadRequest());
            }
        }
        /// <summary>
        /// New position in stream.
        /// </summary>
        /// <param name="svc"></param>
        /// <param name="line">Received line.</param>
        /// <returns>true if it was processed by current handler, otherwise it means ignoring.</returns>
        public override bool Positioned(ISvc svc, RawText line)
        {
            if (svc.Sln.SolutionConfigList == null)
            {
                svc.Sln.SolutionConfigList = new List <IConfPlatform>();
            }

            string _line;

            while ((_line = svc.ReadLine(this)) != null && _line.Trim() != "EndGlobalSection")
            {
                string left = _line.Before('=')?.Trim(); // Debug|Win32 = Debug|Win32
                if (left == null ||
                    String.Compare(left, "DESCRIPTION", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    LSender.Send(this, $"Solution Configuration has been ignored for line '{_line}'", Message.Level.Debug);
                    continue;
                }

                string[] cfg = left.Split('|');
                if (cfg.Length < 2)
                {
                    continue;
                }

                LSender.Send(this, $"Solution Configuration ->['{cfg[0]}' ; '{cfg[1]}']", Message.Level.Info);
                svc.Sln.SolutionConfigList.Add(new ConfigSln(cfg[0], cfg[1]));
            }

            return(true);
        }
Ejemplo n.º 11
0
        public string GetDataText()
        {
            if (RawText.IsWhitespace()) return String.Empty;

            return RawText.Substring(DataStartIndex, DataEndIndex - DataStartIndex)
                .Replace("\\#", "#"); // unescape comments
        }
Ejemplo n.º 12
0
        public LineAndCommit[] Blame(Commit commit, string path)
        {
            var leaf = commit.Tree[path] as Leaf;

            if (leaf == null)
            {
                throw new ArgumentException("The given path does not exist in this commit: " + path);
            }

            byte[]  data    = leaf.RawData;
            IntList lineMap = RawParseUtils.lineMap(data, 0, data.Length);
            var     lines   = new LineAndCommit[lineMap.size()];
            var     curText = new RawText(data);

            Commit prevAncestor = commit;

            Leaf   prevLeaf   = null;
            Commit prevCommit = null;
            int    emptyLines = lineMap.size();

            foreach (Commit ancestor in commit.Ancestors)
            {
                var cleaf = ancestor.Tree[path] as Leaf;
                if (prevCommit != null && (cleaf == null || cleaf.Hash != prevLeaf.Hash))
                {
                    byte[] prevData = prevLeaf.RawData;
                    if (prevData == null)
                    {
                        break;
                    }
                    var prevText = new RawText(prevData);
                    var differ   = new MyersDiff(prevText, curText);
                    foreach (Edit e in differ.getEdits())
                    {
                        for (int n = e.BeginB; n < e.EndB; n++)
                        {
                            if (lines[n] == null)
                            {
                                lines[n] = CreateViewModel(GetLine(commit.Encoding, curText, n), prevCommit);
                                emptyLines--;
                            }
                        }
                    }
                    if (cleaf == null || emptyLines <= 0)
                    {
                        break;
                    }
                }
                prevCommit = ancestor;
                prevLeaf   = cleaf;
            }
            for (int n = 0; n < lines.Length; n++)
            {
                if (lines[n] == null)
                {
                    lines[n] = CreateViewModel(GetLine(commit.Encoding, curText, n), prevAncestor);
                }
            }
            return(lines);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// New position in stream.
        /// </summary>
        /// <param name="svc"></param>
        /// <param name="line">Received line.</param>
        /// <returns>true if it was processed by current handler, otherwise it means ignoring.</returns>
        public override bool Positioned(ISvc svc, RawText line)
        {
            string _line;

            while ((_line = svc.ReadLine(this)) != null && _line.Trim() != "EndGlobalSection")
            {
                int pos = _line.IndexOf('='); // Guids: src = dest
                if (pos < 0)
                {
                    LSender.Send(this, $"Incorrect NestedProjects records: '{_line}'", Message.Level.Warn);
                    return(false);
                }

                string src  = _line.Substring(0, pos).Trim();
                string dest = _line.Substring(pos + 1).Trim();

                LSender.Send(this, $"NestedProjects '{src}' -> '{dest}'", Message.Level.Info);

                var parent = svc.Sln.SolutionFolderList.Where(f => f.header.pGuid == dest).First();

                svc.Sln.SolutionFolderList.Where(f => f.header.pGuid == src)
                .ForEach(f => f.header.parent.Value = parent);

                svc.Sln.ProjectItemList.Where(p => p.pGuid == src)
                .ForEach(p => p.parent.Value = parent);
            }

            return(true);
        }
Ejemplo n.º 14
0
        public Commit[] Blame(string path)
        {
            Leaf leaf = Tree [path] as Leaf;

            if (leaf == null)
            {
                throw new ArgumentException("The given path does not exist in this commit: " + path);
            }
            byte[] data      = leaf.RawData;
            int    lineCount = RawParseUtils.lineMap(data, 0, data.Length).size();

            Commit[] lines        = new Commit [lineCount];
            var      curText      = new RawText(data);
            Commit   prevAncestor = this;

            Leaf   prevLeaf   = null;
            Commit prevCommit = null;
            int    emptyLines = lineCount;

            foreach (Commit ancestor in Ancestors)
            {
                Leaf cleaf = ancestor.Tree [path] as Leaf;
                if (prevCommit != null && (cleaf == null || cleaf.Hash != prevLeaf.Hash))
                {
                    byte[] prevData = prevLeaf.RawData;
                    if (prevData == null)
                    {
                        break;
                    }
                    var prevText = new RawText(prevData);
                    var differ   = new MyersDiff(prevText, curText);
                    foreach (Edit e in differ.getEdits())
                    {
                        for (int n = e.BeginB; n < e.EndB; n++)
                        {
                            if (lines [n] == null)
                            {
                                lines [n] = prevCommit;
                                emptyLines--;
                            }
                        }
                    }
                    if (cleaf == null || emptyLines <= 0)
                    {
                        break;
                    }
                }
                prevCommit = ancestor;
                prevLeaf   = cleaf;
            }
            for (int n = 0; n < lines.Length; n++)
            {
                if (lines [n] == null)
                {
                    lines [n] = prevAncestor;
                }
            }
            return(lines);
        }
Ejemplo n.º 15
0
 private bool IsNoNewlineAtEndOfFile(RawText lastRawTextOrDefault)
 {
     if (lastRawTextOrDefault != null)
     {
         return(lastRawTextOrDefault.GetString(lastRawTextOrDefault.Size() - 1).Equals("\\ No newline at end of file"));
     }
     return(false);
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Formats the results of a merge of <see cref="RawText"/> objects in a Git
        /// conformant way. This method also assumes that the <see cref="RawText"/> objects
        /// being merged are line oriented files which use LF as delimiter. This
        /// method will also use LF to separate chunks and conflict metadata,
        /// therefore it fits only to texts that are LF-separated lines.
        /// </summary>
        /// <param name="out">the outputstream where to write the textual presentation</param>
        /// <param name="res">the merge result which should be presented</param>
        /// <param name="seqName">
        /// When a conflict is reported each conflicting range will get a
        /// name. This name is following the "&lt;&lt;&lt;&lt;&lt;&lt;&lt; " or "&gt;&gt;&gt;&gt;&gt;&gt;&gt; "
        /// conflict markers. The names for the sequences are given in
        /// this list
        /// </param>
        /// <param name="charsetName">
        /// the name of the characterSet used when writing conflict
        /// metadata
        /// </param>
        public void formatMerge(BinaryWriter @out, MergeResult res,
                                List <String> seqName, string charsetName)
        {
            String lastConflictingName = null; // is set to non-null whenever we are
            // in a conflict
            bool threeWayMerge = (res.getSequences().Count == 3);

            foreach (MergeChunk chunk in res)
            {
                RawText seq = (RawText)res.getSequences()[
                    chunk.getSequenceIndex()];
                if (lastConflictingName != null &&
                    chunk.getConflictState() != MergeChunk.ConflictState.NEXT_CONFLICTING_RANGE)
                {
                    // found the end of an conflict
                    @out.Write((">>>>>>> " + lastConflictingName + "\n").getBytes(charsetName));
                    lastConflictingName = null;
                }
                if (chunk.getConflictState() == MergeChunk.ConflictState.FIRST_CONFLICTING_RANGE)
                {
                    // found the start of an conflict
                    @out.Write(("<<<<<<< " + seqName[chunk.getSequenceIndex()] +
                                "\n").getBytes(charsetName));
                    lastConflictingName = seqName[chunk.getSequenceIndex()];
                }
                else if (chunk.getConflictState() == MergeChunk.ConflictState.NEXT_CONFLICTING_RANGE)
                {
                    // found another conflicting chunk

                    /*
                     * In case of a non-three-way merge I'll add the name of the
                     * conflicting chunk behind the equal signs. I also append the
                     * name of the last conflicting chunk after the ending
                     * greater-than signs. If somebody knows a better notation to
                     * present non-three-way merges - feel free to correct here.
                     */
                    lastConflictingName = seqName[chunk.getSequenceIndex()];
                    @out.Write((threeWayMerge ? "=======\n" : "======= "
                                + lastConflictingName + "\n").getBytes(charsetName));
                }
                // the lines with conflict-metadata are written. Now write the chunk
                for (int i = chunk.getBegin(); i < chunk.getEnd(); i++)
                {
                    if (i > 0)
                    {
                        @out.Write('\n');
                    }
                    seq.writeLine(@out.BaseStream, i);
                }
            }
            // one possible leftover: if the merge result ended with a conflict we
            // have to close the last conflict here
            if (lastConflictingName != null)
            {
                @out.Write('\n');
                @out.Write((">>>>>>> " + lastConflictingName + "\n").getBytes(charsetName));
            }
        }
Ejemplo n.º 17
0
        static IEnumerable <Hunk> GetDiffHunks(RawText curText, RawText ancestorText)
        {
            Dictionary <string, int> codeDictionary = new Dictionary <string, int> ();
            int codeCounter = 0;

            int[] ancestorDiffCodes = GetDiffCodes(ref codeCounter, codeDictionary, ancestorText);
            int[] currentDiffCodes  = GetDiffCodes(ref codeCounter, codeDictionary, curText);
            return(Diff.GetDiff <int> (ancestorDiffCodes, currentDiffCodes));
        }
Ejemplo n.º 18
0
        public void testWriteLine2()
        {
            var a = new RawText(Constants.encodeASCII("foo-a\nfoo-b"));
            var o = new MemoryStream();

            a.writeLine(o, 1);
            byte[] r = o.ToArray();
            Assert.AreEqual("foo-b", RawParseUtils.decode(r));
        }
Ejemplo n.º 19
0
        public void testWriteLine3()
        {
            var a = new RawText(Constants.encodeASCII("a\n\nb\n"));
            var o = new MemoryStream();

            a.writeLine(o, 1);
            byte[] r = o.ToArray();
            Assert.AreEqual(string.Empty, RawParseUtils.decode(r));
        }
Ejemplo n.º 20
0
        public override bool ToCommand(IDaoProvider provider, SqlCommandBuilder builder, ISqlParameters parameters)
        {
            string sqlName = provider.EscapeParam(ParamName);

            builder.AppendCommandText(RawText.Replace(ParamName, sqlName));
            builder.AddCommandParameter(sqlName, parameters.Resolve(ParamName));

            return(true);
        }
Ejemplo n.º 21
0
        /// <exception cref="System.IO.IOException"></exception>
        private void DecideMode()
        {
            isBinary = RawText.IsBinary(binbuf, binbufcnt);
            int cachedLen = binbufcnt;

            binbufcnt = binbuf.Length + 1;
            // full!
            Write(binbuf, 0, cachedLen);
        }
Ejemplo n.º 22
0
        public string DiffFile(string fileName, string commitId1, string commitId2)
        {
            try
            {
                if (!this.HasGitRepository)
                {
                    return("");
                }

                var tmpFileName = Path.ChangeExtension(Path.GetTempFileName(), ".diff");
                var fileNameRel = GetRelativeFileName(fileName);

                if (GitBash.Exists)
                {
                    GitBash.RunCmd(string.Format("diff {2} {3} -- \"{0}\" > \"{1}\"", fileNameRel, tmpFileName, commitId1, commitId2), this.GitWorkingDirectory);
                }
                else
                {
                    HistogramDiff hd = new HistogramDiff();
                    hd.SetFallbackAlgorithm(null);

                    RawText a = string.IsNullOrWhiteSpace(commitId1) ? new RawText(new byte[0]) :
                                new RawText(this.RepositoryGraph.GetFileContent(commitId1, fileNameRel) ?? new byte[0]);
                    RawText b = string.IsNullOrWhiteSpace(commitId2) ? new RawText(new byte[0]) :
                                new RawText(this.RepositoryGraph.GetFileContent(commitId2, fileNameRel) ?? new byte[0]);

                    var list = hd.Diff(RawTextComparator.DEFAULT, a, b);

                    using (Stream stream = new FileStream(tmpFileName, System.IO.FileMode.CreateNew))
                    {
                        DiffFormatter df = new DiffFormatter(stream);
                        df.Format(list, a, b);
                        df.Flush();
                    }

                    //using (Stream mstream = new MemoryStream(),
                    //      stream = new BufferedStream(mstream))
                    //{
                    //    DiffFormatter df = new DiffFormatter(stream);
                    //    df.Format(list, a, b);
                    //    df.Flush();
                    //    stream.Seek(0, SeekOrigin.Begin);
                    //    var ret = new StreamReader(stream).ReadToEnd();
                    //    ret = ret.Replace("\r", "").Replace("\n", "\r\n");
                    //    File.WriteAllText(tmpFileName, ret);
                    //}
                }

                return(tmpFileName);
            }
            catch (Exception ex)
            {
                Log.WriteLine("Refresh: {0}\r\n{1}", this.initFolder, ex.ToString());

                return("");
            }
        }
Ejemplo n.º 23
0
    public static RawText Parse(BinaryReader b, int stringLength)
    {
        var m = new RawText
        {
            Length = b.ReadByte(),
            Value  = b.ReadBytes(stringLength)
        };

        return(m);
    }
Ejemplo n.º 24
0
        /* Function: DecodePropertyValue
         * Extracts the property value from the passed XML value, stripping off the surrounding quotes and any escaped quotes
         * within.
         */
        private string DecodePropertyValue(int valueIndex, int valueLength)
        {
            string value = RawText.Substring(valueIndex + 1, valueLength - 2);

            value = value.Replace("\\\"", "\"");
            value = value.Replace("\\'", "'");
            value = HTMLEntityChars.DecodeAll(value);

            return(value);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// New position in stream.
        /// </summary>
        /// <param name="svc"></param>
        /// <param name="line">Received line.</param>
        /// <returns>true if it was processed by current handler, otherwise it means ignoring.</returns>
        public override bool Positioned(ISvc svc, RawText line)
        {
            var pItem = new ProjectItem(line.trimmed, svc.Sln.SolutionDir);

            if (pItem.pGuid == null ||
                !String.Equals(Guids.SLN_FOLDER, pItem.pType, StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }

            LSender.Send(this, $"Found solution-folder: '{pItem.name}'", Message.Level.Info);

            var folderItems = new List <RawText>();

            while ((line = svc.ReadLine(this)) != null && (line != "EndProject"))
            {
                if (!line.trimmed.StartsWith("ProjectSection(SolutionItems) = preProject", StringComparison.Ordinal))
                {
                    continue;
                }

                for (line = svc.ReadLine(this); line != null; line = svc.ReadLine(this))
                {
                    if (line.trimmed.StartsWith("EndProjectSection", StringComparison.Ordinal))
                    {
                        break;
                    }

                    var item = line.trimmed.Before('=');
                    if (item == null)
                    {
                        LSender.Send(
                            this,
                            $"Ignored incorrect item for '{pItem.name}':{pItem.pGuid} - '{line}'",
                            Message.Level.Warn
                            );
                        continue;
                    }

                    item = item.TrimEnd();
                    LSender.Send(this, $"Found item: '{item}'", Message.Level.Info);

                    folderItems.Add(new RawText(item, svc.CurrentEncoding));
                }
            }

            if (svc.Sln.SolutionFolderList == null)
            {
                svc.Sln.SolutionFolderList = new List <SolutionFolder>();
            }

            svc.Sln.SolutionFolderList.Add(new SolutionFolder(pItem, folderItems));
            return(true);
        }
 private void loadTemplateText()
 {
     try {
         if (RawText != string.Empty)
         {
             TemplateText = RawText.Substring(RawText.IndexOf("-->") + 3);
         }
     } catch (Exception e) {
         throw new Exception("Didn't find the end of the xml block.", e);
     }
 }
Ejemplo n.º 27
0
    public static List <SimpleEncounterData> Parse(string path)
    {
        var res = new List <SimpleEncounterData>();

        using (BinaryReader b = new BinaryReader(File.Open(path, FileMode.Open)))
        {
            while (b.BaseStream.Position != b.BaseStream.Length)
            {
                var m = new SimpleEncounterData();
                for (int i = 0; i < 4; ++i)
                {
                    var codes = new short[8];
                    for (int j = 0; j < 8; ++j)
                    {
                        codes[j] = Convert.ToInt16(b.ReadByte());
                    }
                    m.ChoiceCodes[i] = codes;
                }
                ;

                for (int i = 0; i < 4; ++i)
                {
                    var args = new short[8];
                    for (int j = 0; j < 8; ++j)
                    {
                        args[j] = b.ReadInt16().SwapBytes();
                    }
                    m.ChoiceArgs[i] = args;
                }

                for (int i = 0; i < 4; ++i)
                {
                    m.ChoiceResultIndex[i] = Convert.ToInt16(b.ReadByte());
                }

                m.CanBackout = b.ReadByte();
                m.MaxTimes   = b.ReadByte();
                m.Unknown    = b.ReadInt16().SwapBytes();
                m.Prompt     = b.ReadInt16().SwapBytes();

                for (int i = 0; i < 4; ++i)
                {
                    m.OptionTexts[i] = RawText.Parse(b, 79).ToString();
                }

                res.Add(m);
            }
        }



        return(res);
    }
Ejemplo n.º 28
0
 public void Delete(RawText rawText)
 {
     try
     {
         db.Entry(rawText).State = EntityState.Deleted;
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         Log.Error(ex.Message, ex);
     }
 }
        /// <summary>Construct a new BlameResult for a generator.</summary>
        /// <remarks>Construct a new BlameResult for a generator.</remarks>
        /// <param name="gen">the generator the result will consume records from.</param>
        /// <returns>
        /// the new result object. null if the generator cannot find the path
        /// it starts from.
        /// </returns>
        /// <exception cref="System.IO.IOException">the repository cannot be read.</exception>
        public static NGit.Blame.BlameResult Create(BlameGenerator gen)
        {
            string  path     = gen.GetResultPath();
            RawText contents = gen.GetResultContents();

            if (contents == null)
            {
                gen.Release();
                return(null);
            }
            return(new NGit.Blame.BlameResult(gen, path, contents));
        }
Ejemplo n.º 30
0
 public void Insert(RawText rawText)
 {
     try
     {
         db.RawTexts.Add(rawText);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         Log.Error(ex.Message, ex);
     }
 }
Ejemplo n.º 31
0
        // TODO: This method already exists in the Text class...
        private string GetLine(Encoding encoding, RawText text, int n)
        {
            if (n == text.LineStartIndices.size() - 1)
            {
                return(string.Empty);
            }

            int start = text.LineStartIndices.get(n + 1);
            int end   = n + 2 >= text.LineStartIndices.size() ? text.Content.Count() : text.LineStartIndices.get(n + 2);

            return(encoding.GetString(text.Content, start, end - start).TrimEnd());
        }
Ejemplo n.º 32
0
 internal Text(RawText raw_text, Encoding encoding)
 {
     m_raw_text = raw_text;
     Encoding = encoding;
 }