コード例 #1
0
        protected override void PerformWork(IList<ArraySegment<Message>> items, out int totalCount, out object state)
        {
            // The list of cursors represent (streamid, payloadid)
            var nextCursors = new ulong?[_cursors.Count];
            totalCount = 0;

            // Get the enumerator so that we can extract messages for this subscription
            IEnumerator<Tuple<ScaleoutMapping, int>> enumerator = GetMappings().GetEnumerator();

            while (totalCount < MaxMessages && enumerator.MoveNext())
            {
                ScaleoutMapping mapping = enumerator.Current.Item1;
                int streamIndex = enumerator.Current.Item2;

                ulong? nextCursor = nextCursors[streamIndex];

                // Only keep going with this stream if the cursor we're looking at is bigger than
                // anything we already processed
                if (nextCursor == null || mapping.Id > nextCursor)
                {
                    ulong mappingId = ExtractMessages(streamIndex, mapping, items, ref totalCount);

                    // Update the cursor id
                    nextCursors[streamIndex] = mappingId;
                }
            }

            state = nextCursors;
        }
コード例 #2
0
ファイル: StatusUpdate.cs プロジェクト: RoDaniel/featurehouse
        internal StatusUpdate(string name)
        {
            jobName = name;

            estimatedTime = null;
            hasError = false;
            isComplete = false;
            wasAborted = false;
            error = null;
            log = null;
            audioPosition = null;
            cliplength = null;
            audioFileSize = null;
            nbFramesDone = null;
            nbFramesTotal = null;
            projectedFileSize = null;
            timeElapsed = TimeSpan.Zero;
            processingspeed = null;
            filesize = null;

            for (int i = 0; i < UpdatesPerEstimate; ++i)
            {
                previousUpdates[i] = TimeSpan.Zero;
                previousUpdatesProgress[i] = 0M;
            }
        }
コード例 #3
0
ファイル: TableOrder.cs プロジェクト: forr/BonTemps
 public TableOrder(ulong? tableOrderID)
 {
     this.tableOrderID = tableOrderID;
     this.tableID = null;
     this.orderID = null;
     this.orderReady = false;
 }
コード例 #4
0
        void CheckLimits(object state)
        {
            lock (limitLock)
            {
                var currentMemoryPeak = jobObject.GetPeakJobMemoryUsed();
                var currentMemoryLimit = jobObject.GetJobMemoryLimit();

                bool valueHasChanged = !lastMemoryPeak.HasValue || currentMemoryPeak != lastMemoryPeak.Value;
                bool limitHasChanged = !lastMemoryLimit.HasValue || currentMemoryLimit != lastMemoryLimit.Value;

                try
                {
                    if (valueHasChanged || limitHasChanged)
                    {
                        if (currentMemoryPeak >= currentMemoryLimit)
                            OnMemoryLimitReached();
                    }
                }
                finally
                {
                    lastMemoryPeak = currentMemoryPeak;
                    lastMemoryLimit = currentMemoryLimit;
                }
            }
        }
コード例 #5
0
ファイル: Account.cs プロジェクト: orior/d3sharp
        protected override ulong GenerateNewPersistentId()
        {
            if (_persistantIdCounter == null)
                _persistantIdCounter = AccountManager.GetNextAvailablePersistantId();

            return (ulong)++_persistantIdCounter;
        }
コード例 #6
0
        public Subclipping(CloudMediaContext context, List<IAsset> assetlist, Mainform mainform)
        {
            InitializeComponent();
            buttonJobOptions.Initialize(context);
            this.Icon = Bitmaps.Azure_Explorer_ico;
            _context = context;
            _parentassetmanifestdata = new ManifestTimingData();
            _selectedAssets = assetlist;
            _mainform = mainform;

            if (_selectedAssets.Count == 1 && _selectedAssets.FirstOrDefault() != null)  // one asset only
            {
                var myAsset = assetlist.FirstOrDefault();
                textBoxAssetName.Text = myAsset.Name;

                // let's try to read asset timing
                _parentassetmanifestdata = AssetInfo.GetManifestTimingData(myAsset);

                if (!_parentassetmanifestdata.Error)  // we were able to read asset timings and not live
                {
                    _timescale = timeControlStart.TimeScale = timeControlEnd.TimeScale = _parentassetmanifestdata.TimeScale;
                    timeControlStart.ScaledFirstTimestampOffset = timeControlEnd.ScaledFirstTimestampOffset = _parentassetmanifestdata.TimestampOffset;

                    textBoxOffset.Text = _parentassetmanifestdata.TimestampOffset.ToString();
                    labelOffset.Visible = textBoxOffset.Visible = true;

                    textBoxFilterTimeScale.Text = _timescale.ToString();
                    textBoxFilterTimeScale.Visible = labelAssetTimescale.Visible = true;

                    timeControlStart.Max = timeControlEnd.Max = _parentassetmanifestdata.AssetDuration;

                    labelassetduration.Visible = textBoxAssetDuration.Visible = true;
                    textBoxAssetDuration.Text = timeControlStart.Max.ToString(@"d\.hh\:mm\:ss") + (_parentassetmanifestdata.IsLive ? " (LIVE)" : "");
                    // let set duration and active track bat
                    timeControlStart.TotalDuration = timeControlEnd.TotalDuration = _parentassetmanifestdata.AssetDuration;
                    timeControlStart.DisplayTrackBar = true;
                    timeControlEnd.DisplayTrackBar = true;
                    timeControlEnd.SetTimeStamp(timeControlEnd.Max);

                }

                else // one asset but not able to read asset timings
                {
                    timeControlStart.DisplayTrackBar = timeControlEnd.DisplayTrackBar = false;
                    timeControlStart.TimeScale = timeControlEnd.TimeScale = _timescale;
                    timeControlStart.Max = timeControlEnd.Max = TimeSpan.MaxValue;
                    //timeControlEnd.SetTimeStamp(timeControlEnd.Max);
                }
            }
            else // several assets
            {
                groupBoxTrimming.Enabled = panelAssetInfo.Visible = false; // no trimming and no asset info
                radioButtonAssetFilter.Enabled = false; // no asset filter option
                timeControlStart.DisplayTrackBar = timeControlEnd.DisplayTrackBar = false;
                timeControlStart.TimeScale = timeControlEnd.TimeScale = _timescale;
                timeControlStart.Max = timeControlEnd.Max = TimeSpan.MaxValue;
                //timeControlEnd.SetTimeStamp(timeControlEnd.Max);
            }
        }
コード例 #7
0
 public static void CheckUnaryDecrementNullableULongTest(bool useInterpreter)
 {
     ulong?[] values = new ulong?[] { null, 0, 1, ulong.MaxValue };
     for (int i = 0; i < values.Length; i++)
     {
         VerifyDecrementNullableULong(values[i], useInterpreter);
     }
 }
コード例 #8
0
 public static void CheckUnaryIncrementNullableULongTest()
 {
     ulong?[] values = new ulong?[] { null, 0, 1, ulong.MaxValue };
     for (int i = 0; i < values.Length; i++)
     {
         VerifyIncrementNullableULong(values[i]);
     }
 }
