/// <summary> /// Process the "ports" section of the XML document /// </summary> /// <param name="portsSection">Object representing the ports section</param> /// <returns>A collection of Port objects containing information about each individual port</returns> private static IEnumerable <Port> PortsSection(ports portsSection) { return(portsSection != null && portsSection.port != null ? portsSection.port.Select( x => new Port { PortNumber = int.Parse(x.portid), Protocol = x.protocol != portProtocol.sctp ? (ProtocolType) Enum.Parse(typeof(ProtocolType), x.protocol == portProtocol.ip ? x.protocol.ToString().ToUpperInvariant() : x.protocol.ToString().Capitalize()) : ProtocolType.Unknown, Filtered = x.state.state1.Contains("filtered"), Closed = x.state.state1.Contains("closed"), Service = x.service != null ? new Service { Name = x.service.name, Product = x.service.product, Os = x.service.ostype, Version = x.service.version } : default(Service) } ) : Enumerable.Empty <Port>()); }
/// <summary> /// Process the "extraports" section of the XML document (contains large numbers of ports in the same state) /// </summary> /// <param name="portsSection">Object representing the ports section</param> /// <returns>A collection of ExtraPorts objects if the extraports section exists, empty otherwise</returns> private static IEnumerable <ExtraPorts> ExtraPortsSection(ports portsSection) { return(portsSection != null && portsSection.extraports != null ? portsSection.extraports.Select( x => new ExtraPorts { Count = int.Parse(x.count), State = x.state }) : Enumerable.Empty <ExtraPorts>()); }
public Task <ports> CreateNewPort(ports item) { using (var db = new OcphDbContext()) { item.Id = db.Ports.InsertAndGetLastID(item); if (item.Id <= 0) { throw new SystemException("Data Tidak Tersimpan"); } return(Task.FromResult(item)); } }
private async void SaveAction(object obj) { try { var item = (ports)this; ports result = await context.CreateNewPort(item); this.SaveSuccess = true; this.SaveResult = result; WindowClose(); } catch (Exception ex) { Helpers.ShowErrorMessage(ex.Message); } }
public int calc_address(int reg, ports port, bool RD_WR) { int value = 1; if (RD_WR) //read { value = ((reg << 6 & 0x000007c0) | ((int)port << 0xB & 0x0000F800) | (1)); } else //Write { value = ((reg << 6 & 0x000007c0) | ((int)port << 0xB & 0x0000F800) | (3)); } return value; }
/// <summary> /// Process the "ports" section of the XML document /// </summary> /// <param name="portsSection">Object representing the ports section</param> /// <returns>A collection of Port objects containing information about each individual port</returns> private static IEnumerable<Port> PortsSection(ports portsSection) { return portsSection != null && portsSection.port != null ? portsSection.port.Select( x => new Port { PortNumber = int.Parse(x.portid), Protocol = x.protocol != portProtocol.sctp ? (ProtocolType) Enum.Parse(typeof (ProtocolType), x.protocol == portProtocol.ip ? x.protocol.ToString().ToUpperInvariant() : x.protocol.ToString().Capitalize()) : ProtocolType.Unknown, Filtered = x.state.state1 == "filtered", Service = x.service != null ? new Service { Name = x.service.name, Product = x.service.product, Os = x.service.ostype, Version = x.service.version } : default(Service) } ) : Enumerable.Empty<Port>(); }
/// <summary> /// Process the "extraports" section of the XML document (contains large numbers of ports in the same state) /// </summary> /// <param name="portsSection">Object representing the ports section</param> /// <returns>A collection of ExtraPorts objects if the extraports section exists, empty otherwise</returns> private static IEnumerable<ExtraPorts> ExtraPortsSection(ports portsSection) { return portsSection != null && portsSection.extraports != null ? portsSection.extraports.Select( x => new ExtraPorts { Count = int.Parse(x.count), State = x.state }) : Enumerable.Empty<ExtraPorts>(); }