public override Target this[string id] { get { Target target = null; if (_targetCache != null) { target = _targetCache[id]; if (target != null) { return(target); } } if (_targetStorage != null && _targetStorage.ContainsKey(id)) { target = TargetsReader.ReadXml(_targetStorage[id]); if (target != null && _targetCache != null) { _targetCache.Add(target); } } return(target); } }
//protected void InitializeConfiguration(IConfig config) //{ // var hostKey = config[BlobContainerLocalConfig.ContainerHost]; // _containerName = config[BlobContainerLocalConfig.ContainerName]; // _host = hostKey; // _container = _containerName; // _access = (EntityAccess)Enum.Parse(typeof(EntityAccess), // config.Get(BlobContainerLocalConfig.OptionalAccess, // EntityAccess.Private.ToString())); //} protected void InternalSaveObject <TData>(string objId, TData obj) { try { if (mutex.Wait(TimeSpan.FromSeconds(DefaultTime))) { var data = JsonConvert.SerializeObject(obj); if (_persistentDictionary.ContainsKey(objId)) { _persistentDictionary[objId] = data; } else { _persistentDictionary.Add(objId, data); } _persistentDictionary.Flush(); mutex.Release(); } } catch (Exception ex) { throw new BlobAccessException(ex); } }
public void Update <T>(string key, T newvalue) { if (_persistentDictionary.ContainsKey(key)) { _persistentDictionary.Remove(key); } Put(key, newvalue); }
/// <summary> /// Test dictionary insert/replace/delete. /// </summary> /// <typeparam name="TKey">Key type of the dictionary.</typeparam> /// <typeparam name="TValue">Value type of the dictionary.</typeparam> /// <param name="dictionary">The dictionary to test.</param> /// <param name="key">Key that is present in the dictionary.</param> /// <param name="value">Value associated with the key in the dictionary.</param> private static void TestBasicOperations <TKey, TValue>(PersistentDictionary <TKey, TValue> dictionary, TKey key, TValue value) where TKey : IComparable <TKey> { var kvp = new KeyValuePair <TKey, TValue>(key, value); // Add a record dictionary.Add(key, value); // Test PersistentDictionary.Add error handling try { dictionary.Add(key, value); Assert.Fail("Expected ArgumentException from Add"); } catch (ArgumentException) { // Expected } // Overwrite a value dictionary[key] = value; // Retrieve a value Assert.AreEqual(value, dictionary[key], "Retrieve with [] failed"); TValue t; Assert.IsTrue(dictionary.TryGetValue(key, out t), "TryGetValue({0}) failed", key); Assert.AreEqual(value, t, "TryGetValue({0}) returned the wrong value", key); // Clear and re-insert dictionary.Clear(); Assert.AreEqual(0, dictionary.Count, "Dictionary is empty. Count is wrong"); dictionary[key] = value; Assert.AreEqual(1, dictionary.Count, "Item was just inserted. Count is wrong"); // Get the keys and values Assert.AreEqual(dictionary.Keys.First(), key, "Keys collection"); Assert.AreEqual(dictionary.Values.First(), value, "Values collection"); // Test PersistentDictionary.Contains (true) Assert.IsTrue(dictionary.ContainsKey(key), "Dictionary should have contained key {0}", key); Assert.IsTrue(dictionary.ContainsValue(value), "Dictionary should have contained value {0}", value); Assert.IsTrue(dictionary.Contains(kvp), "Dictionary should have contained <{0},{1}>", key, value); // Test PersistentDictionary.Remove Assert.IsTrue(dictionary.Remove(key), "Key {0} should exist, but removal failed", key); Assert.IsFalse(dictionary.Remove(key), "Key {0} doesn't exist, but removal succeeded", key); dictionary.Add(kvp); Assert.IsTrue(dictionary.Remove(kvp), "KeyValuePair <{0},{1}> should exist, but removal failed", kvp.Key, kvp.Value); Assert.IsFalse(dictionary.Remove(kvp), "KeyValuePair <{0},{1}> doesn't exist, but removal succeeded", kvp.Key, kvp.Value); // Test PersistentDictionary.Contains (false) Assert.IsFalse(dictionary.ContainsKey(key), "Dictionary should have contained key {0}", key); Assert.IsFalse(dictionary.ContainsValue(value), "Dictionary should have contained value {0}", value); Assert.IsFalse(dictionary.Contains(kvp), "Dictionary should have contained <{0},{1}>", key, value); }
static void Benchmark() { var payload = new byte[4 * 1024]; var dir = "temp"; if (!Directory.Exists(dir)) Directory.CreateDirectory(dir); Utility.Timeit("File system", 1, () => { var random = new Random(); for (var i = 0; i < 40000; ++i) { var path = string.Format("{0}/{1}.txt", dir, random.Next(1000)); switch (random.Next(2)) { case 0: File.WriteAllBytes(path, payload); break; case 1: if (File.Exists(path)) File.Delete(path); break; default: throw new NotSupportedException(); } } }); Utility.Timeit("PersistentDictionary", 1, () => { if (File.Exists("1.txt")) File.Delete("1.txt"); var random = new Random(); using (var dict = new PersistentDictionary("1.txt")) { for (var i = 0; i < 40000; ++i) { var key = string.Format("{0}/{1}.txt", dir, random.Next(1000)); switch (random.Next(2)) { case 0: if (dict.ContainsKey(key)) dict[key] = payload; else dict.Add(key, payload); break; case 1: if (dict.ContainsKey(key)) dict.Remove(key); break; default: throw new NotSupportedException(); } } } }); }
private void Store(long index, string text) { if (index < 0) { throw new InvalidOperationException("Event index must be >= 0!"); } if (_directory.ContainsKey(index)) { throw new InvalidOperationException($"Event with index {index} has already been stored and cannot be overwritten!"); } _directory.Add(index, text); }
public override Target this[string id] { get { Target target = null; if (_quickStorage != null && _quickStorage.Count != 0) { target = _quickStorage[id]; if (target != null) { return(target); } } if (_targetCache != null) { target = _targetCache[id]; if (target != null) { return(target); } } if (_targetStorage != null && _targetStorage.ContainsKey(id)) { target = TargetsReader.ReadXml(_targetStorage[id]); if (target != null && _targetCache != null) { _targetCache.Add(target); } return(target); } if (_otherStorages != null && _otherStorages.Count != 0) { // We will not cache any target from the other sources, since // each has internal cache... for (int i = 0; i < _otherStorages.Count; i++) { target = _otherStorages[i][id]; if (target != null) { break; } } } return(target); } }
public override XPathNavigator GetContent(string key) { XPathNavigator navigator = null; if (_indexedDocument != null) { string innerXml = null; if (_indexedDocument.ContainsKey(key)) { innerXml = _indexedDocument[key]; } if (String.IsNullOrEmpty(innerXml)) { return(null); } if (_settings == null) { _settings = new XmlReaderSettings(); _settings.ConformanceLevel = ConformanceLevel.Fragment; } StringReader textReader = new StringReader(innerXml); using (XmlReader reader = XmlReader.Create(textReader, _settings)) { XPathDocument document = new XPathDocument(reader); navigator = document.CreateNavigator(); } } return(navigator); }
public override void Initialize(string workingDir, bool createNotFound) { if (String.IsNullOrEmpty(workingDir)) { throw new InvalidOperationException(); } if (!Directory.Exists(workingDir)) { Directory.CreateDirectory(workingDir); } if (_isSystem) { _dataSourceDir = workingDir; } else { string tempFile = Path.GetFileNameWithoutExtension( Path.GetTempFileName()); _dataSourceDir = Path.Combine(workingDir, tempFile); } _isExisted = PersistentDictionaryFile.Exists(_dataSourceDir); if (_isExisted) { this.CheckDataIndex(_dataSourceDir); _targetStorage = new PersistentDictionary <string, string>(_dataSourceDir); if (_targetStorage.ContainsKey("$DataCount$")) { _count = Convert.ToInt32(_targetStorage["$DataCount$"]); if (_count <= 0) { _count = _targetStorage.Count; } } else { _count = _targetStorage.Count; } } else { _count = 0; if (createNotFound) { _targetStorage = new PersistentDictionary <string, string>(_dataSourceDir); } } if (_targetStorage != null) { _targetCache = new DatabaseTargetCache(100); } _isInitialized = true; }
public override void Initialize(string workingDir, bool createNotFound) { if (String.IsNullOrEmpty(workingDir)) { throw new InvalidOperationException(); } _quickStorage = new MemoryTargetStorage(); if (!Directory.Exists(workingDir)) { Directory.CreateDirectory(workingDir); } // For non-system, we will delete the directory after use... _targetDataDir = workingDir; _isExisted = PersistentDictionaryFile.Exists(_targetDataDir); if (_isExisted) { this.CheckDataIndex(_targetDataDir); _targetStorage = new PersistentDictionary <string, string>(_targetDataDir); if (_targetStorage.ContainsKey("$DataCount$")) { _count = Convert.ToInt32(_targetStorage["$DataCount$"]); if (_count <= 0) { _count = _targetStorage.Count; } } else { _count = _targetStorage.Count; } if (_useQuickTargets) { this.AddQuickTargets(); } } else { _count = 0; if (createNotFound) { _targetStorage = new PersistentDictionary <string, string>(_targetDataDir); } } if (_targetStorage != null) { _targetCache = new DatabaseTargetCache(100); } _isInitialized = true; }
public override bool Contains(string id) { if (String.IsNullOrEmpty(id)) { return(false); } return(_linksDatabase.ContainsKey(id)); }
public void addConfigEntry(string key, string configEntryValue) { using (PersistentDictionary <string, string> dictionary = new PersistentDictionary <string, string>(getConfigLogPath())) { if (!dictionary.ContainsKey(key)) { dictionary.Add(key, configEntryValue); } } }
/// <summary> /// Uses IPropertyResolver to get value from object and position /// indicated by index /// </summary> /// <param name="index"></param> /// <param name="propertyName"></param> /// <returns></returns> public object GetItemValue(int index, string propertyName) { if (m_dict.ContainsKey(index) == false) { return(string.Empty); } var obj = m_dict[index]; var value = PropertyResolver.ReadValue(obj, propertyName); return(value); }
public void changeConfig(string name, string value) { using (PersistentDictionary <string, string> dictionary = new PersistentDictionary <string, string>(getConfigLogPath())) { if (dictionary.ContainsKey(name)) { dictionary.Remove(name); dictionary.Add(name, value); } } }
public static void FillStore(string folder, PersistentDictionary <string, string> dic) { foreach (string rawFile in ListRawFiles(folder)) { string source = PeptidAce.Utilities.vsCSV.GetFileName_NoExtension(rawFile); if (!dic.ContainsKey(source)) { dic.Add(source, rawFile); } } }
public bool Contains(string key) { if (Cache.Contains(key)) { return(true); } if (EsentDic.ContainsKey(key)) { return(true); } return(false); }
public void Start(CancellationTokenSource cancelationTokenSource) { //асинхронен хендлър - Consume<T>(IQueue queue, Func<IMessage<T>, MessageReceivedInfo, Task> onMessage) //Consume(queue, (body, properties, info) => Task.Factory.StartNew(() => //{ //var message = Encoding.UTF8.GetString(body); //Console.WriteLine("Got message: '{0}'", message); //})); //bus.Advanced.Consume( //синхронен хендлър - Consume<T>(IQueue queue, Action<IMessage<T>, MessageReceivedInfo> on Message) bus.Advanced.Consume <EasyNetQ.SystemMessages.Error>(queue, (message, info) => { try { using (var processedErrorMessages = new PersistentDictionary <string, int>(instancePersistenceFolder)) { var key = message.Body.BasicProperties.CorrelationId; int retryCount = 1; if (processedErrorMessages.ContainsKey(key)) { retryCount = processedErrorMessages[key]; processedErrorMessages[key] = ++retryCount; } else { processedErrorMessages.Add(key, retryCount); } var msgBody = message.Body; var className = getClassNameFromExchange(msgBody.Exchange); log.InfoFormat( "Processing ErrorQueue Message. DateTime = {0}, RetryCount = {1}, Message = {2}", msgBody.DateTime, retryCount, msgBody.Message); applyStrategies(className, retryCount, msgBody); } } catch (Exception ex) { if (!cancelationTokenSource.IsCancellationRequested) { log.ErrorFormat("ERROR Consuming message from ErrorQueue! {0}", ex); } } }); }
private void AddRow(int id) { if (dict.ContainsKey(id)) { return; } var cust = new Customer(); cust.Name = customerNames[rnd.Next(0, customerNames.Length)]; cust.TotalRevenue = id; dict.Add(id, cust); }
public List <string> GetPermutations(double mass) { List <string> results = new List <string>(); int index = (int)(mass / Precision); string[] combinations = emptyArray; if (Dictionary.ContainsKey(index)) { combinations = Dictionary[index].Split(','); } foreach (string comb in combinations) { double SeqMass = AminoAcidMasses.GetMass(comb); if (Math.Abs(SeqMass - mass) < Precision) { foreach (IList <char> str in new Permutations <char>(new List <char>(comb), GenerateOption.WithoutRepetition)) { results.Add(string.Concat(str)); } } } return(results); }
public string getValueString(string key) { using (PersistentDictionary <string, string> dictionary = new PersistentDictionary <string, string>(getConfigLogPath())) { if (dictionary.ContainsKey(key)) { return(dictionary[key]); } else { return(""); } } }
/// <summary> /// Ask the user for their first name and see if we remember /// their last name. /// </summary> public static void Main() { PersistentDictionary<string, string> dictionary = new PersistentDictionary<string, string>("Names"); Console.WriteLine("What is your first name?"); string firstName = Console.ReadLine(); if (dictionary.ContainsKey(firstName)) { Console.WriteLine("Welcome back {0} {1}", firstName, dictionary[firstName]); } else { Console.WriteLine("I don't know you, {0}. What is your last name?", firstName); dictionary[firstName] = Console.ReadLine(); } }
/// <summary> /// Add the specified urls to the RSS dictionary. /// </summary> /// <param name="urls">Urls to add.</param> private static void Add(string[] urls) { foreach (string url in urls) { // Don't overwrite an existing entry if (!dictionary.ContainsKey(url)) { dictionary[url] = new RssFeedData { LastRetrieved = null, Data = String.Empty, }; } } }
static void Main(string[] args) { PersistentDictionary <string, string> dictionary = new PersistentDictionary <string, string>("Names"); Console.WriteLine("What is your first name?"); string firstName = Console.ReadLine(); if (dictionary.ContainsKey(firstName)) { Console.WriteLine("Welcome back {0} {1}", firstName, dictionary[firstName]); } else { Console.WriteLine("I don't know you, {0}. What is your last name?", firstName); dictionary[firstName] = Console.ReadLine(); } }
public string this[string id] { get { if (String.IsNullOrEmpty(id)) { return(String.Empty); } if (_databaseMsdnUrls != null && _databaseMsdnUrls.ContainsKey(id)) { return(_databaseMsdnUrls[id]); } return(String.Empty); } }
public bool Contains(string key) { return(_persistentDictionary != null && _persistentDictionary.ContainsKey(key)); }
private bool WriteToc(XmlWriter writer) { String tocFile = _options.HelpTocFile; if (String.IsNullOrEmpty(tocFile) || !File.Exists(tocFile)) { return(false); } XmlReaderSettings settings = new XmlReaderSettings(); settings.ConformanceLevel = ConformanceLevel.Fragment; settings.IgnoreWhitespace = true; settings.IgnoreComments = true; XmlReader reader = XmlReader.Create(tocFile, settings); //<param name="Local" value="Html\15ed547b-455d-808c-259e-1eaa3c86dccc.htm"> //"html" before GUID string _localFilePrefix = _options.HtmlFolder; string fileAttr; string titleValue; try { bool isDefaultTopic = true; while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: if (reader.Name == "topic") { fileAttr = reader.GetAttribute("file") + ".htm"; if (_plusTree.ContainsKey(fileAttr)) { titleValue = _plusTree[fileAttr]; } else { titleValue = String.Empty; } if (isDefaultTopic) { _defaultTopic = String.Empty; isDefaultTopic = false; } if (reader.IsEmptyElement) { writer.WriteEndElement(); } } break; case XmlNodeType.EndElement: if (reader.Name == "topic") { writer.WriteEndElement(); } break; default: break; } } reader.Close(); reader = null; return(true); } catch (Exception ex) { if (reader != null) { reader.Close(); reader = null; } if (_logger != null) { _logger.WriteLine(ex, BuildLoggerLevel.Ended); } return(false); } }
public bool ContainsKey(int cep) { CheckCacheOpened(); return(pairs.ContainsKey(cep)); }
/// <summary> /// Checks whether the cache entry already exists in the cache. /// </summary> /// <param name="key">A unique identifier for the cache entry.</param> /// <param name="regionName">Optional. A named region in the cache where the cache can be found, if regions are implemented. The default value for the optional parameter is null.</param> /// <returns> /// true if the cache contains a cache entry with the same key value as <paramref name="key"/>; otherwise, false. /// </returns> /// <remarks>CFI, 2012-03-10</remarks> public override bool Contains(string key, string regionName = null) { CleanExpired(); return(values.ContainsKey(key)); }
private void ProcessingThread() { // Start AcquireFrame/ReleaseFrame loop while (senseManager.AcquireFrame(true) >= pxcmStatus.PXCM_STATUS_NO_ERROR) { // Acquire the color image data PXCMCapture.Sample sample = senseManager.QuerySample(); Bitmap colorBitmap; PXCMImage.ImageData colorData; int topScore = 0; FaceExpression expression = FaceExpression.None; sample.color.AcquireAccess(PXCMImage.Access.ACCESS_READ, PXCMImage.PixelFormat.PIXEL_FORMAT_RGB24, out colorData); colorBitmap = colorData.ToBitmap(0, sample.color.info.width, sample.color.info.height); try { IBarcodeReader reader = new BarcodeReader(); // load a bitmap //var barcodeBitmap = (Bitmap)Bitmap.LoadFrom("C:\\sample-barcode-image.png"); // detect and decode the barcode inside the bitmap var result = reader.Decode(colorBitmap); // do something with the result if (result != null) { MessageBox.Show(result.BarcodeFormat.ToString()); MessageBox.Show(result.Text); } } catch (Exception ex) { } // Get face data if (faceData != null) { faceData.Update(); numFacesDetected = faceData.QueryNumberOfDetectedFaces(); if (numFacesDetected > 0) { // Get the first face detected (index 0) PXCMFaceData.Face face = faceData.QueryFaceByIndex(0); // Retrieve face location data PXCMFaceData.DetectionData faceDetectionData = face.QueryDetection(); if (faceDetectionData != null) { PXCMRectI32 faceRectangle; faceDetectionData.QueryBoundingRect(out faceRectangle); if ((faceRectangle.h > 90) || (faceRectangle.w > 90)) { faceRectangleHeight = faceRectangle.h * 3 / 2; faceRectangleWidth = faceRectangle.w * 3 / 2; } else if (((faceRectangle.h < 90) || (faceRectangle.w < 90)) && ((faceRectangle.h > 70) || (faceRectangle.w > 70))) { faceRectangleHeight = faceRectangle.h * 2; faceRectangleWidth = faceRectangle.w * 2; } else { faceRectangleHeight = faceRectangle.h * 5 / 2; faceRectangleWidth = faceRectangle.w * 5 / 2; } faceRectangleX = faceRectangle.x; faceRectangleY = faceRectangle.y; } // Retrieve pose estimation data PXCMFaceData.PoseData facePoseData = face.QueryPose(); if (facePoseData != null) { PXCMFaceData.PoseEulerAngles headAngles; facePoseData.QueryPoseAngles(out headAngles); headRoll = headAngles.roll; headPitch = headAngles.pitch; headYaw = headAngles.yaw; } // Retrieve expression data PXCMFaceData.ExpressionsData expressionData = face.QueryExpressions(); if (expressionData != null) { PXCMFaceData.ExpressionsData.FaceExpressionResult score; expressionData.QueryExpression(PXCMFaceData.ExpressionsData.FaceExpression.EXPRESSION_KISS, out score); expressionScore[Convert.ToInt32(FaceExpression.Kiss)] = score.intensity; expressionData.QueryExpression(PXCMFaceData.ExpressionsData.FaceExpression.EXPRESSION_MOUTH_OPEN, out score); expressionScore[Convert.ToInt32(FaceExpression.Open)] = score.intensity; expressionData.QueryExpression(PXCMFaceData.ExpressionsData.FaceExpression.EXPRESSION_SMILE, out score); expressionScore[Convert.ToInt32(FaceExpression.Smile)] = score.intensity; expressionData.QueryExpression(PXCMFaceData.ExpressionsData.FaceExpression.EXPRESSION_TONGUE_OUT, out score); expressionScore[Convert.ToInt32(FaceExpression.Tongue)] = score.intensity; // Determine the highest scoring expression for (int i = 1; i < TotalExpressions; i++) { if (expressionScore[i] > topScore) { expression = (FaceExpression)i; } } } // Process face recognition data if (face != null) { // Retrieve the recognition data instance recognitionData = face.QueryRecognition(); // Set the user ID and process register/unregister logic if (recognitionData.IsRegistered()) { userId = Convert.ToString(recognitionData.QueryUserID()); if (doUnregister) { recognitionData.UnregisterUser(); SaveDatabaseToFile(); doUnregister = false; if (_persistentDict.ContainsKey(userId) == true) { _persistentDict.Remove(userId); } } } else { if (doRegister) { int uId = recognitionData.RegisterUser(); SaveDatabaseToFile(); if (newUserName != "") { if (_persistentDict.ContainsKey(uId.ToString()) == false) { _persistentDict.Add(uId.ToString(), newUserName); _persistentDict.Flush(); newUserName = ""; } } // Capture a jpg image of registered user colorBitmap.Save("image.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); doRegister = false; } else { userId = "New User"; } } } } else { userId = "No users in view"; } } //hand = senseManager.QueryHand(); //if (hand != null) //{ // // Retrieve the most recent processed data // handData = hand.CreateOutput(); // handData.Update(); // // Get number of tracked hands // nhands = handData.QueryNumberOfHands(); // if (nhands > 0) // { // // Retrieve hand identifier // handData.QueryHandId(PXCMHandData.AccessOrderType.ACCESS_ORDER_BY_TIME, 0, out handId); // // Retrieve hand data // handData.QueryHandDataById(handId, out ihand); // PXCMHandData.BodySideType bodySideType = ihand.QueryBodySide(); // if (bodySideType == PXCMHandData.BodySideType.BODY_SIDE_LEFT) // { // leftHand = true; // } // else if (bodySideType == PXCMHandData.BodySideType.BODY_SIDE_RIGHT) // { // leftHand = false; // } // // Retrieve all hand joint data // for (int i = 0; i < nhands; i++) // { // for (int j = 0; j < 0x20; j++) // { // PXCMHandData.JointData jointData; // ihand.QueryTrackedJoint((PXCMHandData.JointType)j, out jointData); // nodes[i][j] = jointData; // } // } // // Get world coordinates for tip of middle finger on the first hand in camera range // handTipX = nodes[0][Convert.ToInt32(PXCMHandData.JointType.JOINT_MIDDLE_TIP)].positionWorld.x; // handTipY = nodes[0][Convert.ToInt32(PXCMHandData.JointType.JOINT_MIDDLE_TIP)].positionWorld.y; // handTipZ = nodes[0][Convert.ToInt32(PXCMHandData.JointType.JOINT_MIDDLE_TIP)].positionWorld.z; // swipehandTipX = nodes[0][Convert.ToInt32(PXCMHandData.JointType.JOINT_MIDDLE_TIP)].positionImage.x; // swipehandTipY = nodes[0][Convert.ToInt32(PXCMHandData.JointType.JOINT_MIDDLE_TIP)].positionImage.y; // swipehandTipZ = nodes[0][Convert.ToInt32(PXCMHandData.JointType.JOINT_MIDDLE_TIP)].positionImage.z; // //Console.Out.WriteLine("Before x={0}", swipehandTipX); // //Console.Out.WriteLine("Before speed={0}", nodes[0][Convert.ToInt32(PXCMHandData.JointType.JOINT_MIDDLE_TIP)].speed.x); // // Retrieve gesture data // if (handData.IsGestureFired("spreadfingers", out gestureData)) { gesture = Gesture.FingerSpread; } // else if (handData.IsGestureFired("two_fingers_pinch_open", out gestureData)) { gesture = Gesture.Pinch; } // else if (handData.IsGestureFired("wave", out gestureData)) { gesture = Gesture.Wave; } // else if (handData.IsGestureFired("swipe_left", out gestureData)) { gesture = Gesture.SwipeLeft; } // else if (handData.IsGestureFired("swipe_right", out gestureData)) { gesture = Gesture.SwipeRight; } // else if (handData.IsGestureFired("fist", out gestureData)) { gesture = Gesture.Fist; } // else if (handData.IsGestureFired("thumb_up", out gestureData)) { gesture = Gesture.Thumb; } // } // else // { // gesture = Gesture.Undefined; // } // //UpdateUI(); // if (handData != null) handData.Dispose(); //} // Display the color stream and other UI elements //UpdateUI(colorBitmap, expression, gesture); UpdateUI(colorBitmap, expression); // Release resources colorBitmap.Dispose(); sample.color.ReleaseAccess(colorData); sample.color.Dispose(); // Release the frame senseManager.ReleaseFrame(); } }
/// <inheritdoc /> public override bool ContainsKey(string key) { return(index.ContainsKey(key)); }
/// <summary> /// Проверка на наличие информации о данно сервере /// </summary> /// <param name="endpoint">Уникальный идентификатор сервера</param> /// <returns>true - сервер присылал advertise-запрос, false - не присылал </returns> public bool HasAdvertise(string endpoint) { return(_servers.ContainsKey(endpoint.ToLower())); }
private void WriteHhc() { XmlReaderSettings settings = new XmlReaderSettings(); settings.ConformanceLevel = ConformanceLevel.Fragment; settings.IgnoreWhitespace = true; settings.IgnoreComments = true; XmlReader reader = XmlReader.Create(_options.TocFile, settings); //<param name="Local" value="Html\15ed547b-455d-808c-259e-1eaa3c86dccc.htm"> //"html" before GUID string _localFilePrefix = _options.HtmlDirectory.Substring( _options.HtmlDirectory.LastIndexOf('\\') + 1); string fileAttr; string titleValue; StreamWriter sw = null; try { sw = new StreamWriter( String.Format("{0}\\{1}.hhc", _options.OutputDirectory, _options.ProjectName), false, Encoding.GetEncoding(_lang.CodePage)); sw.WriteLine("<!DOCTYPE html PUBLIC \"-//IETF//DTD HTML//EN\">"); sw.WriteLine("<html>"); sw.WriteLine(" <body>"); //<object type="text/site properties"> // <param name="Window Styles" value="0x801627"/> //</object> string tocStyle = _options.TocStyle; if (!String.IsNullOrEmpty(tocStyle)) { sw.WriteLine(" <object type=\"text/site properties\">"); sw.WriteLine(String.Format(" <param name=\"Window Styles\" value=\"{0}\"/>", tocStyle)); sw.WriteLine(" </object>"); } bool isDefaultTopic = true; while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: if (reader.Name == "topic") { _indentCount = reader.Depth; fileAttr = reader.GetAttribute("file") + ".htm"; if (_plusTree.ContainsKey(fileAttr)) { titleValue = _plusTree[fileAttr]; } else { titleValue = String.Empty; } WriteHhcLine(sw, "<ul>"); WriteHhcLine(sw, " <li><object type=\"text/sitemap\">"); WriteHhcLine(sw, String.Format(" <param name=\"Name\" value=\"{0}\"/>", titleValue)); WriteHhcLine(sw, String.Format(" <param name=\"Local\" value=\"{0}\\{1}\"/>", _localFilePrefix, fileAttr)); if (isDefaultTopic) { _defaultTopic = _localFilePrefix + "\\" + reader.GetAttribute("file") + ".htm"; isDefaultTopic = false; } WriteHhcLine(sw, " </object></li>"); if (reader.IsEmptyElement) { WriteHhcLine(sw, "</ul>"); } } break; case XmlNodeType.EndElement: if (reader.Name == "topic") { _indentCount = reader.Depth; WriteHhcLine(sw, "</ul>"); } break; default: break; } } sw.WriteLine(" </body>"); sw.WriteLine("</html>"); sw.Close(); sw = null; reader.Close(); reader = null; } catch (Exception ex) { if (sw != null) { sw.Close(); sw = null; } if (reader != null) { reader.Close(); reader = null; } if (_logger != null) { _logger.WriteLine(ex, BuildLoggerLevel.Ended); } } }