コード例 #9
0
        /// <summary>
        ///     Creates status of thread in idle state.
        /// </summary>
        public ComputationalThreadStatus()
        {
            _state = ThreadStatus.ThreadState.Idle;
            _lastStateChange = DateTime.UtcNow;

            _problemType = null;
            _problemInstanceId = null;
            _partialProblemId = null;
        }
コード例 #10
0
ファイル: Order.cs プロジェクト: forr/BonTemps
 public Order(ulong? orderID)
 {
     this.orderID = orderID;
     this.clientID = null;
     this.startDateTime = null;
     this.endDateTime = null;
     this.seated = false;
     this.payed = false;
 }
コード例 #11
0
ファイル: LuceneResult.cs プロジェクト: heran/DekiWiki
 //--- Constructors ---
 public LuceneResult(Document document, float score) {
     Document = document;
     Score = score;
     var field = document.GetField("id.page");
     if(field == null) {
         return;
     }
     ulong pageId;
     PageId = ulong.TryParse(field.StringValue(), out pageId) ? pageId : (ulong?)null;
 }
コード例 #12
0
ファイル: PDFDocument.cs プロジェクト: unbelt/Telerik
 public override void LoadProperty(string key, string value)
 {
     if (key == "pages")
     {
         this.NumberOfPages = ulong.Parse(value);
     }
     else
     {
         base.LoadProperty(key, value);
     }
 }
コード例 #13
0
ファイル: VideoDocument.cs プロジェクト: unbelt/Telerik
 public override void LoadProperty(string key, string value)
 {
     if (key == "framerate")
     {
         this.FrameRate = ulong.Parse(value);
     }
     else
     {
         base.LoadProperty(key, value);
     }
 }
コード例 #14
0
 public override void LoadProperty(string key, string value)
 {
     if (key == "chars")
     {
         this.chars = ulong.Parse(value);
     }
     else
     {
         base.LoadProperty(key, value);
     }
 }
コード例 #15
0
        public ulong GetNext()
        {
            if (this.id == null)
                this.id = ulong.MinValue;

            while (this.id <= this.ids.Max && this.ids.Contains ((ulong) this.id))
                ++ this.id;

            this.ids.Add ((ulong) this.id);

            return (ulong) this.id;
        }
コード例 #16
0
ファイル: LocalHexSettings.cs プロジェクト: arkanoid1/dnSpy
		public LocalHexSettings(DnHexBox dnHexBox) {
			this.BytesGroupCount = dnHexBox.BytesGroupCount;
			this.BytesPerLine = dnHexBox.BytesPerLine;
			this.UseHexPrefix = dnHexBox.UseHexPrefix;
			this.ShowAscii = dnHexBox.ShowAscii;
			this.LowerCaseHex = dnHexBox.LowerCaseHex;
			this.AsciiEncoding = dnHexBox.AsciiEncoding;
			this.HexOffsetSize = dnHexBox.HexOffsetSize;
			this.UseRelativeOffsets = dnHexBox.UseRelativeOffsets;
			this.BaseOffset = dnHexBox.BaseOffset;
			this.StartOffset = dnHexBox.StartOffset == dnHexBox.DocumentStartOffset ? (ulong?)null : dnHexBox.StartOffset;
			this.EndOffset = dnHexBox.EndOffset == dnHexBox.DocumentEndOffset ? (ulong?)null : dnHexBox.EndOffset;
		}
コード例 #17
0
ファイル: NumberLiteralValue.cs プロジェクト: xxjeng/nuxleus
 public NumberLiteralValue(ulong value)
 {
     if (value <= long.MaxValue)
     {
         Value = (long)value;
         UnsignedValue = null;
     }
     else
     {
         Value = null;
         UnsignedValue = value;
     }
 }
コード例 #18
0
ファイル: LocalHexSettings.cs プロジェクト: nakijun/dnSpy
		public LocalHexSettings(HexTabState tabState) {
			this.BytesGroupCount = tabState.BytesGroupCount;
			this.BytesPerLine = tabState.BytesPerLine;
			this.UseHexPrefix = tabState.UseHexPrefix;
			this.ShowAscii = tabState.ShowAscii;
			this.LowerCaseHex = tabState.LowerCaseHex;
			this.AsciiEncoding = tabState.AsciiEncoding;
			this.HexOffsetSize = tabState.HexBox.HexOffsetSize;
			this.UseRelativeOffsets = tabState.HexBox.UseRelativeOffsets;
			this.BaseOffset = tabState.HexBox.BaseOffset;
			this.StartOffset = tabState.HexBox.StartOffset == tabState.DocumentStartOffset ? (ulong?)null : tabState.HexBox.StartOffset;
			this.EndOffset = tabState.HexBox.EndOffset == tabState.DocumentEndOffset ? (ulong?)null : tabState.HexBox.EndOffset;
		}
コード例 #19
0
ファイル: ExcelDocument.cs プロジェクト: unbelt/Telerik
 public override void LoadProperty(string key, string value)
 {
     if (key == "rows")
     {
         this.NumberOfRows = ulong.Parse(value);
     }
     else if (key == "cols")
     {
         this.NumberOfColumns = ulong.Parse(value);
     }
     else
     {
         base.LoadProperty(key, value);
     }
 }
コード例 #20
0
		private void Parse(byte[] bytes)
		{
			var flag = bytes[0];
			bytes = bytes.RemoveFromStart(1);

			var hasPort = (flag & 0x80) > 0;
			var hasSteamId = (flag & 0x10) > 0;
			var hasSourceTv = (flag & 0x40) > 0;
			var hasKeywords = (flag & 0x20) > 0;
			var hasGameId = (flag & 0x01) > 0;

			if (hasPort)
			{
				Port = bytes.ReadInt16();
				bytes = bytes.RemoveFromStart(2);
			}

			if (hasSteamId)
			{
				UnsignedServerSteamId = bytes.ReadUInt64();
				SignedServerSteamId = bytes.ReadInt64();
				bytes = bytes.RemoveFromStart(8);
			}

			if (hasSourceTv)
			{
				SourceTvPort = bytes.ReadInt16();
				bytes = bytes.RemoveFromStart(2);

				SourceTvName = bytes.ReadStringUntilNullTerminator();
				bytes = bytes.RemoveFromStart(SourceTvName.Length + 1);
			}

			if (hasKeywords)
			{
				Keywords = bytes.ReadStringUntilNullTerminator();
				bytes = bytes.RemoveFromStart(Keywords.Length + 1);
			}

			if (hasGameId)
			{
				GameSteamId = bytes.ReadUInt64();
				bytes = bytes.RemoveFromStart(8);
			}

			if (bytes.Any())
				throw new ResponseLengthException();
		}
コード例 #21
0
ファイル: StoreCommand.cs プロジェクト: samoshkin/MemcacheIt
        public StoreCommand(CacheItem item, TimeToLive timeToLive, StoreMode storeMode)
        {
            Condition.Requires(item).IsNotNull(
                "When storing item, item should be specified.");
            Condition.Requires(item.Data).IsNotNull(
                "When storing item '{0}', item's value should be specified.".FormatString(item));
            Condition.Requires(timeToLive).IsNotNull(
                "When storing item '{0}', item's time to live should be specified.".FormatString(item));
            Condition.Requires(storeMode).IsNotEqualTo(StoreMode.CheckAndSet,
                "To initialize 'Check and Set' command use another constructor, which accepts unique ID.");

            _item = item;
            _timeToLive = timeToLive;
            _storeMode = storeMode;
            _uniqueID = null;
        }
