public override int GetHashCode() { int hash = 1; if (ContextId.Length != 0) { hash ^= ContextId.GetHashCode(); } if (Current != 0L) { hash ^= Current.GetHashCode(); } if (Total != 0L) { hash ^= Total.GetHashCode(); } if (TotalSize != 0L) { hash ^= TotalSize.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public ScopeExtension SetExtension(ContextId languageContextId, ScopeExtension extension) { ContractUtils.RequiresNotNull(extension, "extension"); if (languageContextId.Id >= _extensions.Length) { Array.Resize(ref _extensions, languageContextId.Id + 1); } ScopeExtension original = Interlocked.CompareExchange(ref _extensions[languageContextId.Id], extension, null); return original ?? extension; }
public override string ToPrettyString() { return("AssignmentToDoItem {" + ($"\n{nameof(Type)}: {Type.GetApiRepresentation()}," + $"\n{nameof(IgnoreUrl)}: {IgnoreUrl}," + $"\n{nameof(PermanentIgnoreUrl)}: {PermanentIgnoreUrl}," + $"\n{nameof(ContextId)}: {ContextId.ToPrettyString()}," + $"\n{nameof(Assignment)}: {Assignment.ToPrettyString()}").Indent(4) + "\n}"); }
public override int GetHashCode() { unchecked { int hashCode = AppId; hashCode = (hashCode * 397) ^ ContextId.GetHashCode(); hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0); return(hashCode); } }
/// <summary> /// Sets the ScopeExtension to the provided value for the given ContextId. /// /// The extension can only be set once. The returned value is either the new ScopeExtension /// if no value was previously set or the previous value. /// </summary> public ScopeExtension SetExtension(ContextId languageContextId, ScopeExtension extension) { ContractUtils.RequiresNotNull(extension, "extension"); lock (_extensions) { if (languageContextId.Id >= _extensions.Length) { Array.Resize(ref _extensions, languageContextId.Id + 1); } return _extensions[languageContextId.Id] ?? (_extensions[languageContextId.Id] = extension); } }
/// <inheritdoc /> public override int GetHashCode() { unchecked { var hashCode = Amount.GetHashCode(); hashCode = (hashCode * 397) ^ AppId.GetHashCode(); hashCode = (hashCode * 397) ^ CurrencyId.GetHashCode(); hashCode = (hashCode * 397) ^ ContextId.GetHashCode(); return(hashCode); } }
internal void Show(ContextId id, FrameworkElement[] contextData, string headerNamePrefix = null) { ChangeMenu(Context[id]); if (headerNamePrefix != null) { Header.Content = $"{ headerNamePrefix } { Header.Content as string }"; } CurrentContextId = id; CurrentContextData = contextData; Visibility = Visibility.Visible; }
/// <inheritdoc /> public override int GetHashCode() { unchecked { var hashCode = (int)Action; hashCode = (hashCode * 397) ^ AppId; hashCode = (hashCode * 397) ^ AssetId.GetHashCode(); hashCode = (hashCode * 397) ^ CurrencyId.GetHashCode(); hashCode = (hashCode * 397) ^ ContextId.GetHashCode(); hashCode = (hashCode * 397) ^ SteamId.GetHashCode(); hashCode = (hashCode * 397) ^ (Text != null ? Text.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Timestamp.GetHashCode(); return(hashCode); } }
public void Consume(IContextCodeFeatureStateUpdated message) { Uri codeFeatureUri = message.CodeFeatureId; try { var codeFeatureId = new CodeFeatureId(codeFeatureUri); var contextId = new ContextId(message.ContextId); var update = new UpdateContextCodeFeature(contextId, message.ContextKey, codeFeatureId, message.Enabled, message.Timestamp, message.CommandId ?? message.EventId); _updateCache.UpdateCache(update); } catch (FormatException ex) { _log.Error(string.Format("The CodeFeatureId was not valid: {0}", codeFeatureUri), ex); } }
public void FireBullet(APCharacterController launcher, ContextId contextId) { if ((m_ammo > 0 || m_infiniteAmmo) && (m_bullet != null)) { if (!m_infiniteAmmo) { m_ammo--; } AttackContext curContext = m_contextStand; switch (contextId) { case ContextId.eRun: curContext = m_contextRun; break; case ContextId.eInAir: curContext = m_contextInAir; break; case ContextId.eCrouched: curContext = m_contextCrouched; break; } // make sure move horizontal direction is valid float fAngle = Mathf.Deg2Rad * curContext.m_bulletDirection; Vector2 v2MoveDir = new Vector2(Mathf.Cos(fAngle), -Mathf.Sin(fAngle)); if (launcher.GetMotor().m_faceRight&& v2MoveDir.x < 0f || !launcher.GetMotor().m_faceRight&& v2MoveDir.x > 0f) { v2MoveDir.x = -v2MoveDir.x; } // spawn and launch bullet (add player velocity before spawn) Vector2 pointPos = launcher.transform.TransformPoint(curContext.m_bulletStartPosition); pointPos = pointPos + (Time.deltaTime * launcher.GetMotor().m_velocity); APBullet newBullet = (APBullet)UnityEngine.Object.Instantiate(m_bullet, pointPos, Quaternion.identity); // init bullet v2MoveDir = launcher.transform.TransformDirection(v2MoveDir); newBullet.Setup(launcher, pointPos, v2MoveDir); // launch listeners launcher.EventListeners.ForEach(e => e.OnAttackBulletFired(this, newBullet)); } }
protected override void ButtonEx_Click(object sender, RoutedEventArgs e) { var elementList = new XElement[2]; var contextElement = createRequestElement(Common.Requests.SetContext); contextElement.SetAttributeValue(Common.IDAttrib, ContextId.ToString()); contextElement.SetAttributeValue(Common.Data.RowType, ContextType); var actionElement = _controlHarness.MethodElement; var method = MethodName ?? "menuActionProperties"; actionElement.SetAttributeValue(Common.RequestMethodName, method); if (!string.IsNullOrEmpty(ModelObject)) { actionElement.SetAttributeValue(Common.contextObject, ModelObject); } elementList[0] = contextElement; elementList[1] = actionElement; _controlHarness.SendXml(elementList); }
public void SetName(ContextId context, SymbolId name, object value, ScopeMemberAttributes attrs) { int id = context.Id; EnsureDictionary(id); EnsureAttrDict(id); if (_attrs != null && id < _attrs.Count) _attrs[id].CheckWritable(name); _dicts[id][name] = value; _attrs[id].Set(name, attrs); }
/// <summary> /// Sets a name that is only available in the specified context. /// /// Provides the ScopeMemberAttributes which should be set on the provided object. /// </summary> /// <exception cref="MemberAccessException">The name has already been published and marked as ReadOnly</exception> public void SetName(ContextId context, SymbolId name, object value, ScopeMemberAttributes attributes) { if (_attrs != null) _attrs.CheckWritable(name); if (context == ContextId.Empty) { SetName(name, value); } else { if (_contextScopes == null) _contextScopes = new ContextSensitiveScope(); _contextScopes.SetName(context, name, value, attributes); } }
/// <summary> /// Sets the name to the specified value for the current context. /// /// The name is an arbitrary object. /// </summary> public void SetObjectName(ContextId context, object name, object value, ScopeMemberAttributes attributes) { //int id = context.Id; //if (id == 0) { // if (_attrs != null) _attrs.CheckWritable(name); _dict.AddObjectKey(name, value); // if (attributes != ScopeMemberAttributes.None) { // if (_attrs == null) _attrs = new ScopeAttributeDictionary(); // _attrs.Set(name, attributes); // } //} else { // if (_contextScopes == null) _contextScopes = new ContextSensitiveScope(); // _contextScopes.SetObjectName(context, name, value, attributes); //} }
/// <summary> /// Try to find a scenario for the target context. On failure, a new /// scenario is created if the creation is allowed, otherwise the /// predicted scenario is returned. /// </summary> /// <returns>A prediction, or null in case of error.</returns> public PredictionArgs Prediction() { Context context = null; PredictionArgs prediction = null; lock (_localizerLock) { if (ContextId != null) { try { context = _contextService.GetById(ContextId); if (context == null) { // notify error if (LocalizerErrorNotification != null) { var args = new LocalizerErrorNotificationEventArgs( LocalizerErrorNotificationCode.UnknownContext); ThreadPool.QueueUserWorkItem(new WaitCallback(DoNotification), args); } } } catch (Exception ex) { if (LocalizerErrorNotification != null) { // notify error var args = new LocalizerErrorNotificationEventArgs( LocalizerErrorNotificationCode.DatabaseError, ex); ThreadPool.QueueUserWorkItem(new WaitCallback(DoNotification), args); } } } if (context != null) { // context found in the database prediction = new PredictionArgs { Success = false }; IEnumerable <ContextPreference> pref = null; for (var attempts = this.Retries + 1; attempts > 0; attempts--) { prediction.PredictedScenario = GetScenarioForCurrentPosition(out pref); if (prediction.PredictedScenario == null) { // retry, eventually.. continue; } if (ContextId.Equals(prediction.PredictedScenario.ContextId.ToString())) { // correct prediction _scenarioService.IncreaseAccuracy(prediction.PredictedScenario); prediction.Success = true; break; } // wrong prediction _scenarioService.DecreaseAccuracy(prediction.PredictedScenario); } if (!prediction.Success && CreationAllowed) { // create a new scenario for the requested context prediction.PredictedScenario = new Scenario { ContextId = new ObjectId(ContextId), CreationTime = DateTime.Now }; try { _scenarioService.Create(prediction.PredictedScenario); } catch (Exception ex) { if (LocalizerErrorNotification != null) { // notify error var args = new LocalizerErrorNotificationEventArgs( LocalizerErrorNotificationCode.DatabaseError, ex); ThreadPool.QueueUserWorkItem(new WaitCallback(DoNotification), args); } prediction = null; } } } // end if(context != null) } // unlock return(prediction); }
ContextMetadata() { _id = new ContextId(typeof(TContext)); }
protected ApplicationContext() { Id = new ContextId(); }
public void Evaluated(ContextId contextId, string contextKey, bool enabled) { var evaluted = new CodeSwitchEvaluated(CodeFeatureMetadata <TFeature> .Id, contextId, contextKey, enabled); ForEach(x => x.OnNext(evaluted)); }
public override int GetHashCode() { return(ContextId.GetHashCode() ^ AssetId.GetHashCode() ^ AppId.GetHashCode() ^ Amount.GetHashCode()); }
public void SetName(ContextId context, SymbolId name, object value) { int id = context.Id; EnsureDictionary(id); if (_attrs != null && id < _attrs.Count) _attrs[id].CheckWritable(name); _dicts[id][name] = value; }
/// <summary> /// Friend class: LanguageContext /// </summary> /// <param name="languageContextId"></param> /// <returns></returns> internal ModuleContext GetModuleContext(ContextId languageContextId) { return (languageContextId.Id < _moduleContexts.Length) ? _moduleContexts[languageContextId.Id] : null; }
public void SetObjectName(ContextId context, object name, object value, ScopeMemberAttributes attrs) { int id = context.Id; EnsureDictionary(id); if (attrs != ScopeMemberAttributes.None) EnsureAttrDict(id); if (_attrs != null && id < _attrs.Count) _attrs[id].CheckWritable(name); _dicts[id].AddObjectKey(name, value); if (attrs != ScopeMemberAttributes.None) _attrs[id].Set(name, attrs); }
public override int GetHashCode() { return ContextId.GetHashCode() ^ Generation.GetHashCode(); }
/// <summary> /// Friend class: LanguageContext /// Shouldn't be public since the module contexts are baked into code contexts in the case the module is optimized. /// </summary> internal ModuleContext SetModuleContext(ContextId languageContextId, ModuleContext moduleContext) { if (languageContextId.Id >= _moduleContexts.Length) { Array.Resize(ref _moduleContexts, languageContextId.Id + 1); } ModuleContext original = Interlocked.CompareExchange<ModuleContext>(ref _moduleContexts[languageContextId.Id], moduleContext, null); return original ?? moduleContext; }
public ScopeExtension GetExtension(ContextId languageContextId) { return (languageContextId.Id < _extensions.Length) ? _extensions[languageContextId.Id] : null; }