/// <summary> /// Processes UoW disposed event. /// </summary> /// <param name="uow">Disposed UoW.</param> /// <remarks>SyncRoot <c>lock</c> required here.</remarks> internal void OnUowDisposed(TUnitOfWork uow) { if (!_openedUoWs.TryRemove(uow, out var _)) { Critical.Assert(false, "Wrong Unit of Work or double dispose."); } }
/// <inheritdoc/> public void RemoveLock(IIxInstanceLock instanceLock) { if (instanceLock == null) { throw new ArgumentNullException(nameof(instanceLock)); } EnsureTreeLocked(); if (ReferenceEquals(instanceLock, _initTempLock)) { Critical.Assert( _objectCreationTask != null, "You need to setup instance object factory before releasing creator lock."); Critical.Assert( _objectCreationTask.Value.IsCompleted, "Creator lock should be removed only after object instantiation completes."); _initTempLock = null; } // --------- We are under tree lock -------------- if (!_locks.Remove(instanceLock)) { Critical.Assert(false, "Lock was not registered in the target or already removed."); } UpdateDisposeSuspendState(); UpdateChildrenDisposeCompleteSuspendState(); }
private static void ActivateInternal(Guid apiKey) { try { LegacyManager.CompleteMigration().RunSynchronously(); } catch (Exception) { } YandexMetrica.MigrateApiKeys(); LiteMetricaService liteMetricaService = Store.Get <LiteMetricaService>(); if (((IEnumerable <Guid>)Critical.GetApiKeys()).Contains <Guid>(apiKey)) { liteMetricaService.Wake(false, true); } else { Critical.AddApiKey(apiKey); liteMetricaService.Wake(true, true); Critical.Submit(); } lock (YandexMetrica.CacheLock) { liteMetricaService.Report(YandexMetrica.Cache.ToArray()); YandexMetrica.Cache.Clear(); YandexMetrica._liteMetricaService = liteMetricaService; } liteMetricaService.ForceSend = true; }
static void InitTimers(SchedulerTask task) { MainScheduler.QueueRepeat(RandomMessage, null, Server.Config.AnnouncementInterval); Critical.QueueRepeat(ServerTasks.UpdateEntityPositions, null, TimeSpan.FromMilliseconds(Server.Config.PositionUpdateInterval)); }
/// public IxArgumentInstance(IxArgumentProvider providerNode, [CanBeNull] object instanceObj) { Critical.CheckedAssert(providerNode != null, "Provider node should not be null."); Object = instanceObj; ProviderNode = providerNode; }
public static async Task <HttpResponseMessage> PostAsync( Uri uri, Stream stream) { try { HttpClient httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Add("user-agent", ServiceData.UserAgent); StreamContent streamContent = new StreamContent(stream); streamContent.Headers.ContentEncoding.Add("gzip"); using (HttpResponseMessage response = await httpClient.PostAsync(uri, (HttpContent)streamContent, CancellationToken.None)) { if (response.IsSuccessStatusCode) { return(response); } if (await response.Content.ReadAsStringAsync() == "Incorrect uuid") { Critical.SetUuid((string)null); } return(response); } } catch (Exception) { return((HttpResponseMessage)null); } }
public IxLock(IIxInstanceLock instanceLock) { Critical.Assert(instanceLock != null, "Lock target should not be null."); _instanceLock = instanceLock; _target = (T)_instanceLock.Target.Object; }
public IxLock(T target) { Critical.CheckedAssert( typeof(T).GetTypeInfo().IsClass, "Cluster reference hack can be created only for reference types."); _target = target; }
public static dynamic GetTSObject(Critical dynObject) { if (dynObject is null) { return(null); } return(dynObject.teklaObject); }
/// <inheritdoc/> public override async ValueTask <IIxInstanceLock> GetInstance( IIxInstance parentInstance, IxIdentifier identifier, IxHost.IxResolveContext context, [CanBeNull] IxResolveFrame frame) { Critical.Assert(false, "Not supported."); return(null); }
private void Start() { Critical c = GetComponent <Critical>(); if (c) { Destroy(c); } }
public Unit() { Modification = new ModificationInfos(); AttackDamage = 51; CurrentHp = MaxHp = 100; PhysicalShield = 52; Shield = 22; Modification.Critical.AddModification(Critical.CriticalStrike()); }
public EngineStatus Free() { Critical.NoThrow(() => Engine.I.FS.Dispose()); Critical.NoThrow(() => Engine.I.Log.End()); // todo: check this int collectWaiting = I.Core.RM.CollectWaiting(x => true); return(collectWaiting == 0 ? (EngineStatus.Free) : (EngineStatus.FreeWithMemoryLeaks)); }
protected override long EvaluateInternal(RollData data, DiceAST root, int depth) { long rolls = Expression.Evaluate(data, root, depth + 1); rolls += Critical?.Evaluate(data, root, depth + 1) ?? 0; rolls += Fumble?.Evaluate(data, root, depth + 1) ?? 0; MarkCrits(); return(rolls); }
private void UpdateChildrenDisposeCompleteSuspendState() { try { _childrenDisposeCompleted.SuspendTrigger(_locks.Any()); } catch (InvalidOperationException) { Critical.Assert(false, "Cannot set child lock, full dispose was completed."); } }
/// <summary> /// Initializes a new instance of the <see cref="IxInstancePinLock"/> class. /// </summary> /// <param name="target">IndirectX instance.</param> public IxInstancePinLock(IIxInstance target) { Critical.Assert(target != null, "Pin lock target should not be null."); Target = target; lock (target.ProviderNode.Host.InstanceTreeSyncRoot) { Target.AddLock(this); } }
/// <summary> /// Registers persistence <c>plugin</c>. /// </summary> /// <param name="plugin">Persistence <c>plugin</c>.</param> internal void RegisterPlugin(PersistencePluginBase <TPersistence, TUnitOfWork> plugin) { if (plugin == null) { throw new ArgumentNullException(nameof(plugin)); } Critical.Assert(!_isInitialized, "You cannot register plugin after persistence become initialized."); _plugins.Add(plugin); }
private static void MigrateApiKeys() { Guid[] apiKeys = Critical.GetApiKeys(); Guid[] array = YandexMetrica.InternalConfig.KnownKeys.Where <Guid>((Func <Guid, bool>)(k => !((IEnumerable <Guid>)apiKeys).Contains <Guid>(k))).ToArray <Guid>(); ((IEnumerable <Guid>)array).ForEach <Guid>(new Action <Guid>(Critical.AddApiKey)); if (!((IEnumerable <Guid>)array).Any <Guid>()) { return; } Critical.Submit(); }
private async ValueTask <IIxInstanceLock> RegistrationScopeBinder( IIxInstance originInstance, IxResolvePath resolvePath, IxResolveContext context, [CanBeNull] IxResolveFrame frame, IxResolveBoundDelegate resolveBound) { IIxInstance curInstance = originInstance; Critical.Assert(resolvePath.Path.Any(), "Registration scope binder does not support empty path."); lock (InstanceTreeSyncRoot) { while (curInstance != null) { if (curInstance.ProviderNode == resolvePath.Root) { break; } curInstance = curInstance.ParentInstance; } } if (curInstance == null) { throw new InvalidOperationException("Resolve algorithms problems"); } Func <IIxInstance, int, ValueTask <IIxInstanceLock> > resolvePathElements = null; resolvePathElements = async(parentInstance, index) => { if (index < resolvePath.Path.Count - 1) { using (IIxInstanceLock instanceLock = await Resolve( parentInstance, resolvePath.Path[index].Identifier, context, frame)) { return(await resolvePathElements(instanceLock.Target, index + 1)); } } return(await resolveBound(parentInstance, resolvePath.Path.Last(), context)); }; IIxInstanceLock resultInstanceLock = await resolvePathElements(curInstance, 0); return(resultInstanceLock); }
internal static void Free() { Critical.NoThrow(() => _user.Core.Log.Info("--- Application shutting down ---")); EngineStatus[] status = new EngineStatus[5]; status[4] = Proxy.Game.Free(); status[1] = Proxy.Physics.Free(); status[2] = Proxy.Scripting.Free(); status[3] = Proxy.Render.Free(); status[0] = Proxy.Core.Free(); Critical.NoThrow(() => Memory.Collect(false)); }
public object GetData(IxProviderNode providerNode) { Critical.CheckedAssert(providerNode != null, "providerNode != null"); if (!Monitor.IsEntered(_originInstance.ProviderNode.Host.InstanceTreeSyncRoot)) { Critical.Assert(false, "Data manipulations should be performed under lock."); } _rootContext.ProvidersData.TryGetValue(providerNode, out object result); return(result); }
/// <inheritdoc/> public void AddOwnedLock(IIxInstanceLock instanceLock) { if (instanceLock == null) { throw new ArgumentNullException(nameof(instanceLock)); } EnsureTreeLocked(); if (!_ownedLocks.Add(instanceLock)) { Critical.Assert(false, "Owned Lock already registered in the owner."); } }
internal void AddCritical(CritNode crit) { if (Critical == null) { Critical = crit; return; } else { Critical.AddCritical(crit.Critical); Critical.AddFumble(crit.Fumble); } }
static void InitTimers(SchedulerTask task) { TextFile announcementsFile = TextFile.Files["Announcements"]; announcementsFile.EnsureExists(); string[] lines = announcementsFile.GetText(); messages = new List <string>(lines); MainScheduler.QueueRepeat(RandomMessage, null, TimeSpan.FromMinutes(5)); Critical.QueueRepeat(ServerTasks.UpdateEntityPositions, null, TimeSpan.FromMilliseconds(ServerConfig.PositionUpdateInterval)); }
public static async Task <HttpResponseMessage> PostAsync( this ReportPackage package) { return(await LiteClient.PostAsync(new Uri(Config.Global.ReportUrl + "/report?".GlueGetList(new Dictionary <string, object>() { { "deviceid", (object)Critical.GetDeviceId() }, { "uuid", (object)Critical.GetUuid() } }, false) + package.UrlParameters), (Stream) new MemoryStream(package.GetRawStream().ToArray()))); }
public IxResolveContext( IIxInstance originInstance, [CanBeNull] IxResolveContext parentContext, IReadOnlyDictionary <IxIdentifier, object> arguments) { Critical.CheckedAssert(originInstance != null, "Origin instance should be null."); Critical.CheckedAssert(arguments != null, "Arguments dictionary should not be null."); Arguments = arguments; _originInstance = originInstance; ParentContext = parentContext; _rootContext = parentContext?._rootContext ?? this; Critical.CheckedAssert(_rootContext != null, "Root context should not be null."); }
/// <inheritdoc/> public void RemoveOwnedLock(IIxInstanceLock instanceLock) { if (instanceLock == null) { throw new ArgumentNullException(nameof(instanceLock)); } EnsureTreeLocked(); // --------- We are under tree lock -------------- if (!_ownedLocks.Remove(instanceLock)) { Critical.Assert(false, "Owned lock was not registered in the owner or already removed."); } }
static void InitRest(SchedulerTask task) { CountdownGame.Instance.AutoStart(); ZSGame.Instance.AutoStart(); LSGame.Instance.AutoStart(); CTFGame.Instance.AutoStart(); TWGame.Instance.AutoStart(); MainScheduler.QueueRepeat(BlockQueue.Loop, null, TimeSpan.FromMilliseconds(BlockQueue.Interval)); Critical.QueueRepeat(ServerTasks.TickPlayers, null, TimeSpan.FromMilliseconds(20)); Logger.Log(LogType.SystemActivity, "Finished setting up server"); SetupFinished = true; }
internal void AddCritical(ComparisonNode comp) { if (comp == null) { return; } if (Critical == null) { Critical = comp; } else { Critical.Add(comp); } }
public override string ToString() { StringBuilder sb = new StringBuilder(Expression?.ToString() ?? String.Empty); if (Critical != null) { sb.AppendFormat(".critical({0})", Critical.ToString()); } if (Fumble != null) { sb.AppendFormat(".fumble({0})", Fumble.ToString()); } return(sb.ToString()); }