コード例 #22
0
        internal MPNowPlayingInfo(NSDictionary source)
        {
            if (source == null)
                return;

            NSObject result;

            if (source.TryGetValue (MPNowPlayingInfoCenter.PropertyElapsedPlaybackTime, out result))
                ElapsedPlaybackTime = (result as NSNumber).DoubleValue;
            if (source.TryGetValue (MPNowPlayingInfoCenter.PropertyPlaybackRate, out result))
                PlaybackRate = (result as NSNumber).DoubleValue;
            if (source.TryGetValue (MPNowPlayingInfoCenter.PropertyPlaybackQueueIndex, out result))
                PlaybackQueueIndex = (int) (result as NSNumber).UInt32Value;
            if (source.TryGetValue (MPNowPlayingInfoCenter.PropertyPlaybackQueueCount, out result))
                PlaybackQueueCount = (int) (result as NSNumber).UInt32Value;
            if (source.TryGetValue (MPNowPlayingInfoCenter.PropertyChapterNumber, out result))
                ChapterNumber = (int) (result as NSNumber).UInt32Value;
            if (source.TryGetValue (MPNowPlayingInfoCenter.PropertyChapterCount, out result))
                ChapterCount = (int) (result as NSNumber).UInt32Value;
            if (source.TryGetValue (MPNowPlayingInfoCenter.PropertyDefaultPlaybackRate, out result))
                DefaultPlaybackRate = (double) (result as NSNumber).DoubleValue;
            if (source.TryGetValue (MPMediaItem.AlbumTrackCountProperty, out result))
                AlbumTrackCount = (int) (result as NSNumber).UInt32Value;
            if (source.TryGetValue (MPMediaItem.AlbumTrackNumberProperty, out result))
                AlbumTrackNumber = (int) (result as NSNumber).UInt32Value;
            if (source.TryGetValue (MPMediaItem.DiscCountProperty, out result))
                DiscCount = (int) (result as NSNumber).UInt32Value;
            if (source.TryGetValue (MPMediaItem.DiscNumberProperty, out result))
                DiscNumber = (int) (result as NSNumber).UInt32Value;
            if (source.TryGetValue (MPMediaItem.PersistentIDProperty, out result))
                PersistentID = (result as NSNumber).UInt64Value;
            if (source.TryGetValue (MPMediaItem.PlaybackDurationProperty, out result))
                PlaybackDuration = (result as NSNumber).DoubleValue;

            if (source.TryGetValue (MPMediaItem.AlbumTitleProperty, out result))
                AlbumTitle = (string) (result as NSString);
            if (source.TryGetValue (MPMediaItem.ArtistProperty, out result))
                Artist = (string) (result as NSString);
            if (source.TryGetValue (MPMediaItem.ArtworkProperty, out result))
                Artwork = result as MPMediaItemArtwork;
            if (source.TryGetValue (MPMediaItem.ComposerProperty, out result))
                Composer = (string) (result as NSString);
            if (source.TryGetValue (MPMediaItem.GenreProperty, out result))
                Genre = (string) (result as NSString);
            if (source.TryGetValue (MPMediaItem.TitleProperty, out result))
                Title = (string) (result as NSString);
        }
コード例 #23
0
		public void Initialize()
		{
			Item1 = 10;
			Item2 = 202;
			Item3 = 203;
			Item4 = 204;
			Item5 = 205.091f;
			Item6 = 206.123m;
			Item7 = 207.456;
			Item8 = true;
			Item9 = 209;
			Item10 = 120;
			Item11 = 2011;
			Item12 = 2012;
			Item13 = 2013;
			Text = "Hello there !";
		}
コード例 #24
0
        internal Resource(XmlReader reader)
        {
            ulong size;
            TimeSpan duration;
            Resolution resolution;
            uint bitrate, sample_frequency, bits_per_sample, nr_audio_channels, color_depth;

            if (ulong.TryParse (reader["size"], out size))
                this.size = size;

            if (TimeSpan.TryParse (reader["duration"], out duration)) // TODO our own parsing
                this.duration = duration;

            if (uint.TryParse (reader["bitrate"], out bitrate))
                this.bitrate = bitrate;

            if (uint.TryParse (reader["sampleFrequency"], out sample_frequency))
                this.sample_frequency = sample_frequency;

            if (uint.TryParse (reader["bitsPerSecond"], out bits_per_sample))
                this.bits_per_sample = bits_per_sample;

            if (uint.TryParse (reader["nrAudioChannels"], out nr_audio_channels))
                this.nr_audio_channels = nr_audio_channels;

            // FIXME I shouldn't have to qualify this
            if (Mono.Upnp.Dcp.MediaServer1.ContentDirectory1.Resolution.TryParse (reader["resolution"], out resolution))
                this.resolution = resolution;

            if (uint.TryParse (reader["colorDepth"], out color_depth))
                this.color_depth = color_depth;

            protocol_info = reader["protocolInfo"];

            protection = reader["protection"];

            var import_uri = reader["importUri"];
            if (Uri.IsWellFormedUriString (import_uri, UriKind.Absolute)) {
                this.import_uri = new Uri (import_uri);
            }

            uri = new Uri (reader.ReadString ());
        }
    void FixedUpdate()
    {
        BodySourceManager bodyManager = BodySourceManager.GetComponent<BodySourceManager>();

        WindowsKinect.Body[] allBodiesInTheScreen = bodyManager == null
            ? new WindowsKinect.Body[0]
            : GetAllSkeletonsInTheScreen(bodyManager);

        if (allBodiesInTheScreen.Length < 1)
        {
            PlayerSkeleton = null;
            return;
        }

        bool noTrackingId = trackingId == null;
        WindowsKinect.Body firstBodyEnteringTheScreen = allBodiesInTheScreen[0];
        PlayerSkeleton = noTrackingId ? firstBodyEnteringTheScreen : GetCurrentSkeleton(trackingId.Value, allBodiesInTheScreen);
        trackingId = noTrackingId
            ? (ulong?)firstBodyEnteringTheScreen.TrackingId
            : (PlayerSkeleton == null ? (ulong?)null : (ulong?)PlayerSkeleton.TrackingId);
    }
コード例 #26
0
        public LevelDbStorageModule(string baseDirectory, ChainType rulesType,
            ulong? blocksCacheSize = null, ulong? blocksWriteCacheSize = null,
            ulong? blockTxesCacheSize = null, ulong? blockTxesWriteCacheSize = null,
            ulong? chainStateCacheSize = null, ulong? chainStateWriteCacheSize = null,
            string[] blockTxesStorageLocations = null)
        {
            this.baseDirectory = baseDirectory;
            this.blockTxesStorageLocations = blockTxesStorageLocations;
            dataDirectory = Path.Combine(baseDirectory, "Data", rulesType.ToString());
            peersDirectory = Path.Combine(baseDirectory, "Peers", rulesType.ToString());
            chainType = rulesType;

            this.blocksCacheSize = blocksCacheSize;
            this.blocksWriteCacheSize = blocksWriteCacheSize;

            this.blockTxesCacheSize = blockTxesCacheSize ?? (ulong)128.MEBIBYTE();
            this.blockTxesWriteCacheSize = blockTxesWriteCacheSize ?? (ulong)32.MEBIBYTE();

            this.chainStateCacheSize = chainStateCacheSize ?? (ulong)512.MEBIBYTE();
            this.chainStateWriteCacheSize = chainStateWriteCacheSize ?? (ulong)128.MEBIBYTE();
        }
