public virtual void TestGetRMDelegationTokenService() { string defaultRMAddress = YarnConfiguration.DefaultRmAddress; YarnConfiguration conf = new YarnConfiguration(); // HA is not enabled Text tokenService = ClientRMProxy.GetRMDelegationTokenService(conf); string[] services = tokenService.ToString().Split(","); NUnit.Framework.Assert.AreEqual(1, services.Length); foreach (string service in services) { NUnit.Framework.Assert.IsTrue("Incorrect token service name", service.Contains(defaultRMAddress )); } // HA is enabled conf.SetBoolean(YarnConfiguration.RmHaEnabled, true); conf.Set(YarnConfiguration.RmHaIds, "rm1,rm2"); conf.Set(HAUtil.AddSuffix(YarnConfiguration.RmHostname, "rm1"), "0.0.0.0"); conf.Set(HAUtil.AddSuffix(YarnConfiguration.RmHostname, "rm2"), "0.0.0.0"); tokenService = ClientRMProxy.GetRMDelegationTokenService(conf); services = tokenService.ToString().Split(","); NUnit.Framework.Assert.AreEqual(2, services.Length); foreach (string service_1 in services) { NUnit.Framework.Assert.IsTrue("Incorrect token service name", service_1.Contains( defaultRMAddress)); } }
/// <summary> /// The callback for when a player is trying to connect to this server from /// the NAT server /// </summary> /// <param name="player">The NAT server player</param> /// <param name="frame">The data that the NAT server has sent for consumption</param> private void PlayerConnectRequestReceived(NetworkingPlayer player, Text frame, NetWorker sender) { Logging.BMSLog.Log("PLAYER CONNECTION REQUEST"); Logging.BMSLog.Log(frame.ToString()); try { // This is a Text frame with JSON so parse it all var json = JSON.Parse(frame.ToString()); // If this is a route from the NAT then read it if (json["nat"] != null) { Logging.BMSLog.Log("DOING NAT"); // These fields are required for this server to punch a hole for a client if (json["nat"]["host"] != null && json["nat"]["port"] != null) { string host = json["nat"]["host"]; ushort port = json["nat"]["port"].AsUShort; //Logging.BMSLog.Log($"HOST IS {host} AND PORT IS {port}"); // Fire the event that a client is trying to connect if (clientConnectAttempt != null) { clientConnectAttempt(host, port); } } } } catch { /* Ignore message */ } }
string CalculateDisplayTarget(double value, double var) { value = value / multiplierValue; Debug.Log(value); Debug.Log(multiplierValue); if (multiplierValue == 100) { return((value / 10).ToString() + "k"); } if (multiplierValue == 1000) { return(value.ToString() + "k"); } else if (multiplierValue == 10000) { return(value.ToString() + "0k"); } else if (multiplierValue == 100000) { return((value / 10).ToString() + "M"); } else if (multiplierValue == 1000000) { return(value.ToString() + "M"); } else { value = value * multiplierValue; } return(value.ToString()); }
private void MessageReceived(NetworkingPlayer player, Text frame, NetWorker sender) { Log(">MessageReceived: " + frame.ToString()); try { JSONNode data = JSONNode.Parse(frame.ToString()); if (data["register"] != null) { Register(player, data["register"]); } else if (data["update"] != null) { Update(player, data["update"]); } else if (data["get"] != null) { Get(player, data["get"]); } else if (data["alive"] != null) { HostIsStillAlive(player, data["alive"]); } } catch { // Ignore the message and disocnnect the requester Log(">Ignoring message and disconnecting..."); server.Disconnect(player, true); } }
/// <summary> /// First the match case option is checked, then the term translations and their /// source term positions are retrieved with FindMatches. Finally the term /// translations are inserted with InjectMatches /// </summary> /// <param name="text"></param> public void VisitText(Text text) { bool matchCase = _options.MatchCase == "true" ? true : false; bool useBoundaryChars = _options.UseBoundaryCharacters == "true" ? true : false; //List containing all four types of matches: normal and regex matches plus normal and regex replace matches List <PositionAndTranslation> allMatches = new List <PositionAndTranslation>(); //Add normal and regex matches allMatches.AddRange(_trieProcessor.FindMatches(this._trie, text.ToString(), _options.TokenBoundaryCharacters, matchCase, useBoundaryChars)); allMatches.AddRange(_trieProcessor.FindRegexMatches(this._regexTrie, text.ToString(), _options.TokenBoundaryCharacters, useBoundaryChars)); //Add the results of the secondary regex tries to the match list //The match discardal in the case of secondary regex trie matches using groups should be implemented here, possibly with a switch allMatches.AddRange(_trieProcessor.FindRegexMatches( this.SndRegexTrie, text.ToString(), _options.TokenBoundaryCharacters, useBoundaryChars)); allMatches.AddRange(_trieProcessor.FindMatches( this.SndTrie, text.ToString(), _options.TokenBoundaryCharacters, matchCase, useBoundaryChars)); //If there are matches, remove the overlaps and inject them if (allMatches.Count > 0) { this._positionAndTranslationOfTerms = _trieProcessor.RemoveOverLaps(allMatches); this._segment.Add(_trieProcessor.InjectMatches(text.ToString(), _positionAndTranslationOfTerms)); this._originalSegmentChanged = true; } else { _segment.Add(text); } }
/// <summary>Cancel a token by removing it from cache.</summary> /// <returns>Identifier of the canceled token</returns> /// <exception cref="Org.Apache.Hadoop.Security.Token.SecretManager.InvalidToken">for invalid token /// </exception> /// <exception cref="Org.Apache.Hadoop.Security.AccessControlException">if the user isn't allowed to cancel /// </exception> /// <exception cref="System.IO.IOException"/> public virtual TokenIdent CancelToken(Org.Apache.Hadoop.Security.Token.Token <TokenIdent > token, string canceller) { lock (this) { ByteArrayInputStream buf = new ByteArrayInputStream(token.GetIdentifier()); DataInputStream @in = new DataInputStream(buf); TokenIdent id = CreateIdentifier(); id.ReadFields(@in); Log.Info("Token cancelation requested for identifier: " + id); if (id.GetUser() == null) { throw new SecretManager.InvalidToken("Token with no owner"); } string owner = id.GetUser().GetUserName(); Text renewer = id.GetRenewer(); HadoopKerberosName cancelerKrbName = new HadoopKerberosName(canceller); string cancelerShortName = cancelerKrbName.GetShortName(); if (!canceller.Equals(owner) && (renewer == null || renewer.ToString().IsEmpty() || !cancelerShortName.Equals(renewer.ToString()))) { throw new AccessControlException(canceller + " is not authorized to cancel the token" ); } AbstractDelegationTokenSecretManager.DelegationTokenInformation info = Collections.Remove (currentTokens, id); if (info == null) { throw new SecretManager.InvalidToken("Token not found"); } RemoveStoredToken(id); return(id); } }
public string GetText() { string s = text.ToString(); if (s.EndsWith("_")) { s = s.Remove(s.Length - 1); } return(s); }
/// <summary> /// First the match case option is checked, then the term translations and their /// source term positions are retrieved with FindMatches. /// </summary> /// <param name="text"></param> //This used to be broken (only the last element would be taken into account), I fixed it 15.11.2011 public void VisitText(Text text) { bool matchCase = _options.MatchCase == "true" ? true : false; bool useBoundaryChars = _options.UseBoundaryCharacters == "true" ? true : false; List <PositionAndTranslation> allMatches = new List <PositionAndTranslation>(); allMatches.AddRange(_trieProcessor.FindMatches(_trie, text.ToString(), _options.TokenBoundaryCharacters, matchCase, useBoundaryChars)); allMatches.AddRange(_trieProcessor.FindRegexMatches(_regexTrie, text.ToString(), _options.TokenBoundaryCharacters, useBoundaryChars)); _TermList.AddRange(_trieProcessor.RemoveOverLaps(allMatches)); }
public virtual void TestUTF8() { LineReader @in = MakeStream("abcd\u20acbdcd\u20ac"); Text line = new Text(); @in.ReadLine(line); NUnit.Framework.Assert.AreEqual("readLine changed utf8 characters", "abcd\u20acbdcd\u20ac" , line.ToString()); @in = MakeStream("abc\u200axyz"); @in.ReadLine(line); NUnit.Framework.Assert.AreEqual("split on fake newline", "abc\u200axyz", line.ToString ()); }
public void SendButton() { if (IsConnected && (dataToSend.ToString() != "" || dataToSend.ToString() != null)) { print(dataToSend.text); BluetoothService.WritetoBluetooth(dataToSend.text.ToString()); dataToShown.text = dataToSend.text; } else { BluetoothService.WritetoBluetooth("@O"); dataToShown.text = "@O"; } }
/// <exception cref="System.IO.IOException"/> public virtual void TestClose() { Configuration conf = new Configuration(); LocalFileSystem fs = FileSystem.GetLocal(conf); // create a sequence file 1 Path path1 = new Path(Runtime.GetProperty("test.build.data", ".") + "/test1.seq"); SequenceFile.Writer writer = SequenceFile.CreateWriter(fs, conf, path1, typeof(Text ), typeof(NullWritable), SequenceFile.CompressionType.Block); writer.Append(new Text("file1-1"), NullWritable.Get()); writer.Append(new Text("file1-2"), NullWritable.Get()); writer.Close(); Path path2 = new Path(Runtime.GetProperty("test.build.data", ".") + "/test2.seq"); writer = SequenceFile.CreateWriter(fs, conf, path2, typeof(Text), typeof(NullWritable ), SequenceFile.CompressionType.Block); writer.Append(new Text("file2-1"), NullWritable.Get()); writer.Append(new Text("file2-2"), NullWritable.Get()); writer.Close(); // Create a reader which uses 4 BuiltInZLibInflater instances SequenceFile.Reader reader = new SequenceFile.Reader(fs, path1, conf); // Returns the 4 BuiltInZLibInflater instances to the CodecPool reader.Close(); // The second close _could_ erroneously returns the same // 4 BuiltInZLibInflater instances to the CodecPool again reader.Close(); // The first reader gets 4 BuiltInZLibInflater instances from the CodecPool SequenceFile.Reader reader1 = new SequenceFile.Reader(fs, path1, conf); // read first value from reader1 Text text = new Text(); reader1.Next(text); Assert.Equal("file1-1", text.ToString()); // The second reader _could_ get the same 4 BuiltInZLibInflater // instances from the CodePool as reader1 SequenceFile.Reader reader2 = new SequenceFile.Reader(fs, path2, conf); // read first value from reader2 reader2.Next(text); Assert.Equal("file2-1", text.ToString()); // read second value from reader1 reader1.Next(text); Assert.Equal("file1-2", text.ToString()); // read second value from reader2 (this throws an exception) reader2.Next(text); Assert.Equal("file2-2", text.ToString()); NUnit.Framework.Assert.IsFalse(reader1.Next(text)); NUnit.Framework.Assert.IsFalse(reader2.Next(text)); }
void OnTriggerEnter2D(Collider2D collision) { Debug.Log("COLL"); if (collision.gameObject.tag == "Finish") { int score = Int32.Parse(this.score.text); score++; this.score.text = score++.ToString(); tutorial = false; } else if (collision.gameObject.tag == "Enemy") { int score = Int32.Parse(this.score.text); score -= 2; this.score.text = score.ToString(); } moving = false; RigidBody2D.velocity = new Vector2(0.0F, 0.0F); player.transform.position = new Vector3(0.0F, PositionY, 0.0F); if (PlayerPrefs.GetInt("Highscore") < Int32.Parse(this.score.text)) { PlayerPrefs.SetInt("Highscore", Int32.Parse(this.score.text)); } if (Int32.Parse(score.text) < 0) { score.text = "0"; } }
// Use this for initialization void Start() { resultsc = ScoreManager.getScore(); highscore = PlayerPrefs.GetInt(key, 0); sc_text.text = "Score "; highSc_text.text = highSc_text.ToString(); }
public static void Postfix(MechComponent __instance, ref Text __result) { try { if (!__instance.IsFunctional || __instance.GetType() != typeof(Weapon)) { return; } Weapon weapon = (Weapon)__instance; if (IsJammed(weapon)) { string originalUIName = __result.ToString(); Color color = LazySingletonBehavior <UIManager> .Instance.UIColorRefs.orangeHalf; __result = new Localize.Text($"<color=#{ColorUtility.ToHtmlStringRGBA(color)}>{originalUIName}</color>", new object[] { }); //string weaponCaliber = new String(originalUIName.Where(Char.IsDigit).ToArray()); //__result = new Localize.Text($"JAMMED <size=75%>(UAC/{weaponCaliber})</size>", new object[] { }); //__result.Append(" <size=75%>( JAMMED )</size>", new object[0]); //__result = new Localize.Text("UAC JAMMED", new object[] { }); } } catch (Exception e) { Logger.Error(e); } }
public static void MultiPurchasePopup_Refresh_Postfix(SG_Stores_MultiPurchasePopup __instance, int ___costPerUnit, int ___quantityBeingSold, LocalizableText ___TitleText, LocalizableText ___DescriptionText, string ___itemName, HBSDOTweenButton ___ConfirmButton) { Mod.Log.Debug("SG_S_MPP:R entered."); int value = ___costPerUnit * ___quantityBeingSold; Mod.Log.Debug($"SG_S_MPP:R value:{value} = costPerUnit:{___costPerUnit} x quantityBeingSold:{___quantityBeingSold}."); string actionS = "??"; if (State.StoreIsBuying) { actionS = "BUY"; } else if (State.StoreIsSelling) { actionS = "SELL"; } Text titleT = new Text($"{actionS}: {___itemName}"); ___TitleText.SetText(titleT.ToString(), new object[] { }); Text descT = new Text($"{actionS} FOR <color=#F79B26>{SimGameState.GetCBillString(value)}</color>"); ___DescriptionText.SetText(descT.ToString(), new object[] { }); ___ConfirmButton.SetText(actionS); }
void Update() { Debug.Log("시간" + clearText); if (clearText.ToString() == "6시 1분") { spriteRenderer.sprite = Resources.Load <Sprite> ("Background/6pm") as Sprite; } else if (clearText.ToString() == "7시 1분") { spriteRenderer.sprite = Resources.Load <Sprite> ("Background/7pm") as Sprite; } else if (clearText.ToString() == "8시 1분") { spriteRenderer.sprite = Resources.Load <Sprite> ("Background/8pm") as Sprite; } }
public static void Postfix(TooltipPrefab_Chassis __instance, object data, TextMeshProUGUI ___descriptionText) { Mod.Log.Debug($"TP_C:SD - Init"); if (data != null && ___descriptionText != null) { ChassisDef chassisDef = (ChassisDef)data; double storageTons = Helper.CalculateChassisTonnage(chassisDef); // Calculate total tonnage costs SimGameState sgs = UnityGameInstance.BattleTechGame.Simulation; double totalTonnage = Helper.CalculateTonnageForAllMechParts(sgs); int storageCost = 0; if (totalTonnage > 0) { int totalCost = Helper.CalculateTotalForMechPartsCargo(sgs, totalTonnage); double tonnageFraction = storageTons / totalTonnage; storageCost = (int)Math.Ceiling(totalCost * tonnageFraction); } else { double factoredTonnage = Math.Ceiling(storageTons * Mod.Config.PartsFactor); double scaledTonnage = Math.Pow(factoredTonnage, Mod.Config.PartsExponent); storageCost = (int)(Mod.Config.PartsCostPerTon * scaledTonnage); } Text newDetails = new Text(chassisDef.Description.Details + $"\n\n<color=#FF0000>Cargo Cost:{SimGameState.GetCBillString(storageCost)} from {storageTons} tons</color>"); Mod.Log.Debug($" Setting details: {newDetails}u"); ___descriptionText.SetText(newDetails.ToString()); } else { Mod.Log.Debug($"TP_C:SD - Skipping"); } }
/// <summary> /// Initializes a new instance of <see cref="MdHeading"/> /// </summary> /// <param name="text">The text of the heading. Must not be null.</param> /// <param name="level">The heading's level. Value must be in the range [1,6]</param> public MdHeading(MdSpan text, int level) { if (level < 1 || level > 6) { throw new ArgumentOutOfRangeException(nameof(level), "Value must be in the range [1,6]"); } if (text == null) { throw new ArgumentNullException(nameof(text)); } if (text is MdSingleLineSpan singleLineSpan) { Text = singleLineSpan; } else { Text = new MdSingleLineSpan(text); } Level = level; AutoGeneratedId = HtmlUtilities.ToUrlSlug(Text.ToString()); Anchor = AutoGeneratedId; }
private void OnTextChanged(object sender, TextChangedEventArgs e) { if (View?.SelectedItem != null) { View.SelectedItem.Caption = Text.ToString(); } }
void TimeField_Changed(object sender, ustring e) { if (!DateTime.TryParseExact(Text.ToString(), Format, CultureInfo.CurrentCulture, DateTimeStyles.None, out DateTime result)) { Text = e; } }
public void UnicodeText() { var empty = default(Text); var nihao = new Text("\u4f60\u597d"); AssertEqual( new byte[] { 0x75, 0x30, 0x3a }, // "u0:" _codec.Encode(empty) ); AssertEqual( new byte[] { 0x75, 0x36, 0x3a, 0xe4, 0xbd, 0xa0, 0xe5, 0xa5, 0xbd, // "u6:\xe4\xbd\xa0\xe5\xa5\xbd" }, _codec.Encode(nihao) // "你好" ); var complex = new Text("new lines and\n\"quotes\" become escaped to \\"); Assert.Equal("\"\"", empty.Inspection); Assert.Equal("\"\u4f60\u597d\"", nihao.Inspection); Assert.Equal( "\"new lines and\\n\\\"quotes\\\" become escaped to \\\\\"", complex.Inspection ); Assert.Equal("Bencodex.Types.Text \"\"", empty.ToString()); Assert.Equal("Bencodex.Types.Text \"\u4f60\u597d\"", nihao.ToString()); }
void UpKey(bool controlDown) { if (controlDown) { int pos = caret == -1 ? Text.Length : caret; if (pos < MaxCharsPerLine) { return; } caret = pos - MaxCharsPerLine; UpdateCaret(); return; } if (typingLogPos == game.Chat.InputLog.Count) { originalText = Text.ToString(); } if (game.Chat.InputLog.Count > 0) { typingLogPos--; if (typingLogPos < 0) { typingLogPos = 0; } Text.Clear(); Text.Append(0, game.Chat.InputLog[typingLogPos]); caret = -1; Recreate(); } }
public void OnClick() { // Set the info // username PlayerPrefs.SetString(Keys.instance.usernameStored, usernameEntry.ToString()); // password PlayerPrefs.SetString(Keys.instance.passwordStored, passwordEntry.ToString()); // Name PlayerPrefs.SetString(Keys.instance.nameStored, nameEntry.ToString()); // Parse for age int.TryParse(ageEntry.text, out ageNumber); PlayerPrefs.SetInt(Keys.instance.ageStored, ageNumber); //Parse for grade int.TryParse(gradeEntry.text, out gradeNumber); PlayerPrefs.SetInt(Keys.instance.playerGrade, gradeNumber); Debug.Log("Account Creation successful! Username: "******" Password: "******" Age: " + PlayerPrefs.GetInt(Keys.instance.ageStored) + " Name: " + PlayerPrefs.GetString(Keys.instance.nameStored) + " Grade: " + PlayerPrefs.GetInt(Keys.instance.playerGrade) + " Gender: " + PlayerPrefs.GetInt(Keys.instance.isMale)); /*Debug.Log(nameEntry.text + " = " + nameEntry); * Debug.Log(usernameEntry.text + " = " + usernameEntry); * Debug.Log(passwordEntry.text + " = " + passwordEntry); * Debug.Log(ageEntry.text + " = " + ageEntry); * Debug.Log(gradeEntry.text + " = " + gradeEntry); * Debug.Log("Gender is" + genderEntry);*/ }
public string ComposeNewStrRow(params string[] text) { Text.Append(Environment.NewLine); Text.Append(text[0]); Text.Append(text[1]); return(Text.ToString()); }
public void ShowRankUI(int socre, int highsocre, int numbersGame) { RanUI.SetActive(true); R_score.text = score.ToString(); R_highscore.text = highscore.ToString(); R_numbersscore.text = numbersGame.ToString(); }
public override TokenState Accept(char input, int position) { if (innerExtensions == 0) { if (input == ',') { Context.Token.Attributes.LastOrDefault().Value = Text.ToString(); return(Move <TokenAttributeNameState>()); } } if (input == '}') { if (innerExtensions == 0) { Context.LastIndex = position; Context.Token.Attributes.LastOrDefault().Value = Text.ToString(); return(Move <TokenDoneState>()); } else { innerExtensions--; } } if (input == '{') { innerExtensions++; } Text.Append(input); return(this); }
public DbCommand CreateCommand(DbConnection conn) { #if NETCOREAPP2_1 using (CodeTrackFactory.Track("CreateCommand", CodeTrackLevel.Function, null, "EFCore")) { #endif DbCommand cmd = conn.CreateCommand(); cmd.CommandText = Text.ToString(); cmd.CommandType = CommandType; DbCommand = cmd; for (int i = 0; i < Parameters.Count; i++) { Parameter p = Parameters[i]; var cmdp = cmd.CreateParameter(); cmdp.ParameterName = p.Name; cmdp.Value = p.Value; cmdp.Direction = p.Direction; cmd.Parameters.Add(cmdp); } return(cmd); #if NETCOREAPP2_1 } #endif }
void BindData() { if (this.isRTLookUpEnter) { this.isRTLookUpEnter = false; } else { if (this.Text != this.displayText) { this.displayText = ""; this.displayValue = ""; this.resultRow = null; this.dataSource = null; CJiaRTLookUpMoreColArgs args = new CJiaRTLookUpMoreColArgs(); args.SearchValue = Text.ToString(); if (GetData != null) { GetData(null, args); } this.ShowPopup(); this.isRTLookUpEnter = true; } } }
public void Reset() { health = 5; healthamount.text = healthamount.ToString(); cherries = 0; cherrytext.text = cherrytext.ToString(); }
> SelectToken(Text service, ICollection <Org.Apache.Hadoop.Security.Token.Token <TokenIdentifier > > tokens) { if (service == null) { return(null); } if (Log.IsDebugEnabled()) { Log.Debug("Looking for a token with service " + service.ToString()); } foreach (Org.Apache.Hadoop.Security.Token.Token <TokenIdentifier> token in tokens) { if (Log.IsDebugEnabled()) { Log.Debug("Token kind is " + token.GetKind().ToString() + " and the token's service name is " + token.GetService()); } if (TimelineDelegationTokenIdentifier.KindName.Equals(token.GetKind()) && service .Equals(token.GetService())) { return((Org.Apache.Hadoop.Security.Token.Token <TimelineDelegationTokenIdentifier> )token); } } return(null); }
public static void Print(Text text, IConsonant consonant, IVowel vowel) { Console.WriteLine("-----Восстановленный исходный текст--------------"); Console.WriteLine(); Console.WriteLine(text.ToString()); Console.WriteLine("------Сортированные списки букв------------------"); Console.WriteLine(); text.PrintLettersByDesc(vowel); Console.WriteLine(); text.PrintLettersByDesc(consonant); Console.WriteLine(); }
public Sentence(Text userText) { OriginalText = userText.ToString(); BreakIntoSentences(); }
public void NormalizesLineEndingsToSingleLineFeedCharacter() { var multiline = new Text("Line 1\rLine 2\nLine 3\r\nLine 4"); multiline.ToString().ShouldBe("Line 1\nLine 2\nLine 3\nLine 4"); }
string CalculateDisplayTarget(double value, double var) { value = value / multiplierValue; Debug.Log (value); Debug.Log (multiplierValue); if(multiplierValue == 100) { return (value/10).ToString() + "k"; } if(multiplierValue == 1000) { return value.ToString() + "k"; } else if(multiplierValue == 10000) { return value.ToString() + "0k"; } else if(multiplierValue == 100000) { return (value/10).ToString() + "M"; } else if(multiplierValue == 1000000) { return value.ToString() + "M"; } else { value = value * multiplierValue; } return value.ToString(); }