enumeration

Enumeration Utility Library

元气小坏坏 提交于 2019-12-12 19:09:44
问题 I'm looking for a open source library or examples for working with Enum types in .Net. In addition to the standard extensions that people use for Enums (TypeParse, etc.), I need a way to perform operations like returning the value of the Description attribute for a given enumeration value or to return a enumeration value that has a Description attribute value that matches a given string. For example: //if extension method var race = Race.FromDescription("AA") // returns Race.AfricanAmerican /

Should a GetEnumerator method still be idempotent when the class does not implement IEnumerable

雨燕双飞 提交于 2019-12-12 16:28:36
问题 This question piggy backs of another question which I raised regarding abusing the IEnumerable interface by modifying an object as you iterate over it. The general consensus is that no anything that Implements IEnumerable should be idempotent. But .net supports compile time duck typing with the foreach statement. Any object that provides an IEnumerator GetEnumerator() method can be used inside a foreach statement. So should the GetEnumerator method be idempotent or is it when it implements

OpenInputDesktop() to determine Secure/Login desktop

强颜欢笑 提交于 2019-12-12 16:07:44
问题 Visual C++ 2008 How to establish whether or not the currently interactive user is at either the Locked desktop (Windows-Key L) or the Shutdown Screen (Vista or 7) waiting for programs to close during log-out. HDESK hd = OpenInputDesktop(0, false, READ_CONTROL); This works fine for a user app on the Default desktop, but fails with error Code 5 when at the Locked or Shutdown desktops due to, I understand, the user not having permissions to open the secure desktop object. Calling this from a

SWIFT ALAssetsLibrary not enumerating groups

一曲冷凌霜 提交于 2019-12-12 15:34:49
问题 I'm trying to gather thumbnails of all the user's images into an array, but when I call the enumerateAssetsUsingBlock method of ALAssetsLibrary nothing seems to happen. import UIKit import AssetsLibrary class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate { @IBOutlet var photoLibView: UICollectionView var assetLibrary : ALAssetsLibrary = ALAssetsLibrary() func showCustomLibrary() { self.assetLibrary = ALAssetsLibrary() var assetsArray :

Issue using .net web service from ColdFusion

独自空忆成欢 提交于 2019-12-12 13:28:06
问题 I've been running into some challenges with a web service I'm trying to use of from ColdFusion. The service (AccountsService), has a method, GetAccountLinksByUser that returns accounts associated with a given user. This method accepts two arguments: UPN, which is just a unique string to identify the user. This is no problem, as far as I can tell. sourceType. This is ultimately a string, but is defined in the WSDL as simple type with one of three possible values. Here's a relevant sections of

What is the advantage of creating an enumerable object using to_enum in Ruby?

半腔热情 提交于 2019-12-12 09:32:34
问题 Why would you create a proxy reference to an object in Ruby, by using the to_enum method rather than just using the object directly? I cannot think of any practical use for this, trying to understand this concept & where someone might use it, but all the examples I have seen seem very trivial. For example, why use: "hello".enum_for(:each_char).map {|c| c.succ } instead of "hello".each_char.map {|c| c.succ } I know this is a very simple example, does anyone have any real-world examples? 回答1:

Best way to enumerate a cartesian product with labels in python?

限于喜欢 提交于 2019-12-12 09:01:49
问题 Given a dictionary mapping variables to possible outcomes: { 'lblA' : [False, True], 'lblB' : [False, True], 'lblC' : [0,1,2] } I want to enumerate all possible dictionary outcomes: [ { 'lblA' : False , 'lblB' : False, 'lblC' : 0 }, { 'lblA' : True , 'lblB' : False, 'lblC' : 0 }, { 'lblA' : False , 'lblB' : True, 'lblC' : 0 }, { 'lblA' : True , 'lblB' : True, 'lblC' : 0 }, { 'lblA' : False , 'lblB' : False, 'lblC' : 1 }, { 'lblA' : True , 'lblB' : False, 'lblC' : 1 }, { 'lblA' : False , 'lblB

How can I display enumeration value in MATLAB object

不打扰是莪最后的温柔 提交于 2019-12-12 08:39:47
问题 Given the following two classes classdef EnumClass enumeration enumVal1 enumVal2 end end classdef EnumDisplay properties enumValue = EnumClass.enumVal1 numberValue = 1 end end When displaying an EnumClass , the value is displayed: >> E = EnumClass.enumVal1 E = enumVal1 but when displaying EnumDisplay in the command window, the enumeration value is suppressed, and only the array size and class are displayed. >> C = EnumDisplay() C = EnumDisplay with properties: enumValue: [1x1 EnumClass]

Why can't we change Values of a dictionary while enumerating its keys?

一世执手 提交于 2019-12-12 08:17:43
问题 class Program { static void Main(string[] args) { var dictionary = new Dictionary<string, int>() { {"1", 1}, {"2", 2}, {"3", 3} }; foreach (var s in dictionary.Keys) { // Throws the "Collection was modified exception..." on the next iteration // What's up with that? dictionary[s] = 1; } } } I completely understand why this exception is thrown when enumerating a list- it seems reasonable to expect that during enumeration, the Structure of the enumerated object does not change. However- does

Enumerator disposal when not using using, foreach or manually calling Dispose()

 ̄綄美尐妖づ 提交于 2019-12-12 07:13:50
问题 I'm using yield return to iterate over an SqlDataReader 's records: IEnumerable<Reading> GetReadings() { using (var connection = new SqlConnection(_connectionString)) { using (var command = new SqlCommand(_query, connection)) { connection.Open(); using (var reader = command.ExecuteReader()) { while (reader.Read()) { yield return new Reading { End = reader.GetDateTime(0), Value = reader.GetDouble(1) }; } } connection.Close(); } } } I'm then using an adapted version of this accepted answer to