コード例 #27
0
 public void AddElement(ulong element, ulong displacement)
 {
     if (FirstElement == null)
     {
         FirstElement = LastElement = element;
         FirstElementDisplacement = LastElementDisplacement = displacement;
         Length = 1;
     }
     else
     {
         if ((element > LastElement) && (displacement > LastElementDisplacement))
         {
             LastElement = element;
             LastElementDisplacement = displacement;
             Length++;
         }
         else
         {
             throw new ArgumentException("This number is not in chain");
         }
     }
 }
コード例 #28
0
 public TokenisedUser(ulong?id, string token = null, Users baseUser = null)
 {
     Id       = id;
     Token    = token;
     BaseUser = baseUser;
 }
コード例 #29
0
ファイル: ProtectionService.cs プロジェクト: Nielk1/NadekoBot
        public async Task <AntiSpamStats> StartAntiSpamAsync(ulong guildId, int messageCount, PunishmentAction action,
                                                             int punishDurationMinutes, ulong?roleId)
        {
            var g = _client.GetGuild(guildId);
            await _mute.GetMuteRole(g).ConfigureAwait(false);

            if (!IsDurationAllowed(action))
            {
                punishDurationMinutes = 0;
            }

            var stats = new AntiSpamStats
            {
                AntiSpamSettings = new AntiSpamSetting()
                {
                    Action           = action,
                    MessageThreshold = messageCount,
                    MuteTime         = punishDurationMinutes,
                    RoleId           = roleId,
                }
            };

            stats = _antiSpamGuilds.AddOrUpdate(guildId, stats, (key, old) =>
            {
                stats.AntiSpamSettings.IgnoredChannels = old.AntiSpamSettings.IgnoredChannels;
                return(stats);
            });

            using (var uow = _db.GetDbContext())
            {
                var gc = uow.GuildConfigs.ForId(guildId, set => set.Include(x => x.AntiSpamSetting));

                if (gc.AntiSpamSetting != null)
                {
                    gc.AntiSpamSetting.Action           = stats.AntiSpamSettings.Action;
                    gc.AntiSpamSetting.MessageThreshold = stats.AntiSpamSettings.MessageThreshold;
                    gc.AntiSpamSetting.MuteTime         = stats.AntiSpamSettings.MuteTime;
                    gc.AntiSpamSetting.RoleId           = stats.AntiSpamSettings.RoleId;
                }
                else
                {
                    gc.AntiSpamSetting = stats.AntiSpamSettings;
                }
                await uow.SaveChangesAsync();
            }
            return(stats);
        }
コード例 #30
0
        public new static MemFile Deserialize(ResourceInfo resourceInfo, ushort version, uint slotRamRequired, uint slotVRamRequired, uint otherRamRequired, uint otherVRamRequired, ulong?nameHash, byte[] rawData, IMapper mapper)
        {
            MemFile type = mapper.Map <MemFile>(Resource.Deserialize(resourceInfo, version, slotRamRequired, slotVRamRequired, otherRamRequired, otherVRamRequired, nameHash, rawData, null));

            if (version == 2)
            {
                using (MemoryStream memory = new MemoryStream(rawData))
                {
                    uint pathLength = memory.ReadUInt32();
                    type.Path = memory.ReadString((int)pathLength);
                    memory.Seek(sizeof(uint), SeekOrigin.Current);
                    memory.Seek(sizeof(uint), SeekOrigin.Current);
                    byte[] buffer = memory.ReadAllBytesFromCurrentPosition();
                    type.Data = Encoding.UTF8.GetBytes(Encoding.UTF8.GetString(buffer));
                }
            }

            else if (version == 4)
            {
                using (MemoryStream memory = new MemoryStream(rawData))
                {
                    memory.Seek(sizeof(uint), SeekOrigin.Begin);
                    uint pathLength = memory.ReadUInt32();
                    type.Path = memory.ReadString((int)pathLength);
                    type.Info.SourceDataDescription = type.Path;
                    memory.Seek(sizeof(uint), SeekOrigin.Current);
                    memory.Seek(sizeof(uint), SeekOrigin.Current);
                    uint dataLength = memory.ReadUInt32();
                    type.Data = memory.ReadAllBytesFromCurrentPosition();
                }
            }

            return(type);
        }
コード例 #31
0
 public Task <IReadOnlyCollection <IUser> > GetReactionUsersAsync(string emoji, int limit, ulong?afterUserId, RequestOptions options = null)
 => MessageHelper.GetReactionUsersAsync(this, emoji, x => { x.Limit = limit; x.AfterUserId = afterUserId.HasValue ? afterUserId.Value : Optional.Create <ulong>(); }, Discord, options);
コード例 #32
0
        internal override void Update(Model model)
        {
            base.Update(model);

            if (model.IsTextToSpeech.IsSpecified)
            {
                _isTTS = model.IsTextToSpeech.Value;
            }
            if (model.Pinned.IsSpecified)
            {
                _isPinned = model.Pinned.Value;
            }
            if (model.EditedTimestamp.IsSpecified)
            {
                _editedTimestampTicks = model.EditedTimestamp.Value?.UtcTicks;
            }
            if (model.MentionEveryone.IsSpecified)
            {
                _isMentioningEveryone = model.MentionEveryone.Value;
            }
            if (model.WebhookId.IsSpecified)
            {
                _webhookId = model.WebhookId.Value;
            }

            if (model.IsBlocked.IsSpecified)
            {
                _isBlocked = model.IsBlocked.Value;
            }

            if (model.Attachments.IsSpecified)
            {
                var value = model.Attachments.Value;
                if (value.Length > 0)
                {
                    var attachments = ImmutableArray.CreateBuilder <Attachment>(value.Length);
                    for (int i = 0; i < value.Length; i++)
                    {
                        attachments.Add(Attachment.Create(value[i]));
                    }
                    _attachments = attachments.ToImmutable();
                }
                else
                {
                    _attachments = ImmutableArray.Create <Attachment>();
                }
            }

            if (model.Embeds.IsSpecified)
            {
                var value = model.Embeds.Value;
                if (value.Length > 0)
                {
                    var embeds = ImmutableArray.CreateBuilder <Embed>(value.Length);
                    for (int i = 0; i < value.Length; i++)
                    {
                        embeds.Add(value[i].ToEntity());
                    }
                    _embeds = embeds.ToImmutable();
                }
                else
                {
                    _embeds = ImmutableArray.Create <Embed>();
                }
            }

            if (model.Content.IsSpecified)
            {
                var text = model.Content.Value;
                _tags         = MessageHelper.ParseTags(text, null, null, ImmutableArray.Create <IUser>());
                model.Content = text;
            }
        }
