System.Collections.Generic.IEnumerable.Contains(ushort)

Here are the examples of the csharp api System.Collections.Generic.IEnumerable.Contains(ushort) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

8 Examples 7

19 Source : RealLiveDisassembler.cs
with MIT License
from arcusmaximus

private bool IsCurrentFunctionOneOf(Dictionary<byte, ushort[]> functions)
        {
            ushort[] functionsOfModule;
            return functions.TryGetValue(_currentModule.Value, out functionsOfModule) && functionsOfModule.Contains(_currentFunction.Value);
        }

19 Source : TLMLineUtils.cs
with MIT License
from klyte45

public static bool GetNearStopPoints(Vector3 pos, float maxDistance, ref Dictionary<ushort, Vector3> stopsFound, ItemClreplaced.SubService[] subservicesAllowed = null, int maxDepht = 4, int depth = 0)
        {
            if (depth >= maxDepht)
            {
                return false;
            }

            if (subservicesAllowed == null)
            {
                subservicesAllowed = new ItemClreplaced.SubService[] { ItemClreplaced.SubService.PublicTransportTrain, ItemClreplaced.SubService.PublicTransportMetro };
            }
            int num = Mathf.Max((int)((pos.x - maxDistance) / 64f + 135f), 0);
            int num2 = Mathf.Max((int)((pos.z - maxDistance) / 64f + 135f), 0);
            int num3 = Mathf.Min((int)((pos.x + maxDistance) / 64f + 135f), 269);
            int num4 = Mathf.Min((int)((pos.z + maxDistance) / 64f + 135f), 269);
            bool noneFound = true;
            NetManager nm = Singleton<NetManager>.instance;
            TransportManager tm = Singleton<TransportManager>.instance;
            for (int i = num2; i <= num4; i++)
            {
                for (int j = num; j <= num3; j++)
                {
                    ushort stopId = nm.m_nodeGrid[i * 270 + j];
                    int num7 = 0;
                    while (stopId != 0)
                    {
                        NetInfo info = nm.m_nodes.m_buffer[stopId].Info;

                        if ((info.m_clreplaced.m_service == ItemClreplaced.Service.PublicTransport) && subservicesAllowed.Contains(info.m_clreplaced.m_subService))
                        {
                            ushort transportLine = nm.m_nodes.m_buffer[stopId].m_transportLine;
                            if (transportLine != 0)
                            {
                                if (!stopsFound.Keys.Contains(stopId))
                                {
                                    float num8 = Vector3.SqrMagnitude(pos - nm.m_nodes.m_buffer[stopId].m_position);
                                    if (num8 < maxDistance * maxDistance)
                                    {
                                        stopsFound[stopId] = nm.m_nodes.m_buffer[stopId].m_position;
                                        GetNearStopPoints(nm.m_nodes.m_buffer[stopId].m_position, maxDistance, ref stopsFound, subservicesAllowed, maxDepht, depth + 1);
                                        noneFound = false;
                                    }
                                }
                            }
                        }

                        stopId = nm.m_nodes.m_buffer[stopId].m_nextGridNode;
                        if (++num7 >= 32768)
                        {
                            CODebugBase<LogChannel>.Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);
                            break;
                        }
                    }
                }
            }
            return noneFound;
        }

19 Source : Program.cs
with MIT License
from overtools

private static void AllCMF(string[] args) {
            ushort[] types = args.Skip(2).Select(x => ushort.Parse(x, NumberStyles.HexNumber)).ToArray();

            Directory.CreateDirectory(AllCMFDir);
            foreach (KeyValuePair<ulong, ProductHandler_Tank.replacedet> replacedet in TankHandler.m_replacedets) {
                ushort type = teResourceGUID.Type(replacedet.Key);
                if (!types.Contains(type)) continue;
                try {
                    using (Stream stream = TankHandler.OpenFile(replacedet.Key)) {
                        if (stream == null) continue;
                        string typeDir = Path.Combine(AllCMFDir, type.ToString("X3"));
                        Directory.CreateDirectory(typeDir);
                        using (Stream file = File.OpenWrite(Path.Combine(typeDir, teResourceGUID.replacedtring(replacedet.Key)))) {
                            stream.CopyTo(file);
                        }
                    }
                } catch (Exception e) {
                    Console.Out.WriteLine(e);
                }
            }
        }

