private void _buildPackageFromCsvFile() { string filePath = EditorUtility.OpenFilePanel("Select CSV file to read", "", "csv"); if (string.IsNullOrEmpty(filePath)) { Debug.LogWarning("[TextDataPackageInspector] Invalid file path was specified"); return; } using (StreamReader csvFileStreamReader = new StreamReader(filePath)) { using (CsvReader csvReader = new CsvReader(csvFileStreamReader, CultureInfo.InvariantCulture)) { var record = new TextRecord(); var records = csvReader.EnumerateRecords(record); var packageData = _initPackageData(); foreach (var currRecord in records) { var parsedData = _getKeyValuePairByLocaleType(currRecord, mCurrSelectedType); packageData.Add(new TextDataPackage.TextDataEntity { mKey = parsedData.Item1, mValue = parsedData.Item2 }); } mCurrEditedObject.mData = packageData; } } }
public static void AddTestRecords(DnsRecordTable store) { // Addresses store.Add(new AddressRecord("foo.com", "192.169.0.1")); store.Add(new AddressRecord("foo.com", "192.169.0.2")); store.Add(new AddressRecord("foo.com", "192.169.0.3")); store.Add(new AddressRecord("bar.com", "192.168.0.1")); store.Add(new AddressRecord("goo.com", "192.167.0.1")); store.Add(new AddressRecord("goo.com", "192.167.0.2")); store.Add(new AddressRecord("localhost", "127.0.0.1")); store.Add(new AddressRecord("bigrecord.com", "1.2.3.4")); const string BigString = "0123456789abcdefghijklmnop"; TextRecord txt = new TextRecord("goo.com", new string[] { BigString, "One_" + BigString, "Two_" + BigString }); store.Add(txt); StringBuilder builder = new StringBuilder(64); for (int i = 0; i < 64; ++i) { builder.Append('a'); } string bigTextString = builder.ToString(); string[] textStrings = new string[128]; for (int i = 0; i < textStrings.Length; ++i) { textStrings[i] = bigTextString; } store.Add(new TextRecord("bigrecord.com", textStrings)); store.Add(new SRVRecord("foo.com", 20, 353, "x.y.z.com")); store.Add(new MXRecord("goo.com", "foo.bar.xyz")); }
public void NdefTextRecordUTF8() { // Arrange const string CorrectText = "Super ça marche "; const string LanguageCode = "en"; // Text is Encoding.UTF8 and once extractes "Super ça marche " (with space at the end); Span <byte> txtRaw = new byte[] { 0x91, 0x01, 0x14, 0x54, 0x02, 0x65, 0x6E, 0x53, 0x75, 0x70, 0x65, 0x72, 0x20, 0xC3, 0xA7, 0x61, 0x20, 0x6D, 0x61, 0x72, 0x63, 0x68, 0x65, 0x20 }; // Act var txtRecord = new TextRecord(txtRaw); // Assert Assert.Equal(CorrectText, txtRecord.Text); Assert.True(txtRecord.Header.IsFirstMessage); Assert.False(txtRecord.Header.IsLastMessage); Assert.False(txtRecord.Header.IsComposedMessage); Assert.Equal(4, txtRecord.Header.Length); Assert.Equal(20, txtRecord.Payload?.Length); Assert.Equal(LanguageCode, txtRecord.LanguageCode); // Arrange // Now compose a new text message and compare it with the original one var newTxtRecord = new TextRecord(CorrectText, LanguageCode, Encoding.UTF8); // Assert Assert.Equal(txtRaw.Slice(4).ToArray(), newTxtRecord.Payload); Assert.Equal(4, newTxtRecord.Header.Length); }
public void RecordSpeech(string jsonString) { SpeechHistory history = JsonUtility.FromJson <SpeechHistory>(jsonString); TextRecord textRecord = new TextRecord(history.durationSec); VoiceRecord voiceRecord = new VoiceRecord(history.durationSec, history.fileID); TimelineRecord timeline = timelineRecords.Find(t => t.timeSec == history.timeSec); if (timeline == null) { timeline = new TimelineRecord(); timeline.timeSec = history.timeSec; timeline.text = textRecord; timeline.voice = voiceRecord; timelineRecords.Add(timeline); return; } if (timeline.text == null) { timeline.text = textRecord; } if (timeline.voice == null) { timeline.voice = voiceRecord; } else { Utilities.MergeValues(timeline.voice, voiceRecord); } }
private static TextRecord CreateTextRecord() { TextRecord r = new TextRecord(); r.HorizontalAlignment = (TextRecord.HORIZONTAL_ALIGNMENT_CENTER); r.VerticalAlignment = (TextRecord.VERTICAL_ALIGNMENT_CENTER); r.DisplayMode = ((short)1); r.RgbColor = (0x00000000); r.X = (-37); r.Y = (-60); r.Width = (0); r.Height = (0); r.IsAutoColor = (true); r.ShowKey = (false); r.ShowValue = (false); //r.IsVertical = (false); r.IsAutoGeneratedText = (true); r.IsGenerated = (true); r.IsAutoLabelDeleted = (false); r.IsAutoBackground = (true); //r.Rotation = ((short)0); r.ShowCategoryLabelAsPercentage = (false); r.ShowValueAsPercentage = (false); r.ShowBubbleSizes = (false); r.ShowLabel = (false); r.IndexOfColorValue = ((short)77); r.DataLabelPlacement = ((short)0); r.TextRotation = ((short)0); return(r); }
Populate(BrowseData browseData, ResolveData resolveData) { nameField.Text = browseData.Name; typeField.Text = browseData.Type; domainField.Text = browseData.Domain; hostField.Text = resolveData.HostName; portField.Text = resolveData.Port.ToString(); serviceTextField.Items.Clear(); if (resolveData.TxtRecord != null) { for (int idx = 0; idx < TextRecord.GetCount(resolveData.TxtRecord); idx++) { String key; Byte[] bytes; bytes = TextRecord.GetItemAtIndex(resolveData.TxtRecord, idx, out key); if (key.Length > 0) { String val = ""; if (bytes != null) { val = Encoding.ASCII.GetString(bytes, 0, bytes.Length); } serviceTextField.Items.Add(key + "=" + val); } } } }
public void TestLoad() { TextRecord record = new TextRecord(TestcaseRecordInputStream.Create((short)0x1025, data)); Assert.AreEqual(TextRecord.HORIZONTAL_ALIGNMENT_CENTER, record.HorizontalAlignment); Assert.AreEqual(TextRecord.VERTICAL_ALIGNMENT_CENTER, record.VerticalAlignment); Assert.AreEqual(TextRecord.DISPLAY_MODE_TRANSPARENT, record.DisplayMode); Assert.AreEqual(0, record.RgbColor); Assert.AreEqual(-42, record.X); Assert.AreEqual(-60, record.Y); Assert.AreEqual(0, record.Width); Assert.AreEqual(0, record.Height); Assert.AreEqual(177, record.Options1); Assert.AreEqual(true, record.IsAutoColor); Assert.AreEqual(false, record.ShowKey); Assert.AreEqual(false, record.ShowValue); Assert.AreEqual(false, record.IsVertical); Assert.AreEqual(true, record.IsAutoGeneratedText); Assert.AreEqual(true, record.IsGenerated); Assert.AreEqual(false, record.IsAutoLabelDeleted); Assert.AreEqual(true, record.IsAutoBackground); Assert.AreEqual(TextRecord.ROTATION_NONE, record.Rotation); Assert.AreEqual(false, record.ShowCategoryLabelAsPercentage); Assert.AreEqual(false, record.ShowValueAsPercentage); Assert.AreEqual(false, record.ShowBubbleSizes); Assert.AreEqual(false, record.ShowLabel); Assert.AreEqual(77, record.IndexOfColorValue); Assert.AreEqual(11088, record.Options2); Assert.AreEqual(0, record.DataLabelPlacement); Assert.AreEqual(0, record.TextRotation); Assert.AreEqual(36, record.RecordSize); }
public void UpdateNDEFMessage(NDEFMessage message) { CleanupRecordItems(); float y = 0; List <NDEFRecord> records = message.Records; int length = records.Count; for (int i = 0; i < length; i++) { NDEFRecord record = records[i]; RecordItem recordItem = null; switch (record.Type) { case NDEFRecordType.TEXT: recordItem = CreateRecordItem(textRecordItemPrefab); TextRecord textRecord = (TextRecord)record; recordItem.UpdateLabel(string.Format(TEXT_RECORD_FORMAT, NDEFRecordType.TEXT, textRecord.text, textRecord.languageCode, textRecord.textEncoding)); tagInfoContentLabel.text = string.Format(TEXT_RECORD_FORMAT, NDEFRecordType.TEXT, textRecord.text, textRecord.languageCode, textRecord.textEncoding); //infosSenderText.text = textRecord.text; senderController.SendValue(textRecord.text); break; case NDEFRecordType.URI: recordItem = CreateRecordItem(uriRecordItemPrefab); UriRecord uriRecord = (UriRecord)record; recordItem.UpdateLabel(string.Format(URI_RECORD_FORMAT, NDEFRecordType.URI, uriRecord.fullUri, uriRecord.uri, uriRecord.protocol)); break; case NDEFRecordType.MIME_MEDIA: recordItem = CreateRecordItem(mimeMediaRecordItemPrefab); MimeMediaRecord mimeMediaRecord = (MimeMediaRecord)record; recordItem.UpdateLabel(string.Format(MIME_MEDIA_RECORD_FORMAT, NDEFRecordType.MIME_MEDIA, mimeMediaRecord.mimeType)); ((ImageRecordItem)recordItem).LoadImage(mimeMediaRecord.mimeData); break; case NDEFRecordType.EXTERNAL_TYPE: recordItem = CreateRecordItem(externalTypeRecordItemPrefab); ExternalTypeRecord externalTypeRecord = (ExternalTypeRecord)record; int dataLength = externalTypeRecord.domainData.Length; string dataValue = Encoding.UTF8.GetString(externalTypeRecord.domainData); recordItem.UpdateLabel(string.Format(EXTERNAL_TYPE_FORMAT, NDEFRecordType.EXTERNAL_TYPE, externalTypeRecord.domainName, externalTypeRecord.domainType, dataLength, dataValue)); break; case NDEFRecordType.SMART_POSTER: recordItem = CreateRecordItem(smartPosterRecordItemPrefab); SmartPosterRecord smartPosterRecord = (SmartPosterRecord)record; int totalRecords = smartPosterRecord.titleRecords.Count + smartPosterRecord.iconRecords.Count + smartPosterRecord.extraRecords.Count; recordItem.UpdateLabel(string.Format(SMART_POSTER_RECORD_FORMAT, NDEFRecordType.SMART_POSTER, smartPosterRecord.uriRecord.fullUri, smartPosterRecord.action, smartPosterRecord.size, smartPosterRecord.mimeType, totalRecords)); break; } recordItem.RectTransform.anchoredPosition = new Vector2(0, y); y -= recordItem.RectTransform.rect.height; y -= Y_SPACING; } ndefMessageScrollRect.content.sizeDelta = new Vector2(0, Mathf.Abs(y)); }
public static AnswerRecord ReadAnswerRecord(byte[] bBuffer, int startIndex) { AnswerRecord retval = new AnswerRecord(); retval.mOriginalBuffer = new byte[bBuffer.Length]; retval.mStartIndex = startIndex; Array.Copy(bBuffer, 0, retval.mOriginalBuffer, 0, bBuffer.Length); UInt16 i = GetUInt16(bBuffer, startIndex); int offset = 0; if (i > 0xc000) { retval.mName = GetNameAtLocation(bBuffer, i - 0xc000); offset = 2; } else { retval.Name = GetNameAtLocation(bBuffer, i); offset = i; } retval.mNameBufferLength = GetLabelLength(bBuffer, startIndex); retval.mType = GetUInt16(bBuffer, startIndex + offset); retval.mClass = GetUInt16(bBuffer, startIndex + offset + 2); retval.TTL = GetUInt32(bBuffer, startIndex + offset + 4); UInt16 RDLength = GetUInt16(bBuffer, startIndex + offset + 8); retval.mData = new byte[RDLength]; Array.Copy(bBuffer, startIndex + offset + 10, retval.mData, 0, RDLength); retval.mLength = offset + RDLength + 10; if (retval.Type == (UInt16)TYPECODE.NS) { retval = new NameServerRecord(retval); } if (retval.Type == (UInt16)TYPECODE.A) { retval = new AddressRecord(retval); } if (retval.Type == (UInt16)TYPECODE.MX) { retval = new MailExchangeRecord(retval); } if (retval.Type == (UInt16)TYPECODE.CNAME) { retval = new CanonicalNameRecord(retval); } if (retval.Type == (UInt16)TYPECODE.SOA) { retval = new StartOfAuthorityRecord(retval); } if (retval.Type == (UInt16)TYPECODE.TXT) { retval = new TextRecord(retval); } if (retval.Type == (UInt16)TYPECODE.PTR) { retval = new PointerRecord(retval); } return(retval); }
private void UpdateValueAndIndexArrays(ElementRecord elementRecord, ref TextRecord textRecord, PhpArray values, PhpArray indices, bool middle) { // if we have no valid data in the middle, just end if (middle && textRecord == null) { return; } if (!middle && elementRecord.State == ElementState.Interior) { UpdateValueAndIndexArrays(elementRecord, ref textRecord, values, indices, true); } if (values != null) { PhpArray arrayRecord = new PhpArray(); arrayRecord.Add("tag", elementRecord.ElementName); arrayRecord.Add("level", elementRecord.Level); if (elementRecord.State == ElementState.Beginning) { arrayRecord.Add("type", middle ? "open" : "complete"); } else { arrayRecord.Add("type", middle ? "cdata" : "close"); } if (textRecord != null) { arrayRecord.Add("value", textRecord.Text); } if (elementRecord.State == ElementState.Beginning && elementRecord.Attributes.Count != 0) { arrayRecord.Add("attributes", elementRecord.Attributes); } var value_idx = values.Add(arrayRecord) - 1; if (indices != null) { var elementIndices = indices[elementRecord.ElementName].AsArray(); if (elementIndices == null) { indices[elementRecord.ElementName] = elementIndices = new PhpArray(); } // add the max index (last inserted value) elementIndices.Add(value_idx); } } textRecord = null; }
internal static CfTextRecord FromTextRecord(TextRecord source) { if (source == null) { return(null); } var result = EnumeratedMapper.EnumFromSoapEnumerated <CfResult>(source.Result); var questionResponse = ActionRecordQuestionResponseMapper.FromActionRecordQuestionResponse(source.QuestionResponse); return(new CfTextRecord(result, source.FinishTime, source.BilledAmount, questionResponse, source.id, source.Message)); }
private void parseRecords() { Records = new TextRecord[Header.SlotCnt]; int cnt = 0; foreach (short recordOffset in SlotArray) { Records[cnt++] = new TextRecord(ArrayHelper.SliceArray(RawBytes.ToArray(), recordOffset, RawBytes.Count - recordOffset), this); } }
/// <summary> /// Gets TextRecord data by index. /// Special formatting characters are parsed into [0x00] format. /// </summary> public TextRecord GetTextRecordByIndex(int index) { TextRecord textRecord = new TextRecord(); if (isLoaded) { textRecord.id = header.TextRecordHeaders[index].TextRecordId; textRecord.text = ParseBytesToString(GetBytesByIndex(index)); } return(textRecord); }
private Tuple <string, string> _getKeyValuePairByLocaleType(TextRecord textEntity, E_LOCALE_TYPE locale) { switch (locale) { case E_LOCALE_TYPE.EN: return(new Tuple <string, string>(textEntity.Key, textEntity.En)); case E_LOCALE_TYPE.RU: return(new Tuple <string, string>(textEntity.Key, textEntity.Ru)); } return(new Tuple <string, string>(textEntity.Key, string.Empty)); }
public AttachedLabelAggregate(RecordStream rs, ChartRecordAggregate container) : base(RuleName_ATTACHEDLABEL, container) { ChartSheetAggregate cs = GetContainer <ChartSheetAggregate>(ChartRecordAggregate.RuleName_CHARTSHEET); _isFirst = cs.AttachLabelCount == 0; cs.AttachLabelCount++; text = (TextRecord)rs.GetNext(); rs.GetNext();//BeginRecord pos = (PosRecord)rs.GetNext(); if (rs.PeekNextChartSid() == FontXRecord.sid) { fontX = (FontXRecord)rs.GetNext(); } if (rs.PeekNextChartSid() == AlRunsRecord.sid) { alRuns = (AlRunsRecord)rs.GetNext(); } brai = (BRAIRecord)rs.GetNext(); if (rs.PeekNextChartSid() == SeriesTextRecord.sid) { seriesText = (SeriesTextRecord)rs.GetNext(); } if (rs.PeekNextChartSid() == FrameRecord.sid) { frame = new FrameAggregate(rs, this); } if (rs.PeekNextChartSid() == ObjectLinkRecord.sid) { objectLink = (ObjectLinkRecord)rs.GetNext(); } if (rs.PeekNextChartSid() == DataLabExtContentsRecord.sid) { dataLab = (DataLabExtContentsRecord)rs.GetNext(); } if (rs.PeekNextChartSid() == CrtLayout12Record.sid) { crtLayout = (CrtLayout12Record)rs.GetNext(); } if (rs.PeekNextChartSid() == TextPropsStreamRecord.sid) { textProps = new TextPropsAggregate(rs, this); } if (rs.PeekNextChartSid() == CrtMlFrtRecord.sid) { crtMlFrt = new CrtMlFrtAggregate(rs, this); } Record r = rs.GetNext();//EndRecord Debug.Assert(r.GetType() == typeof(EndRecord)); }
public void OnAddRecordClick() { if (pendingMessage == null) { pendingMessage = new NDEFMessage(); } NDEFRecord record = null; string value = view.TypeDropdown.options[view.TypeDropdown.value].text; NDEFRecordType type = (NDEFRecordType)Enum.Parse(typeof(NDEFRecordType), value); switch (type) { case NDEFRecordType.TEXT: string text = view.TextInput.text; string languageCode = view.LanguageCodeInput.text; if (languageCode.Length != 2) { languageCode = "en"; } TextRecord.TextEncoding textEncoding = (TextRecord.TextEncoding)view.TextEncodingDropdown.value; record = new TextRecord(text, languageCode, textEncoding); break; case NDEFRecordType.URI: string uri = view.UriInput.text; record = new UriRecord(uri); break; case NDEFRecordType.MIME_MEDIA: string mimeType = "image/png"; //We're only using png images atm IconID iconID = (IconID)view.IconDropdown.value; byte[] mimeData = GetIconBytes(iconID); record = new MimeMediaRecord(mimeType, mimeData); break; case NDEFRecordType.EXTERNAL_TYPE: string domainName = view.DomainNameInput.text; string domainType = view.DomainTypeInput.text; string domainDataString = view.DomainDataInput.text; byte[] domainData = Encoding.UTF8.GetBytes(domainDataString); //Data represents a string in this example record = new ExternalTypeRecord(domainName, domainType, domainData); break; } pendingMessage.Records.Add(record); view.UpdateNDEFMessage(pendingMessage); }
public AttachedLabelAggregate(RecordStream rs, ChartRecordAggregate container) : base(RuleName_ATTACHEDLABEL, container) { ChartSheetAggregate cs = GetContainer<ChartSheetAggregate>(ChartRecordAggregate.RuleName_CHARTSHEET); IsFirst = cs.AttachLabelCount == 0; cs.AttachLabelCount++; text = (TextRecord)rs.GetNext(); rs.GetNext();//BeginRecord pos = (PosRecord)rs.GetNext(); if (rs.PeekNextChartSid() == FontXRecord.sid) { fontX = (FontXRecord)rs.GetNext(); } if (rs.PeekNextChartSid() == AlRunsRecord.sid) { alRuns = (AlRunsRecord)rs.GetNext(); } brai = (BRAIRecord)rs.GetNext(); if (rs.PeekNextChartSid() == SeriesTextRecord.sid) { seriesText = (SeriesTextRecord)rs.GetNext(); } if (rs.PeekNextChartSid() == FrameRecord.sid) { frame = new FrameAggregate(rs, this); } if (rs.PeekNextChartSid() == ObjectLinkRecord.sid) { objectLink = (ObjectLinkRecord)rs.GetNext(); } if (rs.PeekNextChartSid() == DataLabExtContentsRecord.sid) { dataLab = (DataLabExtContentsRecord)rs.GetNext(); } if (rs.PeekNextChartSid() == CrtLayout12Record.sid) { crtLayout = (CrtLayout12Record)rs.GetNext(); } if (rs.PeekNextChartSid() == TextPropsStreamRecord.sid) { textProps = new TextPropsAggregate(rs, this); } if (rs.PeekNextChartSid() == CrtMlFrtRecord.sid) { crtMlFrt = new CrtMlFrtAggregate(rs, this); } Record r = rs.GetNext();//EndRecord Debug.Assert(r.GetType() == typeof(EndRecord)); }
internal void Accept(TextRecord tr, System.Drawing.Rectangle r) { if (r.Size.Height > m_Span.Height) m_Span.Height = r.Size.Height; if (r.Size.Width > m_Span.Width) m_Span.Width = r.Size.Width; m_textRecords.Add(tr); if (m_textRecords.Count == 1) m_rcTextBounds = tr.ActualRectangle(); else { m_rcTextBounds = Rectangle.Union(m_rcTextBounds, tr.ActualRectangle()); } }
/// <summary> /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see> /// </summary> public override void ReadData(byte version, BufferedBinaryReader binaryReader) { RecordHeader rh = new RecordHeader(); rh.ReadData(binaryReader); characterId = binaryReader.ReadUInt16(); if (rect == null) { rect = new Rect(); } rect.ReadData(binaryReader); if (matrix == null) { matrix = new Matrix(); } matrix.ReadData(binaryReader); TextRecordCollection.GLYPH_BITS = binaryReader.ReadByte(); TextRecordCollection.ADVANCE_BITS = binaryReader.ReadByte(); if (textRecords == null) { textRecords = new TextRecordCollection(); } else { textRecords.Clear(); } bool endOfRecordsFlag = false; while (!endOfRecordsFlag) { TextRecord textRecord = new TextRecord(); textRecord.ReadData(binaryReader, ref endOfRecordsFlag, (TagCodeEnum)this.TagCode); if (!endOfRecordsFlag) { textRecords.Add(textRecord); } } }
/// <summary> /// Dumps entire text database to CSV. /// </summary> /// <param name="path">Full path to output file.</param> public void DumpToCSV(string path) { if (!isLoaded) { return; } StreamWriter writer = File.CreateText(path); writer.WriteLine("sep=\t"); writer.WriteLine("\"ID\"\t\"DATA\""); for (int i = 0; i < RecordCount; i++) { TextRecord record = GetTextRecordByIndex(i); writer.WriteLine("\"{0}\"\t\"{1}\"", record.id, record.text); } writer.Close(); }
public void TestStore() { TextRecord record = new TextRecord(); record.HorizontalAlignment = (TextRecord.HORIZONTAL_ALIGNMENT_CENTER); record.VerticalAlignment = (TextRecord.VERTICAL_ALIGNMENT_CENTER); record.DisplayMode = (TextRecord.DISPLAY_MODE_TRANSPARENT); record.RgbColor = (0); record.X = (-42); record.Y = (-60); record.Width = (0); record.Height = (0); record.IsAutoColor = (true); record.ShowKey = (false); record.ShowValue = (false); record.IsVertical = (false); record.IsAutoGeneratedText = (true); record.IsGenerated = (true); record.IsAutoLabelDeleted = (false); record.IsAutoBackground = (true); record.Rotation = (TextRecord.ROTATION_NONE); record.ShowCategoryLabelAsPercentage = (false); record.ShowValueAsPercentage = (false); record.ShowBubbleSizes = (false); record.ShowLabel = (false); record.IndexOfColorValue = (short)77; record.Options2 = (short)0x2b50; // record.DataLabelPlacement=((short)0x2b50 ); record.TextRotation = (short)0; byte [] recordBytes = record.Serialize(); Assert.AreEqual(recordBytes.Length - 4, data.Length); for (int i = 0; i < data.Length; i++) { Assert.AreEqual(data[i], recordBytes[i + 4], "At offset " + i); } }
/// <summary> /// Resolves method. /// This method provides the way to update the textrecords glyph indexes /// from Font object contained by the Swf Dictionnary. /// </summary> /// <param name="swf">SWF.</param> public override void Resolve(Swf swf) { IEnumerator records = textRecords.GetEnumerator(); while (records.MoveNext()) { TextRecord textRecord = (TextRecord)records.Current; IEnumerator glyphs = textRecord.GlyphEntries.GetEnumerator(); while (glyphs.MoveNext()) { GlyphEntry glyph = (GlyphEntry)glyphs.Current; if (glyph.GlyphCharacter != '\0') { object font = swf.Dictionary[textRecord.FontId]; if (font != null && font is DefineFont2Tag) { int glyphIndex = ((DefineFont2Tag)font).GlyphShapesTable.GetCharIndex(glyph.GlyphCharacter); glyph.GlyphIndex = (uint)glyphIndex; } //TODO: For DefineFont } } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString.Count >= 1) { string type = Request.QueryString["Type"]; if (type == "Student") { string Paper = Request.QueryString["Paper"]; string Date = Request.QueryString["Date"]; string Id = Request.QueryString["Id"]; string path = Request.QueryString["path"]; PupilDetails pupil1 = new PupilDetails(Id); //construct filename..... string fname = path; //date is 11/03/2012 etc..... fname += Date.Substring(6, 4) + "_"; //for month want to go back to either 1 or 6..... int m = System.Convert.ToInt16(Date.Substring(3, 2)); if (m < 5) { fname += "01_"; } else { fname += "06_"; } fname += Paper.Trim(); fname += ".txt"; //going to open the file Cerval_Library.TextReader tr1 = new Cerval_Library.TextReader(); try { FileStream f1 = new FileStream(fname, FileMode.Open); Cerval_Library.TextRecord tx1 = new TextRecord(); tr1.ReadTextLine(f1, ref tx1); //field 3 onwards are q nos.. string[] questions = new string[50]; for (int i = 3; i < tx1.number_fields + 1; i++) { questions[i] = tx1.field[i]; } tr1.ReadTextLine(f1, ref tx1); //field 3 onwards are max marks.. string[] max = new string[50]; for (int i = 3; i < tx1.number_fields + 1; i++) { max[i] = tx1.field[i]; } //row 3 has descriptions... tr1.ReadTextLine(f1, ref tx1); //field 3 onwards are max marks.. string[] desc = new string[50]; for (int i = 3; i < tx1.number_fields + 1; i++) { desc[i] = tx1.field[i]; } while (tr1.ReadTextLine(f1, ref tx1) == Cerval_Library.TextReader.READ_LINE_STATUS.VALID) { if (tx1.field[1].Trim() == pupil1.m_adno.ToString()) { string s = tx1.field[0];//this is uci s = "<p ><h3>Paper Breakdowns for " + pupil1.m_GivenName + " " + pupil1.m_Surname + " for" + Paper + "</h3><br /><TABLE BORDER class=\"ResultsTbl\" style = \"font-size:small ; \">"; s += "<tr><th>Question</th><th>Max Mark</th><th>Your Mark</th><th>Question Description</th></tr>"; for (int i = 3; i < tx1.number_fields + 1; i++) { s += "<tr><td>" + questions[i] + "</td><td>" + max[i] + "</td><td>" + tx1.field[i] + "</td><td>" + desc[i] + "</td></tr>"; } s += "</table>"; s += "<br/><h3>Please note these are raw not UMS marks.</h3>"; content4.InnerHtml = s; f1.Close(); break; } } f1.Close(); } catch { //assume file not found.... content4.InnerHtml = "<h3> No data found for this paper</h3>"; } } } } }
public void InputTextType_IfContextInputRecordRecordTextIsStartWithSharp_ReturnUnknown() { //Arrange const string stringBeginWithSharp = "#---"; var context = new FileLineRecorderContext(_dhcpUnifiedRecorder); var inputTextRecord = new TextRecord { RecordText = stringBeginWithSharp }; context.InputRecord = inputTextRecord; Exception error = null; //Act // ReSharper disable ExpressionIsAlwaysNull var actual = MethodTestHelper.RunInstanceMethod<DhcpUnifiedRecorder, RecordInputType>("InputTextType", _dhcpUnifiedRecorder, new object[] { context, error }); // ReSharper restore ExpressionIsAlwaysNull //Assert Assert.AreEqual(actual, RecordInputType.Comment); }
public void GetHeaderText_IfContextInputRecordIsTrue_ReturnExpectedString() { //Arrange var context = new FileLineRecorderContext(_exchangeUnifiedRecorder) { InputRecord = null }; var inputTextRecord = new TextRecord { RecordText = "#Fields: ---" }; context.InputRecord = inputTextRecord; //Act var actual = MethodTestHelper.RunInstanceMethod<ExchangeUnifiedRecorder, string>("GetHeaderText", _exchangeUnifiedRecorder, new object[] { context }); //Assert Assert.AreEqual(actual, " ---"); }
private void ParseStep(XmlReader reader, Stack<ElementRecord> elementStack, ref TextRecord textChunk, PhpArray values, PhpArray indices) { string elementName; bool emptyElement; ElementRecord currentElementRecord = null; switch (reader.NodeType) { case XmlNodeType.Element: elementName = reader.Name; emptyElement = reader.IsEmptyElement; PhpArray attributeArray = new PhpArray(); if (_processNamespaces && elementName.IndexOf(":") >= 0) { string localName = elementName.Substring(elementName.IndexOf(":") + 1); elementName = reader.NamespaceURI + _namespaceSeparator + localName; } if (reader.MoveToFirstAttribute()) { do { if (_processNamespaces && reader.Name.StartsWith("xmlns:")) { string namespaceID = reader.Name.Substring(6); string namespaceUri = reader.Value; if (_startNamespaceDeclHandler.Callback != null) _startNamespaceDeclHandler.Invoke(this, namespaceID, namespaceUri); continue; } attributeArray.Add(_enableCaseFolding ? reader.Name.ToUpperInvariant() : reader.Name, reader.Value); } while (reader.MoveToNextAttribute()); } // update current top of stack if (elementStack.Count != 0) { currentElementRecord = elementStack.Peek(); UpdateValueAndIndexArrays(currentElementRecord, ref textChunk, values, indices, true); if (currentElementRecord.State == ElementState.Beginning) currentElementRecord.State = ElementState.Interior; } // push the element into the stack (needed for parse_into_struct) elementStack.Push( new ElementRecord() { ElementName = elementName, Level = reader.Depth, State = ElementState.Beginning, Attributes = (PhpArray)attributeArray.DeepCopy() }); if (_startElementHandler.Callback != null) _startElementHandler.Invoke(this, _enableCaseFolding ? elementName.ToUpperInvariant() : elementName, attributeArray); else if (_defaultHandler.Callback != null) _defaultHandler.Invoke(this, ""); if (emptyElement) goto case XmlNodeType.EndElement; // and end the element immediately (<element/>, XmlNodeType.EndElement will not be called) break; case XmlNodeType.EndElement: elementName = reader.Name; if (_processNamespaces && elementName.IndexOf(":") >= 0) { string localName = elementName.Substring(elementName.IndexOf(":") + 1); elementName = reader.NamespaceURI + _namespaceSeparator + localName; } // pop the top element record currentElementRecord = elementStack.Pop(); UpdateValueAndIndexArrays(currentElementRecord, ref textChunk, values, indices, false); if (_endElementHandler.Callback != null) _endElementHandler.Invoke(this, _enableCaseFolding ? elementName.ToUpperInvariant() : elementName); else if (_defaultHandler.Callback != null) _defaultHandler.Invoke(this, ""); break; case XmlNodeType.Whitespace: case XmlNodeType.Text: case XmlNodeType.CDATA: if (textChunk == null) { textChunk = new TextRecord() { Text = reader.Value }; } else { textChunk.Text += reader.Value; } if (_characterDataHandler.Callback != null) _characterDataHandler.Invoke(this, reader.Value); else if (_defaultHandler.Callback != null) _defaultHandler.Invoke(this, reader.Value); break; case XmlNodeType.ProcessingInstruction: if (_processingInstructionHandler.Callback != null) _processingInstructionHandler.Invoke(this, reader.Name, reader.Value); else if (_defaultHandler.Callback != null) _defaultHandler.Invoke(this, string.Empty); break; } }
void DisassembleRecord(BamlContext ctx, TextRecord record) { WriteText("Value="); WriteString(record.Value); }
public void InputTextType_IfContextInputRecordStartsWithSharpFields_ReturnHeader() { //Arrange var context = new FileLineRecorderContext(_exchangeUnifiedRecorder); var inputTextRecord = new TextRecord { RecordText = "#Fields: " }; context.InputRecord = inputTextRecord; Exception error = null; //Act // ReSharper disable ExpressionIsAlwaysNull var actual = MethodTestHelper.RunInstanceMethod<ExchangeUnifiedRecorder, RecordInputType>("InputTextType", _exchangeUnifiedRecorder, new object[] { context, error }); // ReSharper restore ExpressionIsAlwaysNull //Assert Assert.AreEqual(actual, RecordInputType.Header); }
public void InputTextType_IfContextInputRecordRecordTextIsNotNull_ReturnReocrd() { //Arrange var context = new FileLineRecorderContext(_trendMicroUrlUnifiedRecorder); var inputTextRecord = new TextRecord { RecordText = String.Empty }; context.InputRecord = inputTextRecord; Exception error = null; //Act // ReSharper disable ExpressionIsAlwaysNull var actual = MethodTestHelper.RunInstanceMethod<TrendMicroUrlUnifiedRecorder, RecordInputType>("InputTextType", _trendMicroUrlUnifiedRecorder, new object[] { context, error }); // ReSharper restore ExpressionIsAlwaysNull //Assert Assert.AreEqual(actual, RecordInputType.Record); }
public TerminalRecorderContext(RecorderBase recorder) : base(recorder) { InputRecord = new TextRecord(); ReadTimeout = 60000; }
private void WalkBaml(ResourcePart part) { Dictionary <string, string> namespaces = new Dictionary <string, string>(); foreach (BamlRecord record in part.Baml) { if (record.Type == BamlRecordType.TypeInfo) { TypeInfoRecord typeInfo = (TypeInfoRecord)record; TypeDefinition type; if (typesMap.TryGetValue(typeInfo.TypeFullName, out type)) { AddUsedType(type); } continue; } if (record.Type == BamlRecordType.XmlnsProperty) { XmlnsPropertyRecord ns = (XmlnsPropertyRecord)record; const string CLR_NAMESPACE = "clr-namespace:"; if (ns.XmlNamespace.StartsWith(CLR_NAMESPACE)) { namespaces.Add(ns.Prefix, ns.XmlNamespace.Substring(CLR_NAMESPACE.Length)); } continue; } if (record.Type == BamlRecordType.Text) { TextRecord textRecord = (TextRecord)record; int index = textRecord.Value.IndexOf(':'); if (index == -1) { continue; // not ns reference } string name; if (!namespaces.TryGetValue(textRecord.Value.Substring(0, index), out name)) { continue; } name += "." + textRecord.Value.Substring(index + 1); TypeDefinition type; // type as string? if (typesMap.TryGetValue(name, out type)) { AddUsedType(type); continue; } index = name.LastIndexOf(".", StringComparison.InvariantCulture); // member? if (typesMap.TryGetValue(name.Substring(0, index), out type)) { AddUsedType(type); } continue; } if (record.Type == BamlRecordType.PropertyWithConverter) { PropertyWithConverterRecord propertyInfo = (PropertyWithConverterRecord)record; string resourceName = propertyInfo.Value; if (resourceName.StartsWith(wpfPathPrefix)) { resourceName = resourceName.Substring(wpfPathPrefix.Length, resourceName.Length - wpfPathPrefix.Length); } if (resourceName.EndsWith(".xaml", StringComparison.InvariantCultureIgnoreCase)) { resourceName = resourceName.Substring(0, resourceName.Length - 4) + "baml"; } resourceName = resourceName.ToLower(); ResourcePart resourcePart; if (!wpfRootParts.TryGetValue(resourceName, out resourcePart)) { continue; } if (resourcePart.Baml != null) { AddUsedBaml(resourcePart); } else { Log($"WPF resource used: {resourceName}"); usedWpfResources.Add(resourceName); } } } }
protected void ProcessYearFile(int Key_stage) { string s = "DataUpload_YearFile_" + DateTime.Now.ToLongTimeString() + ".txt"; s = s.Replace(":", "-"); string path = Server.MapPath(@"../App_Data/") + s; //String username = System.Security.Principal.WindowsIdentity.GetCurrent().Name; FileUpload_picker.SaveAs(path); Cerval_Library.TextReader text1 = new Cerval_Library.TextReader(); Cerval_Library.TextRecord t = new TextRecord(); FileStream f = new FileStream(path, FileMode.Open); string s2 = ""; string[] Course_Name = new string[20]; string[] Course_ID = new string[20]; text1.ReadTextLine(f, ref t);//header row s = t.field[2]; int n = t.number_fields; SimplePupil pupil1 = new SimplePupil(); if ((s != "Adno") || (n < 4)) { f.Close(); return; } CourseList cl1 = new CourseList(Key_stage); for (int i = 3; i < n; i++) { Course_Name[i] = t.field[i]; foreach (Course c in cl1._courses) { if (c.CourseCode == Course_Name[i]) { Course_ID[i] = c._CourseID.ToString(); } } } while (text1.ReadTextLine(f, ref t) == Cerval_Library.TextReader.READ_LINE_STATUS.VALID) { //if all goes well col 2 is adno.... s = t.field[2]; for (int i = 3; i < n; i++) { s2 = t.field[i];//result try { pupil1.Load(System.Convert.ToInt32(s)); try { int r = System.Convert.ToInt32(s2); if ((r > 0) && (r < 101)) { SaveResult(pupil1.m_StudentId.ToString(), s2, Course_ID[i]); } } catch { } } catch { } } } f.Close(); }
public void TestFixtureTearDown() { _textRecord = null; }
public void TestFixtureSetup() { _textRecord = new TextRecord(); }
protected void Button1_Click(object sender, EventArgs e) { //file has Board short name/optioncode/grade/mark if (!FileUpload1.HasFile) { return; } Cerval_Library.TextReader TxtRd1 = new Cerval_Library.TextReader(); TextRecord t = new TextRecord(); int l = 0; int n = 0; string s1 = ""; char ct = (char)0x09; int n_Board = 0; int n_OptionCode = 0; int n_Grade = 0; int n_Mark = 0; bool f_Board = false; bool f_OptionCode = false; bool f_Grade = false; bool f_Mark = false; while (TxtRd1.ReadTextLine(FileUpload1.FileContent, ref t) == Cerval_Library.TextReader.READ_LINE_STATUS.VALID) { l = s1.Length; for (int i = 0; i <= t.number_fields; i++) { s1 += t.field[i] + ct; } if (s1.Length > l) { s1 += Environment.NewLine; } if (n == 0) { //going to look for our columns: for (int i = 0; i <= t.number_fields; i++) { switch (t.field[i]) { case "Board": n_Board = i; f_Board = true; break; case "Option": n_OptionCode = i; f_OptionCode = true; break; case "Mark": n_Mark = i; f_Mark = true; break; case "Grade": n_Grade = i; f_Grade = true; break; default: break; } } // so do we have all the required columns?? if (!(f_Board && f_OptionCode && f_Grade && f_Mark)) { Label_Text.Text = "Can't recognise the format of this file. "; if (!f_Board) { Label_Text.Text += "No Board Column"; } if (!f_OptionCode) { Label_Text.Text += "No Option Column"; } if (!f_Mark) { Label_Text.Text += "No Mark Column"; } if (!f_Grade) { Label_Text.Text += "No Grade Column"; } return; } else { Label_Text.Text = "File Format Fine: "; } } } //so process the file... string s2 = ""; char[] ct1 = new char[1]; ct1[0] = (char)0x09; string[] fields = new string[20]; using (StringReader sr = new StringReader(s1)) { string firstline = sr.ReadLine(); string line; while ((line = sr.ReadLine()) != null) { fields = line.Split(ct1); bool found = false; Exam_Board eb1 = new Exam_Board(); eb1.Load(fields[n_Board]); ExamOption eo1 = new ExamOption(); if (eo1.Load(fields[n_OptionCode], SeasonCode.ToString(), YearCode.ToString(), eb1.m_ExamBoardId)) { //valid option cod ExamTQMBoundaryList l1 = new ExamTQMBoundaryList(); l1.LoadList(eo1.m_OptionID, YearCode.ToString(), SeasonCode.ToString()); foreach (ExamTQMBoundary b in l1.m_list) { if (b.Grade == fields[n_Grade]) { b.Mark = Convert.ToInt32(fields[n_Mark]); b.Save(); found = true; s2 += eb1.m_OrganisationFriendlyName + ct + eo1.m_OptionCode + ct + eo1.m_OptionTitle + ct + b.Grade + ct + b.Mark + ct + "Updated" + System.Environment.NewLine; } } if (!found) { ExamTQMBoundary etqm1 = new ExamTQMBoundary(); etqm1.OptionId = eo1.m_OptionID; etqm1.Mark = Convert.ToInt32(fields[n_Mark]); etqm1.Grade = fields[n_Grade]; etqm1.OptionCode = eo1.m_OptionCode; etqm1.OptionTitle = eo1.m_OptionTitle; etqm1.Season = SeasonCode.ToString(); etqm1.Year = YearCode.ToString(); etqm1.Version = 22; etqm1.Save(); s2 += eb1.m_OrganisationFriendlyName + ct + eo1.m_OptionCode + ct + eo1.m_OptionTitle + ct + etqm1.Grade + ct + etqm1.Mark + ct + "New Entry" + System.Environment.NewLine; } } } Label_Text.Text = " Completed... saved as below:"; TextBox1.Text = s2; } }
public void InputTextType_IfContextInputRecordLenthIsZero_ReturnComment() { //Arrange var context = new FileLineRecorderContext(_netscalerUnifiedRecorder); var inputTextRecord = new TextRecord { RecordText = String.Empty }; context.InputRecord = inputTextRecord; Exception error = null; //Act // ReSharper disable ExpressionIsAlwaysNull var actual = MethodTestHelper.RunInstanceMethod<NetscalerUnifiedRecorder, RecordInputType>("InputTextType", _netscalerUnifiedRecorder, new object[] { context, error }); // ReSharper restore ExpressionIsAlwaysNull //Assert Assert.AreEqual(actual, RecordInputType.Comment); }
/// <summary> /// Gets TextRecord data by index. /// Special formatting characters are parsed into [0x00] format. /// </summary> public TextRecord GetTextRecordByIndex(int index) { TextRecord textRecord = new TextRecord(); if (isLoaded) { textRecord.id = header.TextRecordHeaders[index].TextRecordId; textRecord.text = ParseBytesToString(GetBytesByIndex(index)); } return textRecord; }
protected void Button1_Click(object sender, EventArgs e) { using (WebClient client = new WebClient()) { client.Headers.Add("user-agent", "Mozilla / 5.0(Windows NT 10.0; WOW64; Trident / 7.0; rv: 11.0) like Gecko"); //client.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); client.Headers.Add("Authorization", "SNAeoB88JTmAXfNTAfpR"); try { string response = client.DownloadString("https://sandbox.apply-for-teacher-training.service.gov.uk/api/v1"); } catch (Exception e2) { string s5455 = e2.ToString(); s5455 = e2.InnerException.ToString(); } } return; ISAMS_ExamStudentAccessList list44 = new ISAMS_ExamStudentAccessList(); list44.load(18); ISAMS_ExamSeatingPlan_List list33 = new ISAMS_ExamSeatingPlan_List(); list33.Load(18); // ISAMS_Set_PTOList Leena = new ISAMS_Set_PTOList(); // Leena.load(12); return; ExamComponentResultList ecrl1 = new ExamComponentResultList(); ecrl1.Load_OptionStudent(new Guid("d22c0f3e-38ff-4a81-9c00-dc7892548f68"), new Guid("fbbd073f-b4cd-4fb1-a12f-e3a755e7cc63")); string s = ""; foreach (ExamComponentResult r in ecrl1.m_list) { s = r.ComponentStatus; } Response.Redirect("../studentinformation/ComponentResults.aspx?StudentId=fbbd073f-b4cd-4fb1-a12f-e3a755e7cc63 &OptionId=d22c0f3e-38ff-4a81-9c00-dc7892548f68"); TT_compare(); return; //call from button.. RegistrationsList r1 = new RegistrationsList(); r1.Get_Recent_Registrations("6368"); foreach (Registrations r in r1.Registrations) { TextBox1.Text += r.m_date.ToString() + " " + r.m_staff + Environment.NewLine; } return; List <string> test3 = Get_Registrations("6368"); foreach (string s4 in test3) { TextBox1.Text += s4 + Environment.NewLine; } return; IntPtr token = IntPtr.Zero; string adno = "6368"; bool isSuccess = LogonUser("test-staff", "challoners", "123Password", LOGON32_LOGON_NEW_CREDENTIALS, LOGON32_PROVIDER_DEFAULT, ref token); using (WindowsImpersonationContext person = new WindowsIdentity(token).Impersonate()) { string path1 = @"\\registration.challoners.net\STEARsoft\Reg\data\cc\testfile.txt"; //StreamReader sr1 = new StreamReader(path1); //string s = sr1.ReadLine(); //Label4.Text = s; //s = s; int i = 0; s = ""; int imax = 0; string sfile = ""; string[] fileEntries = Directory.GetFiles(@"\\registration.challoners.net\STEARsoft\Reg\data", "attend*.csv"); foreach (string fileName in fileEntries) { //find last one! s = fileName.Substring(fileName.IndexOf("log")); try { s = s.Substring(3, 2); i = System.Convert.ToInt32(s); if (i > imax) { imax = i; sfile = fileName; } } catch { try { s = s.Substring(3, 3); i = System.Convert.ToInt32(s); if (i > imax) { imax = i; sfile = fileName; } } catch { } } } if (imax > 0) { string s1 = ""; Label4.Text = sfile; StreamReader sr1 = new StreamReader(sfile); while (!sr1.EndOfStream) { s = sr1.ReadLine(); string[] fred = s.Split((char)(',')); if (fred[4] == adno) { s1 = fred[11]; } } } person.Undo(); } return; //adno first name surname StudentId CourseId StaffId CommentType poliyID text Cerval_Library.TextReader text1 = new Cerval_Library.TextReader(); Cerval_Library.TextRecord t = new TextRecord(); string path = Server.MapPath(@"../App_Data/test.txt"); FileStream f = new FileStream(path, FileMode.Open); text1.ReadTextLine(f, ref t);//header row while (text1.ReadTextLine(f, ref t) == Cerval_Library.TextReader.READ_LINE_STATUS.VALID) { ReportComment r = new ReportComment(); r.m_studentId = new Guid(t.field[3]); r.m_courseId = new Guid(t.field[4]); r.m_staffId = new Guid(t.field[5]); r.m_commentType = System.Convert.ToInt32(t.field[6]); r.m_dateCreated = DateTime.Now; r.m_dateModified = r.m_dateCreated; r.m_collectionOutputPolicyId = new Guid(t.field[7]); r.m_content = t.field[8]; r.Save(); } f.Close(); }
/// <summary> /// Parses this object out of a stream /// </summary> protected override void Parse() { BinaryReader br = new BinaryReader(this._dataStream); this._characterID = br.ReadUInt16(); this._textBounds.Parse(this._dataStream); this._textMatrix.Parse(this._dataStream); this._glyphBits = br.ReadByte(); this._advancedBits = br.ReadByte(); byte temp = 0; TextRecord tempRecord = null; while (0 != (temp = br.ReadByte())) { tempRecord = new TextRecord(this._SwfVersion); tempRecord.Parse(this._dataStream, this._tag.TagType, this._glyphBits, this._advancedBits, temp); this.TextRecords.Add(tempRecord); } }
public void OnBeforeSetData_IfContextNotNull_ReturnNextInstructionDo() { //Arrange RecorderContext context = new FileLineRecorderContext(_windowsSharelog); context.Record.Datetime = "2014-09-15 14:12:53"; const string text = "Lorem ipsum dolor sit amet, consectetur adipisicing elit"; var inputTextRecord = new TextRecord { RecordText = text }; context.InputRecord = inputTextRecord; //Act // ReSharper disable ExpressionIsAlwaysNull var actual = MethodTestHelper.RunInstanceMethod<WindowsShareLogUnifiedRecorder, NextInstruction>("OnBeforeSetData", _windowsSharelog, new object[] { context }); // ReSharper restore ExpressionIsAlwaysNull //Assert Assert.AreEqual(actual, NextInstruction.Do); }
public void GetHeaderText_IfContextInputRecordLengthIsSmallerThanEigth_ArgumentOutOfRangeException() { //Arrange var context = new FileLineRecorderContext(_exchangeUnifiedRecorder) { InputRecord = null }; var inputTextRecord = new TextRecord { RecordText = "field" }; context.InputRecord = inputTextRecord; //Act // ReSharper disable ExpressionIsAlwaysNull MethodTestHelper.RunInstanceMethod<ExchangeUnifiedRecorder, string>("GetHeaderText", _exchangeUnifiedRecorder, new object[] { context }); // ReSharper restore ExpressionIsAlwaysNull //Assert //Unhandled ArgumentOutOfRangeException }
public void InputTextType_IfContextInputRecordRecordTextIsNull_ReturnComment() { //Arrange var context = new FileLineRecorderContext(_windowsSharelog); var inputTextRecord = new TextRecord { RecordText = null }; context.InputRecord = inputTextRecord; Exception error = null; //Act // ReSharper disable ExpressionIsAlwaysNull var actual = MethodTestHelper.RunInstanceMethod<WindowsShareLogUnifiedRecorder, RecordInputType>("InputTextType", _windowsSharelog, new object[] { context, error }); // ReSharper restore ExpressionIsAlwaysNull //Assert Assert.AreEqual(actual, RecordInputType.Comment); }
public BAMLConverterTypeReference(BAMLAnalyzer.XmlNsContext xmlnsCtx, TypeSig sig, TextRecord rec) { this.xmlnsCtx = xmlnsCtx; this.sig = sig; textRec = rec; }
public void InputTextType_IfContextInputRecordRecordTextIsNull_ReturnUnknown() { //Arrange var context = new FileLineRecorderContext(_paloAltoUrlUnifiedRecorder); var inputTextRecord = new TextRecord { RecordText = null }; context.InputRecord = inputTextRecord; Exception error = null; //Act // ReSharper disable ExpressionIsAlwaysNull var actual = MethodTestHelper.RunInstanceMethod<PaloAltoUrlUnifiedRecorder, RecordInputType>("InputTextType", _paloAltoUrlUnifiedRecorder, new object[] { context, error }); // ReSharper restore ExpressionIsAlwaysNull //Assert Assert.AreEqual(actual, RecordInputType.Unknown); }
private void UpdateValueAndIndexArrays(ElementRecord elementRecord, ref TextRecord textRecord, PhpArray values, PhpArray indices, bool middle) { // if we have no valid data in the middle, just end if (middle && textRecord == null) return; if (!middle && elementRecord.State == ElementState.Interior) UpdateValueAndIndexArrays(elementRecord, ref textRecord, values, indices, true); if (values != null) { PhpArray arrayRecord = new PhpArray(); arrayRecord.Add("tag", elementRecord.ElementName); arrayRecord.Add("level", elementRecord.Level); if (elementRecord.State == ElementState.Beginning) arrayRecord.Add("type", middle ? "open" : "complete"); else arrayRecord.Add("type", middle ? "cdata" : "close"); if (textRecord != null) arrayRecord.Add("value", textRecord.Text); if (elementRecord.State == ElementState.Beginning && elementRecord.Attributes.Count != 0) arrayRecord.Add("attributes", elementRecord.Attributes); values.Add(arrayRecord); if (indices != null) { PhpArray elementIndices; if (!indices.ContainsKey(elementRecord.ElementName)) { elementIndices = new PhpArray(); indices.Add(elementRecord.ElementName, elementIndices); } else elementIndices = (PhpArray)indices[elementRecord.ElementName]; // add the max index (last inserted value) elementIndices.Add(values.MaxIntegerKey); } } textRecord = null; }
private bool ParseInternal(DTypeDesc caller, NamingContext context, string xml, PhpArray values, PhpArray indices) { StringReader stringReader = new StringReader(xml); XmlTextReader reader = new XmlTextReader(stringReader); Stack <ElementRecord> elementStack = new Stack <ElementRecord>(); TextRecord textChunk = null; _startElementHandler.BindOrBiteMyLegsOff(caller, context); _endElementHandler.BindOrBiteMyLegsOff(caller, context); _defaultHandler.BindOrBiteMyLegsOff(caller, context); _startNamespaceDeclHandler.BindOrBiteMyLegsOff(caller, context); _endNamespaceDeclHandler.BindOrBiteMyLegsOff(caller, context); _characterDataHandler.BindOrBiteMyLegsOff(caller, context); _processingInstructionHandler.BindOrBiteMyLegsOff(caller, context); while (reader.ReadState == ReadState.Initial || reader.ReadState == ReadState.Interactive) { try { reader.Read(); } catch (XmlException) { _lastLineNumber = reader.LineNumber; _lastColumnNumber = reader.LinePosition; _lastByteIndex = -1; _errorCode = (int)XmlParserError.XML_ERROR_GENERIC; return(false); } //these are usually required _lastLineNumber = reader.LineNumber; _lastColumnNumber = reader.LinePosition; // we cannot do this - we could if we had underlying stream, but that would require // encoding string -> byte[] which is pointless switch (reader.ReadState) { case ReadState.Error: //report error break; case ReadState.EndOfFile: //end of file break; case ReadState.Closed: case ReadState.Initial: //nonsense Debug.Fail(); break; case ReadState.Interactive: //debug step, that prints out the current state of the parser (pretty printed) //Debug_ParseStep(reader); ParseStep(reader, elementStack, ref textChunk, values, indices); break; } if (reader.ReadState == ReadState.Error || reader.ReadState == ReadState.EndOfFile || reader.ReadState == ReadState.Closed) { break; } } return(true); }
private void ParseStep(XmlReader reader, Stack <ElementRecord> elementStack, ref TextRecord textChunk, PhpArray values, PhpArray indices) { string elementName; bool emptyElement; ElementRecord currentElementRecord = null; switch (reader.NodeType) { case XmlNodeType.Element: elementName = reader.Name; emptyElement = reader.IsEmptyElement; PhpArray attributeArray = new PhpArray(); if (_processNamespaces && elementName.IndexOf(":") >= 0) { string localName = elementName.Substring(elementName.IndexOf(":") + 1); elementName = reader.NamespaceURI + _namespaceSeparator + localName; } if (reader.MoveToFirstAttribute()) { do { if (_processNamespaces && reader.Name.StartsWith("xmlns:")) { string namespaceID = reader.Name.Substring(6); string namespaceUri = reader.Value; if (_startNamespaceDeclHandler.Callback != null) { _startNamespaceDeclHandler.Invoke(this, namespaceID, namespaceUri); } continue; } attributeArray.Add(_enableCaseFolding ? reader.Name.ToUpperInvariant() : reader.Name, reader.Value); }while (reader.MoveToNextAttribute()); } // update current top of stack if (elementStack.Count != 0) { currentElementRecord = elementStack.Peek(); UpdateValueAndIndexArrays(currentElementRecord, ref textChunk, values, indices, true); if (currentElementRecord.State == ElementState.Beginning) { currentElementRecord.State = ElementState.Interior; } } // push the element into the stack (needed for parse_into_struct) elementStack.Push( new ElementRecord() { ElementName = elementName, Level = reader.Depth, State = ElementState.Beginning, Attributes = (PhpArray)attributeArray.DeepCopy() }); if (_startElementHandler.Callback != null) { _startElementHandler.Invoke(this, _enableCaseFolding ? elementName.ToUpperInvariant() : elementName, attributeArray); } else if (_defaultHandler.Callback != null) { _defaultHandler.Invoke(this, ""); } if (emptyElement) { goto case XmlNodeType.EndElement; // and end the element immediately (<element/>, XmlNodeType.EndElement will not be called) } break; case XmlNodeType.EndElement: elementName = reader.Name; if (_processNamespaces && elementName.IndexOf(":") >= 0) { string localName = elementName.Substring(elementName.IndexOf(":") + 1); elementName = reader.NamespaceURI + _namespaceSeparator + localName; } // pop the top element record currentElementRecord = elementStack.Pop(); UpdateValueAndIndexArrays(currentElementRecord, ref textChunk, values, indices, false); if (_endElementHandler.Callback != null) { _endElementHandler.Invoke(this, _enableCaseFolding ? elementName.ToUpperInvariant() : elementName); } else if (_defaultHandler.Callback != null) { _defaultHandler.Invoke(this, ""); } break; case XmlNodeType.Whitespace: case XmlNodeType.Text: case XmlNodeType.CDATA: if (textChunk == null) { textChunk = new TextRecord() { Text = reader.Value }; } else { textChunk.Text += reader.Value; } if (_characterDataHandler.Callback != null) { _characterDataHandler.Invoke(this, reader.Value); } else if (_defaultHandler.Callback != null) { _defaultHandler.Invoke(this, reader.Value); } break; case XmlNodeType.ProcessingInstruction: if (_processingInstructionHandler.Callback != null) { _processingInstructionHandler.Invoke(this, reader.Name, reader.Value); } else if (_defaultHandler.Callback != null) { _defaultHandler.Invoke(this, string.Empty); } break; } }
public void InputTextType_IfContextInputRecordRecordTextIsRecordLikeString_ReturnRecord() { //Arrange const string text = "Lorem ipsum dolor sit amet, consectetur adipisicing elit"; var context = new FileLineRecorderContext(_mssqlErrorUnifiedRecorder); var inputTextRecord = new TextRecord { RecordText = text }; context.InputRecord = inputTextRecord; Exception error = null; //Act // ReSharper disable ExpressionIsAlwaysNull var actual = MethodTestHelper.RunInstanceMethod<MssqlErrorUnifiedRecorder, RecordInputType>("InputTextType", _mssqlErrorUnifiedRecorder, new object[] { context, error }); // ReSharper restore ExpressionIsAlwaysNull //Assert Assert.AreEqual(actual, RecordInputType.Record); }
public LinuxHistoryContext(RecorderBase recorder) : base(recorder) { InputRecord = new TextRecord(); }
protected void Button_FileUpload_Click(object sender, EventArgs e) { SimplePupil pupil1 = new SimplePupil(); if (FileUpload_picker.FileName.ToUpper().Contains("WHOLEYEAR"))//should be WholeYear10 or etc { try { string s1 = FileUpload_picker.FileName.Substring(9); if (s1.StartsWith("1")) { s1 = s1.Substring(0, 2); } else { s1 = s1.Substring(0, 1); } int year = System.Convert.ToInt32(s1); int k = 4; if (year < 10) { k = 3; } if (year > 11) { k = 5; } //need to set up the date for result string s2 = ""; DateTime SetListDate = new DateTime(); Utility u = new Utility(); TextBox2.Text = u.GetResultDate(s1, ref s2, ref SetListDate).ToShortDateString(); ProcessYearFile(k); return; } catch { } } string s = "DataUpload_" + TextBox1.Text + "_" + DateTime.Now.ToLongTimeString() + ".txt"; s = s.Replace(":", "-"); string path = Server.MapPath(@"../App_Data/") + s; //String username = System.Security.Principal.WindowsIdentity.GetCurrent().Name; FileUpload_picker.SaveAs(path); Stream mystream = FileUpload_picker.FileContent; byte[] buffer = new byte[mystream.Length]; mystream.Read(buffer, 0, (int)mystream.Length); Cerval_Library.TextReader text1 = new Cerval_Library.TextReader(); Cerval_Library.TextRecord t = new TextRecord(); FileStream f = new FileStream(path, FileMode.Open); while (text1.ReadTextLine(f, ref t) == Cerval_Library.TextReader.READ_LINE_STATUS.VALID) { //if all goes well col 2 is adno.... s = t.field[2]; try { pupil1.Load(System.Convert.ToInt32(s)); TextBox tst1 = (TextBox)content0.FindControl(pupil1.m_StudentId.ToString()); if (tst1 != null) { //so we have the adno of a student in the list... s = t.field[3];//and a grade try { int r = System.Convert.ToInt32(s); if ((r > 0) && (r < 101)) { SaveResult(pupil1.m_StudentId.ToString(), s, TextBox3.Text); } } catch { } } } catch { } } f.Close(); //File.Delete(path); Table1.Controls.Clear(); AddControls(true); }