コード例 #33
0
        [Aliases("ships")]                       // alternative names for the command
        public async Task Ship(CommandContext ctx, [Description("Search term")] params string[] args)
        {
            var _logAction   = $"MessageCommands_Ping > {ctx.Message.Author.Id}";
            var _dateStarted = DateTime.Now;

            Log.Information("{logAction}: Command called", _logAction);


            await ctx.Message.CreateReactionAsync(_services.SearchEmoji);

            var _client = await _services.GetSCTMClient();

            if (_client == null)
            {
                Log.Error("{logAction}: Unable to get SCTM Client", _logAction);
            }
            else
            {
                try
                {
                    string _searchTerm = null;
                    if (args != null && args.Any())
                    {
                        _searchTerm = string.Join(' ', args);
                    }
                    if (_searchTerm == null || _searchTerm.Length == 0)
                    {
                        throw new Exception("No search term provided");
                    }

                    var _url = _config["SCTM:Urls:Ships"];
                    if (_searchTerm != null)
                    {
                        _url += $"?search={_searchTerm}";
                    }

                    var _request = await _client.GetAsync(_url);

                    var _content = await _request.Content.ReadAsStringAsync();

                    if (_request.IsSuccessStatusCode)
                    {
                        //var _leaderboards = await _services.GetLeaderboards_Organization(ctx.Message.Channel.GuildId.ToString());

                        var _ships = JsonConvert.DeserializeObject <List <Ship> >(_content);

                        foreach (var ship in _ships)
                        {
                            string _leaderName      = null;
                            string _leaderAvatarUrl = null;
                            ulong? _leaderProfit    = null;
                            ulong? _leaderXP        = null;
                            int?   _leaderRecords   = null;

                            //if (_leaderboards?.Results.Ships != null)
                            //{
                            //    var _shipXp = _leaderboards.Results.Ships.Where(i => i.Name.ToLower() == $"{ship.Manufacturer.KnownAs.ToLower()} {ship.ModelName.ToLower()}").FirstOrDefault();
                            //    if (_shipXp != null)
                            //    {
                            //        foreach (var team in _shipXp.Entrants)
                            //        {
                            //            var _topPlayer = team.TopPlayers.OrderByDescending(i => i.EarnedCredits).FirstOrDefault();
                            //            if (_topPlayer != null && (_leaderProfit == null || _topPlayer.EarnedCredits > _leaderProfit))
                            //            {
                            //                try
                            //                {
                            //                    var _player = await ctx.Guild.GetMemberAsync(ulong.Parse(_topPlayer.Name));
                            //                    _leaderName = _player.Username;
                            //                    _leaderProfit = _topPlayer.EarnedCredits;
                            //                    _leaderAvatarUrl = _player.AvatarUrl;
                            //                    _leaderXP = _topPlayer.Amount;
                            //                    _leaderRecords = _topPlayer.Entries;
                            //                }
                            //                catch (System.Exception)
                            //                {
                            //                    // logging
                            //                }
                            //            }
                            //        }
                            //    }

                            //}

                            var _embed = _embeds.Ship(ship, ctx.Client.CurrentUser);
                            await ctx.Message.RespondAsync(null, false, _embed);
                        }
                    }
                    else
                    {
                        Log.Error("{logAction}: unsuccessful API call: {@content}", _logAction, _content);
                        await ctx.Message.CreateReactionAsync(_services.FailEmoji);
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "{logAction}: Error caught calling SCTM API: {message}", _logAction, ex.Message);
                }
            }


            await ctx.Message.DeleteReactionsEmojiAsync(_services.SearchEmoji);

            var _duration = Math.Round((DateTime.Now - _dateStarted).TotalSeconds, 1);

            Log.Information("{logAction}: complete in {duration} secs", _logAction, _duration);
        }
コード例 #34
0
        public string GetPrimitiveValue(CorType type, out byte[] bytes)
        {
            bytes = null;
            if (type == null)
            {
                return("Internal error: CorType is null");
            }

            if (type.IsEnum)
            {
                return(GetEnumValue(type, out bytes));
            }

            string error;
            var    etype = type.TryGetPrimitiveType;

            switch (etype)
            {
            case CorElementType.Boolean:
            {
                var value = NumberVMUtils.ParseBoolean(text, out error);
                if (!string.IsNullOrEmpty(error))
                {
                    return(error);
                }
                bytes = BitConverter.GetBytes(value);
                return(null);
            }

            case CorElementType.Char:
            {
                var value = NumberVMUtils.ParseChar(text, out error);
                if (!string.IsNullOrEmpty(error))
                {
                    return(error);
                }
                bytes = BitConverter.GetBytes(value);
                return(null);
            }

            case CorElementType.R4:
            {
                var value = NumberVMUtils.ParseSingle(text, out error);
                if (!string.IsNullOrEmpty(error))
                {
                    return(error);
                }
                bytes = BitConverter.GetBytes(value);
                return(null);
            }

            case CorElementType.R8:
            {
                var value = NumberVMUtils.ParseDouble(text, out error);
                if (!string.IsNullOrEmpty(error))
                {
                    return(error);
                }
                bytes = BitConverter.GetBytes(value);
                return(null);
            }

            case CorElementType.ValueType:
                if (type.IsSystemDecimal)
                {
                    var value = NumberVMUtils.ParseDecimal(text, out error);
                    if (!string.IsNullOrEmpty(error))
                    {
                        return(error);
                    }
                    bytes = GetBytes(value);
                    return(null);
                }
                return(null);

            case CorElementType.Class:
                return(null);

            case CorElementType.I:
            case CorElementType.U:
            case CorElementType.Ptr:
            case CorElementType.FnPtr:
                if (text.Trim() == "null")
                {
                    bytes = new byte[IntPtr.Size];
                    return(null);
                }
                break;
            }

            ulong?res = ParseIntegerConstant(etype, text, out error);

            if (res == null)
            {
                return(error ?? dnSpy_Debugger_Resources.LocalsEditValue_Error_InvalidNumber);
            }

            switch (etype)
            {
            case CorElementType.I1:
                bytes = new byte[1] {
                    (byte)res.Value
                };
                return(null);

            case CorElementType.U1:
                bytes = new byte[1] {
                    (byte)res.Value
                };
                return(null);

            case CorElementType.I2:
                bytes = BitConverter.GetBytes((short)res.Value);
                return(null);

            case CorElementType.U2:
                bytes = BitConverter.GetBytes((ushort)res.Value);
                return(null);

            case CorElementType.I4:
                bytes = BitConverter.GetBytes((int)res.Value);
                return(null);

            case CorElementType.U4:
                bytes = BitConverter.GetBytes((uint)res.Value);
                return(null);

            case CorElementType.I8:
                bytes = BitConverter.GetBytes((long)res.Value);
                return(null);

            case CorElementType.U8:
                bytes = BitConverter.GetBytes(res.Value);
                return(null);

            case CorElementType.I:
            case CorElementType.U:
            case CorElementType.Ptr:
            case CorElementType.FnPtr:
                if (IntPtr.Size == 4)
                {
                    goto case CorElementType.I4;
                }
                goto case CorElementType.I8;
            }

            return("Unknown number type");
        }
コード例 #35
0
 public override void Set(string key, int value, ulong?expiry) => _helper.Set(key, value, TimeSpan.FromSeconds(expiry.GetValueOrDefault()), default, default);
