private static JObject GetParams(Stream inputStream) { byte[] buffer = StreamToBytes(inputStream); var bodyData = StringHelperClass.NewString(buffer.ToArray(), "UTF-8"); if (bodyData.Length > 0 && bodyData[0] != '{' && bodyData[0] != '<') { var resultObject = new JObject(); var paramList = bodyData.Split('&'); foreach (var item in paramList) { var nameValue = item.Split('='); if (nameValue.Length == 2) { resultObject[nameValue[0]] = string.IsNullOrEmpty(nameValue[1]) ? null : HttpUtility.UrlDecode(nameValue[1]); } } return(resultObject); } try { return(inputStream.Length == 0 ? JObject.Parse("{}") : JObject.Parse(bodyData)); } catch (Exception) { XmlDocument doc = new XmlDocument(); doc.LoadXml(bodyData); var jsonString = Newtonsoft.Json.JsonConvert.SerializeXmlNode(doc); return(inputStream.Length == 0 ? JObject.Parse("{}") : JObject.Parse(jsonString)); } }
public virtual void Compile(string src) { string[] srcShaders = StringHelperClass.StringSplit(src, "//\n", true); Attach(Shader.CreateCompiled(Shader.VERTEX, srcShaders[0])); Attach(Shader.CreateCompiled(Shader.FRAGMENT, srcShaders[1])); Link(); }
/*All Conversation_NAME-5's are to load a conversation that acknowledges * that it is the Turn-in point of a Quest. Thus, you must turn in a Quest * before you can start a Quest on the same QuestGiver. */ void InformQuestTurnInPoint() { if (Quest.QuestTurnInPoint.name != "Bird") //the bird is special => he dies and never comes back. { QuestGiver target = Quest.QuestTurnInPoint.GetComponent <QuestGiver>(); if (target.Quest != null && this.Quest.QuestStatus) //if the target has a quest to give && the assigning QuestGiver's quest is complete(just needs to be turned in) { string questTurnInPointName = Quest.QuestTurnInPoint.name; GameObject questTurnInPointGo = Quest.QuestTurnInPoint.gameObject; //Below will construct the path of the Conversation_NAME-5 which acknowledges that this is the turn in point of another's completed quest string result = StringHelperClass.ConstructConversationPath(questTurnInPointName); //Below will load a QuestGiver's (that is the QuestTurnInPoint of this Quest) //Conversation_NAME-5, dialogueManager.SetupNewDialogue(questTurnInPointGo, result); //We then need to change the TurnInPoint's QuestGiver's NPC_UI to show a question mark NPC_UI turnInPointNPC_UI = questTurnInPointGo.GetComponentInChildren <NPC_UI>(); turnInPointNPC_UI.ChangeQuestStatus("?", true); //Debug.Log("Changed ? to true from QuestGiver"); //And update boolean value so he can act correctly target.amTurnInPoint = true; } } }
private void LoadLanguageList() { SortedDictionary <string, string> treemap = new SortedDictionary <string, string>(); try { StreamReader bufferedreader = new StreamReader(Minecraft.GetResourceStream("lang.languages.txt"), Encoding.UTF8); for (string s = bufferedreader.ReadLine(); s != null; s = bufferedreader.ReadLine()) { string[] @as = StringHelperClass.StringSplit(s, "=", true); if (@as != null && @as.Length == 2) { treemap[@as[0]] = @as[1]; } } } catch (IOException ioexception) { Utilities.LogException(ioexception); return; } languageList = treemap; }
void InformQuestTurnInPoint() { QuestGiver target = quest.QuestTurnInPoint.GetComponent <QuestGiver>(); if (target.Quest != null) //if the target has a quest to give { string questTurnInPointName = quest.QuestTurnInPoint.name; GameObject questTurnInPointGo = quest.QuestTurnInPoint.gameObject; //Below will construct the path of the Conversation_NAME-5 string result = StringHelperClass.ConstructConversationPath(questTurnInPointName); //Below will load a QuestGiver's (that is the QuestTurnInPoint of this Quest) Conversation_NAME-5, dialogueManager.SetupNewDialogue(questTurnInPointGo, result); //We then need to change the TurnInPoint's QuestGiver's NPC_UI to show a question mark... NPC_UI turnInPointNPC_UI = questTurnInPointGo.GetComponentInChildren <NPC_UI>(); turnInPointNPC_UI.ChangeQuestStatus("?", true); Debug.Log("Changed ? to true from QuestGiver"); //...and update boolean value so he can act correctly target.amTurnInPoint = true; //...and send him the Quest that this object is holding. target.ForeignQuest = quest; } }
public override void onItemClick <T1>(AdapterView <T1> parent, View view, int position, long id) { string device = ((TextView)view).Text.ToString(); logicalName = device.Substring(0, device.IndexOf(DEVICE_ADDRESS_START, StringComparison.Ordinal)); string address = StringHelperClass.SubstringSpecial(device, device.IndexOf(DEVICE_ADDRESS_START, StringComparison.Ordinal) + DEVICE_ADDRESS_START.Length, device.IndexOf(DEVICE_ADDRESS_END, StringComparison.Ordinal)); try { foreach (object entry in bxlConfigLoader.Entries) { JposEntry jposEntry = (JposEntry)entry; bxlConfigLoader.removeEntry(jposEntry.LogicalName); } } catch (Exception e) { Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } try { bxlConfigLoader.addEntry(logicalName, BXLConfigLoader.DEVICE_CATEGORY_POS_PRINTER, logicalName, BXLConfigLoader.DEVICE_BUS_BLUETOOTH, address); bxlConfigLoader.saveFile(); } catch (Exception e) { Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } }
/// <summary> /// Converts a string in JDBC time escape format to a <code>Time</code> value. /// </summary> /// <param name="s"> time in format "hh:mm:ss" </param> /// <returns> a corresponding <code>Time</code> object </returns> public static Time ValueOf(String s) { int hour; int minute; int second; int firstColon; int secondColon; if (s == null) { throw new System.ArgumentException(); } firstColon = s.IndexOf(':'); secondColon = s.IndexOf(':', firstColon + 1); if ((firstColon > 0) & (secondColon > 0) & (secondColon < s.Length() - 1)) { hour = Convert.ToInt32(s.Substring(0, firstColon)); minute = Convert.ToInt32(StringHelperClass.SubstringSpecial(s, firstColon + 1, secondColon)); second = Convert.ToInt32(s.Substring(secondColon + 1)); } else { throw new System.ArgumentException(); } return(new Time(hour, minute, second)); }
internal void ParseDialogueID(Dialogue dialogue) { //comes back as "Ed" string stringID = StringHelperClass.ParseDialogueIDForString(dialogue); SearchForMusicByStringID(stringID); }
public override void onReceive(int channelId, sbyte[] data) { if (outerInstance.mConnectionHandler == null) { return; } DateTime calendar = new GregorianCalendar(); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd aa hh:mm:ss.SSS"); string timeStr = " " + dateFormat.format(calendar); string strToUpdateUI = StringHelperClass.NewString(data); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final String message = strToUpdateUI.concat(timeStr); string message = strToUpdateUI + timeStr; new Thread(() => { try { outerInstance.mConnectionHandler.secureSend(SECURED_CHANNEL_ID, message.GetBytes()); } catch (IOException e) { Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } }).start(); }
// LUCENE-3642: normalize BMP->SMP and check that offsets are correct //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void testCrossPlaneNormalization2() throws java.io.IOException public virtual void testCrossPlaneNormalization2() { Analyzer analyzer = new AnalyzerAnonymousInnerClassHelper2(this); int num = 1000 * RANDOM_MULTIPLIER; for (int i = 0; i < num; i++) { string s = TestUtil.randomUnicodeString(random()); TokenStream ts = analyzer.tokenStream("foo", s); try { ts.reset(); OffsetAttribute offsetAtt = ts.addAttribute(typeof(OffsetAttribute)); while (ts.incrementToken()) { string highlightedText = StringHelperClass.SubstringSpecial(s, offsetAtt.startOffset(), offsetAtt.endOffset()); for (int j = 0, cp = 0; j < highlightedText.Length; j += char.charCount(cp)) { cp = char.ConvertToUtf32(highlightedText, j); assertTrue("non-letter:" + cp.ToString("x"), char.IsLetter(cp)); } } ts.end(); } finally { IOUtils.closeWhileHandlingException(ts); } } // just for fun checkRandomData(random(), analyzer, num); }
/// <summary> /// Writes the Manifest to the specified OutputStream. /// Attributes.Name.MANIFEST_VERSION must be set in /// MainAttributes prior to invoking this method. /// </summary> /// <param name="out"> the output stream </param> /// <exception cref="IOException"> if an I/O error has occurred </exception> /// <seealso cref= #getMainAttributes </seealso> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void write(java.io.OutputStream out) throws java.io.IOException public virtual void Write(OutputStream @out) { DataOutputStream dos = new DataOutputStream(@out); // Write out the main attributes for the manifest Attr.WriteMain(dos); // Now write out the pre-entry attributes IEnumerator <java.util.Map_Entry <String, Attributes> > it = Entries_Renamed.GetEnumerator(); while (it.MoveNext()) { java.util.Map_Entry <String, Attributes> e = it.Current; StringBuffer buffer = new StringBuffer("Name: "); String value = e.Key; if (value != null) { sbyte[] vb = value.GetBytes("UTF8"); value = StringHelperClass.NewString(vb, 0, 0, vb.Length); } buffer.Append(value); buffer.Append("\r\n"); Make72Safe(buffer); dos.WriteBytes(buffer.ToString()); e.Value.Write(dos); } dos.Flush(); }
void WriteQuestOnHUD(QuestBaseClass e) { string questName = e.QuestName; //Debug.Log("Hud rcvd " + questName); //EACH QUEST IS ALWAYS 42 CHARACTERS LONG questText.text += StringHelperClass.PadQuestTextToLengthOfLine(questName); }
public override void onReceive(int channelId, sbyte[] data) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final String message = new String(data); string message = StringHelperClass.NewString(data); outerInstance.addMessage("Received: ", message); }
static ConcurrentDeploymentTest() { IBpmnModelInstance modelInstance = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess().StartEvent().Done(); System.IO.MemoryStream outputStream = new System.IO.MemoryStream(); ESS.FW.Bpm.Model.Bpmn.Bpmn.WriteModelToStream(outputStream, modelInstance); processResource = StringHelperClass.NewString(outputStream.ToArray()); }
private string CheckH2pSuffix(string a) { string[] temp = StringHelperClass.StringSplit(a, "[.]h2p", true); string tempus = temp[0]; tempus = tempus + ".h2p"; return(tempus); }
public override void onReceive(int channelId, sbyte[] data) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final String strToUpdateUI = new String(data); string strToUpdateUI = StringHelperClass.NewString(data); outerInstance.onDataAvailableonChannel(this, channelId, strToUpdateUI); }
private object parseTextData(string data, int tagValue) { // first, get the description of what we're supposed to parse EventValueDescription[] desc = mValueDescriptionMap[tagValue]; if (desc == null) { // TODO parse and create string values. return(null); } if (desc.Length == 1) { return(getObjectFromString(data, desc[0].eventValueType)); } else if (data.StartsWith("[") && data.EndsWith("]")) { data = data.Substring(1, data.Length - 1 - 1); // get each individual values as String string[] values = StringHelperClass.StringSplit(data, ",", true); if (tagValue == GcEventContainer.GC_EVENT_TAG) { // special case for the GC event! object[] objects = new object[2]; objects[0] = getObjectFromString(values[0], EventContainer.EventValueTypes.LONG); objects[1] = getObjectFromString(values[1], EventContainer.EventValueTypes.LONG); return(objects); } else { // must be the same number as the number of descriptors. if (values.Length != desc.Length) { return(null); } object[] objects = new object[values.Length]; for (int i = 0; i < desc.Length; i++) { object obj = getObjectFromString(values[i], desc[i].eventValueType); if (obj == null) { return(null); } objects[i] = obj; } return(objects); } } return(null); }
public virtual bool accept(File dir, string name) { if (name.Length > 4) { string fileExtension = StringHelperClass.SubstringSpecial(name, name.Length - 4, name.Length); return(".jpg".Equals(fileExtension, StringComparison.CurrentCultureIgnoreCase) || ".png".Equals(fileExtension, StringComparison.CurrentCultureIgnoreCase)); } return(false); }
public virtual string replaceVariables(string expression) { int openIndex = expression.IndexOf(EvaluationConstants.OPEN_VARIABLE, StringComparison.Ordinal); if (openIndex < 0) { return(expression); } string replacedExpression = expression; while (openIndex >= 0) { int closedIndex = -1; if (openIndex >= 0) { closedIndex = replacedExpression.IndexOf(EvaluationConstants.CLOSED_VARIABLE, openIndex + 1, StringComparison.Ordinal); if (closedIndex > openIndex) { string variableName = StringHelperClass.SubstringSpecial(replacedExpression, openIndex + EvaluationConstants.OPEN_VARIABLE.Length, closedIndex); // Validate that the variable name is valid. try { isValidName(variableName); } catch (System.ArgumentException iae) { throw new EvaluationException("Invalid variable name of \"" + variableName + "\".", iae); } string variableValue = getVariableValue(variableName); string variableString = EvaluationConstants.OPEN_VARIABLE + variableName + EvaluationConstants.CLOSED_VARIABLE; replacedExpression = EvaluationHelper.replaceAll(replacedExpression, variableString, variableValue); } else { break; } } openIndex = replacedExpression.IndexOf(EvaluationConstants.OPEN_VARIABLE, StringComparison.Ordinal); } // If an open brace is left over, then a variable could not be replaced. int openBraceIndex = replacedExpression.IndexOf(EvaluationConstants.OPEN_VARIABLE, StringComparison.Ordinal); if (openBraceIndex > -1) { throw new EvaluationException("A variable has not been closed (index=" + openBraceIndex + ")."); } return(replacedExpression); }
/// <summary> /// Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e). /// </summary> protected override void KeyTyped(char par1, int par2) { ServerTextField.Func_50037_a(par1, par2); if (par1 == 034) { ActionPerformed(ControlList[0]); } ControlList[0].Enabled = ServerTextField.GetText().Length > 0 && StringHelperClass.StringSplit(ServerTextField.GetText(), ":", true).Length > 0; }
public IList <AppSettingModels> GetCommonSettings() { return(Context.Set <AppSetting>().Where(x => !x.Key.Contains("Logo") && !x.Key.Contains("Image")) .OrderBy(x => x.Key) .Select(x => new AppSettingModels() { Key = x.Key, Value = x.Value, KeyName = StringHelperClass.CamelSplit(x.Key) }).ToList()); }
public IList <AppSettingModels> GetAllSettings() { return(Context.Set <AppSetting>() .OrderBy(x => x.Key) .Select(x => new AppSettingModels { Key = x.Key, Value = x.Value, KeyName = StringHelperClass.CamelSplit(x.Key) }).ToList()); }
public override void onReceive(int channelId, sbyte[] data) { try { Log.i(TAG, "onReceive: channelId" + channelId + "data: " + StringHelperClass.NewString(data, "UTF-8")); } catch (UnsupportedEncodingException e) { Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } }
private string ReadPassword(int length) { sbyte[] ASCIIPassword = new sbyte[length - 1]; chipDat.ReadFully(ASCIIPassword); for (int i = 0; i < ASCIIPassword.Length; i++) { ASCIIPassword[i] ^= unchecked ((sbyte)0x99); } string password = StringHelperClass.NewString(ASCIIPassword, "ASCII"); return(password); }
// -------------------------------------------------------- // encoding // -------------------------------------------------------- /// <summary> /// Base64-encode the given data and return a newly allocated /// String with the result. /// </summary> /// <param name="input"> the data to encode </param> /// <param name="offset"> the position within the input array at which to /// start </param> /// <param name="len"> the number of bytes of input to encode </param> /// <param name="flags"> controls certain features of the encoded output. /// Passing {@code DEFAULT} results in output that /// adheres to RFC 2045. </param> public static string encodeToString(byte[] input, int offset, int len, int flags) { try { return(StringHelperClass.NewString(encode(input, offset, len, flags), "US-ASCII")); } catch (Exception e) { // US-ASCII is guaranteed to be available. throw e; } }
} // equals() /// <summary> /// A routine for parsing the MIME type out of a String. /// </summary> /// <exception cref="NullPointerException"> if <code>rawdata</code> is null </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: private void parse(String rawdata) throws MimeTypeParseException private void Parse(String rawdata) { int slashIndex = rawdata.IndexOf('/'); int semIndex = rawdata.IndexOf(';'); if ((slashIndex < 0) && (semIndex < 0)) { // neither character is present, so treat it // as an error throw new MimeTypeParseException("Unable to find a sub type."); } else if ((slashIndex < 0) && (semIndex >= 0)) { // we have a ';' (and therefore a parameter list), // but no '/' indicating a sub type is present throw new MimeTypeParseException("Unable to find a sub type."); } else if ((slashIndex >= 0) && (semIndex < 0)) { // we have a primary and sub type but no parameter list PrimaryType_Renamed = rawdata.Substring(0, slashIndex).Trim().ToLowerCase(Locale.ENGLISH); SubType_Renamed = rawdata.Substring(slashIndex + 1).Trim().ToLowerCase(Locale.ENGLISH); Parameters_Renamed = new MimeTypeParameterList(); } else if (slashIndex < semIndex) { // we have all three items in the proper sequence PrimaryType_Renamed = rawdata.Substring(0, slashIndex).Trim().ToLowerCase(Locale.ENGLISH); SubType_Renamed = StringHelperClass.SubstringSpecial(rawdata, slashIndex + 1, semIndex).Trim().ToLowerCase(Locale.ENGLISH); Parameters_Renamed = new MimeTypeParameterList(rawdata.Substring(semIndex)); } else { // we have a ';' lexically before a '/' which means we have a primary type // & a parameter list but no sub type throw new MimeTypeParseException("Unable to find a sub type."); } // now validate the primary and sub types // check to see if primary is valid if (!IsValidToken(PrimaryType_Renamed)) { throw new MimeTypeParseException("Primary type is invalid."); } // check to see if sub is valid if (!IsValidToken(SubType_Renamed)) { throw new MimeTypeParseException("Sub type is invalid."); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: private final int findLastEntry(PatternEntry entry, StringBuffer excessChars) throws ParseException private int FindLastEntry(PatternEntry entry, StringBuffer excessChars) { if (entry == null) { return(0); } if (entry.Strength_Renamed != PatternEntry.RESET) { // Search backwards for string that contains this one; // most likely entry is last one int oldIndex = -1; if ((entry.Chars_Renamed.length() == 1)) { int index = entry.Chars_Renamed.charAt(0) >> BYTEPOWER; if ((StatusArray[index] & (BITARRAYMASK << (entry.Chars_Renamed.charAt(0) & BYTEMASK))) != 0) { oldIndex = Patterns.LastIndexOf(entry); } } else { oldIndex = Patterns.LastIndexOf(entry); } if ((oldIndex == -1)) { throw new ParseException("couldn't find last entry: " + entry, oldIndex); } return(oldIndex + 1); } else { int i; for (i = Patterns.Count - 1; i >= 0; --i) { PatternEntry e = Patterns[i]; if (e.Chars_Renamed.regionMatches(0, entry.Chars_Renamed, 0, e.Chars_Renamed.length())) { excessChars.Append(StringHelperClass.SubstringSpecial(entry.Chars_Renamed, e.Chars_Renamed.length(), entry.Chars_Renamed.length())); break; } } if (i == -1) { throw new ParseException("couldn't find: " + entry, i); } return(i + 1); } }
private String ParseName(sbyte[] lbuf, int len) { if (ToLower(lbuf[0]) == 'n' && ToLower(lbuf[1]) == 'a' && ToLower(lbuf[2]) == 'm' && ToLower(lbuf[3]) == 'e' && lbuf[4] == ':' && lbuf[5] == ' ') { try { return(StringHelperClass.NewString(lbuf, 6, len - 6, "UTF8")); } catch (Exception) { } } return(null); }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET: //ORIGINAL LINE: @Override public void directIOOccurred(final jpos.events.DirectIOEvent e) public override void directIOOccurred(DirectIOEvent e) { Activity.runOnUiThread(() => { deviceMessagesTextView.append("DirectIO: " + e + "(" + getBatterStatusString(e.Data) + ")\n"); if (e.Object != null) { deviceMessagesTextView.append(StringHelperClass.NewString((sbyte[])e.Object) + "\n"); } scroll(); }); }
/// <summary> /// Parse a camunda:resource attribute and loads the resource depending on the url scheme. /// Supported Uri schemes are <code>classpath://</code> and <code>deployment://</code>. /// If the scheme is omitted <code>classpath://</code> is assumed. /// </summary> /// <param name="resourcePath"> the path to the resource to load </param> /// <param name="deployment"> the deployment to load resources from </param> /// <returns> the resource content as <seealso cref="string" /> </returns> public static string LoadResourceContent(string resourcePath, DeploymentEntity deployment) { var pathSplit = resourcePath.Split("://", true); string resourceType; if (pathSplit.Length == 1) { resourceType = "classpath"; } else { resourceType = pathSplit[0]; } var resourceLocation = pathSplit[pathSplit.Length - 1]; byte[] resourceBytes = null; if (resourceType.Equals("classpath")) { Stream resourceAsStream = null; try { resourceAsStream = ReflectUtil.GetResourceAsStream(resourceLocation); if (resourceAsStream != null) { resourceBytes = IoUtil.ReadInputStream(resourceAsStream, resourcePath); } } finally { IoUtil.CloseSilently(resourceAsStream); } } else if (resourceType.Equals("deployment")) { ResourceEntity resourceEntity = deployment.GetResource(resourceLocation); if (resourceEntity != null) { resourceBytes = resourceEntity.Bytes; } } if (resourceBytes != null) { return(StringHelperClass.NewString(resourceBytes, Encoding.UTF8.ToString())); } throw Log.CannotFindResource(resourcePath); }