protected SQLCacheDataAccessor(Dictionary<string, byte[]> metadataIfCreation, int maxCacheSize, CacheVersionParameters cacheVersionParameters, string[] EntityConnectionMetadataPaths)
    {
      this.metadataIfCreation = metadataIfCreation;
      this.MaxCacheSize = maxCacheSize;
      this.EntityConnectionMetadataPaths = EntityConnectionMetadataPaths;

      this.cacheVersion = cacheVersionParameters;

#if COMPILED_QUERIES
      this.compiledGetMethod = CompiledQuery.Compile<ClousotCacheEntities, byte[], MethodModel>(
        (context, hash) => context.MethodModels.FirstOrDefault(m => m.Hash == hash));
      this.compiledGetBinding = CompiledQuery.Compile<ClousotCacheEntities, long, Guid, bool>(
        (context, methodid, guid) => context.AssemblyBindings.Any(b => b.MethodId == methodid && b.AssemblyId == guid));
      this.compiledNbToDelete = CompiledQuery.Compile<ClousotCacheEntities, int>(
        context => context.MethodModels.Count() - this.MaxCacheSize);
#else
      this.compiledGetMethod = (context, hash) => context.MethodModels.FirstOrDefault(m => m.Hash == hash);
      this.compiledGetBinding = (context, methodid, guid) => context.AssemblyBindings.Any(b => b.MethodId == methodid && b.AssemblyId == guid);
      this.compiledNbToDelete = (context) => context.MethodModels.Count() - this.MaxCacheSize;
#endif

    }
 public SQLServerCompactCacheDataAccessor(string directoryName, string dbName, Dictionary<string, byte[]> metadataIfCreation, int maxCacheSize, CacheVersionParameters cacheVersionParameters)
   : base(addExtraMetadataIfCreation(metadataIfCreation), maxCacheSize, cacheVersionParameters, new string[]{
     "res://*/Caching.ClousotCacheModel.csdl",
     "res://*/Caching.ClousotCacheModel.ssdl",
     "res://*/Caching.ClousotCacheModel.msl"
   })
 {
     var filename = dbName;
     if (!filename.EndsWith(".sdf")) {
         filename += ".sdf";
     }
     if (directoryName != null)
     {
         filename = Path.Combine(directoryName, filename);
     }
     this.FileName = filename;
 }
Пример #3
0
        protected SQLCacheDataAccessor(Dictionary <string, byte[]> metadataIfCreation, int maxCacheSize, CacheVersionParameters cacheVersionParameters, string[] EntityConnectionMetadataPaths)
        {
            this.metadataIfCreation            = metadataIfCreation;
            this.MaxCacheSize                  = maxCacheSize;
            this.EntityConnectionMetadataPaths = EntityConnectionMetadataPaths;

            this.cacheVersion = cacheVersionParameters;

#if COMPILED_QUERIES
            this.compiledGetMethod = CompiledQuery.Compile <ClousotCacheEntities, byte[], MethodModel>(
                (context, hash) => context.MethodModels.FirstOrDefault(m => m.Hash == hash));
            this.compiledGetBinding = CompiledQuery.Compile <ClousotCacheEntities, long, Guid, bool>(
                (context, methodid, guid) => context.AssemblyBindings.Any(b => b.MethodId == methodid && b.AssemblyId == guid));
            this.compiledNbToDelete = CompiledQuery.Compile <ClousotCacheEntities, int>(
                context => context.MethodModels.Count() - this.MaxCacheSize);
#else
            this.compiledGetMethod  = (context, hash) => context.MethodModels.FirstOrDefault(m => m.Hash == hash);
            this.compiledGetBinding = (context, methodid, guid) => context.AssemblyBindings.Any(b => b.MethodId == methodid && b.AssemblyId == guid);
            this.compiledNbToDelete = (context) => context.MethodModels.Count() - this.MaxCacheSize;
#endif
        }
        public SQLServerCompactCacheDataAccessor(string directoryName, string dbName, Dictionary <string, byte[]> metadataIfCreation, int maxCacheSize, CacheVersionParameters cacheVersionParameters)
            : base(addExtraMetadataIfCreation(metadataIfCreation), maxCacheSize, cacheVersionParameters, new string[] {
            "res://*/Caching.ClousotCacheModel.csdl",
            "res://*/Caching.ClousotCacheModel.ssdl",
            "res://*/Caching.ClousotCacheModel.msl"
        })
        {
            var filename = dbName;

            if (!filename.EndsWith(".sdf"))
            {
                filename += ".sdf";
            }
            if (directoryName != null)
            {
                filename = Path.Combine(directoryName, filename);
            }
            this.FileName = filename;
        }