// Loads all eligible protocols the chart can show data for based on patients returned from each chart series
        public void loadProtocols()
        {
            HashSet <Protocol> protocolsUnique = new HashSet <Protocol>();

            ChartSeries.ForEach(cs => protocolsUnique = getUniqueProtocols(cs, protocolsUnique));
            protocolsUnique.ToList().ForEach(p => Protocols.Add(p));
        }
예제 #2
0
        /// <summary>
        ///   Reads the string representation from the specified <see cref="TextReader"/>.
        /// </summary>
        /// <param name="stream">
        ///   The <see cref="TextReader"/> to read from
        /// </param>
        /// <remarks>
        ///   The string representation is a sequence of <see cref="NetworkProtocol">network protocols</see>.
        /// </remarks>
        void Read(TextReader stream)
        {
            if (stream.Read() != '/')
            {
                throw new FormatException("An IFPS multiaddr must start with '/'.");
            }

            var name = new StringBuilder();
            Protocols.Clear();
            int c;
            while (true)
            {
                name.Clear();
                while (-1 != (c = stream.Read()) && c != '/')
                {
                    name.Append((char)c);
                }
                if (name.Length == 0)
                    break;
                if (!NetworkProtocol.Names.TryGetValue(name.ToString(), out Type protocolType))
                    throw new FormatException(string.Format("The IPFS network protocol '{0}' is unknown.", name.ToString()));
                var p = (NetworkProtocol)Activator.CreateInstance(protocolType);
                p.ReadValue(stream);
                Protocols.Add(p);
            }

            if (Protocols.Count == 0)
                throw new FormatException("The IFPS multiaddr has no protocol specified.");
        }
예제 #3
0
 public TransportBase(IEnumerable <string> protocols)
 {
     foreach (string protocol in protocols)
     {
         Protocols.Add(protocol);
     }
 }
예제 #4
0
 public ProtocolListTypeSpec(IEnumerable <NamedTypeSpec> protos)
     : this()
 {
     foreach (var proto in protos)
     {
         Protocols.Add(proto, false);
     }
 }
예제 #5
0
 public static void AddProtocol(Protocol protocol)
 {
     if (head == null)
     {
         head = protocol;
     }
     Protocols.Add(protocol.Name, protocol);
 }
