public static XElement ToXml(ZoneRecord zoneRecord) { var res = new XElement("ZoneArray", new XAttribute("zoneX", CommonFormatter.Format(zoneRecord.ZoneX)), new XAttribute("zoneY", CommonFormatter.Format(zoneRecord.ZoneY)) ); if (zoneRecord.Reserved != 0) { res.Add(new XAttribute("reserved", zoneRecord.Reserved)); } var xZones = new XElement("zones"); foreach (var data in zoneRecord.Data) { xZones.Add(XZoneData.ToXml(data)); } res.Add(xZones); if (zoneRecord.Reserved > 0) { res.Add(new XAttribute("reserved", zoneRecord.Reserved)); } return(res); }
SwfTagBase ISwfTagVisitor <ISwfStreamReader, SwfTagBase> .Visit(DefineFontAlignZonesTag tag, ISwfStreamReader reader) { tag.FontID = reader.ReadUInt16(); tag.CsmTableHint = (CSMTableHint)reader.ReadUnsignedBits(2); tag.Reserved = (byte)reader.ReadUnsignedBits(6); while (!reader.IsEOF) { var zone = new ZoneRecord(); int count = reader.ReadByte(); for (var j = 0; j < count; j++) { var zoneData = new ZoneData { Position = reader.ReadShortFloat(), Size = reader.ReadShortFloat() }; zone.Data.Add(zoneData); } zone.Reserved = (byte)reader.ReadUnsignedBits(6); zone.ZoneX = reader.ReadBit(); zone.ZoneY = reader.ReadBit(); tag.ZoneTable.Add(zone); } return(tag); }
public ZoneCoeff(ZoneNumber zoneNumber, ZoneRecord zoneRecord, decimal value, DateTime startDate) { ZoneNumber = zoneNumber; ZoneRecord = zoneRecord; Value = value; StartDate = startDate; }
public void UpdateZoneRecord(long accountId, string zoneId, long recordId, string expectedUrl) { var client = new MockDnsimpleClient(UpdateZoneRecordFixture); var data = new ZoneRecord { Name = "", Content = "mxb.example.com", Ttl = 3600, Priority = 20 }; var record = client.Zones.UpdateRecord(accountId, zoneId, recordId, data) .Data; Assert.Multiple(() => { Assert.AreEqual(recordId, record.Id); Assert.AreEqual(zoneId, record.ZoneId); Assert.IsNull(record.ParentId); Assert.IsEmpty(record.Name); Assert.AreEqual("mxb.example.com", record.Content); Assert.AreEqual(3600, record.Ttl); Assert.AreEqual(20, record.Priority); Assert.AreEqual(ZoneRecordType.MX, record.Type); Assert.Contains("global", record.Regions); Assert.IsFalse(record.SystemRecord); Assert.AreEqual(expectedUrl, client.RequestSentTo()); Assert.AreEqual(Method.PATCH, client.HttpMethodUsed()); }); }
public void CreateZoneRecord(string fixture, long accountId, string name, string expectedUrl) { var client = new MockDnsimpleClient(fixture); var record = new ZoneRecord { Name = name, Type = ZoneRecordType.A, Content = "127.0.0.1", Ttl = 600, }; var created = client.Zones .CreateRecord(accountId, "example.com", record) .Data; Assert.Multiple(() => { Assert.AreEqual(1, created.Id); Assert.AreEqual("example.com", created.ZoneId); Assert.AreEqual(name, created.Name); Assert.AreEqual("127.0.0.1", created.Content); Assert.AreEqual(600, created.Ttl); Assert.AreEqual(ZoneRecordType.A, created.Type); Assert.Contains("global", created.Regions); Assert.AreEqual(Method.POST, client.HttpMethodUsed()); Assert.AreEqual(expectedUrl, client.RequestSentTo()); }); }
public void should_match_record(ZoneRecord record, int id, string name, string data, string aux, RecordType type, int ttl, int zoneId) { record.RecordType.ShouldEqual(type); record.Aux.ShouldEqual(aux); record.Data.ShouldEqual(data); record.Name.ShouldEqual(name); record.Id.ShouldEqual(id); record.Ttl.ShouldEqual(ttl); record.ZoneId.ShouldEqual(zoneId); }
private void GetZoneInfo() { HttpClient client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, string.Format(GetZoneInfoUrl, _authId, _authPassword, _domainName)); var result = client.SendAsync(request).GetAwaiter().GetResult(); if (result.IsSuccessStatusCode) { var content = result.Content.ReadAsStringAsync().GetAwaiter().GetResult(); ZoneRecord resultObj = JsonConvert.DeserializeObject <ZoneRecord>(content); Debug.WriteLine(string.Format("Zone is {0}, type is {1}", resultObj.Name, resultObj.Type)); } else { throw new Exception($"Could not get DNS records for zone {_domainName}. Result: {result.StatusCode} - {result.Content.ReadAsStringAsync().GetAwaiter().GetResult()}"); } }
public Invoice(Guid dsoId, int periodId, decimal incomingBalance, DateTime fromDate, DateTime toDate, string counterSerialNumber, Tariff tariff, ZoneRecord zoneRecord, Usage usageT1, Usage usageT2, Usage usageT3, AccountingPointExemption exemption = null, InvoiceType type = InvoiceType.Common, string note = null) { DsoConsumptionId = dsoId; IncomingBalance = incomingBalance; PeriodId = periodId; FromDate = fromDate; ToDate = toDate; UsageT1 = usageT1; UsageT2 = usageT2; UsageT3 = usageT3; Tariff = tariff; Note = note; Type = type; ExemptionCoeff = (exemption?.Category.Coeff ?? 0) > 1 ? (exemption?.Category.Coeff ?? 0) / 100 : (exemption?.Category.Coeff ?? 0); CounterSerialNumber = counterSerialNumber; _exemption = exemption; ZoneRecord = zoneRecord; }
public static ZoneRecord FromXml(XElement xZoneRecord) { var zoneArray = new ZoneRecord(); var xZoneX = xZoneRecord.Attribute("zoneX"); var xZoneY = xZoneRecord.Attribute("zoneY"); var xReserved = xZoneRecord.Attribute("reserved"); zoneArray.ZoneX = CommonFormatter.ParseBool(xZoneX.Value); zoneArray.ZoneY = CommonFormatter.ParseBool(xZoneY.Value); if (xReserved != null) { zoneArray.Reserved = byte.Parse(xReserved.Value); } foreach (var xZoneData in xZoneRecord.RequiredElement("zones").Elements()) { zoneArray.Data.Add(XZoneData.FromXml(xZoneData)); } return(zoneArray); }
/// <summary> /// Parses this object out of a stream /// </summary> protected override void Parse() { BinaryReader br = new BinaryReader(this._dataStream); this._fontID = br.ReadUInt16(); try { AbstractTagHandler handler = this._SourceFileReference.GetCharacterByID(this._fontID); if (handler.Tag.TagType.Equals(TagTypes.DefineFont)) { DefineFont font = (DefineFont)handler; this._numberOfGlyphs = font.NumberOfGlyphs; } else if (handler.Tag.TagType.Equals(TagTypes.DefineFont2)) { DefineFont2 font = (DefineFont2)handler; this._numberOfGlyphs = font.NumberOfGlyphs; } else if (handler.Tag.TagType.Equals(TagTypes.DefineFont3)) { DefineFont3 font = (DefineFont3)handler; this._numberOfGlyphs = font.NumberOfGlyphs; } else { throw new SwfFormatException("The character that matches the font ID(" + this._fontID + ") is no font!"); } } catch (Exception e) { Log.Error(this, e.Message); throw e; } BitStream bits = new BitStream(this._dataStream); this._CSMTableHint = (byte)bits.GetBits(2); byte reserved = (byte)bits.GetBits(6); this._ZoneTable = new ZoneRecord[this._numberOfGlyphs]; for (int i = 0; i < this._numberOfGlyphs; i++) { ZoneRecord zr = new ZoneRecord(this._SwfVersion); zr.Parse(this._dataStream); this._ZoneTable[i] = zr; } }