19 Source : ExtractDebugNewEntities.cs
with MIT License
from overtools

public void AddNewByContentHash(Combo.ComboInfo info, HashSet<CKey> contentHashes, params ushort[] types) {
            foreach (KeyValuePair<ulong, ProductHandler_Tank.replacedet> replacedet in TankHandler.m_replacedets) {
                TankHandler.Unpackreplacedet(replacedet.Value, out var package, out var record);

                ushort fileType = teResourceGUID.Type(replacedet.Key);
                if (fileType == 0x9C) continue; // bundle
                if (fileType == 0x77) continue; // package

                if (!types.Contains(fileType)) continue;

                var cmf = TankHandler.GetContentManifestForreplacedet(replacedet.Key);
                if (!cmf.TryGet(record.m_GUID, out var cmfData)) {
                    //throw new FileNotFoundException();
                    // todo: wtf
                    continue;
                }

                if (contentHashes.Contains(cmfData.ContentKey)) continue;

                if (fileType == 0x4) {
                    var locale = teResourceGUID.Locale(replacedet.Key);
                    if (locale == 0xF) continue; // ? 
                    if (locale == 0x1F) continue; // ? 
                    if (locale == 0x2F) continue; // ? 
                    if (locale == 0x3F) continue; // ? 
                    if (locale == 0x4F) continue; // ? 
                    if (locale == 0x5F) continue; // ? 
                    if (teResourceGUID.Platform(replacedet.Key) == 0x8) continue; // effect images
                }

                Combo.Find(info, replacedet.Key);
            }
        }

19 Source : DFAEventSource.cs
with GNU General Public License v3.0
from qitana

