public ShaderProperties(CacheBase Cache, int Address) { EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); Reader.SeekTo(Address + 12); TemplateTagID = Reader.ReadInt32(); #region ShaderProperties Chunk Reader.SeekTo(Address + 16); int iCount = Reader.ReadInt32(); int iOffset = Reader.ReadInt32() - Cache.Magic; ShaderMaps = new List <rmsh.ShaderProperties.ShaderMap>(); for (int i = 0; i < iCount; i++) { ShaderMaps.Add(new ShaderMap(Cache, iOffset + 24 * i)); } #endregion #region Tiling Chunk Reader.SeekTo(Address + 28); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; Tilings = new List <rmsh.ShaderProperties.Tiling>(); for (int i = 0; i < iCount; i++) { Tilings.Add(new Tiling(Cache, iOffset + 16 * i)); } #endregion }
public ShaderProperties(CacheBase Cache, int Address) { EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); Reader.SeekTo(Address + 12); TemplateTagID = Reader.ReadInt32(); #region ShaderProperties Chunk Reader.SeekTo(Address + 16); int iCount = Reader.ReadInt32(); int iOffset = Reader.ReadInt32() - Cache.Magic; ShaderMaps = new List<rmsh.ShaderProperties.ShaderMap>(); for (int i = 0; i < iCount; i++) ShaderMaps.Add(new ShaderMap(Cache, iOffset + 24 * i)); #endregion #region Tiling Chunk Reader.SeekTo(Address + 28); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; Tilings = new List<rmsh.ShaderProperties.Tiling>(); for (int i = 0; i < iCount; i++) Tilings.Add(new Tiling(Cache, iOffset + 16 * i)); #endregion }
public ModelSection(CacheBase Cache, int Address) { EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); type = Reader.ReadInt16(); Reader.ReadUInt16(); vertcount = Reader.ReadUInt16(); facecount = Reader.ReadUInt16(); Reader.SeekTo(Address + 20); bones = Reader.ReadByte(); Reader.SeekTo(Address + 56); rawOffset = Reader.ReadInt32(); rawSize = Reader.ReadInt32(); Reader.ReadUInt32(); hSize = rawSize - Reader.ReadInt32() - 4; int iCount = Reader.ReadInt32(); int iOffset = Reader.ReadInt32() - Cache.Magic; rSize = new int[iCount]; rOffset = new int[iCount]; rType = new int[iCount]; for (int i = 0; i < iCount; i++) { Reader.SeekTo(iOffset + 16 * i + 4); rType[i] = Reader.ReadInt32(); rSize[i] = Reader.ReadInt32(); rOffset[i] = Reader.ReadInt32(); } }
/// <summary> /// Checks whether the given collection key indexes are cached. /// </summary> /// <param name="collectionKeys">The list of pairs of collection entries and their indexes.</param> /// <param name="keyIndexes">The array of indexes of <paramref name="collectionKeys"/> that have to be checked.</param> /// <param name="persister">The collection persister.</param> /// <param name="batchableCache">The batchable cache.</param> /// <param name="checkCache">Whether to check the cache or just return <see langword="false" /> for all keys.</param> /// <returns>An array of booleans that contains the result for each key.</returns> private bool[] AreCached(List <KeyValuePair <KeyValuePair <CollectionEntry, IPersistentCollection>, int> > collectionKeys, int[] keyIndexes, ICollectionPersister persister, CacheBase batchableCache, bool checkCache) { var result = new bool[keyIndexes.Length]; if (!checkCache || !persister.HasCache || !context.Session.CacheMode.HasFlag(CacheMode.Get)) { return(result); } var cacheKeys = new object[keyIndexes.Length]; var i = 0; foreach (var index in keyIndexes) { var collectionKey = collectionKeys[index].Key; cacheKeys[i++] = context.Session.GenerateCacheKey( collectionKey.Key.LoadedKey, persister.KeyType, persister.Role); } var cacheResult = batchableCache.GetMany(cacheKeys); for (var j = 0; j < result.Length; j++) { result[j] = cacheResult[j] != null; } return(result); }
/// <summary> /// Checks whether the given entity key indexes are cached. /// </summary> /// <param name="entityKeys">The list of pairs of entity keys and their indexes.</param> /// <param name="keyIndexes">The array of indexes of <paramref name="entityKeys"/> that have to be checked.</param> /// <param name="persister">The entity persister.</param> /// <param name="batchableCache">The batchable cache.</param> /// <param name="checkCache">Whether to check the cache or just return <see langword="false" /> for all keys.</param> /// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param> /// <returns>An array of booleans that contains the result for each key.</returns> private async Task <bool[]> AreCachedAsync(List <KeyValuePair <EntityKey, int> > entityKeys, int[] keyIndexes, IEntityPersister persister, CacheBase batchableCache, bool checkCache, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var result = new bool[keyIndexes.Length]; if (!checkCache || !persister.HasCache || !context.Session.CacheMode.HasFlag(CacheMode.Get)) { return(result); } var cacheKeys = new object[keyIndexes.Length]; var i = 0; foreach (var index in keyIndexes) { var entityKey = entityKeys[index].Key; cacheKeys[i++] = context.Session.GenerateCacheKey( entityKey.Identifier, persister.IdentifierType, entityKey.EntityName); } var cacheResult = await(batchableCache.GetManyAsync(cacheKeys, cancellationToken)).ConfigureAwait(false); for (var j = 0; j < result.Length; j++) { result[j] = cacheResult[j] != null; } return(result); }
public CacheIndexHeader(CacheBase Cache) { cache = Cache; var Reader = cache.Reader; #region Read Values XmlNode indexHeaderNode = cache.versionNode.ChildNodes[1]; XmlAttribute attr = indexHeaderNode.Attributes["tagClassCount"]; int offset = int.Parse(attr.Value); Reader.SeekTo(offset + cache.Header.indexOffset); tagClassCount = Reader.ReadInt32(); attr = indexHeaderNode.Attributes["tagInfoOffset"]; offset = int.Parse(attr.Value); Reader.SeekTo(offset + cache.Header.indexOffset); tagInfoOffset = Reader.ReadInt32() - cache.Header.Magic; Reader.SeekTo(cache.Header.indexOffset); cache.Header.Magic = Reader.ReadInt32() - (cache.Header.indexOffset + 32); tagClassCount = Reader.ReadInt32(); tagInfoOffset = Reader.ReadInt32() - cache.Header.Magic; Reader.SeekTo(tagInfoOffset + 8); cache.Magic = Reader.ReadInt32() - (cache.Header.indexOffset + cache.Header.tagDataAddress); Reader.SeekTo(cache.Header.indexOffset + 24); tagCount = Reader.ReadInt32(); #endregion }
/// <summary> /// Returns an array containing list of keys contained in the cache. Null if there are no /// keys or if timeout occurs. /// </summary> /// <param name="cache"></param> /// <param name="timeout"></param> /// <returns></returns> internal static object[] GetKeyset(CacheBase cache, int timeout) { int index = 0; object[] objects = null; cache.Sync.AcquireWriterLock(timeout); try { if (!cache.Sync.IsWriterLockHeld || cache.Count < 1) { return(objects); } objects = new object[cache.Count]; for (IEnumerator i = cache.GetEnumerator(); i.MoveNext() && index < objects.Length;) { objects[index++] = ((DictionaryEntry)i.Current).Key; } } finally { cache.Sync.ReleaseWriterLock(); } return(objects); }
/// <summary> /// Overloaded constructor. Takes the properties as a map. /// </summary> /// <param name="cacheSchemes">collection of cache schemes (config properties).</param> /// <param name="properties">properties collection for this cache.</param> /// <param name="listener">cache events listener</param> /// <param name="timeSched">scheduler to use for periodic tasks</param> public IndexedLocalCache(IDictionary cacheClasses, CacheBase parentCache, IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context) : base(cacheClasses, parentCache, properties, listener, context) { IDictionary props = null; if (properties.Contains("indexes")) { props = properties["indexes"] as IDictionary; } _queryIndexManager = new QueryIndexManager(props, this, _context.CacheRoot.Name); if (!_queryIndexManager.Initialize()) { _queryIndexManager = null; } //+Numan16122014 _cacheStore.ISizableQueryIndexManager = _queryIndexManager; _cacheStore.ISizableEvictionIndexManager = _evictionPolicy; _cacheStore.ISizableExpirationIndexManager = _context.ExpiryMgr; _stats.MaxCount = _cacheStore.MaxCount; _stats.MaxSize = _cacheStore.MaxSize; //+Numan16122014 if (_context.PerfStatsColl != null) { if (_queryIndexManager != null) { _context.PerfStatsColl.SetQueryIndexSize(_queryIndexManager.IndexInMemorySize); } } }
//H2X, H3B, H3R, ODST, HRB, HRR, H4R public static render_model mode(CacheBase Cache, CacheBase.IndexItem Tag) { switch (Cache.Version) { case DefinitionSet.Halo1PC: case DefinitionSet.Halo1CE: case DefinitionSet.Halo1AE: return new Halo1PC.gbxmodel(Cache, Tag.Offset); case DefinitionSet.Halo2Xbox: return new Halo2Xbox.render_model(Cache, Tag.Offset); case DefinitionSet.Halo3Beta: case DefinitionSet.Halo3Retail: return new Halo3Beta.render_model(Cache, Tag.Offset); case DefinitionSet.Halo3ODST: return new Halo3ODST.render_model(Cache, Tag.Offset); case DefinitionSet.HaloReachBeta: return new ReachBeta.render_model(Cache, Tag.Offset); case DefinitionSet.HaloReachRetail: return new ReachRetail.render_model(Cache, Tag.Offset); case DefinitionSet.Halo4Beta: return new Halo4Beta.render_model(Cache, Tag.Offset); case DefinitionSet.Halo4Retail: return new Halo4Retail.render_model(Cache, Tag.Offset); default: throw new NotSupportedException(errorMessage.Replace("----", "mode")); } }
/// <summary> /// Overloaded constructor. Takes the properties as a map. /// </summary> /// <param name="cacheSchemes">collection of cache schemes (config properties).</param> /// <param name="properties">properties collection for this cache.</param> /// <param name="listener">cache events listener</param> /// <param name="timeSched">scheduler to use for periodic tasks</param> public IndexedLocalCache(IDictionary cacheClasses, CacheBase parentCache, IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context) : base(cacheClasses, parentCache, properties, listener, context) { IDictionary props = null; if (properties.Contains("indexes")) { props = properties["indexes"] as IDictionary; } _queryIndexManager = new QueryIndexManager(props, this, _context.CacheRoot.Name); if (!_queryIndexManager.Initialize()) _queryIndexManager = null; //+Numan16122014 _cacheStore.ISizableQueryIndexManager = _queryIndexManager; _cacheStore.ISizableEvictionIndexManager = _evictionPolicy; _cacheStore.ISizableExpirationIndexManager = _context.ExpiryMgr; _stats.MaxCount = _cacheStore.MaxCount; _stats.MaxSize = _cacheStore.MaxSize; //+Numan16122014 if (_context.PerfStatsColl != null) { if (_queryIndexManager != null) _context.PerfStatsColl.SetQueryIndexSize(_queryIndexManager.IndexInMemorySize); } }
/// <summary> /// Recupera as chaves selecionadas. /// </summary> /// <param name="cache">Instancia do cache de onde os itens estão inseridos.</param> /// <param name="evictSize"></param> /// <returns></returns> internal ArrayList GetSelectedKeys(CacheBase cache, long evictSize) { EvictionIndexEntry entry = null; ArrayList list = new ArrayList(); int num = 0; bool flag = false; long next = _head; if (_head != -1) { do { entry = _index[next] as EvictionIndexEntry; foreach (string str in entry.GetAllKeys()) { int itemSize = cache.GetItemSize(str); if (((num + itemSize) >= evictSize) && (num > 0)) { if ((evictSize - num) > ((itemSize + num) - evictSize)) { list.Add(str); } flag = true; break; } list.Add(str); num += itemSize; } next = entry.Next; }while (!flag && (next != -1)); } return(list); }
public scenario_structure_bsp(CacheBase Cache, CacheBase.IndexItem Tag) { cache = Cache; int Address = Tag.Offset; EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); Reader.SeekTo(Address + 68); XBounds = new Range <float>(Reader.ReadSingle(), Reader.ReadSingle()); YBounds = new Range <float>(Reader.ReadSingle(), Reader.ReadSingle()); ZBounds = new Range <float>(Reader.ReadSingle(), Reader.ReadSingle()); #region Clusters Block Reader.SeekTo(Address + 172); int iCount = Reader.ReadInt32(); int iOffset = Reader.ReadInt32() - Tag.Magic; for (int i = 0; i < iCount; i++) { ModelSections.Add(new ModelSection(Cache, Tag, iOffset + 176 * i, null) { FacesIndex = i, VertsIndex = i, NodeIndex = 255 }); Clusters.Add(new Cluster(i)); } #endregion #region Shaders Block Reader.SeekTo(Address + 180); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Tag.Magic; for (int i = 0; i < iCount; i++) { Shaders.Add(new Halo2Xbox.render_model.Shader(Cache, iOffset + 32 * i)); } #endregion #region ModelParts Block Reader.SeekTo(Address + 328); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Tag.Magic; for (int i = 0; i < iCount; i++) { ModelSections.Add(new ModelSection(Cache, Tag, iOffset + 200 * i, BoundingBoxes) { FacesIndex = i + Clusters.Count, VertsIndex = i + Clusters.Count, NodeIndex = 255 }); } #endregion #region GeometryInstances Block Reader.SeekTo(Address + 336); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Tag.Magic; for (int i = 0; i < iCount; i++) { GeomInstances.Add(new InstancedGeometry(Cache, iOffset + 88 * i, Clusters.Count)); } #endregion }
public void LoadBSPTag(CacheBase Cache, CacheBase.IndexItem Tag) { cache = Cache; tag = Tag; sbsp = DefinitionsManager.sbsp(cache, tag); sbsp.BSPName = Path.GetFileNameWithoutExtension(tag.Filename + "." + tag.ClassCode); lblName.Text = sbsp.BSPName; if (cache.Version <= DefinitionSet.Halo2Vista) sbsp.LoadRaw(); isWorking = true; tvRegions.Nodes.Clear(); TreeNode ClusterNode = new TreeNode("Clusters") { Checked = true }; foreach (var clust in sbsp.Clusters) { if (sbsp.ModelSections[clust.SectionIndex].Submeshes.Count > 0) ClusterNode.Nodes.Add(new TreeNode(sbsp.Clusters.IndexOf(clust).ToString("D3")) { Tag = clust, Checked = true }); } if (ClusterNode.Nodes.Count > 0) tvRegions.Nodes.Add(ClusterNode); TreeNode IGnode = new TreeNode("Instances") { Checked = true }; foreach (var IG in sbsp.GeomInstances) { if (sbsp.ModelSections[IG.SectionIndex].Submeshes.Count > 0) IGnode.Nodes.Add(new TreeNode(IG.Name) { Tag = IG, Checked = true }); } if (IGnode.Nodes.Count > 0) tvRegions.Nodes.Add(IGnode); isWorking = false; }
public UsageBlock(CacheBase Cache, int Address) { EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); Usage = Cache.Strings.GetItemByID(Reader.ReadInt32()); }
public void WriteBehind(CacheBase internalCache, object[] keys, object[] values, CacheEntry[] entries, string source, string taskId, OpCode operationCode, WriteBehindAsyncProcessor.TaskState state) { if (_asyncWrites && (_context.DatasourceMgr._writeBehindAsyncProcess != null)) { _context.DatasourceMgr._writeBehindAsyncProcess.Enqueue(new BulkWriteBehindTask(internalCache, this, keys, values, entries, source, taskId, _myProvider, operationCode, state)); } }
public void WriteBehind(CacheBase internalCache, object key, CacheEntry entry, string source, string taskId, OpCode operationCode) { if (_asyncWrites && (_context.DatasourceMgr._writeBehindAsyncProcess != null)) { _context.DatasourceMgr._writeBehindAsyncProcess.Enqueue(new WriteBehindTask(internalCache, this, key, entry, source, taskId, _myProvider, operationCode)); } }
public RawEntry(CacheBase Cache, int Address) { EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); Reader.SeekTo(Address + 12); TagID = Reader.ReadInt32(); RawID = Reader.ReadInt32(); FixupOffset = Reader.ReadInt32(); FixupSize = Reader.ReadInt32(); Reader.ReadInt32(); LocationType = Reader.ReadInt16(); SegmentIndex = Reader.ReadInt16(); Reader.ReadInt32(); #region Resource Fixups Reader.SeekTo(Address + 40); int iCount = Reader.ReadInt32(); int iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) Fixups.Add(new ResourceFixup(Cache, iOffset + 8 * i)); #endregion #region Resource Definition Fixups Reader.SeekTo(Address + 52); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) DefinitionFixups.Add(new ResourceDefinitionFixup(Cache, iOffset + 8 * i)); #endregion }
public bitmap(CacheBase Cache, int Address) { EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); #region Sequence Chunk Reader.SeekTo(Address + 60); int iCount = Reader.ReadInt32(); int iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { Sequences.Add(new Sequence(Cache, iOffset + 60 * i)); } #endregion #region BitmapData Chunk Reader.SeekTo(Address + 68); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { Bitmaps.Add(new BitmapData(Cache, iOffset + 116 * i)); } #endregion }
public HashedLocalCache(IDictionary cacheClasses, CacheBase parentCache, IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context, bool logEntries, ActiveQueryAnalyzer activeQueryAnalyzer) : base(cacheClasses, parentCache, properties, listener, context, activeQueryAnalyzer) { _logMgr = new OpLogManager(logEntries, context); _stats.LocalBuckets = new HashVector(1000); _cacheStore.ISizableBucketIndexManager = this; }
public Submesh(CacheBase Cache, int Address) { EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); Reader.ReadInt32(); ShaderIndex = Reader.ReadInt16(); Reader.SeekTo(Address + 0x48); FaceCount = Reader.ReadInt32() + 2; FaceOffset = Reader.ReadInt32(); Reader.SeekTo(Address + 0x58); VertexCount = Reader.ReadInt32(); Reader.ReadInt32(); Reader.ReadInt32(); VertOffset = Reader.ReadInt32(); Reader.Skip(3); int iCount = Reader.ReadByte(); for (int i = 0; i < iCount; i++) { LocalNodes.Add(Reader.ReadByte()); } }
/// <summary> /// Checks whether the given entity key indexes are cached. /// </summary> /// <param name="entityKeys">The list of pairs of entity keys and their indexes.</param> /// <param name="keyIndexes">The array of indexes of <paramref name="entityKeys"/> that have to be checked.</param> /// <param name="persister">The entity persister.</param> /// <param name="batchableCache">The batchable cache.</param> /// <param name="checkCache">Whether to check the cache or just return <see langword="false" /> for all keys.</param> /// <returns>An array of booleans that contains the result for each key.</returns> private bool[] AreCached(List <KeyValuePair <EntityKey, int> > entityKeys, int[] keyIndexes, IEntityPersister persister, CacheBase batchableCache, bool checkCache) { var result = new bool[keyIndexes.Length]; if (!checkCache || !persister.HasCache || !context.Session.CacheMode.HasFlag(CacheMode.Get)) { return(result); } var cacheKeys = new object[keyIndexes.Length]; var i = 0; foreach (var index in keyIndexes) { var entityKey = entityKeys[index].Key; cacheKeys[i++] = context.Session.GenerateCacheKey( entityKey.Identifier, persister.IdentifierType, entityKey.EntityName); } var cacheResult = batchableCache.GetMany(cacheKeys); for (var j = 0; j < result.Length; j++) { result[j] = cacheResult[j] != null; } return(result); }
public cache_file_resource_layout_table(CacheBase Cache, int Address) { EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); #region Shared Cache Block Reader.SeekTo(Address + 12); int iCount = Reader.ReadInt32(); int iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) SharedCaches.Add(new SharedCache(Cache, iOffset + 264 * i)); #endregion #region Page Block Reader.SeekTo(Address + 24); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) Pages.Add(new Page(Cache, iOffset + 88 * i)); #endregion #region Segment Block Reader.SeekTo(Address + 48); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) Segments.Add(new Segment(Cache, iOffset + 24 * i)); #endregion }
private void PutCacheData(CacheBase cache, Dictionary <CacheKey, List <object> > cacheData) { foreach (var pair in cacheData) { cache.Put(pair.Key, pair.Value); } }
/// <summary> /// Overloaded constructor. Takes the properties as a map. /// </summary> /// <param name="cacheSchemes">collection of cache schemes (config properties).</param> /// <param name="properties">properties collection for this cache.</param> /// <param name="listener">cache events listener</param> /// <param name="timeSched">scheduler to use for periodic tasks</param> public LocalCache(IDictionary cacheClasses, CacheBase parentCache, IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context) : base(properties, parentCache, listener, context) { _stats.ClassName = "local-cache"; Initialize(cacheClasses, properties); }
private void RemoveCacheData(CacheBase cache, Dictionary <CacheKey, List <object> > cacheData) { foreach (var pair in cacheData) { cache.Remove(pair.Key); } }
public void Dispose() { CacheSnapshotPool.Instance.DiposeSnapshot(_pointer.Id, _cache); //Disposes the snapshot from pool for this particular pointer _cache = null; _pointer = null; _snapshot = null; }
public WebDavSqlStoreCollection GetCollection(IWebDavStoreCollection parentCollection, string path, String rootPath, Guid rootGuid) { var p = PrincipleFactory.Instance.GetPrinciple(FromType.WebDav); string userkey = p.UserProfile.SecurityObjectId.ToString(); CacheBase mc = GetCachedObject(path) as CacheBase; WebDavSqlStoreCollection itm = null; if (mc != null) { itm = mc.GetCachedObject(userkey) as WebDavSqlStoreCollection; } if (itm != null) { return(itm); } itm = new WebDavSqlStoreCollection(parentCollection, path, rootPath, rootGuid, Store); if (mc == null) { mc = new CacheBase(); mc.AddCacheObject(userkey, itm); AddCacheObject(path, mc); } else { mc.AddCacheObject(userkey, itm); } return(itm); }
/// <summary> /// Returns an array containing list of keys contained in the cache. Null if there are no /// keys or if timeout occurs. /// </summary> /// <param name="cache"></param> /// <param name="timeout"></param> /// <returns></returns> internal static object[] GetKeys(CacheBase cache, int timeout) { int index = 0; var keys = cache.Keys; object[] objects = null; if (keys.Length < 1) { return(objects); } cache.Sync.AcquireWriterLock(timeout); try { objects = new object[keys.Length]; foreach (var key in keys) { if (index > keys.Length) { break; } objects[index++] = key; } } finally { cache.Sync.ReleaseWriterLock(); } return(objects); }
public render_method_template(CacheBase Cache, int Address) { EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); #region Usage Blocks Reader.SeekTo(Address + 72); int iCount = Reader.ReadInt32(); int iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { ArgumentBlocks.Add(new ArgumentBlock(Cache, iOffset + 4 * i)); } #endregion #region Usage Blocks Reader.SeekTo(Address + 108); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { UsageBlocks.Add(new UsageBlock(Cache, iOffset + 4 * i)); } #endregion }
public ShaderProperties(CacheBase Cache, int Address) { EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); #region ShaderProperties Chunk int iCount = Reader.ReadInt32(); int iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { ShaderMaps.Add(new ShaderMap(Cache, iOffset + 20 * i)); } #endregion #region Tiling Chunk Reader.SeekTo(Address + 12); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { Tilings.Add(new Tiling(Cache, iOffset + 16 * i)); } #endregion }
/// <summary> /// Remove a node from the cluster. /// </summary> /// <param name="hostPort"></param> /// <returns></returns> public bool RemoveNode(string hostname, int port) { // Request Layout: // HostLen int // Host byte[] UTF8 string // Port int byte[] data = null; using (MemoryStream ms = new MemoryStream()) { BinaryWriter w = new BinaryWriter(ms); byte[] hostBytes = CacheBase.WriteHostName(hostname); w.Write(IPAddress.HostToNetworkOrder(hostBytes.Length)); w.Write(hostBytes); w.Write(IPAddress.HostToNetworkOrder(port)); w.Flush(); ms.Flush(); data = ms.ToArray(); } Request request = new Request(Request.Types.RemoveNode, data); var response = base.SendRequest(base.MasterHostName, base.MasterPort, request); if (response == null) { return(false); } return(response.Type != Response.Types.Accepted); }
public BitmapData(CacheBase Cache, int Address) { EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); Class = Reader.ReadString(4); Width = Reader.ReadInt16(); Height = Reader.ReadInt16(); Depth = Reader.ReadByte(); Flags = new Bitmask(Reader.ReadByte()); Type = (BitmapType)Reader.ReadByte(); Reader.ReadByte(); //dunno what this is Format = (BitmapFormat)Reader.ReadInt16(); if ((int)Format > 31) //change to match defined format list Format -= 5; MoreFlags = new Bitmask(Reader.ReadInt16()); RegX = Reader.ReadInt16(); RegY = Reader.ReadInt16(); MipmapCount = Reader.ReadByte(); Reader.ReadByte(); InterleavedIndex = Reader.ReadByte(); Index2 = Reader.ReadByte(); PixelsOffset = Reader.ReadInt32(); PixelsSize = Reader.ReadInt32(); }
public void LoadBitmapTag(CacheBase Cache, CacheBase.IndexItem Tag) { exportAllImagesToolStripMenuItem.Visible = true; cache = Cache; tag = Tag; bitm = DefinitionsManager.bitm(cache, tag); lstBitmaps.Items.Clear(); var list = GetBitmapsByTag(cache, tag, PixelFormat.Format32bppArgb); for (int i = 0; i < list.Count; i++) { var submap = bitm.Bitmaps[i]; lstBitmaps.Items.Add(new ListViewItem(new string[] { i.ToString(), submap.Width.ToString(), submap.Height.ToString(), submap.Type.ToString(), submap.Format.ToString() }) { Tag = (list[i] == null) ? GetErrorImage() : list[i] }); } lstBitmaps.FocusedItem = lstBitmaps.Items[0]; lstBitmaps_SelectedIndexChanged(null, null); }
public InstancedGeometry(CacheBase Cache, int Address, int modifier) { EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); TransformScale = Reader.ReadSingle(); TransformMatrix = new Matrix(); TransformMatrix.m11 = Reader.ReadSingle(); TransformMatrix.m12 = Reader.ReadSingle(); TransformMatrix.m13 = Reader.ReadSingle(); TransformMatrix.m21 = Reader.ReadSingle(); TransformMatrix.m22 = Reader.ReadSingle(); TransformMatrix.m23 = Reader.ReadSingle(); TransformMatrix.m31 = Reader.ReadSingle(); TransformMatrix.m32 = Reader.ReadSingle(); TransformMatrix.m33 = Reader.ReadSingle(); TransformMatrix.m41 = Reader.ReadSingle(); TransformMatrix.m42 = Reader.ReadSingle(); TransformMatrix.m43 = Reader.ReadSingle(); SectionIndex = Reader.ReadInt16() + modifier; Reader.SeekTo(Address + 80); Name = Cache.Strings.GetItemByID(Reader.ReadInt16()); }
public cache_file_resource_gestalt(CacheBase Cache, int Address) { EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); #region Raw Entries Reader.SeekTo(Address + 36); int iCount = Reader.ReadInt32(); int iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { RawEntries.Add(new RawEntry(Cache, iOffset + 96 * i)); } #endregion #region Fixup Data Reader.SeekTo(Address + 132); iCount = Reader.ReadInt32(); Reader.ReadInt32(); Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; Reader.SeekTo(iOffset); FixupData = Reader.ReadBytes(iCount); #endregion }
/// <summary> /// Copies the entries of a cache into an array. Used for state transfer. /// </summary> /// <param name="cache">cache object</param> /// <param name="count">number of entries to return</param> /// <returns>array of cache entries</returns> public static CacheEntry[] GetCacheEntries(CacheBase cache, long count) { long index = 0; CacheEntry[] entArr = null; CacheEntry ent = null; cache.Sync.AcquireReaderLock(Timeout.Infinite); try { if (count == 0 || count > cache.Count) { count = cache.Count; } entArr = new CacheEntry[count]; IDictionaryEnumerator i = cache.GetEnumerator(); while (index < count && i.MoveNext()) { ent = i.Value as CacheEntry; entArr[index++] = ent.RoutableClone(null); } } catch (Exception e) { cache.Context.NCacheLog.Error("CacheHelper.CreateLocalEntry()", e.Message); return(null); } finally { cache.Sync.ReleaseReaderLock(); } return(entArr); }
private object SubmitMapReduceTask(MapReduceOperation operation) { try { _context.NCacheLog.CriticalInfo("MapReduce.TaskTracker ", "MapReduce task with taskId '" + operation.TaskID + "' is submitted"); CacheBase p = (CacheBase)((_context.CacheImpl != null && _context.CacheImpl is CacheBase) ? _context.CacheImpl : null); Runtime.MapReduce.MapReduceTask userTask = (Runtime.MapReduce.MapReduceTask)operation.Data; Filter filter = operation.Filter; if (userTask != null) { MapReduceTask serverTask = new MapReduceTask(p, Callback, userTask.Mapper, userTask.Combiner, userTask.Reducer, userTask.InputProvider == null ? new InputProviders.CacheInputProvider(p.InternalCache, filter != null ? filter.QueryFilter : null, this._context) : userTask.InputProvider, new InMemoryOutpuProvider(taskOutputStore), filter, _context, this.ChunkSize, this.MaxExceptions); serverTask.TaskId = operation.TaskID; serverTask.AddTaskCallbackInfo(operation.CallbackInfo); return(this.SubmitTask(serverTask)); } } catch (Exception ex) { throw new OperationFailedException(ex.Message); } return(null); }
//H2X, H3B, H3R, ODST, HRB, HRR, H4R public static bitmap bitm(CacheBase Cache, CacheBase.IndexItem Tag) { switch (Cache.Version) { case DefinitionSet.Halo1PC: return new Halo1PC.bitmap(Cache, Tag.Offset); case DefinitionSet.Halo1CE: return new Halo1CE.bitmap(Cache, Tag.Offset); case DefinitionSet.Halo2Xbox: return new Halo2Xbox.bitmap(Cache, Tag.Offset); case DefinitionSet.Halo3Beta: case DefinitionSet.Halo3Retail: case DefinitionSet.Halo3ODST: return new Halo3Beta.bitmap(Cache, Tag.Offset); case DefinitionSet.HaloReachBeta: return new ReachBeta.bitmap(Cache, Tag.Offset); case DefinitionSet.HaloReachRetail: case DefinitionSet.Halo4Beta: case DefinitionSet.Halo4Retail: return new ReachRetail.bitmap(Cache, Tag.Offset); default: throw new NotSupportedException(errorMessage.Replace("----", "bitm")); } }
public ArgumentBlock(CacheBase Cache, int Address) { EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); Argument = Cache.Strings.GetItemByID(Reader.ReadInt32()); }
public bink(CacheBase Cache, int Address) { EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); Reader.Skip(4); RawID = Reader.ReadInt32(); }
public static CommandContext Create(CommandContext parent, OpenTagCache info, CacheBase blamCache) { var context = new CommandContext(parent, blamCache.Build); context.AddCommand(new PortShaderCommand(info, blamCache)); context.AddCommand(new PortModelCommand(info, blamCache)); context.AddCommand(new ListBitmapsCommand(info, blamCache)); return context; }
public gbxmodel(CacheBase Cache, int Address) { cache = Cache; EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); Name = "gbxmodel"; Flags = new Bitmask(Reader.ReadInt16()); Reader.SeekTo(Address + 0x30); uScale = Reader.ReadSingle(); vScale = Reader.ReadSingle(); #region MarkerGroups Block Reader.SeekTo(Address + 0xAC); int iCount = Reader.ReadInt32(); int iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) MarkerGroups.Add(new MarkerGroup(Cache, iOffset + 64 * i)); #endregion #region Nodes Block Reader.SeekTo(Address + 0xB8); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) Nodes.Add(new Node(Cache, iOffset + 156 * i)); #endregion #region Regions Block Reader.SeekTo(Address + 0xC4); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) Regions.Add(new Region(Cache, iOffset + 76 * i)); #endregion #region ModelParts Block Reader.SeekTo(Address + 0xD0); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) ModelSections.Add(new ModelSection(Cache, iOffset + 48 * i) { FacesIndex = i, VertsIndex = i, NodeIndex = 255 }); #endregion #region Shaders Block Reader.SeekTo(Address + 0xDC); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) Shaders.Add(new Shader(Cache, iOffset + 32 * i)); #endregion #region BoundingBox Block BoundingBoxes.Add(new BoundingBox()); #endregion }
public render_model(CacheBase Cache, int Address) { cache = Cache; EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); Name = Cache.Strings.GetItemByID(Reader.ReadInt16()); //Flags = new Bitmask(Reader.ReadInt32()); #region BoundingBox Block Reader.SeekTo(Address + 20); int iCount = Reader.ReadInt32(); int iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) BoundingBoxes.Add(new BoundingBox(Cache, iOffset + 56 * i)); #endregion #region Regions Block Reader.SeekTo(Address + 28); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) Regions.Add(new Region(Cache, iOffset + 16 * i)); #endregion #region ModelParts Block Reader.SeekTo(Address + 36); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) ModelSections.Add(new ModelSection(Cache, iOffset + 92 * i) { FacesIndex = i, VertsIndex = i, NodeIndex = 255 }); Reader.SeekTo(Address + 72); #endregion #region Nodes Block iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) Nodes.Add(new Node(Cache, iOffset + 96 * i)); #endregion #region MarkerGroups Block Reader.SeekTo(Address + 88); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) MarkerGroups.Add(new MarkerGroup(Cache, iOffset + 12 * i)); #endregion #region Shaders Block Reader.SeekTo(Address + 96); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) Shaders.Add(new Shader(Cache, iOffset + 32 * i)); #endregion }
public Codec(CacheBase Cache, int Address) { EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); Unknown = Reader.ReadByte(); Type = (SoundType)Reader.ReadByte(); Flags = new Bitmask(Reader.ReadByte()); }
public PortShaderCommand(OpenTagCache info, CacheBase blamCache) : base(CommandFlags.None, "portshader", "", "portshader <blam tag path>", "") { Info = info; BlamCache = blamCache; }
public CacheHeader(CacheBase Cache) { cache = Cache; EndianReader Reader = cache.Reader; Reader.SeekTo(8); fileSize = Reader.ReadInt32(); Reader.ReadInt32(); indexOffset = Reader.ReadInt32(); }
public SoundPermutation(CacheBase Cache, int Address) { EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); NameIndex = Reader.ReadInt16(); Reader.SeekTo(Address + 8); RawChunkIndex = Reader.ReadInt32(); ChunkCount = Reader.ReadInt16(); }
//---, ---, ---, ----, ---, ---, H4R public static bink bink(CacheBase Cache, CacheBase.IndexItem Tag) { switch (Cache.Version) { case DefinitionSet.Halo4Retail: return new Halo4Retail.bink(Cache, Tag.Offset); default: throw new NotSupportedException(errorMessage.Replace("----", "bink")); } }
public ShaderMap(CacheBase Cache, int Address) { EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); Reader.SeekTo(Address + 12); BitmapTagID = Reader.ReadInt32(); Type = Reader.ReadInt16(); Reader.ReadByte(); TilingIndex = Reader.ReadByte(); }
public sound(CacheBase Cache, int Address) { EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); Reader.SeekTo(Address + 12); SoundAddress1 = Reader.ReadUInt32(); SoundAddress2 = Reader.ReadUInt32(); Reader.SeekTo(Address + 52); SoundBankTagID = Reader.ReadInt32(); }
public multilingual_unicode_string_list(CacheBase Cache, int Address) { EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); Reader.SeekTo(Address + 32); for (int i = 0; i < 12; i++) { Indices.Add(Reader.ReadUInt16()); Lengths.Add(Reader.ReadUInt16()); } }
static CacheFactory() { if (cacheBase == null) { lock (typeof(CacheBase)) { if (cacheBase == null) { cacheBase = WebCache.Instance; } } } }
private CacheManager() { switch (_storeType) { case StoreType.File: _cache = new FileCache(); break; case StoreType.SqLite: _cache = new SqliteCache(); break; default: throw new Exception(string.Format("CacheManager .ctor failed: {0} type not handled", _storeType)); } }
public Segment(CacheBase Cache, int Offset) { EndianReader Reader = Cache.Reader; Reader.SeekTo(Offset); RequiredPageIndex = Reader.ReadInt16(); OptionalPageIndex = Reader.ReadInt16(); OptionalPageIndex2 = -1; //doesn't exist till Halo4 RequiredPageOffset = Reader.ReadInt32(); OptionalPageOffset = Reader.ReadInt32(); OptionalPageOffset2 = -1; //doesn't exist till Halo4 SoundNumber = Reader.ReadInt16(); SoundRawIndex = Reader.ReadInt16(); }
public ShaderProperties(CacheBase Cache, int Address) { EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); TemplateTagID = -1; Reader.SeekTo(Address + 20); #region Tiling Chunk int iCount = Reader.ReadInt32(); int iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) Tilings.Add(new Tiling(Cache, iOffset + 16 * i)); #endregion }
public material(CacheBase Cache, int Address) { EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); Reader.SeekTo(Address + 12); BaseShaderTagID = Reader.ReadInt32(); #region ShaderProperties Chunk Reader.SeekTo(Address + 28); int iCount = Reader.ReadInt32(); int iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) Properties.Add(new ShaderProperties(Cache, iOffset + 140 * i)); #endregion }
public shader(CacheBase Cache, int Address) { EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); Reader.SeekTo(Address + 12); BaseShaderTagID = Reader.ReadInt32(); #region ShaderProperties Chunk Reader.SeekTo(Address + 56); int pCount = Reader.ReadInt32(); int pOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < pCount; i++) Properties.Add(new ShaderProperties(Cache, pOffset + 172 * i)); #endregion }
public sound(CacheBase Cache, int Address) { EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); Flags = new Bitmask(Reader.ReadInt16()); SoundClass = Reader.ReadByte(); SampleRate = (SampleRate)Reader.ReadByte(); Encoding = Reader.ReadByte(); CodecIndex = Reader.ReadByte(); PlaybackIndex = Reader.ReadInt16(); DialogueUnknown = Reader.ReadInt16(); Reader.SeekTo(Address + 28); RawID = Reader.ReadInt32(); }
public scenario_structure_bsp(CacheBase Cache, CacheBase.IndexItem Tag) { cache = Cache; int Address = Tag.Offset; EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); Reader.SeekTo(Address + 68); XBounds = new Range<float>(Reader.ReadSingle(), Reader.ReadSingle()); YBounds = new Range<float>(Reader.ReadSingle(), Reader.ReadSingle()); ZBounds = new Range<float>(Reader.ReadSingle(), Reader.ReadSingle()); #region Clusters Block Reader.SeekTo(Address + 172); int iCount = Reader.ReadInt32(); int iOffset = Reader.ReadInt32() - Tag.Magic; for (int i = 0; i < iCount; i++) { ModelSections.Add(new ModelSection(Cache, Tag, iOffset + 176 * i, null) { FacesIndex = i, VertsIndex = i, NodeIndex = 255 }); Clusters.Add(new Cluster(i)); } #endregion #region Shaders Block Reader.SeekTo(Address + 180); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Tag.Magic; for (int i = 0; i < iCount; i++) Shaders.Add(new Halo2Xbox.render_model.Shader(Cache, iOffset + 32 * i)); #endregion #region ModelParts Block Reader.SeekTo(Address + 328); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Tag.Magic; for (int i = 0; i < iCount; i++) ModelSections.Add(new ModelSection(Cache, Tag, iOffset + 200 * i, BoundingBoxes) { FacesIndex = i + Clusters.Count, VertsIndex = i + Clusters.Count, NodeIndex = 255 }); #endregion #region GeometryInstances Block Reader.SeekTo(Address + 336); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Tag.Magic; for (int i = 0; i < iCount; i++) GeomInstances.Add(new InstancedGeometry(Cache, iOffset + 88 * i, Clusters.Count)); #endregion }