void DeserializeItem(String name, bool check) { object val; lock (_serializedItemsLock) { if (check) { // No-op if SessionStateItemCollection is not deserialized from a persistent storage, if (_serializedItems == null) { return; } // User is asking for an item we don't have. if (!_serializedItems.ContainsKey(name)) { return; } } Debug.Assert(_serializedItems != null); Debug.Assert(_stream != null); SerializedItemPosition position = (SerializedItemPosition)_serializedItems[name]; if (position.IsDeserialized) { // It has been deserialized already. return; } // Position the stream to the place where the item is stored. _stream.Seek(position.Offset, SeekOrigin.Begin); // Set the value Debug.Trace("SessionStateItemCollection", "Deserialized an item: keyname=" + name); if (!HttpRuntime.DisableProcessRequestInApplicationTrust) { // VSWhidbey 427316: Sandbox Serialization in non full trust cases if (HttpRuntime.NamedPermissionSet != null && HttpRuntime.ProcessRequestInApplicationTrust) { HttpRuntime.NamedPermissionSet.PermitOnly(); } } // This deserialization work used to be done in AcquireRequestState event when // there is no user code on the stack. // In whidbey we added this on-demand deserialization for performance reason. However, // in medium and low trust cases the page doesn't have permission to do it. // So we have to assert the permission. // (See VSWhidbey 275003) val = ReadValueFromStreamWithAssert(); BaseSet(name, val); // At the end, mark the item as deserialized by making the offset -1 position.MarkDeserializedOffsetAndCheck(); } }
public virtual PluginBase LoadPlugin(PluginLoadInfo plugin) { if (this.PluginsLoaded.ContainsKey(plugin.ClassName)) { return(this.PluginsLoaded[plugin.ClassName]); } Assembly ass = null; if (_Assemblies.ContainsKey(plugin.Filename)) { ass = _Assemblies[plugin.Filename]; } else { string path = Path.Combine(this.AssemblySearchPath, plugin.Filename); ass = Assembly.LoadFile(path); _Assemblies.Add(plugin.Filename, ass); } PluginBase plug = (PluginBase)ass.CreateInstance(plugin.ClassName); this.PluginsLoaded.Add(plugin.ClassName, plug); if (plug.ShowMenuItem) { AddToPluginsMenu(plug); } return(plug); }
async Task <ByteSize> LoadBLobData(SyncTableCfg tableCfg, ILogger log, string loadId, string sourceSql, object maxTs, TableId loadTable) { var path = StringPath.Relative("sync", tableCfg.Name, loadId); var copyTask = Source.CopyTo(path, sourceSql, tableCfg, maxTs); var loadedFiles = new KeyedCollection <StringPath, FileListItem>(f => f.Path); while (true) // load as the files are created { if (copyTask.IsFaulted) { break; } var toLoad = (await Store.List(path).SelectManyList()) .Where(f => !loadedFiles.ContainsKey(f.Path)).ToArray(); if (toLoad.None()) { if (copyTask.IsCompleted) { break; } await 5.Seconds().Delay(); continue; } log.Debug("Sync {Table} - loading: {Files}", tableCfg.Name, toLoad.Join("|", l => l.Path.ToString())); await Dest.LoadFrom(toLoad.Select(f => f.Path), loadTable); loadedFiles.AddRange(toLoad); await toLoad.BlockAction(f => Store.Delete(f.Path, log), parallel : 8); } log.Information("Sync {Table} - copied {Files} files ({Size})", tableCfg.Name, loadedFiles.Count, loadedFiles.Sum(f => f.Bytes).Bytes().Humanize("#,#")); return(loadedFiles.Sum(f => f.Bytes).Bytes()); }
public Stream OpenFile(string filename, bool forceReload) { if (forceReload && _files.ContainsKey(filename)) { long length = _files[filename].Length; _files.RemoveByKey(filename); if (_freeFiles.Contains(filename)) { _freeFiles.Remove(filename); } _currentBufferSize -= length; } this.CacheFile(filename); return(_files[filename]); }
/// <summary> /// Show a new Matrix. /// </summary> public void ShowTransform(String key, Matrix matrix) { if (MatrixCollection.ContainsKey(key)) { MatrixCollection[key].Update(matrix); } else { MatrixCollection.Set(key, new MatrixVisualHelper(matrix)); } }
/// <summary> /// Show a new Vector3. /// </summary> public void ShowVector3(String key, Vector3 baseVector, Vector3 vector, Color color) { if (vector3Collection.ContainsKey(key)) { vector3Collection[key].Update(baseVector, vector, color); } else { vector3Collection.Set(key, new Vector3VisualHelper(baseVector, vector, color)); } }
public virtual WaitableTask <string> SelectSprite(KeyedCollection <Sprite> sprites, string spriteKey) { if (CurrentWaitableSpriteKey?.IsCompleted() == false) { CurrentWaitableSpriteKey.SetError(new Exception("New popup opened")); } gameObject.SetActive(true); SpriteCollection = sprites; CurrentKey = spriteKey; CurrentWaitableSpriteKey = new WaitableTask <string>(); if (spriteKey != null && SpriteCollection.ContainsKey(spriteKey)) { SetImage(SpriteCollection[spriteKey]); } else { SetImage(null); } return(CurrentWaitableSpriteKey); }
public bool ContainsKey(string key) { return(m_Panels.ContainsKey(key)); }