コード例 #36
0
        private static void OnSceneUnloadClient(Guid switchSceneGuid, Stream objectStream)
        {
            if (!NetworkingManager.Singleton.NetworkConfig.EnableSceneManagement || NetworkingManager.Singleton.NetworkConfig.UsePrefabSync)
            {
                SpawnManager.DestroySceneObjects();

                using (PooledBitReader reader = PooledBitReader.Get(objectStream))
                {
                    uint newObjectsCount = reader.ReadUInt32Packed();

                    for (int i = 0; i < newObjectsCount; i++)
                    {
                        bool  isPlayerObject  = reader.ReadBool();
                        ulong networkId       = reader.ReadUInt64Packed();
                        ulong owner           = reader.ReadUInt64Packed();
                        bool  hasParent       = reader.ReadBool();
                        ulong?parentNetworkId = null;

                        if (hasParent)
                        {
                            parentNetworkId = reader.ReadUInt64Packed();
                        }

                        ulong prefabHash = reader.ReadUInt64Packed();

                        Vector3?   position = null;
                        Quaternion?rotation = null;
                        if (reader.ReadBool())
                        {
                            position = new Vector3(reader.ReadSinglePacked(), reader.ReadSinglePacked(), reader.ReadSinglePacked());
                            rotation = Quaternion.Euler(reader.ReadSinglePacked(), reader.ReadSinglePacked(), reader.ReadSinglePacked());
                        }

                        NetworkedObject networkedObject = SpawnManager.CreateLocalNetworkedObject(false, 0, prefabHash, parentNetworkId, position, rotation);
                        SpawnManager.SpawnNetworkedObjectLocally(networkedObject, networkId, true, isPlayerObject, owner, objectStream, false, 0, true, false);

                        Queue <BufferManager.BufferedMessage> bufferQueue = BufferManager.ConsumeBuffersForNetworkId(networkId);

                        // Apply buffered messages
                        if (bufferQueue != null)
                        {
                            while (bufferQueue.Count > 0)
                            {
                                BufferManager.BufferedMessage message = bufferQueue.Dequeue();

                                NetworkingManager.Singleton.HandleIncomingData(message.sender, message.channelName, new ArraySegment <byte>(message.payload.GetBuffer(), (int)message.payload.Position, (int)message.payload.Length), message.receiveTime, false);

                                BufferManager.RecycleConsumedBufferedMessage(message);
                            }
                        }
                    }
                }
            }
            else
            {
                NetworkedObject[] networkedObjects = MonoBehaviour.FindObjectsOfType <NetworkedObject>();

                SpawnManager.ClientCollectSoftSyncSceneObjectSweep(networkedObjects);

                using (PooledBitReader reader = PooledBitReader.Get(objectStream))
                {
                    uint newObjectsCount = reader.ReadUInt32Packed();

                    for (int i = 0; i < newObjectsCount; i++)
                    {
                        bool  isPlayerObject  = reader.ReadBool();
                        ulong networkId       = reader.ReadUInt64Packed();
                        ulong owner           = reader.ReadUInt64Packed();
                        bool  hasParent       = reader.ReadBool();
                        ulong?parentNetworkId = null;

                        if (hasParent)
                        {
                            parentNetworkId = reader.ReadUInt64Packed();
                        }

                        ulong instanceId = reader.ReadUInt64Packed();

                        NetworkedObject networkedObject = SpawnManager.CreateLocalNetworkedObject(true, instanceId, 0, parentNetworkId, null, null);
                        SpawnManager.SpawnNetworkedObjectLocally(networkedObject, networkId, true, isPlayerObject, owner, objectStream, false, 0, true, false);

                        Queue <BufferManager.BufferedMessage> bufferQueue = BufferManager.ConsumeBuffersForNetworkId(networkId);

                        // Apply buffered messages
                        if (bufferQueue != null)
                        {
                            while (bufferQueue.Count > 0)
                            {
                                BufferManager.BufferedMessage message = bufferQueue.Dequeue();

                                NetworkingManager.Singleton.HandleIncomingData(message.sender, message.channelName, new ArraySegment <byte>(message.payload.GetBuffer(), (int)message.payload.Position, (int)message.payload.Length), message.receiveTime, false);

                                BufferManager.RecycleConsumedBufferedMessage(message);
                            }
                        }
                    }
                }
            }

            using (PooledBitStream stream = PooledBitStream.Get())
            {
                using (PooledBitWriter writer = PooledBitWriter.Get(stream))
                {
                    writer.WriteByteArray(switchSceneGuid.ToByteArray());
                    NetworkedObject networkedObject = null;
                    InternalMessageSender.Send(NetworkingManager.Singleton.ServerClientId, MLAPIConstants.MLAPI_CLIENT_SWITCH_SCENE_COMPLETED, "MLAPI_INTERNAL", stream, SecuritySendFlags.None, networkedObject);
                }
            }

            isSwitching = false;

            if (OnSceneSwitched != null)
            {
                OnSceneSwitched();
            }
        }
コード例 #37
0
ファイル: ProtectionService.cs プロジェクト: Nielk1/NadekoBot
        private async Task PunishUsers(PunishmentAction action, ProtectionType pt, int muteTime, ulong?roleId,
                                       params IGuildUser[] gus)
        {
            Log.Information(
                "[{PunishType}] - Punishing [{Count}] users with [{PunishAction}] in {GuildName} guild",
                pt,
                gus.Length,
                action,
                gus[0].Guild.Name);

            foreach (var gu in gus)
            {
                await PunishUserQueue.Writer.WriteAsync(new PunishQueueItem()
                {
                    Action   = action,
                    Type     = pt,
                    User     = gu,
                    MuteTime = muteTime,
                    RoleId   = roleId
                });
            }

            _ = OnAntiProtectionTriggered(action, pt, gus);
        }
コード例 #38
0
 public ExchangeOfferTransaction(NetworkType networkType, int version, Deadline deadline, ulong?maxFee, List <ExchangeOffer> offers, string signature = null, PublicAccount signer = null, TransactionInfo transactionInfo = null) :
     base(networkType, version, EntityType.EXCHANGE_OFFER, deadline, maxFee, signature, signer, transactionInfo)
 {
     Offers = offers ?? throw new ArgumentNullException(nameof(offers));
 }
コード例 #39
0
 public static void CheckNonLiftedComparisonEqualNullableULongTest(bool useInterpreter)
 {
     ulong?[] values = new ulong?[] { null, 0, 1, ulong.MaxValue };
     for (int i = 0; i < values.Length; i++)
     {
         for (int j = 0; j < values.Length; j++)
         {
             VerifyComparisonEqualNullableULong(values[i], values[j], useInterpreter);
         }
     }
 }
コード例 #40
0
 // Contstuct a representation for a key-typed column loaded from a text file. Key values are assumed to be contiguous.
 public MyKey(Reconciler rec, DataKind kind, int oridinal, ulong minKeyValue, ulong?maxKeyValue = null)
     : base(rec, null)
 {
     _kind        = kind;
     _oridinal    = oridinal;
     _minKeyValue = minKeyValue;
     _maxKeyValue = maxKeyValue;
 }
