public Dependants creerDependant(string idAbonnement, Boolean conjoint, int noEnfant) { Dependants dependant = new Dependants(); if (conjoint) { dependant.Id = idAbonnement.Substring(0, idAbonnement.Length - 1) + $"{ddlSexes.SelectedValue}0"; dependant.Nom = tbNomConjoint.Text.Trim(); dependant.Prenom = tbPrenomConjoint.Text.Trim(); dependant.Sexe = ddlSexeConjoint.SelectedValue.ToString(); dependant.DateNaissance = dtpDateNaissanceConjoint.Value.Date; dependant.IdAbonnement = idAbonnement; if (!string.IsNullOrEmpty(tbRemarqueConjoint.Text.Trim())) { dependant.Remarque = tbRemarqueConjoint.Text.Trim(); } // MessageBox.Show(dependant.Id); return(dependant); } else { dependant.Id = idAbonnement.Substring(0, idAbonnement.Length - 1) + $"E{noEnfant+1}"; dependant.Nom = tbNomEnfant.Text.Trim(); dependant.Prenom = tbPrenomEnfant.Text.Trim(); dependant.Sexe = ddlSexeEnfant.SelectedValue.ToString(); dependant.DateNaissance = dtpDateDeNaissanceEnfant.Value.Date; dependant.IdAbonnement = idAbonnement; if (!string.IsNullOrEmpty(tbRemarqueEnfant.Text.Trim())) { dependant.Remarque = tbRemarqueEnfant.Text.Trim(); } // MessageBox.Show(dependant.Id); return(dependant); } }
public void Clean(ulong guestAddress) { if (Owners.TryGetValue(guestAddress, out List <int> entries)) { foreach (int entry in entries) { if ((entry & JumpTable.DynamicEntryTag) == 0) { int removed = _jumpTable.RemoveAll(tableEntry => tableEntry.EntryIndex == entry); Debug.Assert(removed == 1); } else { if (JumpTable.DynamicTableElems > 1) { throw new NotSupportedException(); } int removed = _dynamicTable.RemoveAll(tableEntry => tableEntry.EntryIndex == (entry & ~JumpTable.DynamicEntryTag)); Debug.Assert(removed == 1); } } } Targets.Remove(guestAddress); Dependants.Remove(guestAddress); Owners.Remove(guestAddress); }
public void AddModifier(StatModifier mod) { // Add the mod to the list of modifiers for this stat ModifierMap modMap = null; if (!Modifiers.TryGetValue(mod.statName, out modMap)) { Modifiers[mod.statName] = new ModifierMap(); } HashSet <StatModifier> modSet; if (!Modifiers[mod.statName].TryGetValue(mod.type, out modSet)) { Modifiers[mod.statName][mod.type] = new HashSet <StatModifier>(); } Modifiers[mod.statName][mod.type].Add(mod); // Add the mod stat as a dependant of the mod source if (mod.modSourceStat != null) { List <string> depList; if (!Dependants.TryGetValue(mod.modSourceStat, out depList)) { Dependants[mod.modSourceStat] = new List <string>(); } Dependants[mod.modSourceStat].Add(mod.statName); } UpdateModifiedValue(mod.statName); OnPropertyChange("ModifiedValues"); }
// For future use. public void RemoveFunctionEntries(ulong guestAddress) { Targets.TryRemove(guestAddress, out _); Dependants.TryRemove(guestAddress, out _); if (Owners.TryRemove(guestAddress, out List <int> entries)) { foreach (int entry in entries) { if ((entry & DynamicEntryTag) == 0) { IntPtr addr = GetEntryAddressJumpTable(entry); Marshal.WriteInt64(addr, 0, 0L); Marshal.WriteInt64(addr, 8, 0L); Table.FreeEntry(entry); } else { IntPtr addr = GetEntryAddressDynamicTable(entry & ~DynamicEntryTag); for (int j = 0; j < DynamicTableElems; j++) { Marshal.WriteInt64(addr + j * JumpTableStride, 0, 0L); Marshal.WriteInt64(addr + j * JumpTableStride, 8, 0L); } DynTable.FreeEntry(entry & ~DynamicEntryTag); } } } }
public bool Stop() { if (State != ResourceState.Running && State != ResourceState.Starting) { throw new InvalidOperationException(string.Format("Tried to stop a resource ({0}) that wasn't running.", Name)); } this.Log().Info("Stopping resource {0} (last state: {1}).", Name, State); if (State == ResourceState.Running) { if (!Manager.TriggerEvent("onResourceStop", -1, Name)) { return(false); } } var dependants = Dependants.GetRange(0, Dependants.Count); foreach (var dependant in dependants) { var dependantResource = Manager.GetResource(dependant); dependantResource.Stop(); } Dependants.Clear(); foreach (var dependency in Dependencies) { var dependencyResource = Manager.GetResource(dependency); dependencyResource.RemoveDependant(Name); } // remove the watcher m_watcher.Dispose(); m_watcher = null; // dispose of the script environment m_scriptEnvironment.Dispose(); m_scriptEnvironment = null; if (State == ResourceState.Running) { // broadcast a stop message to all clients var clients = ClientInstances.Clients.Where(c => c.Value.NetChannel != null).Select(c => c.Value); foreach (var client in clients) { client.SendReliableCommand(0x45E855D7, Encoding.UTF8.GetBytes(Name)); // msgResStop } } // done! State = ResourceState.Stopped; return(true); }
private void RestorePreviousValues(IPluginConstructor value) { var toRestore = _previousRegions[value.GetIdentifier()]; foreach (var toolRegion in Dependants.Zip(toRestore, (a, b) => new Tuple <IToolRegion, IToolRegion>(a, b))) { toolRegion.Item1.RestoreRegion(toolRegion.Item2); } }
private void RestorePreviousValues(IWcfAction value) { var toRestore = _previousRegions[value.GetHashCodeBySource()]; foreach (var toolRegion in Dependants.Zip(toRestore, (a, b) => new Tuple <IToolRegion, IToolRegion>(a, b))) { toolRegion.Item1.RestoreRegion(toolRegion.Item2); } }
void RestorePreviousValues(IWebServiceSource value) { var toRestore = _previousRegions[value.Id]; foreach (var toolRegion in Dependants.Zip(toRestore, (a, b) => new Tuple <IToolRegion, IToolRegion>(a, b))) { toolRegion.Item1.RestoreRegion(toolRegion.Item2); } }
public void Clear() { _jumpTable.Clear(); _dynamicTable.Clear(); Targets.Clear(); Dependants.Clear(); Owners.Clear(); }
public Dependants creerDependant(string idAbonnement) { Dependants dependant = new Dependants(); dependant.Id = idAbonnement.Substring(0, idAbonnement.Length - 1) + ((typeLien == 0) ? $"{ddlSexes.SelectedValue}0" : $"E{typeLien}"); dependant.Nom = tbNom.Text.Trim(); dependant.Prenom = tbPrenom.Text.Trim(); dependant.Sexe = ddlSexes.SelectedValue.ToString(); dependant.DateNaissance = dtpDateNaissance.Value.Date; dependant.IdAbonnement = idAbonnement; if (!string.IsNullOrEmpty(tbRemarque.Text.Trim())) { dependant.Remarque = tbRemarque.Text.Trim(); } return(dependant); }
public void RegisterFunction(ulong address, TranslatedFunction func) { Targets.AddOrUpdate(address, func, (key, oldFunc) => func); long funcPtr = func.FuncPtr.ToInt64(); // Update all jump table entries that target this address. if (Dependants.TryGetValue(address, out List <int> myDependants)) { lock (myDependants) { foreach (int entry in myDependants) { IntPtr addr = GetEntryAddressJumpTable(entry); Marshal.WriteInt64(addr, 8, funcPtr); } } } }
public ProjectMetric(string name, IEnumerable <INamespaceMetric> namespaceMetrics, IEnumerable <string> referencedProjects, double relationalCohesion) { Name = name; RelationalCohesion = relationalCohesion; AssemblyDependencies = referencedProjects.AsArray(); EfferentCoupling = AssemblyDependencies.Count(); NamespaceMetrics = namespaceMetrics.AsArray(); LinesOfCode = NamespaceMetrics.Sum(x => x.LinesOfCode); MaintainabilityIndex = LinesOfCode == 0 ? 100 : NamespaceMetrics.Sum(x => x.MaintainabilityIndex * x.LinesOfCode) / LinesOfCode; CyclomaticComplexity = LinesOfCode == 0 ? 0 : NamespaceMetrics.Sum(x => x.CyclomaticComplexity * x.LinesOfCode) / LinesOfCode; Dependencies = NamespaceMetrics.SelectMany(x => x.Dependencies).Where(x => x.Assembly != Name).Distinct(Comparer).AsArray(); Dependants = Dependencies.Select(x => x.Assembly) .Distinct() .AsArray(); AfferentCoupling = Dependants.Count(); var typeMetrics = NamespaceMetrics.SelectMany(x => x.TypeMetrics).AsArray(); Abstractness = typeMetrics.Count(x => x.IsAbstract) / (double)typeMetrics.Length; }
public void ClearIfNeeded() { if (_jumpTable.Count == 0 && _dynamicTable.Count == 0 && Targets.Count == 0 && Dependants.Count == 0 && Owners.Count == 0) { return; } _jumpTable.Clear(); _jumpTable.TrimExcess(); _dynamicTable.Clear(); _dynamicTable.TrimExcess(); Targets.Clear(); Targets.TrimExcess(); Dependants.Clear(); Dependants.TrimExcess(); Owners.Clear(); Owners.TrimExcess(); }
private void UpdateModifiedValue(string name) { ModifiedValues[name] = LeveledValues[name]; ModifierMap modMap; if (Modifiers.TryGetValue(name, out modMap)) { HashSet <StatModifier> addMods; if (modMap.TryGetValue(ModifierType.Additive, out addMods)) { foreach (StatModifier modifier in addMods) { ModifiedValues[name] += modifier.ModValueWithTable(); } } HashSet <StatModifier> multMods; if (modMap.TryGetValue(ModifierType.Multiplicative, out multMods)) { float totalMult = 1.0f; foreach (StatModifier modifier in multMods) { totalMult += modifier.ModValueWithTable(); } ModifiedValues[name] *= totalMult; } } // Propagate changes to dependant stats List <string> depList; if (Dependants.TryGetValue(name, out depList)) { foreach (string dependant in depList) { UpdateModifiedValue(dependant); } } OnPropertyChange(name); }
public int ReserveTableEntry(ulong ownerGuestAddress, ulong address, bool isJump) { int entry = Table.AllocateEntry(); ExpandIfNeededJumpTable(entry); // Is the address we have already registered? If so, put the function address in the jump table. // If not, it will point to the direct call stub. long value = DirectCallStubs.DirectCallStub(isJump).ToInt64(); if (Targets.TryGetValue(address, out TranslatedFunction func)) { value = func.FuncPtr.ToInt64(); } // Make sure changes to the function at the target address update this jump table entry. List <int> targetDependants = Dependants.GetOrAdd(address, (addr) => new List <int>()); lock (targetDependants) { targetDependants.Add(entry); } // Keep track of ownership for jump table entries. List <int> ownerEntries = Owners.GetOrAdd(ownerGuestAddress, (addr) => new List <int>()); lock (ownerEntries) { ownerEntries.Add(entry); } IntPtr addr = GetEntryAddressJumpTable(entry); Marshal.WriteInt64(addr, 0, (long)address); Marshal.WriteInt64(addr, 8, value); return(entry); }
public void Initialize(JumpTable jumpTable) { Targets.Clear(); foreach (ulong guestAddress in jumpTable.Targets.Keys) { Targets.Add(guestAddress); } Dependants.Clear(); foreach (var kv in jumpTable.Dependants) { Dependants.Add(kv.Key, new List <int>(kv.Value)); } Owners.Clear(); foreach (var kv in jumpTable.Owners) { Owners.Add(kv.Key, new List <int>(kv.Value)); } }
public void Initialize(PtcJumpTable ptcJumpTable, ConcurrentDictionary <ulong, TranslatedFunction> funcs) { foreach (ulong guestAddress in ptcJumpTable.Targets) { if (funcs.TryGetValue(guestAddress, out TranslatedFunction func)) { Targets.TryAdd(guestAddress, func); } else { throw new KeyNotFoundException($"({nameof(guestAddress)} = 0x{guestAddress:X16})"); } } foreach (var kv in ptcJumpTable.Dependants) { Dependants.TryAdd(kv.Key, new List <int>(kv.Value)); } foreach (var kv in ptcJumpTable.Owners) { Owners.TryAdd(kv.Key, new List <int>(kv.Value)); } }
void StorePreviousValues(Guid id) { _previousRegions.Remove(id); _previousRegions[id] = new List <IToolRegion>(Dependants.Select(a => a.CloneRegion())); }
private void StorePreviousValues(string actionName) { _previousRegions.Remove(actionName); _previousRegions[actionName] = new List <IToolRegion>(Dependants.Select(a => a.CloneRegion())); }
public void AddDependant(string name) { Dependants.Add(name); }
public void RemoveDependant(string name) { Dependants.Remove(name); }