private void HandleMessage(byte[] message)
        {
            try
            {
                if (message.Length < 32)
                {
                    return;
                }

                var opcode = BitConverter.ToUInt16(message, 18);

                // 必要のないopcodeはここで弾く
                if (!opcodeList.Contains(opcode))
                {
                    return;
                }

                var data = message.Skip(32).ToArray();

                try
                {
                    if (opcode == Config.Structures.FirstOrDefault(x => x.Name == "Started").Opcode)
                    {
                        var structure = Config.Structures.FirstOrDefault(x => x.Name == "Started");
                        var roulette = BitConverter.ToUInt16(data, structure.Offset.RouletteCode);
                        var dungeon = BitConverter.ToUInt16(data, structure.Offset.DungeonCode);

                        lock (status.LockObject)
                        {
                            status.Clear();
                            if (roulette != 0)
                            {
                                status.RouletteCode = roulette;
                            }
                            else
                            {
                                status.DungeonCode = dungeon;
                            }
                            status.MatchingState = MatchingState.QUEUED;

                            DFAStatusUpdate(new JSEvents.DFAStatusUpdateEvent(status.ToJson()));
                            LogInfo("DFA: Queued [{0}/{1}]", roulette, dungeon);
                        }
                    }
                    else if (opcode == Config.Structures.FirstOrDefault(x => x.Name == "Matched").Opcode)
                    {
                        var structure = Config.Structures.FirstOrDefault(x => x.Name == "Matched");
                        var roulette = BitConverter.ToUInt16(data, structure.Offset.RouletteCode);
                        var dungeon = BitConverter.ToUInt16(data, structure.Offset.DungeonCode);
                        var roleFreeFlag = data[structure.Offset.RoleFreeFlag];

                        lock (status.LockObject)
                        {
                            status.SetZero();
                            status.RouletteCode = roulette;
                            status.DungeonCode = dungeon;
                            status.PartyState = (roleFreeFlag > 0) ? PartyState.ROLEFREE : PartyState.NORMAL;
                            status.MatchingState = MatchingState.MATCHED;

                            DFAStatusUpdate(new JSEvents.DFAStatusUpdateEvent(status.ToJson()));
                            LogInfo("DFA: Matched [{0}/{1}]", roulette, dungeon);
                        }
                    }
                    else if (opcode == Config.Structures.FirstOrDefault(x => x.Name == "Canceled").Opcode)
                    {
                        var structure = Config.Structures.FirstOrDefault(x => x.Name == "Canceled");
                        lock (status.LockObject)
                        {
                            status.Clear();

                            DFAStatusUpdate(new JSEvents.DFAStatusUpdateEvent(status.ToJson()));
                            LogInfo("DFA: Canceled");
                        }
                    }
                    else if (opcode == Config.Structures.FirstOrDefault(x => x.Name == "WaitQueue").Opcode)
                    {
                        var structure = Config.Structures.FirstOrDefault(x => x.Name == "WaitQueue");
                        var waitList = data[structure.Offset.WaitList];
                        var waitTime = data[structure.Offset.WaitTime];
                        var tank = data[structure.Offset.Tank];
                        var tankMax = data[structure.Offset.TankMax];
                        var healer = data[structure.Offset.Healer];
                        var healerMax = data[structure.Offset.HealerMax];
                        var dps = data[structure.Offset.Dps];
                        var dpsMax = data[structure.Offset.DpsMax];

                        lock (status.LockObject)
                        {
                            status.WaitList = waitList;
                            status.WaitTime = waitTime;
                            status.Tank = tank;
                            status.TankMax = tankMax;
                            status.Healer = healer;
                            status.HealerMax = healerMax;
                            status.Dps = dps;
                            status.DpsMax = dpsMax;
                            status.NonRole = 0;
                            status.NonRoleMax = 0;
                            status.MatchingState = MatchingState.QUEUED;

                            DFAStatusUpdate(new JSEvents.DFAStatusUpdateEvent(status.ToJson()));
                            LogInfo("DFA: Queued: WaitList:{0} WaitTime:{1} Tank:{2}/{3} Healer:{4}/{5} DPS:{6}/{7}",
                                waitList, waitTime, tank, tankMax, healer, healerMax, dps, dpsMax);
                        }
                    }
                    else if (opcode == Config.Structures.FirstOrDefault(x => x.Name == "PartyUpdate").Opcode)
                    {
                        var structure = Config.Structures.FirstOrDefault(x => x.Name == "PartyUpdate");
                        var tank = data[structure.Offset.Tank];
                        var tankMax = data[structure.Offset.TankMax];
                        var healer = data[structure.Offset.Healer];
                        var healerMax = data[structure.Offset.HealerMax];
                        var dps = data[structure.Offset.Dps];
                        var dpsMax = data[structure.Offset.DpsMax];
                        var nonRole = data[structure.Offset.NonRole];
                        var nonRoleMax = data[structure.Offset.NonRoleMax];

                        lock (status.LockObject)
                        {
                            /*
                             * Ref issue #3
                             * 
                             * ノーマルの場合、nonRole, nonRoleMax には不明な値が入る
                             * 制限解除等ロールフリーの場合、tank,tankMax,healer,healerMax,dps,dpsMax には不明な値が入る
                             * 24を閾値としてこれらの値を確認し、PartyStateがノーマルなのかロールフリーなのかを判定する。
                             * 
                             * すべて0な場合、どちらも不正な値の場合、どちらも正常な値だった場合は
                             * PartyStateは判断できないためそのままにする。
                             * 
                             */

                            var normalParty = new List<int> { tank, tankMax, healer, healerMax, dps, dpsMax };
                            var roleFreeParty = new List<int> { nonRole, nonRoleMax };

                            if ((normalParty.FindAll(x => x > 24).Count > 0 && roleFreeParty.FindAll(x => x > 24).Count > 0) ||
                                (normalParty.FindAll(x => x == 0).Count == normalParty.Count && roleFreeParty.FindAll(x => x == 0).Count == roleFreeParty.Count))
                            {
                                // Zero
                                status.Tank = 0;
                                status.TankMax = 0;
                                status.Healer = 0;
                                status.HealerMax = 0;
                                status.Dps = 0;
                                status.DpsMax = 0;
                                status.NonRole = 0;
                                status.NonRoleMax = 0;
                            }
                            else if (normalParty.FindAll(x => x > 24).Count == 0 && roleFreeParty.FindAll(x => x > 24).Count > 0)
                            {
                                // Normal party
                                status.PartyState = PartyState.NORMAL;
                                status.Tank = tank;
                                status.TankMax = tankMax;
                                status.Healer = healer;
                                status.HealerMax = healerMax;
                                status.Dps = dps;
                                status.DpsMax = dpsMax;
                                status.NonRole = 0;
                                status.NonRoleMax = 0;
                            }
                            else if (normalParty.FindAll(x => x > 24).Count > 0 && roleFreeParty.FindAll(x => x > 24).Count == 0)
                            {
                                // Role-Free party
                                status.PartyState = PartyState.ROLEFREE;
                                status.Tank = 0;
                                status.TankMax = 0;
                                status.Healer = 0;
                                status.HealerMax = 0;
                                status.Dps = 0;
                                status.DpsMax = 0;
                                status.NonRole = nonRole;
                                status.NonRoleMax = nonRoleMax;
                            }
                            else
                            {
                                // all data is valid data.
                                // Can't resolve PartyState.
                                status.Tank = tank;
                                status.TankMax = tankMax;
                                status.Healer = healer;
                                status.HealerMax = healerMax;
                                status.Dps = dps;
                                status.DpsMax = dpsMax;
                                status.NonRole = nonRole;
                                status.NonRoleMax = nonRoleMax;
                            }

                            status.MatchingState = MatchingState.MATCHED;

                            DFAStatusUpdate(new JSEvents.DFAStatusUpdateEvent(status.ToJson()));
                            LogInfo("DFA: Matched: Tank:{0}/{1} Healer:{2}/{3} DPS:{4}/{5} NonRole:{6}/{7}",
                                tank, tankMax, healer, healerMax, dps, dpsMax, nonRole, nonRoleMax);
                        }
                    }
                    else if (opcode == Config.Structures.FirstOrDefault(x => x.Name == "Completed").Opcode)
                    {
                        var structure = Config.Structures.FirstOrDefault(x => x.Name == "Completed");
                        var dungeon = BitConverter.ToUInt16(data, structure.Offset.DungeonCode);

                        lock (status.LockObject)
                        {
                            status.DungeonCode = dungeon;
                            DFAStatusUpdate(new JSEvents.DFAStatusUpdateEvent(status.ToJson()));
                            LogInfo("DFA: Completed [{0}/{1}]", status.RouletteCode, status.DungeonCode);
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogInfo("DFA: Exception: Opcode:{0}, {1}", opcode, ex.Message);
                }
            }
            catch (Exception ex)
            {
                LogInfo("DFA: Exception: {0}", ex.Message);
            }
        }

19 Source : USB.cs
with MIT License
from qmk

public bool DetectBootloader(ManagementBaseObject instance, bool connected = true)
        {
            var deviceId = GetHardwareId(instance);

            var vpr = DeviceIdRegex.Match(deviceId);
            if (vpr.Success)
            {
                var vendorId = Convert.ToUInt16(vpr.Groups[1].ToString(), 16);
                var productId = Convert.ToUInt16(vpr.Groups[2].ToString(), 16);
                var revisionBcd = Convert.ToUInt16(vpr.Groups[3].ToString(), 16);

                string deviceName;
                string comPort = null;
                string mountPoint = null;
                string driverName = GetDriverName(instance);
                Chipset deviceType;

                if (IsSerialDevice(instance))
                {
                    if (vendorId == 0x03EB && productId == 0x6124) // Atmel SAM-BA
                    {
                        deviceName = "Atmel SAM-BA";
                        deviceType = Chipset.AtmelSamBa;
                    }
                    else if (caterinaVids.Contains(vendorId) && caterinaPids.Contains(productId)) // Caterina
                    {
                        deviceName = "Caterina";
                        deviceType = Chipset.Caterina;
                    }
                    else if (vendorId == 0x16C0 && productId == 0x0483) // ArduinoISP/AVRISP
                    {
                        deviceName = "AVRISP";
                        deviceType = Chipset.AvrIsp;
                    }
                    else
                    {
                        return false;
                    }

                    comPort = GetComPort(instance);
                    _flasher.ComPort = comPort;
                }
                else if (vendorId == 0x03EB)
                {
                    if (atmelDfuPids.Contains(productId))
                    {
                        if (revisionBcd == 0x0936) // QMK-DFU
                        {
                            deviceName = "QMK DFU";
                            deviceType = Chipset.QmkDfu;
                        }
                        else // Atmel DFU
                        {
                            deviceName = "Atmel DFU";
                            deviceType = Chipset.AtmelDfu;
                        }
                    }
                    else if (productId == 0x2045) // LUFA MS
                    {
                        deviceName = "LUFA Mreplaced Storage";
                        deviceType = Chipset.LufaMs;
                        mountPoint = GetMountPoint(instance);
                        _flasher.MountPoint = mountPoint;
                    }
                    else
                    {
                        return false;
                    }
                }
                else if (vendorId == 0x16C0 && productId == 0x0478) // PJRC Teensy
                {
                    deviceName = "Halfkay";
                    deviceType = Chipset.Halfkay;
                }
                else if (vendorId == 0x0483 && productId == 0xDF11) // STM32 DFU
                {
                    deviceName = "STM32 DFU";
                    deviceType = Chipset.Stm32Dfu;
                }
                else if (vendorId == 0x314B && productId == 0x0106) // APM32 DFU
                {
                    deviceName = "APM32 DFU";
                    deviceType = Chipset.Apm32Dfu;
                }
                else if (vendorId == 0x1C11 && productId == 0xB007) // Kiibohd
                {
                    deviceName = "Kiibohd";
                    deviceType = Chipset.Kiibohd;
                }
                else if (vendorId == 0x16C0 && productId == 0x05DF) // Objective Development BootloadHID
                {
                    deviceName = "BootloadHID";
                    deviceType = Chipset.BootloadHid;
                }
                else if (vendorId == 0x16C0 && productId == 0x05DC) // USBasp and USBaspLoader
                {
                    deviceName = "USBasp";
                    deviceType = Chipset.UsbAsp;
                }
                else if (vendorId == 0x1781 && productId == 0x0C9F) // AVR Pocket ISP
                {
                    deviceName = "USB Tiny";
                    deviceType = Chipset.UsbTiny;
                }
                else if (vendorId == 0x1EAF && productId == 0x0003) // STM32Duino
                {
                    deviceName = "STM32Duino";
                    deviceType = Chipset.Stm32Duino;
                }
                else
                {
                    return false;
                }

                var connectedString = connected ? "connected" : "disconnected";
                var comPortString = comPort != null ? $" [{comPort}]" : "";
                var mountPointString = mountPoint != null ? $" [{mountPoint}]" : "";
                var driverString = driverName ?? "NO DRIVER";

                _printer.Print($"{deviceName} device {connectedString} ({driverString}): {instance.GetPropertyValue("Manufacturer")} {instance.GetPropertyValue("Name")} ({vendorId:X4}:{productId:X4}:{revisionBcd:X4}){comPortString}{mountPointString}", MessageType.Bootloader);

                _devicesAvailable[(int)deviceType] += (connected ? 1 : -1);

                return true;
            }

            return false;
        }

19 Source : PKM.cs
with GNU General Public License v3.0
from SciresM

public virtual bool CanHoldItem(ushort[] ValidArray)
        {
            return ValidArray.Contains((ushort)HeldItem);
        }

19 Source : Inventory.cs
with GNU General Public License v3.0
from SciresM

public bool Valid(ushort[] LegalItems, bool HaX, int MaxItemID)
        {
            if (Index == 0)
                return true;
            if (Index <= MaxItemID)
                return HaX || LegalItems.Contains((ushort)Index);
            return false;
        }