Exemplo n.º 1
0
        private int AddUnmarkedSegment(int segmentTextStart, int segmentTextEnd)
        {
            if (segmentTextEnd < segmentTextStart)
            {
                return(-1);
            }

            var originalSegmentText =
                OriginalText.Substring(
                    segmentTextStart,
                    segmentTextEnd - segmentTextStart + 1
                    );

            var segmentTextHash = originalSegmentText.GetHashSha256();

            MappingComposerSegment segment;

            if (_segmentsDictionary.TryGetValue(segmentTextHash, out segment) == false)
            {
                segment = new MappingComposerSegment(UniqueSegmentsCount, UniqueUnmarkedSegmentsCount, originalSegmentText);

                _segmentsDictionary.Add(segmentTextHash, segment);

                UniqueUnmarkedSegmentsCount++;
            }

            _segmentsList.Add(segment);

            return(segmentTextEnd + 1);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Validates this codable text (field is Mandatory)
        /// </summary>
        /// <param name="path">The path to this object as a string</param>
        /// <param name="messages">the validation messages to date, these may be added to within this method</param>
        public void ValidateMandatory(string path, List <ValidationMessage> messages)
        {
            var vb = new ValidationBuilder(path, messages);

            if (NullFlavour.HasValue)
            {
                vb.AddValidationMessage(vb.PathName + "NullFlavour", null, "NullFlavour can not be specified for this coadable text field");
                return;
            }

            if (QualifierCodes != null)
            {
                foreach (var qualifierCode in QualifierCodes)
                {
                    qualifierCode.Validate(path, messages);
                }
            }

            if (QualifierCodes != null && OriginalText.IsNullOrEmptyWhitespace())
            {
                vb.AddValidationMessage(vb.PathName + "QualifierCodes & OriginalText", null, "OriginalText must be provided with QualifierCodes");
            }

            Validate(path, messages);
        }
Exemplo n.º 3
0
 public override void Accept(IClientVisitor visitor)
 {
     foreach (var submessage in OriginalText.Split('\n'))
     {
         visitor.Visit(new PublicMessage(submessage));
     }
 }
Exemplo n.º 4
0
        // Обновление текущих едениц перевода
        private void UpdateTranslationUnits()
        {
            // Заполняем текущие еденицы перевода - проходим по языкам, которые заданы для перевода и для каждого запрашиваем у базы
            // список едениц перевода

            m_translationUnits = new Dictionary <string, List <TranslationUnit> >();
            foreach (var translationLanguage in m_workspace.TranslationLanguages)
            {
                List <TranslationUnit> translationLanguageUnits = new List <TranslationUnit>();
                m_translationUnits.Add(translationLanguage.Code, translationLanguageUnits);

                // Запрашиваем список едениц перевода у БД и засовываем его в подготовленный для этого список
                var rawTranslationLanguageUnits = m_repository.GetTranslationUnits(Name, translationLanguage.Code);
                foreach (var rawTranslationLanguageUnit in rawTranslationLanguageUnits)
                {
                    // Перерабатываем сырую еденицу перевода (данные из БД) в нормальную и засовываем ее в список

                    TranslationUnit translationUnit = new TranslationUnit(OriginalText.GetPhraseWords(rawTranslationLanguageUnit.originalPhraseIndexes));
                    translationUnit.translatedPhrase = rawTranslationLanguageUnit.translatedPhrase;
                    translationUnit.infinitiveTranslation.originalPhrase   = rawTranslationLanguageUnit.infinitiveOriginalPhrase;
                    translationUnit.infinitiveTranslation.translatedPhrase = rawTranslationLanguageUnit.infinitiveTranslatedPhrase;

                    translationLanguageUnits.Add(translationUnit);
                }
            }
        }
Exemplo n.º 5
0
        public IEnumerator GetInstanceCreator(ApiWorldInstance instance)
        {
            string creator = instance.ownerId;

            if (creator != null)
            {
                if (creator == APIUser.CurrentUser? .id)
                {
                    if (LocalPlayerEntry.emmNameSpoofEnabled)
                    {
                        textComponent.text = OriginalText.Replace("{instancecreator}", LocalPlayerEntry.emmSpoofedName);
                    }
                    else
                    {
                        textComponent.text = OriginalText.Replace("{instancecreator}", APIUser.CurrentUser.displayName);
                    }
                    yield break;
                }

                textComponent.text = OriginalText.Replace("{instancecreator}", "Loading...");

                yield return(new WaitForSeconds(4));

                APIUser.FetchUser(creator, new Action <APIUser>(OnIdReceived), null);
                yield break;
            }
            else
            {
                textComponent.text = OriginalText.Replace("{instancecreator}", "No Instance Creator");
            }
        }
Exemplo n.º 6
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = OriginalText.GetHashCode();
         hashCode = (hashCode * 397) ^ (Expression != null ? Expression.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (FilterExpressions != null ? FilterExpressions.GetHashCode() : 0);
         return(hashCode);
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// メタデータを含むテキストデータを解析
 /// </summary>
 /// <param name="text">解析するテキスト</param>
 protected virtual void Parse()
 {
     try
     {
         //テキストを先頭から1文字づつ解析
         int max   = OriginalText.Length;
         int index = 0;
         while (index < max)
         {
             if (ParseEscapeSequence(index))
             {
                 //エスケープシーケンスの処理
                 index += 2;
             }
             else
             {
                 string tagName  = "";
                 string tagArg   = "";
                 int    endIndex = ParserUtil.ParseTag(OriginalText, index,
                                                       (name, arg) =>
                 {
                     bool ret = ParseTag(name, arg);
                     if (ret)
                     {
                         tagName = name;
                         tagArg  = arg;
                     }
                     return(ret);
                 });
                 if (index == endIndex)
                 {
                     //タグがなかった
                     //通常パターンのテキストを1文字追加
                     AddChar(OriginalText[index]);
                     ++index;
                 }
                 else
                 {
                     //タグデータを挿入
                     string tagString = OriginalText.Substring(index, endIndex - index + 1);
                     PoolList.Insert(0, MakeTag(tagString, tagName, tagArg));
                     index = endIndex + 1;
                 }
             }
             ParsedDataList.AddRange(PoolList);
             PoolList.Clear();
         }
         PoolList.Clear();
     }
     catch (System.Exception e)
     {
         AddErrorMsg(e.Message + e.StackTrace);
     }
 }
Exemplo n.º 8
0
 public override void OnInstanceChange(ApiWorld world, ApiWorldInstance instance)
 {
     if (APIUser.CurrentUser != null && world.authorId == APIUser.CurrentUser.id && LocalPlayerEntry.emmNameSpoofEnabled)
     {
         textComponent.text = OriginalText.Replace("{worldauthor}", LocalPlayerEntry.emmSpoofedName);
     }
     else
     {
         textComponent.text = OriginalText.Replace("{worldauthor}", world.authorName);
     }
 }
Exemplo n.º 9
0
        protected override void ProcessText(object[] parameters = null)
        {
            string timeString = DateTime.Now.ToString(@"HH\:mm\:ss");

            if (lastTime == timeString)
            {
                return;
            }

            lastTime           = timeString;
            textComponent.text = OriginalText.Replace("{systemtime24hr}", timeString);
        }
Exemplo n.º 10
0
        protected override void ProcessText(object[] parameters = null)
        {
            TimeSpan time       = TimeSpan.FromSeconds(RoomManager.prop_Single_0);
            string   timeString = time.ToString(@"hh\:mm\:ss");

            if (lastTime == timeString)
            {
                return;
            }

            lastTime           = timeString;
            textComponent.text = OriginalText.Replace("{roomtime}", timeString);
        }
Exemplo n.º 11
0
        public CSharpFile(CSharpProject project, string fileName)
        {
            Project      = project;
            FileName     = fileName;
            OriginalText = File.ReadAllText(fileName, Encoding.Default);

            var p = new CSharpParser(project.CompilerSettings);

            SyntaxTree = p.Parse(OriginalText, fileName);

            UnresolvedTypeSystemForFile = SyntaxTree.ToTypeSystem();
            LinesOfCode = 1 + OriginalText.Count(c => c == '\n');
        }
Exemplo n.º 12
0
 public void OnPlayerJoined(VRC.Player player)
 {
     // This will handle getting the master on instance join
     if (player.prop_VRCPlayerApi_0 != null && player.prop_VRCPlayerApi_0.isMaster)
     {
         if (APIUser.CurrentUser != null && player.prop_APIUser_0.id == APIUser.CurrentUser.id && LocalPlayerEntry.emmNameSpoofEnabled)
         {
             textComponent.text = OriginalText.Replace("{instancemaster}", LocalPlayerEntry.emmSpoofedName);
         }
         else
         {
             textComponent.text = OriginalText.Replace("{instancemaster}", player.prop_APIUser_0.displayName);
         }
     }
 }
Exemplo n.º 13
0
        private int NextDelimitedSegmentText(string leftDel, string rightDel, int startAt, out string transSegmentText)
        {
            //Find the first occurance of a left delimiter starting from startAt
            var leftDelIndex =
                OriginalText.IndexOf(
                    leftDel,
                    startAt,
                    StringComparison.Ordinal
                    );

            while (true)
            {
                //No left delimiter is found. end search for segment placeholder
                if (leftDelIndex < 0)
                {
                    transSegmentText = null;
                    return(-1);
                }

                //Find first occurance of a right delimiter starting after the left delimiter that was found
                var rightDelIndex =
                    OriginalText.IndexOf(
                        rightDel,
                        leftDelIndex + leftDel.Length,
                        StringComparison.Ordinal
                        );

                //A right delimiter is not found. End search for segment placeholder
                if (rightDelIndex <= leftDelIndex)
                {
                    transSegmentText = null;
                    return(-1);
                }

                //A right delimiter is found
                var startIndex = leftDelIndex + leftDel.Length;
                var endIndex   = rightDelIndex - 1;
                var length     = endIndex - startIndex + 1;

                //Read the text between the left and right delimiters
                var segmentText = OriginalText.Substring(startIndex, length);

                transSegmentText = segmentText;

                return(leftDelIndex);
            }
        }
Exemplo n.º 14
0
        private IEnumerator GetOnMasterChanged(Player player)
        {
            while (player.field_Public_Player_0 == null)
            {
                yield return(null);
            }

            if (APIUser.CurrentUser != null && player.field_Public_Player_0.prop_APIUser_0.id == APIUser.CurrentUser.id && LocalPlayerEntry.emmNameSpoofEnabled)
            {
                textComponent.text = OriginalText.Replace("{instancemaster}", LocalPlayerEntry.emmSpoofedName);
            }
            else
            {
                textComponent.text = OriginalText.Replace("{instancemaster}", player.field_Public_Player_0.prop_APIUser_0.displayName);
            }
            yield break;
        }
Exemplo n.º 15
0
        public override void Init(object[] parameters = null)
        {
            Il2CppArrayBase <MonoBehaviour> components = GameObject.Find("_Application/ApplicationSetup").GetComponents <MonoBehaviour>();

            foreach (MonoBehaviour component in components)
            {
                if (component.TryCast <Transform>() != null || component.TryCast <ApiCache>() != null)
                {
                    continue;
                }

                foreach (FieldInfo field in component.GetIl2CppType().GetFields())
                {
                    if (field.FieldType == UnhollowerRuntimeLib.Il2CppType.Of <int>())
                    {
                        textComponent.text = OriginalText.Replace("{gameversion}", field.GetValue(component).Unbox <int>().ToString());
                        return;
                    }
                }
            }
        }
Exemplo n.º 16
0
 public CorrectionCandidate(TextElement textElement, Hunspell hunspell, ref Dictionary <string, string> autoReplacementList)
 {
     this.parameter           = null;
     this.textElement         = textElement;
     this.hunspell            = hunspell;
     this.autoReplacementList = autoReplacementList;
     OriginalText             = textElement.Text;
     char[] delimiterChars = { ' ', ',', '.', ':', '\t', '\\', '/', '(', ')', '<', '>', '\r' };
     if (!string.IsNullOrEmpty(OriginalText))
     {
         originalWords = OriginalText.Split(delimiterChars);
         NewText       = OriginalText;
     }
     else
     {
         originalWords = null;
         NewText       = OriginalText;
     }
     currentIndex = -1;
     rgx          = new Regex(@"^.*[\d]+.*$");
 }
Exemplo n.º 17
0
        /// <summary>
        /// Validates this codable text
        /// </summary>
        /// <param name="path">The path to this object as a string</param>
        /// <param name="messages">the validation messages to date, these may be added to within this method</param>
        public void Validate(string path, List <ValidationMessage> messages)
        {
            var vb = new ValidationBuilder(path, messages);

            if (!HasCodeSystem && !Code.IsNullOrEmptyWhitespace())
            {
                vb.AddValidationMessage(vb.PathName, null, "Code can only be provided if a CodeSystem is specified");
            }

            if (!HasCodeSystem && !DisplayName.IsNullOrEmptyWhitespace())
            {
                vb.AddValidationMessage(vb.PathName, null, "DisplayName can only be provided if a CodeSystem is specified");
            }

            if (DisplayName.IsNullOrEmptyWhitespace() && OriginalText.IsNullOrEmptyWhitespace() && NullFlavour == null)
            {
                vb.AddValidationMessage(vb.PathName, null, "Either OriginalText or DisplayName or a NullFlavour must be provided");
            }

            if (Translations != null)
            {
                foreach (var translation in Translations)
                {
                    translation.Validate(path, messages);
                }
            }

            if (QualifierCodes != null)
            {
                foreach (var qualifierCode in QualifierCodes)
                {
                    qualifierCode.Validate(path, messages);
                }
            }

            if (QualifierCodes != null && OriginalText.IsNullOrEmptyWhitespace())
            {
                vb.AddValidationMessage(vb.PathName + "QualifierCodes & OriginalText", null, "OriginalText must be provided with QualifierCodes");
            }
        }
Exemplo n.º 18
0
        public int Execute()
        {
            try
            {
                string subText = "";

                subText = OriginalText.Substring(StartIndex, Length);

                if (VariableStorage.SubTextVar.ContainsKey(SubTextStorVar))
                {
                    VariableStorage.SubTextVar.Remove(SubTextStorVar);
                }
                VariableStorage.SubTextVar.Add(SubTextStorVar, Tuple.Create(this.ID, subText));


                return(1);
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
Exemplo n.º 19
0
        public static void InjectLogs(string preLogText, string postLogText)
        {
            OriginalText = Clipboard.GetText();

            var lines = OriginalText.Split('\n');

            var sb = new StringBuilder();

            for (int i = 0; i < lines.Length; i++)
            {
                if (lines[i].ShouldSkip())
                {
                    continue;
                }

                sb.Append($"{preLogText}{i}: {lines[i].Trim()}{postLogText}");
                sb.Append(Environment.NewLine);
                sb.Append(lines[i]);
            }

            Clipboard.SetText(sb.ToString());
        }
Exemplo n.º 20
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="contents"></param>
        /// <param name="delim"></param>
        /// <param name="correctColCount"></param>
        /// <param name="position"></param>
        /// <param name="disallowedChars">A list of disallowed characters to remove in addition to
        /// those specified by the field. This is for support of globally disallowed characters.</param>
        public Row(string contents, string[] delim, int correctColCount, int position, char[] disallowedChars)
        {
            Position = position;

            //immediately get rid of any characters that are never ever legal
            OriginalText = PreSanitize(contents, disallowedChars);
            var stringVals = OriginalText.Split(delim, StringSplitOptions.None);

            HasCorrectColCount = correctColCount == stringVals.Count();

            //if this is a single row, save the values and scoot
            if (stringVals.Count() <= correctColCount)
            {
                Values = GetValues(stringVals, correctColCount);
                return;
            }

            //but wait! what if it's just two or more rows joined together? In that case it would be twice the number of values except
            //that two values would be smushed together. Luckily we can undo that.
            int tmp = stringVals.Count() - correctColCount;

            if (tmp % (correctColCount - 1) == 0)
            {
                var allRows = SeparateCombinedRows(stringVals, correctColCount, delim);
                ExtraRows.AddRange(allRows.Skip(1).Select(r => new Row(string.Join(delim[0], r), delim, correctColCount, Position, disallowedChars)));

                //set the parameters of this row
                OriginalText       = string.Join(delim[0], allRows[0]);
                HasCorrectColCount = true;
                Values             = GetValues(allRows[0], correctColCount);
            }
            else
            {
                Values = GetValues(stringVals, correctColCount);
            }
        }
Exemplo n.º 21
0
 /// <summary>
 /// Returns true if another TextReplacement is equal to this one (same new and original text and location), false otherwise.
 /// </summary>
 /// <param name="other">The other TextReplacement to compare.</param>
 /// <returns>True of the other TextReplacement is equal to this one, false otherwise.</returns>
 public bool Equals(TextReplacement?other) =>
 other != null &&
 NewText.ContentEquals(other.NewText) &&
 OriginalText.Equals(other.OriginalText);
        /// <summary>
        /// Update or create original text translation in DB
        /// </summary>
        /// <param name="originalText">Contains information about translation</param>
        /// <param name="language">Language for translation</param>
        /// <param name="translationText">Translation text</param>
        private void AddUpdateOriginalTextTranslation(OriginalText originalText, SupportedLanguage language, string translationText)
        {
            var originalTextTranslation = originalText.OriginalTextTranslations.FirstOrDefault(ott => ott.Language == language);

            if (!string.IsNullOrEmpty(translationText))
            {
                if (originalTextTranslation != null)
                {
                    originalTextTranslation.Translation = translationText;
                }
                else
                {
                    originalText.OriginalTextTranslations.Add(
                        new OriginalTextTranslation { Translation = translationText, Language = language });
                }
            }
            else
            {
                if (originalTextTranslation != null)
                {
                    this.DbContext.Delete(originalTextTranslation);
                }
            }
        }
 /// <summary>
 /// Returns true if another TextReplacement is equal to this one (same new and original text and location), false otherwise.
 /// </summary>
 /// <param name="other">The other TextReplacement to compare.</param>
 /// <returns>True of the other TextReplacement is equal to this one, false otherwise.</returns>
 public bool Equals(MappedTextReplacement?other) =>
 other != null &&
 FilePath.Equals(other.FilePath, StringComparison.OrdinalIgnoreCase) &&
 StartingLine == other.StartingLine &&
 NewText.Equals(other.NewText, StringComparison.Ordinal) &&
 OriginalText.Equals(other.OriginalText, StringComparison.Ordinal);
Exemplo n.º 24
0
 public override int GetHashCode()
 {
     return(OriginalText != null ? OriginalText.GetHashCode() : 0);
 }
Exemplo n.º 25
0
 private void OnPlayerCountChanged(Player player)
 {
     textComponent.text = OriginalText.Replace("{playercount}", PlayerManager.field_Private_Static_PlayerManager_0.field_Private_List_1_Player_0.Count.ToString());
 }
Exemplo n.º 26
0
 public void OnEmmWorldCheckCompleted(bool areRiskyFuncsAllowed)
 {
     textComponent.text = OriginalText.Replace("{riskyfuncallowed}", areRiskyFuncsAllowed.ToString());
 }
Exemplo n.º 27
0
 public override string ToString() => $"{OriginalText.Trim()}: ({SourceNodeName}) → ({TargetNodeName})";
Exemplo n.º 28
0
        private int NextIdentifiedSegmentText(string leftDel, int startAt, out string transSegmentText)
        {
            //Find the first occurance of a left delimiter starting from startAt
            var leftDelIndex =
                OriginalText.IndexOf(
                    leftDel,
                    startAt,
                    StringComparison.Ordinal
                    );

            while (true)
            {
                //No left delimiter is found. end search for segment placeholder
                if (leftDelIndex < 0)
                {
                    transSegmentText = null;
                    return(-1);
                }

                //Search for a legal identifier name
                var lastIdntIndex = leftDelIndex + 1;

                while (lastIdntIndex < OriginalText.Length)
                {
                    var c = OriginalText[lastIdntIndex];

                    if (c == '_' || char.IsLetterOrDigit(c))
                    {
                        lastIdntIndex++;
                    }
                    else
                    {
                        break;
                    }
                }

                //A legal identifier name is not found. Continue search for a following left delimiter
                if (lastIdntIndex == leftDelIndex + 1)
                {
                    leftDelIndex =
                        OriginalText.IndexOf(
                            leftDel,
                            leftDelIndex + 1,
                            StringComparison.Ordinal
                            );

                    continue;
                }

                //A right delimiter is found
                var startIndex = leftDelIndex + leftDel.Length;
                var endIndex   = lastIdntIndex - 1;
                var length     = endIndex - startIndex + 1;

                //Read the identifier name
                var segmentText = OriginalText.Substring(startIndex, length);

                transSegmentText = segmentText;

                return(leftDelIndex);
            }
        }
Exemplo n.º 29
0
 public void OnIdReceived(APIUser user)
 {
     textComponent.text = OriginalText.Replace("{instancecreator}", user.displayName);
 }
Exemplo n.º 30
0
 public static string OriginalText1SafeString(this OriginalText original)
 {
     return(original == null ? string.Empty : original.OriginalText1);
 }
Exemplo n.º 31
0
 public override string GetValue()
 {
     return(OriginalText.Substring(Start, Length));
 }