예제 #6
0
        public void Add(TLDefinition tld, Stream srcStm)
        {
            TLFunction tlf = tld as TLFunction;

            if (tlf != null)
            {
                if (tlf.Signature.IsExtension)
                {
                    Extensions.Add(tlf, srcStm);
                }
                else if (tlf.IsTopLevelFunction)
                {
                    if (tlf.Signature is SwiftAddressorType)
                    {
                        Variables.Add(tlf, srcStm);
                    }
                    else if (tlf.Signature is SwiftWitnessTableType)
                    {
                        WitnessTables.Add(tld, srcStm);
                    }
                    else
                    {
                        Functions.Add(tlf, srcStm);
                    }
                }
                else
                {
                    if (tlf.Class.EntityKind == MemberNesting.Protocol)
                    {
                        Protocols.Add(tlf, srcStm);
                    }
                    else
                    {
                        Classes.Add(tld, srcStm);
                    }
                }
            }
            else
            {
                if (tld is TLVariable tlvar && ((TLVariable)tld).Class == null)
                {
                    if (tlvar is TLPropertyDescriptor propDesc)
                    {
                        if (propDesc.ExtensionOn != null)
                        {
                            ExtensionDescriptors.Add(propDesc);
                        }
                        else
                        {
                            PropertyDescriptors.Add(tlvar, srcStm);
                        }
                    }
                    else
                    {
                        Variables.Add(tld, srcStm);
                    }
                }
예제 #7
0
 /// <summary>
 /// Will reset the device information and initialize with the info fromteh DeviceInstance
 /// </summary>
 /// <param name="pDev">DeviceInstance that has the EPR info</param>
 public void ResetDevice(DeviceInstance pDev)
 {
     HostName = pDev.HostName;
     Profile  = pDev.Name;
     Protocols.Clear();
     foreach (ProtocolService _prot in pDev.ImplementedProtocolServices)
     {
         Protocols.Add(_prot.Protocol);
     }
 }
예제 #8
0
 /// <summary>
 ///   Reads the binary representation of the specified <see cref="CodedInputStream"/>.
 /// </summary>
 /// <param name="stream">
 ///   The <see cref="CodedInputStream"/> to read from.
 /// </param>
 /// <remarks>
 ///   The binary representation is a sequence of <see cref="NetworkProtocol">network protocols</see>.
 /// </remarks>
 void Read(CodedInputStream stream)
 {
     Protocols.Clear();
     do
     {
         uint code = (uint)stream.ReadInt64();
         if (!NetworkProtocol.Codes.TryGetValue(code, out Type protocolType))
             throw new InvalidDataException(string.Format("The IPFS network protocol code '{0}' is unknown.", code));
         var p = (NetworkProtocol)Activator.CreateInstance(protocolType);
         p.ReadValue(stream);
         Protocols.Add(p);
     } while (!stream.IsAtEnd);
 }
예제 #9
0
        public IIisExpressConfiguration UseHttps(bool use = true)
        {
            if (use)
            {
                Protocols.Add("https");
            }
            else
            {
                Protocols.Remove("https");
            }

            Protocols = Protocols.Distinct().ToList();
            return(this);
        }
예제 #10
0
        /// <summary>
        ///   Reads the binary representation of the specified <see cref="Google.Protobuf.CodedInputStream"/>.
        /// </summary>
        /// <param name="stream">
        ///   The <see cref="Google.Protobuf.CodedInputStream"/> to read from.
        /// </param>
        /// <remarks>
        ///   The binary representation is a sequence of <see cref="NetworkProtocol">network protocols</see>.
        /// </remarks>
        private void Read(CodedInputStream stream)
        {
            Protocols.Clear();
            do
            {
                var code = (uint)stream.ReadInt64();
                if (!NetworkProtocol.Codes.TryGetValue(code, out var protocolType))
                {
                    throw new InvalidDataException($"The IPFS network protocol code '{code}' is unknown.");
                }

                var p = (NetworkProtocol)Activator.CreateInstance(protocolType);
                p.ReadValue(stream);
                Protocols.Add(p);
            } while (!stream.IsAtEnd);
        }
예제 #11
0
        public void CreateProtocol()
        {
            var protocol = new Protocol {
                Name    = "New protocol",
                Packets = new List <Packet>()
            };

            Protocols = Protocols ?? new List <Protocol>();
            var window     = new ProtocolPropertiesWindow(protocol);
            var showDialog = window.ShowDialog();

            if (showDialog != null && (bool)showDialog)
            {
                Protocols.Add(protocol);
            }
        }
예제 #12
0
        /// <summary>
        /// Given a comma-separated string of rotocols, will convert to the collection of actual protocol values.
        /// </summary>
        /// <param name="pProts">Comman separated string of protocols (or protocol name fragements)</param>
        public void SetProtocols(string pProts)
        {
            string[] _tokens;
            char[]   _delims = { ',' };
            string   _pcol   = "";

            _tokens = pProts.Split(_delims);
            setupProtoMap();

            try
            {
                foreach (string _tkn in _tokens)
                {
                    _pcol = _tkn.ToUpper();
                    Protocols.Add(protocolMap.First(pm => pm.Key.Contains(_pcol)).Value);
                }
            }
            catch (Exception)
            {
                throw new Exception("Unknown Protocol specified: " + _pcol);
            }
        }
예제 #13
0
 public void AddProtocol(Protocol protocol)
 {
     Protocols.Add(protocol);
     Prerequisits.UnionWith(protocol.Dependencies);
     Dependants.UnionWith(protocol.Dependants);
 }
예제 #14
0
 public TransportBase(string protocol)
 {
     Protocols.Add(protocol);
 }
예제 #15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="itemType"></param>
        /// <param name="value"></param>
        private void AddItem(ItemType itemType, object value)
        {
            if (value.ToString().Length == 0)
            {
                return;
            }

            switch (itemType)
            {
            case ItemType.IpAddress:
                var ipAddresses = from ipAddress in IpAddresses where ipAddress.Text.ToUpper() == ((string)value).ToUpper() select ipAddress;
                if (ipAddresses.Count() == 0)
                {
                    IpAddress ipAddress = new IpAddress();
                    ipAddress.Text = (string)value;
                    IpAddresses.Add(ipAddress);
                }
                break;

            case ItemType.HostName:
                var hosts = from host in HostNames where host.ToUpper() == ((string)value).ToUpper() select host;
                if (hosts.Count() == 0)
                {
                    HostNames.Add((string)value);
                }
                break;

            case ItemType.Port:
                var ports = from port in Ports where port == (int)value select port;
                if (ports.Count() == 0)
                {
                    Ports.Add((int)value);
                }
                break;

            case ItemType.Protocol:
                var protocols = from protocol in Protocols where protocol.ToUpper() == ((string)value).ToUpper() select protocol;
                if (protocols.Count() == 0)
                {
                    Protocols.Add(((string)value).ToUpper());
                }
                break;

            case ItemType.Service:
                var services = from service in Services where service.ToUpper() == ((string)value).ToUpper() select service;
                if (services.Count() == 0)
                {
                    Services.Add((string)value);
                }
                break;

            case ItemType.State:
                var states = from state in States where state.ToUpper() == ((string)value).ToUpper() select state;
                if (states.Count() == 0)
                {
                    States.Add((string)value);
                }
                break;

            case ItemType.Severities:
                var severities = from severity in Severities where severity.ToUpper() == ((string)value).ToUpper() select severity;
                if (severities.Count() == 0)
                {
                    Severities.Add((string)value);
                }
                break;

            case ItemType.PluginFamily:
                var pluginFamilies = from pluginFamily in PluginFamilys where pluginFamily.ToUpper() == ((string)value).ToUpper() select pluginFamily;
                if (pluginFamilies.Count() == 0)
                {
                    PluginFamilys.Add((string)value);
                }
                break;

            case ItemType.PluginId:
                var pluginIds = from pluginId in PluginIds where pluginId.ToString().ToUpper() == ((string)value).ToUpper() select pluginId;
                if (pluginIds.Count() == 0)
                {
                    PluginIds.Add(int.Parse(value.ToString()));
                }
                break;

            case ItemType.PluginName:
                var pluginNames = from pluginName in PluginNames where pluginName.ToUpper() == ((string)value).ToUpper() select pluginName;
                if (pluginNames.Count() == 0)
                {
                    PluginNames.Add((string)value);
                }
                break;

            case ItemType.Product:
                var products = from product in Products where product.ToUpper() == ((string)value).ToUpper() select product;
                if (products.Count() == 0)
                {
                    Products.Add((string)value);
                }
                break;

            case ItemType.Versions:
                var versions = from version in Versions where version.ToUpper() == ((string)value).ToUpper() select version;
                if (versions.Count() == 0)
                {
                    Versions.Add((string)value);
                }
                break;

            case ItemType.ExploitAvailable:
                var exploitAvailable = from e in ExploitAvailable where e.ToUpper() == ((string)value).ToUpper() select e;
                if (exploitAvailable.Count() == 0)
                {
                    ExploitAvailable.Add((string)value);
                }
                break;

            default:
                break;
            }
        }
예제 #16
0
파일: CodeGen.cs 프로젝트: yanivru/avro
 /// <summary>
 /// Adds a protocol object to generate code for.
 /// </summary>
 /// <param name="protocol">The protocol.</param>
 public virtual void AddProtocol(Protocol protocol)
 {
     Protocols.Add(protocol);
 }
예제 #17
0
        public void Connect(SCardShareMode shareMode = SCardShareMode.Shared)
        {
            PCSCResult result;

            // Are we already connected?
            if (myHandle != IntPtr.Zero)
            {
                return;
            }

            // Establish a new session context for this card
            result = NativeMethods.SCardEstablishContext(SCardScope.User, IntPtr.Zero, IntPtr.Zero, out myContext);
            if (PCSCResult.None != result)
            {
                throw PCSCException.ThrowByResult(result);
            }

            // Connect to the card
            result = NativeMethods.SCardConnect(myContext, myReaderName, shareMode, DefaultRequestedProtocols, ref myHandle, ref myCommsProtocol);

            if (PCSCResult.None != result)
            {
                // Disconnect (this will gracefully handle the context release)
                Disconnect();
                throw PCSCException.ThrowByResult(result);
            }

            // Retrieve our ATR
            byte[]        readerName   = new byte[255];
            uint          readerLen    = 255;
            SCardState    state        = 0;
            SCardProtocol cardProtocol = 0;
            uint          atrLen       = NativeMethods.SCARD_ATR_LENGTH;

            byte[] atr = new byte[atrLen];

            result = NativeMethods.SCardStatus(myHandle, readerName, ref readerLen, out state, out cardProtocol, atr, ref atrLen);
            if (result != PCSCResult.None)
            {
                // Disconnect from the card
                Disconnect();
                throw PCSCException.ThrowByResult(result);
            }


            //
            // Protocol Enumeration
            //
            try
            {
                // Add the default 7816 protocol
                Protocols.Add(new PCSCIso7816Protocol(atr, this));

                // Determine whether this card is contactless or not
                if (SupportsIso14443)
                {
                    // Replace the 7816 protocol with 14443
                    Protocols.Clear();

                    var protocol = new PCSCIso14443AProtocol(atr, this);
                    Protocols.Add(protocol);

                    // Create our OptionalCommands object
                    OptionalCommands = new PCSCOptionalCommands(protocol);

                    //
                    // HACK: Adding a PCSCMifareProtocol to all ISO14443 cards, what
                    //       we should be doing is somehow determining if this card
                    //       supports Mifare or Mifare emulation
                    //
                    Protocols.Add(new PCSCMifareProtocol(this));
                }
            }
            catch (Exception)
            {
                // Disconnect from the card
                Disconnect();
                throw PCSCException.ThrowUnsupportedProtocol();
            }
        }
예제 #18
0
파일: ModuleSpace.cs 프로젝트: e2wugui/zeze
 public void Add(Protocol protocol)
 {
     Program.AddNamedObject(Path(".", protocol.Name), protocol);
     Protocols.Add(protocol.Name, protocol);
 }