public void SetVisibleItems(HeaderType type, ICollection <TItem> visibleItems) { Matrix.SetVisibleItems(type, visibleItems); matrixHeight = Matrix.HeaderRows.Count; matrixWidth = Matrix.HeaderColumns.Count; bool changedCoords = false; if (currentCell.X > matrixHeight) { currentCell = new Coords(matrixHeight - 1, currentCell.Y); changedCoords = true; } if (currentCell.Y > matrixWidth) { currentCell = new Coords(currentCell.X, matrixWidth - 1); changedCoords = true; } if (changedCoords) { SetHoveredCell(); } if (matrixHeight >= 0 && matrixWidth >= 0) { InvalidateVisual(); } }
/// <summary> /// Sets the header. /// </summary> /// <param name="header"> /// The header. /// </param> /// <param name="sdmxObjects"> /// The beans. /// </param> public static void SetHeader(HeaderType header, ISdmxObjects sdmxObjects) { header.ID = "IDREF" + refNumber; refNumber++; header.Test = false; header.Prepared = DateTime.Now; var sender = new PartyType(); header.Sender.Add(sender); string senderId; if (sdmxObjects != null && sdmxObjects.Header != null && sdmxObjects.Header.Sender != null) { // Get header information from the supplied beans senderId = sdmxObjects.Header.Sender.Id; } else { // Get header info from HeaderHelper senderId = HeaderHelper.Instance.SenderId; } sender.id = senderId; var receiver = new PartyType(); header.Receiver.Add(receiver); receiver.id = HeaderHelper.Instance.ReceiverId; }
private static void HeaderTypeValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var control = (CWindowHeader)d; HeaderType newval = (HeaderType)e.NewValue; switch (newval) { case HeaderType.Close: control.B_1.C_ButtonType = CWindowControlButton.ButtonType.close; control.B_1.Visibility = Visibility.Visible; control.B_2.Visibility = Visibility.Hidden; control.B_3.Visibility = Visibility.Hidden; break; case HeaderType.Close_Minimize: control.B_1.C_ButtonType = CWindowControlButton.ButtonType.close; control.B_2.C_ButtonType = CWindowControlButton.ButtonType.minimize; control.B_1.Visibility = Visibility.Visible; control.B_2.Visibility = Visibility.Visible; control.B_3.Visibility = Visibility.Hidden; break; case HeaderType.Close_Minimize_Maximize: control.B_1.C_ButtonType = CWindowControlButton.ButtonType.close; control.B_2.C_ButtonType = CWindowControlButton.ButtonType.maximize; control.B_3.C_ButtonType = CWindowControlButton.ButtonType.minimize; control.B_1.Visibility = Visibility.Visible; control.B_2.Visibility = Visibility.Visible; control.B_3.Visibility = Visibility.Visible; break; default: break; } }
public void Run(ILogger _logger) { var client = new EventPortTypeClient(); // Bypass invalid SSL certificate client.ClientCredentials.ServiceCertificate.SslCertificateAuthentication = new X509ServiceCertificateAuthentication() { CertificateValidationMode = X509CertificateValidationMode.None, RevocationMode = X509RevocationMode.NoCheck }; HeaderType hd = new HeaderType(); hd.ClientTimeZoneID = "Asia/Ho_Chi_Minh"; hd.Identity = "91"; var eventName = "CFCScoring"; var itemTypes = GenerateItemTypes(); var request = new EventRequest(hd, itemTypes, eventName); _logger.LogInformation($"CheckScoring - Request: {ConvertToXML(request)}"); EventResponse response = null; try { response = client.EventAsync(request).Result; _logger.LogInformation($"CheckScoring - Response: {JsonConvert.SerializeObject(response)}"); } catch (Exception ex) { throw ex; } }
/// <summary> /// Build 16 bit data header /// </summary> /// <param name="type"></param> /// <param name="p0"></param> /// <param name="p1"></param> /// <param name="p2"></param> /// <param name="p3"></param> /// <returns></returns> public static string Build16BitDataHeader(HeaderType type, int p0, int p1, int p2, int p3, CRC16 crcCalculator) { var sb = new StringBuilder(); sb.Append(Bin16BitHeader); sb.Append((char)ControlBytes.ZDLE); sb.Append('J'); sb.Append(((char)p0).ToString()); sb.Append(((char)p1).ToString()); sb.Append(((char)p2).ToString()); sb.Append(((char)p3).ToString()); var b = new byte[5]; b[0] = Convert.ToByte(type); b[1] = Convert.ToByte(p0); b[2] = Convert.ToByte(p1); b[3] = Convert.ToByte(p2); b[4] = Convert.ToByte(p3); var crc = CRCHelper.Compute16BitHeaderAsArray((int)type, p0, p1, p2, p3, crcCalculator); var crc1 = crc[1]; var crc2 = crc[0]; sb.Append(((char)crc1).ToString()); sb.Append(((char)crc2).ToString()); var command = sb.ToString(); return(command); }
internal static HeaderType Validate(int streamId, ICharSequence name, HeaderType?previousHeaderType) { if (PseudoHeaderName.HasPseudoHeaderFormat(name)) { if (previousHeaderType == HeaderType.RegularHeader) { ThrowHelper.ThrowStreamError_AfterRegularHeader(streamId, name); } var pseudoHeader = PseudoHeaderName.GetPseudoHeader(name); if (pseudoHeader is null) { ThrowHelper.ThrowStreamError_InvalidPseudoHeader(streamId, name); } HeaderType currentHeaderType = pseudoHeader.IsRequestOnly ? HeaderType.RequestPseudoHeader : HeaderType.ResponsePseudoHeader; if (previousHeaderType.HasValue && currentHeaderType != previousHeaderType.Value) { ThrowHelper.ThrowStreamError_MixOfRequest(streamId); } return(currentHeaderType); } return(HeaderType.RegularHeader); }
/// <summary> /// Build 16 bit binary header. /// /// A binary header is sent by the sending program to the receiving program.All bytes in a binary header are ZDLE encoded. /// A binary header begins with the sequence ZPAD, ZDLE, ZBIN. /// 0 or more binary data subpackets with 16 bit CRC will follow depending on the frame type. /// * ZDLE A TYPE F3/P0 F2/P1 F1/P2 F0/P3 CRC-1 CRC-2 /// </summary> /// <param name="type"></param> /// <param name="f0"></param> /// <param name="f1"></param> /// <param name="f2"></param> /// <param name="f3"></param> /// <returns></returns> public static string Build16BitBinHeader(HeaderType type, ZFILEConversionOption f0, ZFILEManagementOption f1, ZFILETransportOption f2, ZFILEExtendedOptions f3, CRC16 crcCalculator) { var sb = new StringBuilder(); sb.Append(Bin16BitHeader); sb.Append(((char)(int)type).ToString()); sb.Append(((char)f3).ToString()); sb.Append(((char)f2).ToString()); sb.Append(((char)f1).ToString()); sb.Append(((char)f0).ToString()); var b = new byte[5]; b[0] = Convert.ToByte(type); b[1] = Convert.ToByte(f3); b[2] = Convert.ToByte(f2); b[3] = Convert.ToByte(f1); b[4] = Convert.ToByte(f0); var crc = CRCHelper.Compute16BitHeaderAsArray((int)type, (int)f3, (int)f2, (int)f1, (int)f0, crcCalculator); int crc1 = crc[1]; int crc2 = crc[0]; sb.Append(((char)crc1).ToString()); sb.Append(((char)crc2).ToString()); var command = sb.ToString(); return(command); }
public BitMask(HeaderType headerType, CompressionType compressionType, Stream stream) { if (compressionType != CompressionType.BI_BITFIELDS || compressionType != CompressionType.BI_ALPHABITFIELDS) { throw new InvalidOperationException("BitMask can only be used with compression " + "types of BI_BITFIELDS or BI_ALPHABITFIELDS"); } if (headerType < HeaderType.BITMAPINFOHEADER) { throw new InvalidOperationException("BitMask can only be used with HeaderTypes " + "greater than or equal to BITMAPINFOHEADER"); } stream.Seek((int)headerType + FileHeader.FILE_HEADER_SIZE, SeekOrigin.Begin); if (headerType == HeaderType.BITMAPINFOHEADER) { SetRGB(stream); } else //(headerType > HeaderType.BITMAPINFOHEADER) { SetRGBA(stream); } }
public void HighlightLine(HeaderType type, NodeBase node) { var items = type == HeaderType.Columns ? Matrix.HeaderColumns : Matrix.HeaderRows; for (int i = 0; i < items.Count; i++) { if (items[i].Value.Equals(node)) { if (currentCell.X == i && type == HeaderType.Rows) { return; } if (currentCell.Y == i && type == HeaderType.Columns) { return; } currentCell = type == HeaderType.Columns ? new Coords(i, currentCell.Y) : new Coords(currentCell.X, i); SetHoveredCell(); InvalidateVisual(); return; } } }
public Header(HeaderType type) { this.Type = type; this.ContentType = "text/html"; this.Cookies = new CookieCollection(); this.OtherParameters = new Dictionary <string, string>(); }
private static void EncodeType(HeaderType headerType, byte[] encodedHeader) { var bytes = BitConverter.GetBytes((int)headerType); Array.Copy(bytes, 0, encodedHeader, HeaderConstants.CommandLength, HeaderConstants.TypeLength); }
public void TestIndexer(HeaderType headerType) { INameValueCollection headers = this.CreateHeaders(headerType); string value = Guid.NewGuid().ToString(); headers[Key] = value; Assert.AreEqual(value, headers[Key]); }
public void TestClear(HeaderType headerType) { INameValueCollection headers = this.CreateHeaders(headerType); headers[Key] = Guid.NewGuid().ToString(); headers.Clear(); Assert.IsNull(headers[Key]); }
// Token: 0x0600026C RID: 620 RVA: 0x0000DC0C File Offset: 0x0000BE0C public HeaderNameDef(int hash, string name, HeaderType headerType, HeaderId publicHeaderId, bool restricted) { this.hash = (byte)hash; this.restricted = restricted; this.headerType = headerType; this.name = name; this.publicHeaderId = publicHeaderId; }
public PCIeMemory(IPCIeRouter parent, uint size) : base(parent) { this.memory = new uint[size / 4]; for (var i = 0u; i < HeaderType.MaxNumberOfBARs(); ++i) { AddBaseAddressRegister(i, new MemoryBaseAddressRegister(size, MemoryBaseAddressRegister.BarType.LocateIn32Bit, true)); } }
/// <summary> /// Send byte command /// </summary> /// <param name="Command">Byte array</param> /// <returns></returns> ResponseHeader SendCommand(byte[] Command, bool withResponse = false, HeaderType expectedResponse = HeaderType.None) { ResponseHeader response = default(ResponseHeader); for (int i = 0; i < ReadRetryAttempts; i++) { // Lock and send command lock (PadLock) { PrepareSerialPort(); SerialPort.Write(Command, 0, Command.Length); } // Delay a bit Thread.Sleep(TaskTimeout); if (!withResponse) { break; } int bytesToRead = SerialPort.BytesToRead; //Response header needs to be of bytes // this will prevent from loosing bytes if we read too quickly if (bytesToRead > 19) { var buffer = new byte[SerialPort.BytesToRead]; lock (PadLock) { SerialPort.Read(buffer, 0, SerialPort.BytesToRead); } response = new ResponseHeader(buffer); if (response?.ZHeader == expectedResponse) { break; } else { // Sleep n ms and try again Thread.Sleep(ReadRetryAttemptTimeout); } } else if (expectedResponse == HeaderType.None) { break; } else { // Sleep n ms and try again Thread.Sleep(ReadRetryAttemptTimeout); } } return(response); }
/// <summary> /// Removes the specified header in the document /// </summary> /// <param name="type">The header part type</param> public void RemoveHeader(WmlDocument doc, HeaderType type, int sectionIndex) { using (OpenXmlMemoryStreamDocument streamDoc = new OpenXmlMemoryStreamDocument(doc)) using (WordprocessingDocument document = streamDoc.GetWordprocessingDocument()) { OpenXmlPart headerPart = GetHeaderPart(document, type, sectionIndex); headerPart.RemovePart(); } }
/// <summary> /// Return all headers except for content-type, accept, accept-encoding and accept-charset /// </summary> /// <returns></returns> public Dictionary <string, string> HeaderForEverythingElse() { return (_headers.Where( x => !HeaderType.GetAll() .Any(y => y.Value.Equals(x.Key, StringComparison.InvariantCultureIgnoreCase))) .ToDictionary(x => x.Key, x => x.Value)); }
private static void AddAuthenticationHeader(this HttpRequestMessage message, HeaderType type, string token) { if (message.Headers.Authorization != null) { throw new InvalidOperationException("message already has an authentication header"); } message.Headers.Authorization = new AuthenticationHeaderValue(type.ToString(), token); }
static string BuildHexFrame(HeaderType type, ZRINIT_Header_ZF0 trcapa) { int trpfort = ((int)trcapa) >> 0x8; int trpfaible = ((int)trcapa) - trpfort * 0xff; string frame = BuildHexFrame(type, 0, 0, trpfort, trpfaible); return(frame); }
protected PCIeBasePeripheral(IPCIeRouter parent, HeaderType headerType) { if (!IsHeaderAcceptable(headerType)) { throw new ConstructionException($"Currently only devices of type {HeaderType.Bridge} or {HeaderType.Endpoint} are supported."); } this.parent = parent; this.HeaderType = headerType; this.baseAddressRegisters = new BaseAddressRegister[headerType.MaxNumberOfBARs()]; var registerMap = new Dictionary <long, DoubleWordRegister> { { (long)Registers.DeviceAndVendorId, new DoubleWordRegister(this) .WithValueField(0, 16, FieldMode.Read, valueProviderCallback: _ => VendorId) .WithValueField(16, 16, FieldMode.Read, valueProviderCallback: _ => DeviceId) }, { (long)Registers.StatusAndConfiguration, new DoubleWordRegister(this) //unsupported fields do not have to be implemented. Maybe we should move it to inheriting classes? //First 16 bits: command register. RW. Writing 0 to these fields should effectively disable all accesses but the configuration accesses .WithTaggedFlag("I/O Space", 0) .WithTaggedFlag("Memory Space", 1) .WithTaggedFlag("Bus Master", 2) .WithTaggedFlag("Special Cycles", 3) .WithTaggedFlag("Memory Write and Invalidate Enable", 4) .WithTaggedFlag("VGA Palette Snoop", 5) .WithTaggedFlag("Parity Error Response", 6) .WithReservedBits(7, 1) .WithTaggedFlag("SERR# Enable", 8) .WithTaggedFlag("Fast Back-to-Back Enable", 9) .WithTaggedFlag("Interrupt Disable", 10) .WithReservedBits(11, 8) //Second 16 bits: status register. W1C. .WithTaggedFlag("Interrupt Status", 19) .WithFlag(20, FieldMode.Read, valueProviderCallback: _ => capabilities.Any(), name: "Capabilities List") .WithTaggedFlag("66 MHz Capabale", 21) .WithReservedBits(22, 1) .WithTaggedFlag("Fast Back-to-Back capable", 23) .WithTaggedFlag("Master Data Parity Error", 24) .WithTag("DEVSEL Timing", 25, 2) .WithTaggedFlag("Signaled Target Abort", 27) .WithTaggedFlag("Received Target Abort", 28) .WithTaggedFlag("Received Master Abort", 29) .WithTaggedFlag("Signaled System Error", 30) .WithTaggedFlag("Detected Parity Error", 31) }, { (long)Registers.ClassCode, new DoubleWordRegister(this) .WithValueField(0, 8, FieldMode.Read, valueProviderCallback: _ => RevisionId) .WithValueField(16, 16, FieldMode.Read, valueProviderCallback: _ => ClassCode) }, { (long)Registers.Header, new DoubleWordRegister(this) .WithTag("Cacheline Size", 0, 8) .WithTag("Latency Timer", 8, 8) .WithEnumField(16, 8, FieldMode.Read, valueProviderCallback: (HeaderType _) => headerType) .WithTag("BIST", 24, 8) }, { (long)Registers.Capabilities, new DoubleWordRegister(this) .WithValueField(0, 8, FieldMode.Read, valueProviderCallback: _ => capabilities.FirstOrDefault().Key) }, }; registers = new DoubleWordRegisterCollection(this, registerMap); AddCapability(0x80, new PCIeCapability(this)); }
/// <summary> /// Encode RTMP header into given ByteBuffer /// </summary> /// <param name="header">RTMP message header</param> /// <param name="lastHeader">Previous header</param> /// <param name="buffer">Buffer to write encoded header to</param> /// <returns>Encoded header data</returns> public static ByteBuffer EncodeHeader(RtmpHeader header, RtmpHeader lastHeader, ByteBuffer buffer) { HeaderType headerType = GetHeaderType(header, lastHeader); EncodeHeaderByte(buffer, (byte)headerType, header.ChannelId); switch (headerType) { case HeaderType.HeaderNew: if (header.Timer < 0xffffff) { buffer.WriteMediumInt(header.Timer); } else { buffer.WriteMediumInt(0xffffff); } buffer.WriteMediumInt(header.Size); buffer.Put((byte)header.DataType); buffer.WriteReverseInt(header.StreamId); break; case HeaderType.HeaderSameSource: if (header.Timer < 0xffffff) { buffer.WriteMediumInt(header.Timer); } else { buffer.WriteMediumInt(0xffffff); } buffer.WriteMediumInt(header.Size); buffer.Put((byte)header.DataType); break; case HeaderType.HeaderTimerChange: if (header.Timer < 0xffffff) { buffer.WriteMediumInt(header.Timer); } else { buffer.WriteMediumInt(0xffffff); } break; case HeaderType.HeaderContinue: break; } if (header.Timer >= 0xffffff) { buffer.PutInt(header.Timer); } return(buffer); }
public FundingSummaryModel(string title, HeaderType headerType = HeaderType.None, int excelHeaderStyle = 4) { ExcelHeaderStyle = excelHeaderStyle; ExcelRecordStyle = 4; Title = title; HeaderType = headerType; YearlyValues = new List <FundingSummaryReportYearlyValueModel>(); Totals = new List <decimal>(); }
internal Header(HeaderType type, byte[] rawData) : base() { if ((type < 0) || (type >= HeaderType.EndOfEntry)) { throw new ArgumentOutOfRangeException(nameof(type), "Type not supported."); } this.HeaderType = type; this.RawData = rawData; }
public void TestGetValues(HeaderType headerType) { INameValueCollection headers = this.CreateHeaders(headerType); string value1 = Guid.NewGuid().ToString(); headers.Add(Key, value1); IEnumerable <string> values = headers.GetValues(Key); Assert.AreEqual(1, values.Count()); }
internal Header(HeaderType type, byte[] rawData) : base() { if (type is < 0 or >= HeaderType.EndOfEntry) { throw new ArgumentOutOfRangeException(nameof(type), "Type not supported."); } HeaderType = type; RawData = rawData; }
public static XDocument GetHeader(WordprocessingDocument document, HeaderType type, int sectionIndex) { OpenXmlPart header = GetHeaderPart(document, type, sectionIndex); if (header != null) { return(header.GetXDocument()); } return(null); }
/// <summary> /// Determines whether the collection contains a specific type. /// If multiple elements exist with the same type, the first one is returned. /// </summary> /// <param name="type">The item type to locate.</param> public bool Contains(HeaderType type) { foreach (var item in this.BaseCollection) { if (item.HeaderType == type) { return(true); } } return(false); }
/// <summary> /// Gets field based on a type. /// If multiple elements exist with the same field type, the first one is returned. /// If type does not exist, it is created. /// /// If value is set to null, field is removed. /// </summary> /// <param name="type">Type.</param> /// <exception cref="ArgumentOutOfRangeException">Only null value is supported.</exception> /// <exception cref="NotSupportedException">Collection is read-only.</exception> public Header this[HeaderType type] { get { foreach (var field in this.BaseCollection) { if (field.HeaderType == type) { return(field); } } if (this.IsReadOnly) { return(new Header(type)); } //return dummy header if collection is read-only var newField = new Header(this, type); //create a new field if one cannot be found var i = this.BaseCollection.Count; for (i = 0; i < this.BaseCollection.Count; i++) { if (this.BaseCollection[i].HeaderType > type) { break; } } this.BaseCollection.Insert(i, newField); //insert it in order (does not change order for existing ones) return(newField); } set { if (this.IsReadOnly) { throw new NotSupportedException("Collection is read-only."); } if (value != null) { throw new ArgumentOutOfRangeException(nameof(value), "Only null value is supported."); } Header fieldToRemove = null; foreach (var field in this.BaseCollection) { if (field.HeaderType == type) { fieldToRemove = field; break; } } if (fieldToRemove != null) { this.Remove(fieldToRemove); } } }
public static bool IsCall2(this HeaderType type) { switch (type) { case HeaderType.HESSIAN_2: return(true); default: return(false); } }
public static bool IsReply1(this HeaderType type) { switch (type) { case HeaderType.CALL_1_REPLY_1: return(true); default: return(false); } }
public void Reset() { HeaderType = 0; PacketType = 0; m_nChannel = 0; m_nTimeStamp = 0; m_nInfoField2 = 0; m_nBodySize = 0; m_nBytesRead = 0; m_hasAbsTimestamp = false; m_body = null; }
public void Reset() { headerType = 0; packetType = 0; channel = 0; timeStamp = 0; infoField2 = 0; bodySize = 0; bytesRead = 0; hasAbsTimestamp = false; body = null; }
/// <summary> /// Gets the header lenght. /// </summary> /// <param name="headerType"></param> /// <returns></returns> public static int GetHeaderLength(HeaderType headerType) { switch (headerType) { case HeaderType.HeaderNew: return 12; case HeaderType.HeaderSameSource: return 8; case HeaderType.HeaderTimerChange: return 4; case HeaderType.HeaderContinue: return 1; default: return -1; } }
public BitMask(HeaderType headerType, CompressionType compressionType, Stream stream) { if(compressionType != CompressionType.BI_BITFIELDS || compressionType != CompressionType.BI_ALPHABITFIELDS) throw new InvalidOperationException("BitMask can only be used with compression " + "types of BI_BITFIELDS or BI_ALPHABITFIELDS"); if(headerType < HeaderType.BITMAPINFOHEADER) throw new InvalidOperationException("BitMask can only be used with HeaderTypes " + "greater than or equal to BITMAPINFOHEADER"); stream.Seek((int)headerType + FileHeader.FILE_HEADER_SIZE, SeekOrigin.Begin); if (headerType == HeaderType.BITMAPINFOHEADER) SetRGB(stream); else //(headerType > HeaderType.BITMAPINFOHEADER) SetRGBA(stream); }
// Constructor // public Header(string NewDirectory, string NewName, long NewID, long ColumnCount, long RecordCount, long KeyCount, long NewMaxCount, HeaderType Type) :base(RECORD_LEN) { // Fix the directory // if (NewDirectory.Last() != '\\') NewDirectory = NewDirectory.Trim() + '\\'; // Fix the name // if (Name.Contains(DOT) == true) Name = Name.Split(DOT)[0].Trim(); this[OFFSET_NAME] = new Cell(NewName); this[OFFSET_ID] = new Cell(NewID); this[OFFSET_DIRECTORY] = new Cell(NewDirectory); this[OFFSET_EXTENSION] = new Cell(DEFAULT_EXTENSION); this[OFFSET_COLUMN_COUNT] = new Cell(ColumnCount); this[OFFSET_RECORD_COUNT] = new Cell(RecordCount); this[OFFSET_TIME_STAMP] = new Cell(DateTime.Now); this[OFFSET_KEY_COUNT] = new Cell(KeyCount); this[OFFSET_MAX_RECORDS] = new Cell(NewMaxCount); this[OFFSET_TYPE] = new Cell((byte)Type); }
/// <summary> /// Adds a new header reference in the section properties /// </summary> /// <param name="type">The header part type</param> /// <param name="headerPartId">the header part id</param> public static void AddHeaderReference(WordprocessingDocument document, HeaderType type, string headerPartId, int sectionIndex) { // If the document does not have a property section a new one must be created if (SectionPropertiesElements(document).Count() == 0) { AddDefaultSectionProperties(document); } string typeName = ""; switch ((HeaderType)type) { case HeaderType.First: typeName = "first"; break; case HeaderType.Even: typeName = "even"; break; case HeaderType.Default: typeName = "default"; break; } XElement sectionPropertyElement = SectionPropertiesElements(document).Skip(sectionIndex).FirstOrDefault(); if (sectionPropertyElement != null) { sectionPropertyElement.Add( new XElement(ns + "headerReference", new XAttribute(ns + "type", typeName), new XAttribute(relationshipns + "id", headerPartId))); if (sectionPropertyElement.Element(ns + "titlePg") == null) sectionPropertyElement.Add( new XElement(ns + "titlePg") ); } document.MainDocumentPart.PutXDocument(); }
protected static byte[] CreatePacket(HeaderType type, uint number, byte[] data) { byte[] packet = new byte[9+data.Length]; packet[0] = (byte)type; Buffer.BlockCopy(BitConverter.GetBytes(number), 0, packet, 1, sizeof(uint)); Buffer.BlockCopy(BitConverter.GetBytes(data.Length), 0, packet, 5, sizeof(int)); Buffer.BlockCopy(data, 0, packet, 9, data.Length); return packet; }
public void SendTo(byte[] data, IPEndPoint ipEndPoint, HeaderType type) { byte[] packet = CreatePacket(type, m_packetNumber++, data); if (HasType((byte)type, HeaderType.Reliable) && !HasType((byte)type, HeaderType.Reply)) { m_sentReliableLock.WaitOne(); m_sentReliablePacketList.Add(new SendPacketInfo(ipEndPoint, m_packetNumber, packet)); m_sentReliableLock.Release(); } SendTo(packet, ipEndPoint); }
/// <summary> /// Set a new header in a document /// </summary> /// <param name="header">XDocument containing the header to add in the document</param> /// <param name="type">The header part type</param> public static OpenXmlPowerToolsDocument SetHeader(WmlDocument doc, XDocument header, HeaderType type, int sectionIndex) { using (OpenXmlMemoryStreamDocument streamDoc = new OpenXmlMemoryStreamDocument(doc)) { using (WordprocessingDocument document = streamDoc.GetWordprocessingDocument()) { // Removes the reference in the document.xml and the header part if those already // exist XElement headerReferenceElement = GetHeaderReference(document, type, sectionIndex); if (headerReferenceElement != null) { GetHeaderPart(document, type, sectionIndex).RemovePart(); headerReferenceElement.Remove(); } // Add the new header HeaderPart headerPart = document.MainDocumentPart.AddNewPart<HeaderPart>(); headerPart.PutXDocument(header); // Creates the relationship of the header inside the section properties in the document string relID = document.MainDocumentPart.GetIdOfPart(headerPart); AddHeaderReference(document, type, relID, sectionIndex); // add in the settings part the EvendAndOddHeaders. this element // allow to see the odd and even headers and headers in the document. SettingAccessor.AddEvenAndOddHeadersElement(document); } return streamDoc.GetModifiedDocument(); } }
/// <summary> /// The specified header part from the document /// </summary> /// <param name="type">The header part type</param> /// <returns>A OpenXmlPart containing the header part</returns> public static OpenXmlPart GetHeaderPart(WordprocessingDocument document, HeaderType type, int sectionIndex) { // look in the section properties of the main document part, the respective Header // needed to extract XElement headerReferenceElement = GetHeaderReference(document, type, sectionIndex); if (headerReferenceElement != null) { // get the relation id of the Header part to extract from the document string relationId = headerReferenceElement.Attribute(relationshipns + "id").Value; return document.MainDocumentPart.GetPartById(relationId); } else return null; }
/// <summary> /// Adds a new header part in the document /// </summary> /// <param name="type">The footer part type</param> /// <returns>A XDocument contaning the added header</returns> public static XDocument AddNewHeader(WordprocessingDocument document, HeaderType type) { // Creates the new header part HeaderPart newHeaderPart = document.MainDocumentPart.AddNewPart<HeaderPart>(); XDocument emptyHeader = CreateEmptyHeaderDocument(); newHeaderPart.PutXDocument(emptyHeader); string newHeaderPartId = document.MainDocumentPart.GetIdOfPart(newHeaderPart); AddHeaderReference(document, type, newHeaderPartId, 0); return emptyHeader; }
protected void ReceivedDataPacket(int dataLength, byte[] receivedPacket, IPEndPoint ipEndPoint, HeaderType type = 0) { byte[] data = new byte[dataLength]; Buffer.BlockCopy(receivedPacket, 9, data, 0, dataLength); if (null != m_receivedDataHandler) m_receivedDataHandler(data, ipEndPoint, type); }
public Header(string NewDirectory, string NewName, long NewID, RecordSet Data, HeaderType Type) : this(NewDirectory, NewName, NewID, Data.Columns.Count, Data.Count, Data.SortBy.Count, Data.MaxRecords, Type) { }
/// <summary> /// Read single chunk header<para/> /// Чтение заголовка одного чанка /// </summary> /// <param name="f">BinaryReader</param> /// <param name="validate">Throw error if chunk does not match this parameter<para/>Выбрасывается исключение, если тип чанка не совпадает с указанным</param> static Header ReadHeader(BinaryReader f, HeaderType validate = HeaderType.Any) { Header h = new Header(); // Reading base sections // Чтение базовых секций string n = new string(f.ReadChars(4)); h.Size = f.ReadInt32(); // Determine chunk type // Определение типа чанка switch (n.ToUpper()) { case "ANPK": h.Type = HeaderType.AnimationPackage; break; case "INFO": h.Type = HeaderType.Collection; break; case "NAME": h.Type = HeaderType.Name; break; case "DGAN": h.Type = HeaderType.Objects; break; case "CPAN": h.Type = HeaderType.Animation; break; case "ANIM": h.Type = HeaderType.AnimationData; break; case "KR00": h.Type = HeaderType.RotationKey; break; case "KRT0": h.Type = HeaderType.RotationTransitionKey; break; case "KRTS": h.Type = HeaderType.RotationTransitionScaleKey; break; default: throw new Exception("[AnimationFile] Unknown chunk type: "+n); } // Validate // Проверка if (validate != HeaderType.Any) { if (h.Type != validate) { throw new Exception("[AnimationFile] Unexpected chunk type: " + h.Type); } } return h; }
public Message() { this.Header = HeaderType.Default; this.Data = ""; }
/////////////////////////////////////////////////////////////////////////////////////////////////// ////////////BUILD FROM V2.0 SCHEMA /////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Initializes a new instance of the <see cref="HeaderImpl"/> class. /// </summary> /// <param name="headerType"> /// The header type. /// </param> public HeaderImpl(HeaderType headerType) { this._additionalAttributes = new Dictionary<string, string>(); this._name = new List<ITextTypeWrapper>(); this._source = new List<ITextTypeWrapper>(); this._receiver = new List<IParty>(); this._structureReferences = new List<IDatasetStructureReference>(); this._test = headerType.Test; if (headerType.DataSetAction != null) { switch (headerType.DataSetAction) { case Org.Sdmx.Resources.SdmxMl.Schemas.V20.common.ActionTypeConstants.Append: this._datasetAction = DatasetAction.GetFromEnum(DatasetActionEnumType.Append); break; case Org.Sdmx.Resources.SdmxMl.Schemas.V20.common.ActionTypeConstants.Replace: this._datasetAction = DatasetAction.GetFromEnum(DatasetActionEnumType.Replace); break; case Org.Sdmx.Resources.SdmxMl.Schemas.V20.common.ActionTypeConstants.Delete: this._datasetAction = DatasetAction.GetFromEnum(DatasetActionEnumType.Delete); break; } } this._id = headerType.ID; this._datasetId = headerType.DataSetID; if (headerType.Extracted != null) { this._extracted = headerType.Extracted; } if (ObjectUtil.ValidCollection(headerType.Name)) { foreach (Org.Sdmx.Resources.SdmxMl.Schemas.V20.common.TextType tt in headerType.Name) { this._name.Add(new TextTypeWrapperImpl(tt, null)); } } var prepared = headerType.Prepared as DateTime?; if (prepared != null) { this._prepared = prepared; } if (ObjectUtil.ValidCollection(headerType.Receiver)) { foreach (Org.Sdmx.Resources.SdmxMl.Schemas.V20.message.PartyType party in headerType.Receiver) { this._receiver.Add(new PartyCore(party)); } } if (headerType.ReportingBegin != null) { this._reportingBegin = DateUtil.FormatDate(headerType.ReportingBegin, true); } if (headerType.ReportingEnd != null) { this._reportingEnd = DateUtil.FormatDate(headerType.ReportingEnd, true); } if (ObjectUtil.ValidCollection(headerType.Sender)) { this._sender = new PartyCore(headerType.Sender[0]); } if (ObjectUtil.ValidCollection(headerType.Source)) { foreach (Org.Sdmx.Resources.SdmxMl.Schemas.V20.common.TextType textType in headerType.Source) { this._source.Add(new TextTypeWrapperImpl(textType, null)); } } if (!string.IsNullOrWhiteSpace(headerType.KeyFamilyAgency)) { this._additionalAttributes.Add(Header.DsdAgencyRef, headerType.KeyFamilyAgency); } if (!string.IsNullOrWhiteSpace(headerType.KeyFamilyRef)) { this._additionalAttributes.Add(Header.DsdRef, headerType.KeyFamilyRef); } this.Validate(); }
public HeaderCell(string name, string caption, DataType cellType, HeaderType type) : base(name, caption, cellType) { this.HeaderType = type; }
private static IComparable CoerceTypes(IComparable value, HeaderType type) { if (type == HeaderType.Numeric) { string valueString = value.ToString(); double dblVal; if (double.TryParse(valueString, NumberStyles.Any, CultureInfo.InvariantCulture, out dblVal)) { return dblVal; } return (double)-127; } else if (type == HeaderType.String) { return value.ToString(); } return value; }
public static BusinessPremiseRequest CreateBusinessPremiseRequest(BusinessPremiseType businessPremise) { BusinessPremiseRequest request = new BusinessPremiseRequest() { Id = "test", BusinessPremise = businessPremise }; HeaderType header = new HeaderType() { DateTime = Misc.FormatCurrentTime(), MessageID = Guid.NewGuid().ToString() }; request.Header = header; return request; }
/// <summary> /// Get the specified header from the document /// </summary> /// <param name="type">The header part type</param> /// <returns>A XDocument containing the header</returns> public static XDocument GetHeader(WmlDocument doc, HeaderType type, int sectionIndex) { using (OpenXmlMemoryStreamDocument streamDoc = new OpenXmlMemoryStreamDocument(doc)) using (WordprocessingDocument document = streamDoc.GetWordprocessingDocument()) { OpenXmlPart header = GetHeaderPart(document, type, sectionIndex); if (header != null) return header.GetXDocument(); return null; } }
public static InvoiceRequest CreateInvoiceRequest(InvoiceType invoice) { InvoiceRequest request = new InvoiceRequest() { Id = "test", Item = invoice }; HeaderType header = new HeaderType() { DateTime = Misc.FormatCurrentTime(), MessageID = Guid.NewGuid().ToString() }; request.Header = header; return request; }
// Statics // public static string FilePath(string Dir, string Name, HeaderType Type) { Header h = new Header(Dir.Trim(), Name.Trim(), 0, 0, 0, 0, 0, Type); return h.Path; }
/// <summary> /// Header reference nodes inside the document /// </summary> /// <param name="type">The header part type</param> /// <returns>XElement containing the part reference in the document</returns> public static XElement GetHeaderReference(WordprocessingDocument document, HeaderType type, int sectionIndex) { XDocument mainDocument = document.MainDocumentPart.GetXDocument(); XName headerReferenceTag = ns + "headerReference"; XName typeTag = ns + "type"; string typeName = ""; switch (type) { case HeaderType.First: typeName = "first"; break; case HeaderType.Even: typeName = "even"; break; case HeaderType.Default: typeName = "default"; break; } XElement sectionPropertyElement = SectionPropertiesElements(document).Skip(sectionIndex).FirstOrDefault(); if (sectionPropertyElement != null) { return sectionPropertyElement.Descendants().Where(tag => (tag.Name == headerReferenceTag) && (tag.Attribute(typeTag).Value == typeName)).FirstOrDefault(); } return null; }
protected static bool HasType(byte header, HeaderType type) { return 0 != (header & (byte)type); }
public static XDocument GetHeader(WordprocessingDocument document, HeaderType type, int sectionIndex) { OpenXmlPart header = GetHeaderPart(document, type, sectionIndex); if (header != null) return header.GetXDocument(); return null; }
/// <summary> /// Build success response. /// </summary> /// <param name="buildFrom"> /// The source sdmx objects. /// </param> /// <param name="warningMessage"> /// The warning message. /// </param> /// <returns> /// The <see cref="RegistryInterface"/>. /// </returns> public RegistryInterface BuildSuccessResponse(ISdmxObjects buildFrom, string warningMessage) { // PLEASE NOTE. The code here is slightly different than in Java. // That is because of the differences between Java XmlBeans and .NET Linq2Xsd generated classes. // Please consult GIT log before making any changes. var responseType = new RegistryInterface(); RegistryInterfaceType regInterface = responseType.Content; HeaderType headerType; if (buildFrom.Header != null) { headerType = this._headerXmlsBuilder.Build(buildFrom.Header); regInterface.Header = headerType; } else { headerType = new HeaderType(); regInterface.Header = headerType; V2Helper.SetHeader(headerType, buildFrom); } var returnType = new QueryStructureResponseType(); regInterface.QueryStructureResponse = returnType; var statusMessage = new StatusMessageType(); returnType.StatusMessage = statusMessage; if (!string.IsNullOrWhiteSpace(warningMessage) || !ObjectUtil.ValidCollection(buildFrom.GetAllMaintainables())) { statusMessage.status = StatusTypeConstants.Warning; var tt = new TextType(); statusMessage.MessageText.Add(tt); tt.TypedValue = !string.IsNullOrWhiteSpace(warningMessage) ? warningMessage : "No Structures Match The Query Parameters"; } else { statusMessage.status = StatusTypeConstants.Success; } ISet<ICategorisationObject> categorisations = buildFrom.Categorisations; // GET CATEGORY SCHEMES if (buildFrom.CategorySchemes.Count > 0) { var catSchemesType = new CategorySchemesType(); returnType.CategorySchemes = catSchemesType; /* foreach */ foreach (ICategorySchemeObject cateogrySchemeBean in buildFrom.CategorySchemes) { ISet<ICategorisationObject> matchingCategorisations = new HashSet<ICategorisationObject>(); /* foreach */ foreach (ICategorisationObject cat in categorisations) { if (MaintainableUtil<ICategorySchemeObject>.Match(cateogrySchemeBean, cat.CategoryReference)) { matchingCategorisations.Add(cat); } } catSchemesType.CategoryScheme.Add( this._categorySchemeXmlBuilder.Build(cateogrySchemeBean, categorisations)); } } // GET CODELISTS if (buildFrom.Codelists.Count > 0) { CodeListsType codeListsType = new CodeListsType(); returnType.CodeLists = codeListsType; //CodeListsType codeListsType = returnType.CodeLists; /* foreach */ foreach (ICodelistObject codelistBean in buildFrom.Codelists) { codeListsType.CodeList.Add(this._codelistXmlBuilder.Build(codelistBean)); } } // CONCEPT SCHEMES if (buildFrom.ConceptSchemes.Count > 0) { ConceptsType conceptsType = new ConceptsType(); returnType.Concepts = conceptsType; /* foreach */ foreach (IConceptSchemeObject conceptSchemeBean in buildFrom.ConceptSchemes) { conceptsType.ConceptScheme.Add(this._conceptSchemeXmlBuilder.Build(conceptSchemeBean)); } } // DATAFLOWS if (buildFrom.Dataflows.Count > 0) { var dataflowsType = new DataflowsType(); returnType.Dataflows = dataflowsType; /* foreach */ foreach (IDataflowObject currentBean in buildFrom.Dataflows) { dataflowsType.Dataflow.Add( this._dataflowXmlBuilder.Build(currentBean, GetCategorisations(currentBean, categorisations))); } } // HIERARCIC CODELIST if (buildFrom.HierarchicalCodelists.Count > 0) { HierarchicalCodelistsType hierarchicalCodelistsType = new HierarchicalCodelistsType(); returnType.HierarchicalCodelists = hierarchicalCodelistsType; /* foreach */ foreach (IHierarchicalCodelistObject currentBean0 in buildFrom.HierarchicalCodelists) { hierarchicalCodelistsType.HierarchicalCodelist.Add( this._hierarchicalCodelistXmlBuilder.Build(currentBean0)); } } // KEY FAMILY if (buildFrom.DataStructures.Count > 0) { var keyFamiliesType = new KeyFamiliesType(); returnType.KeyFamilies = keyFamiliesType; /* foreach */ foreach (IDataStructureObject currentBean1 in buildFrom.DataStructures) { keyFamiliesType.KeyFamily.Add(this._dataStructureXmlBuilder.Build(currentBean1)); } } // METADATA FLOW if (buildFrom.Metadataflows.Count > 0) { var metadataflowsType = new MetadataflowsType(); returnType.Metadataflows = metadataflowsType; /* foreach */ foreach (IMetadataFlow currentBean2 in buildFrom.Metadataflows) { metadataflowsType.Metadataflow.Add( this._metadataflowXmlBuilder.Build( currentBean2, GetCategorisations(currentBean2, categorisations))); } } // METADATA STRUCTURE if (buildFrom.MetadataStructures.Count > 0) { var msdsType = new MetadataStructureDefinitionsType(); returnType.MetadataStructureDefinitions = msdsType; /* foreach */ foreach (IMetadataStructureDefinitionObject currentBean3 in buildFrom.MetadataStructures) { msdsType.MetadataStructureDefinition.Add( this._metadataStructureDefinitionXmlsBuilder.Build(currentBean3)); } } OrganisationSchemesType orgSchemesType = null; // AGENCY SCHEMES if (buildFrom.AgenciesSchemes.Count > 0) { orgSchemesType = new OrganisationSchemesType(); returnType.OrganisationSchemes = orgSchemesType; /* foreach */ foreach (IAgencyScheme currentBean4 in buildFrom.AgenciesSchemes) { orgSchemesType.OrganisationScheme.Add(this._organisationSchemeXmlBuilder.Build(currentBean4)); } } // DATA CONSUMER SCHEMES if (buildFrom.DataConsumerSchemes.Count > 0) { if (orgSchemesType == null) { orgSchemesType = new OrganisationSchemesType(); returnType.OrganisationSchemes = orgSchemesType; } /* foreach */ foreach (IDataConsumerScheme currentBean5 in buildFrom.DataConsumerSchemes) { orgSchemesType.OrganisationScheme.Add(this._organisationSchemeXmlBuilder.Build(currentBean5)); } } // DATA PROVIDER SCHEMES if (buildFrom.DataProviderSchemes.Count > 0) { if (orgSchemesType == null) { orgSchemesType = new OrganisationSchemesType(); returnType.OrganisationSchemes = orgSchemesType; } /* foreach */ foreach (IDataProviderScheme currentBean6 in buildFrom.DataProviderSchemes) { orgSchemesType.OrganisationScheme.Add(this._organisationSchemeXmlBuilder.Build(currentBean6)); } } // PROCESSES if (buildFrom.Processes.Count > 0) { var processesType = new ProcessesType(); returnType.Processes = processesType; /* foreach */ foreach (IProcessObject currentBean7 in buildFrom.Processes) { processesType.Process.Add(this._processXmlBuilder.Build(currentBean7)); } } // STRUCTURE SETS if (buildFrom.StructureSets.Count > 0) { var structureSetsType = new StructureSetsType(); returnType.StructureSets = structureSetsType; /* foreach */ foreach (IStructureSetObject currentBean8 in buildFrom.StructureSets) { structureSetsType.StructureSet.Add(this._structureSetXmlBuilder.Build(currentBean8)); } } // REPORTING TAXONOMIES if (buildFrom.ReportingTaxonomys.Count > 0) { var reportingTaxonomiesType = new ReportingTaxonomiesType(); returnType.ReportingTaxonomies = reportingTaxonomiesType; /* foreach */ foreach (IReportingTaxonomyObject currentBean9 in buildFrom.ReportingTaxonomys) { reportingTaxonomiesType.ReportingTaxonomy.Add(this._reportingTaxonomyXmlBuilder.Build(currentBean9)); } } if (buildFrom.AttachmentConstraints.Count > 0) { throw new SdmxNotImplementedException( ExceptionCode.Unsupported, "Attachment Constraint at SMDX v2.0 - please use SDMX v2.1"); } if (buildFrom.ContentConstraintObjects.Count > 0) { throw new SdmxNotImplementedException( ExceptionCode.Unsupported, "Content Constraint at SMDX v2.0 - please use SDMX v2.1"); } return responseType; }
/// <summary> /// Sets the header. /// </summary> /// <param name="regInterface"> /// The registry interface. /// </param> /// <param name="sdmxObjects"> /// The beans. /// </param> public static void SetHeader(RegistryInterfaceType regInterface, ISdmxObjects sdmxObjects) { var header = new HeaderType(); regInterface.Header = header; SetHeader(header, sdmxObjects); }
public static char TypeQualifier(HeaderType T) { switch (T) { case HeaderType.Table: return 'T'; case HeaderType.Fragment: return 'F'; case HeaderType.Union: return 'U'; case HeaderType.Big: return 'M'; default : return 'X'; } }