コード例 #41
0
 public static void AddMaybeU64(FlatBufferBuilder builder, ulong?maybeU64)
 {
     builder.AddUlong(22, maybeU64);
 }
コード例 #42
0
 public void RaiseStaticEvent <T1, T2, T3>(Action <T1, T2, T3> action, T1 arg1, T2 arg2, T3 arg3, ulong?receiver = null)
 {
     if (action.Method.CustomAttributes.Any(data => data.AttributeType == typeof(EventAttribute)))
     {
         ulong  id   = action.Method.GetCustomAttribute <EventAttribute>().Id;
         byte[] data = PackData(id, arg1, arg2, arg3);
         SendData(action.Method, data, receiver);
     }
 }
コード例 #43
0
 public static Offset <optional_scalars.ScalarStuff> CreateScalarStuff(FlatBufferBuilder builder,
                                                                       sbyte just_i8      = 0,
                                                                       sbyte?maybe_i8     = null,
                                                                       sbyte default_i8   = 42,
                                                                       byte just_u8       = 0,
                                                                       byte?maybe_u8      = null,
                                                                       byte default_u8    = 42,
                                                                       short just_i16     = 0,
                                                                       short?maybe_i16    = null,
                                                                       short default_i16  = 42,
                                                                       ushort just_u16    = 0,
                                                                       ushort?maybe_u16   = null,
                                                                       ushort default_u16 = 42,
                                                                       int just_i32       = 0,
                                                                       int?maybe_i32      = null,
                                                                       int default_i32    = 42,
                                                                       uint just_u32      = 0,
                                                                       uint?maybe_u32     = null,
                                                                       uint default_u32   = 42,
                                                                       long just_i64      = 0,
                                                                       long?maybe_i64     = null,
                                                                       long default_i64   = 42,
                                                                       ulong just_u64     = 0,
                                                                       ulong?maybe_u64    = null,
                                                                       ulong default_u64  = 42,
                                                                       float just_f32     = 0.0f,
                                                                       float?maybe_f32    = null,
                                                                       float default_f32  = 42.0f,
                                                                       double just_f64    = 0.0,
                                                                       double?maybe_f64   = null,
                                                                       double default_f64 = 42.0,
                                                                       bool just_bool     = false,
                                                                       bool?maybe_bool    = null,
                                                                       bool default_bool  = true,
                                                                       optional_scalars.OptionalByte just_enum    = optional_scalars.OptionalByte.None,
                                                                       optional_scalars.OptionalByte?maybe_enum   = null,
                                                                       optional_scalars.OptionalByte default_enum = optional_scalars.OptionalByte.One)
 {
     builder.StartTable(36);
     ScalarStuff.AddDefaultF64(builder, default_f64);
     ScalarStuff.AddMaybeF64(builder, maybe_f64);
     ScalarStuff.AddJustF64(builder, just_f64);
     ScalarStuff.AddDefaultU64(builder, default_u64);
     ScalarStuff.AddMaybeU64(builder, maybe_u64);
     ScalarStuff.AddJustU64(builder, just_u64);
     ScalarStuff.AddDefaultI64(builder, default_i64);
     ScalarStuff.AddMaybeI64(builder, maybe_i64);
     ScalarStuff.AddJustI64(builder, just_i64);
     ScalarStuff.AddDefaultF32(builder, default_f32);
     ScalarStuff.AddMaybeF32(builder, maybe_f32);
     ScalarStuff.AddJustF32(builder, just_f32);
     ScalarStuff.AddDefaultU32(builder, default_u32);
     ScalarStuff.AddMaybeU32(builder, maybe_u32);
     ScalarStuff.AddJustU32(builder, just_u32);
     ScalarStuff.AddDefaultI32(builder, default_i32);
     ScalarStuff.AddMaybeI32(builder, maybe_i32);
     ScalarStuff.AddJustI32(builder, just_i32);
     ScalarStuff.AddDefaultU16(builder, default_u16);
     ScalarStuff.AddMaybeU16(builder, maybe_u16);
     ScalarStuff.AddJustU16(builder, just_u16);
     ScalarStuff.AddDefaultI16(builder, default_i16);
     ScalarStuff.AddMaybeI16(builder, maybe_i16);
     ScalarStuff.AddJustI16(builder, just_i16);
     ScalarStuff.AddDefaultEnum(builder, default_enum);
     ScalarStuff.AddMaybeEnum(builder, maybe_enum);
     ScalarStuff.AddJustEnum(builder, just_enum);
     ScalarStuff.AddDefaultBool(builder, default_bool);
     ScalarStuff.AddMaybeBool(builder, maybe_bool);
     ScalarStuff.AddJustBool(builder, just_bool);
     ScalarStuff.AddDefaultU8(builder, default_u8);
     ScalarStuff.AddMaybeU8(builder, maybe_u8);
     ScalarStuff.AddJustU8(builder, just_u8);
     ScalarStuff.AddDefaultI8(builder, default_i8);
     ScalarStuff.AddMaybeI8(builder, maybe_i8);
     ScalarStuff.AddJustI8(builder, just_i8);
     return(ScalarStuff.EndScalarStuff(builder));
 }
コード例 #44
0
 /// <summary>
 /// Create a representation for a key loaded from TextLoader as an unsigned integer (32 bits).
 /// </summary>
 /// <param name="ordinal">The zero-based index of the field to read from.</param>
 /// <param name="minKeyValue">smallest value of the loaded key values</param>
 /// <param name="maxKeyValue">If specified, it's the largest allowed value of the loaded key values. Use null if key is unbounded.</param>
 /// <returns>The column representation.</returns>
 public Key <uint> LoadKey(int ordinal, ulong minKeyValue, ulong?maxKeyValue) => Load <uint>(DataKind.U4, ordinal, minKeyValue, maxKeyValue);
コード例 #45
0
 public static void AreNotEqual(this Assert assert, ulong?expected, ulong?actual)
 {
     assert.NotEqual(actual, expected);
 }
コード例 #46
0
 /// <summary>
 /// Create a representation for a key loaded from TextLoader as an unsigned integer (32 bits).
 /// </summary>
 /// <param name="ordinal">The zero-based index of the field to read from.</param>
 /// <param name="keyCount">If specified, it's the count or cardinality of valid key values.
 /// Using null initalizes <paramref name="keyCount"/> to uint.MaxValue</param>
 /// <returns>The column representation.</returns>
 public Key <uint> LoadKey(int ordinal, ulong?keyCount) => Load <uint>(DataKind.U4, ordinal, keyCount);
コード例 #47
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="AddressModification" /> class.
 /// </summary>
 /// <param name="networkType"></param>
 /// <param name="version"></param>
 /// <param name="deadline"></param>
 /// <param name="propertyType"></param>
 /// <param name="propertyModifications"></param>
 /// <param name="maxFee"></param>
 /// <param name="signature"></param>
 /// <param name="signer"></param>
 /// <param name="transactionInfo"></param>
 public AddressModification(NetworkType networkType, int version,
                            Deadline deadline, PropertyType propertyType,
                            IList <AccountPropertyModification <Address> > propertyModifications, ulong?maxFee, string signature = null,
                            PublicAccount signer = null, TransactionInfo transactionInfo = null) : base(networkType, version,
                                                                                                        EntityType.MODIFY_ACCOUNT_PROPERTY_ADDRESS, deadline, propertyType, propertyModifications, maxFee,
                                                                                                        signature, signer, transactionInfo)
 {
 }
