public bool TryGetMethodModelForHash(byte[] hash, out MethodModel result) { try { if (!this.OpenConnection()) { result = null; return(false); } result = this.compiledGetMethod(this.objectContext, hash); return(result != null); } catch (Exception e) { if (!(e is SqlCeException || e is SqlException || e is IOException || e is DataException)) { throw; } Console.WriteLine("Error: unable to read the cache: " + e.Message); result = null; return(false); } }
private void Add(MethodModel m) { Contract.Requires(m != null); Contract.Requires(m.Outcomes != null); Contract.Requires(m.Suggestions != null); this.ContractInstructions += m.ContractInstructions; this.Contracts += m.Contracts; this.MethodInstructions += m.MethodInstructions; this.Outcomes += m.Outcomes.Count(); this.StatsBottom += m.StatsBottom; this.StatsFalse += m.StatsFalse; this.StatsTop += m.StatsTop; this.StatsTrue += m.StatsTrue; this.Suggestions += m.Suggestions.Count(); this.SwallowedBottom += m.SwallowedBottom; this.SwallowedFalse += m.SwallowedFalse; this.SwallowedTop += m.SwallowedTop; this.SwallowedTrue += m.SwallowedTrue; this.Timeout += m.Timeout ? 1 : 0; this.HasWarnings += m.StatsBottom + m.StatsFalse + m.StatsTop > 0 ? 1 : 0; this.ZeroTop += m.StatsTop == 0 ? 1 : 0; }
/// <summary> /// Create a new MethodModel object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="hash">Initial value of the Hash property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="timeout">Initial value of the Timeout property.</param> public static MethodModel CreateMethodModel(global::System.Int64 id, global::System.Byte[] hash, global::System.String name, global::System.Boolean timeout) { MethodModel methodModel = new MethodModel(); methodModel.Id = id; methodModel.Hash = hash; methodModel.Name = name; methodModel.Timeout = timeout; return methodModel; }
/// <summary> /// Deprecated Method for adding a new object to the MethodModels EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToMethodModels(MethodModel methodModel) { base.AddObject("MethodModels", methodModel); }
public bool TryAddMethodModel(MethodModel methodModel) { try { if (!this.OpenConnection()) return false; var oldEntry = this.compiledGetMethod(this.objectContext, methodModel.Hash); if (oldEntry != null) { this.objectContext.DeleteObject(oldEntry); // We force the removing this.objectContext.SaveChanges(); } this.objectContext.AddToMethodModels(methodModel); this.objectContext.SaveChanges(); AddAssemblyBinding(methodModel); this.objectContext.SaveChanges(); // FIFO algorithm #if false // ignore FIFO for now var nbToDelete = this.compiledNbToDelete(this.objectContext); if (nbToDelete > 0) { var toDelete = this.compiledMethodsToDelete(this.objectContext, nbToDelete); foreach (var m in toDelete) this.objectContext.DeleteObject(m); this.objectContext.SaveChanges(); } #endif return true; } catch (Exception e) { if (!(e is SqlCeException || e is SqlException || e is IOException || e is DataException)) throw; Console.WriteLine("Error: unable to add the method in the cache: " + e.Message); return false; } }
public void AddAssemblyBinding(MethodModel methodModel) { if (this.objectContext == null) return; if (this.compiledGetBinding(this.objectContext, methodModel.Id, this.currentAssemblyGuid)) return; methodModel.AssemblyBindings.Add(new AssemblyBinding { AssemblyId = this.currentAssemblyGuid }); }
public bool TryGetMethodModelForHash(byte[] hash, out MethodModel result) { try { if (!this.OpenConnection()) { result = null; return false; } result = this.compiledGetMethod(this.objectContext, hash); return result != null; } catch (Exception e) { if (!(e is SqlCeException || e is SqlException || e is IOException || e is DataException)) throw; Console.WriteLine("Error: unable to read the cache: " + e.Message); result = null; return false; } }