コード例 #48
0
 private Key <T> Load <T>(DataKind kind, int ordinal, ulong?keyCount)
 {
     Contracts.CheckParam(ordinal >= 0, nameof(ordinal), "Should be non-negative");
     return(new MyKey <T>(_rec, kind, ordinal, keyCount));
 }
コード例 #49
0
        public int?GetActiveVirtualThreadId(IGlobalExpressionEvaluator evaluator)
        {
            ulong?id = evaluator.EvaluateIntegralExpression("osRtxInfo.thread.run.curr");

            return((int?)id);
        }
コード例 #50
0
        public GeometryTrianglesNV
        (
            StructureType?sType   = StructureType.GeometryTrianglesNV,
            void *pNext           = null,
            Buffer?vertexData     = null,
            ulong?vertexOffset    = null,
            uint?vertexCount      = null,
            ulong?vertexStride    = null,
            Format?vertexFormat   = null,
            Buffer?indexData      = null,
            ulong?indexOffset     = null,
            uint?indexCount       = null,
            IndexType?indexType   = null,
            Buffer?transformData  = null,
            ulong?transformOffset = null
        ) : this()
        {
            if (sType is not null)
            {
                SType = sType.Value;
            }

            if (pNext is not null)
            {
                PNext = pNext;
            }

            if (vertexData is not null)
            {
                VertexData = vertexData.Value;
            }

            if (vertexOffset is not null)
            {
                VertexOffset = vertexOffset.Value;
            }

            if (vertexCount is not null)
            {
                VertexCount = vertexCount.Value;
            }

            if (vertexStride is not null)
            {
                VertexStride = vertexStride.Value;
            }

            if (vertexFormat is not null)
            {
                VertexFormat = vertexFormat.Value;
            }

            if (indexData is not null)
            {
                IndexData = indexData.Value;
            }

            if (indexOffset is not null)
            {
                IndexOffset = indexOffset.Value;
            }

            if (indexCount is not null)
            {
                IndexCount = indexCount.Value;
            }

            if (indexType is not null)
            {
                IndexType = indexType.Value;
            }

            if (transformData is not null)
            {
                TransformData = transformData.Value;
            }

            if (transformOffset is not null)
            {
                TransformOffset = transformOffset.Value;
            }
        }
コード例 #51
0
 public CrcParameters(byte size, ulong polynomial, ulong initialValue, ulong finalXorValue, bool reflectInput, bool reflectOutput, ulong?expectedCheck = null)
 {
     Size          = size;
     Polynomial    = polynomial;
     InitialValue  = initialValue;
     FinalXorValue = finalXorValue;
     ReflectInput  = reflectInput;
     ReflectOutput = reflectOutput;
     ExpectedCheck = expectedCheck;
 }
コード例 #52
0
        public static MessageBuilder AddImage(this MessageResponse response, string url, string title = null, string titleUrl = null, ulong?channelId = null)
        {
            var factory = response.Context.RequestServices.GetRequiredService <IMessageFactory>();
            var message = factory.CreateImage(url, title, titleUrl);

            message.ChannelId = channelId ?? response.Context.Request.ChannelId;

            response.Actions.Add(message);

            return(message);
        }
コード例 #53
0
        public static MessageBuilder AddSuccess(this MessageResponse response, string content, ulong?channelId = null)
        {
            var factory = response.Context.RequestServices.GetRequiredService <IMessageFactory>();
            var message = factory.CreateSuccess(content);

            message.ChannelId = channelId ?? response.Context.Request.ChannelId;

            response.Actions.Add(message);

            return(message);
        }
コード例 #54
0
        public static long?ToInt64(this string value, int radix)
        {
            ulong?uint64 = value.ToUInt64(radix);

            return(!uint64.HasValue ? new long?() : new long?((long)uint64.GetValueOrDefault()));
        }
コード例 #55
0
        /// <summary>
        /// Obtém o código do funcionário atual.
        /// </summary>
        /// <returns>Código do funcionário atual.</returns>
        private static ulong? ObterFuncionárioAtual()
        {
            Entidades.Pessoa.Funcionário funcionário;

            funcionário = Entidades.Pessoa.Funcionário.FuncionárioAtual;

            if (funcionário != null)
                return funcionário.Código;
            else
                return null;
        }
コード例 #56
0
        public static uint?ToUInt32(this string value, int radix)
        {
            ulong?uint64 = value.ToUInt64(radix);

            return(!uint64.HasValue ? new uint?() : new uint?((uint)uint64.GetValueOrDefault()));
        }
コード例 #57
0
 public static void CheckLiftedAddNullableULongTest()
 {
     ulong?[] values = new ulong?[] { null, 0, 1, ulong.MaxValue };
     for (int i = 0; i < values.Length; i++)
     {
         for (int j = 0; j < values.Length; j++)
         {
             VerifyAddNullableULong(values[i], values[j]);
         }
     }
 }
コード例 #58
0
        public static short?ToInt16(this string value, int radix)
        {
            ulong?uint64 = value.ToUInt64(radix);

            return(!uint64.HasValue ? new short?() : new short?((short)uint64.GetValueOrDefault()));
        }
コード例 #59
0
 static void FromUInt64()
 {
     Console.WriteLine("--- FromUInt64");
     ulong?[] a = new ulong?[] { new ulong?(), new ulong?(20), new ulong?(30) };
     TestCore(a);
 }
コード例 #60
0
        protected BaseRiscV(IRiscVTimeProvider timeProvider, uint hartId, string cpuType, Machine machine, PrivilegeArchitecture privilegeArchitecture, Endianess endianness, CpuBitness bitness, ulong?nmiVectorAddress = null, uint?nmiVectorLength = null)
            : base(hartId, cpuType, machine, endianness, bitness)
        {
            HartId                     = hartId;
            this.timeProvider          = timeProvider;
            this.privilegeArchitecture = privilegeArchitecture;
            ShouldEnterDebugMode       = true;
            nonstandardCSR             = new Dictionary <ulong, Tuple <Func <ulong>, Action <ulong> > >();
            customInstructionsMapping  = new Dictionary <ulong, Action <UInt64> >();
            this.NMIVectorLength       = nmiVectorLength;
            this.NMIVectorAddress      = nmiVectorAddress;

            architectureSets = DecodeArchitecture(cpuType);
            EnableArchitectureVariants();

            if (this.NMIVectorAddress.HasValue && this.NMIVectorLength.HasValue && this.NMIVectorLength > 0)
            {
                this.Log(LogLevel.Noisy, "Non maskable interrupts enabled with paramters: {0} = {1}, {2} = {3}",
                         nameof(this.NMIVectorAddress), this.NMIVectorAddress, nameof(this.NMIVectorLength), this.NMIVectorLength);
                TlibSetNmiVector(this.NMIVectorAddress.Value, this.NMIVectorLength.Value);
            }
            else
            {
                this.Log(LogLevel.Noisy, "Non maskable interrupts disabled");
                TlibSetNmiVector(0, 0);
            }

            UserState = new Dictionary <string, object>();
        }