enumeration

How to stop enumerating attributes of a NSAttributedString?

佐手、 提交于 2019-12-01 17:48:25
问题 In the documentation of the enumerateAttribute method it is said, regarding the stop argument of the block, that: The block can set the value to true to stop further processing of the set. However, inside the block the stop argument is a let and I can't set it to true . I need to stop enumerating after the first attribute occurrence found. How could I do that? 回答1: The parameter is a reference that holds the actual value: let attributed: NSAttributedString = ... attributed.enumerateAttribute(

Enumerated types in SQL Server 2008?

久未见 提交于 2019-12-01 17:25:50
Is there some kind of mechanism in SQL Server to allow Enumerated type like functionality? For example, if I have a column Called "UpdateStatus" it usually gets setup with single letter values like so: D X U I This could equate to a lot of things. That leads to confusion. The alternative is to have it be a string column like this: Downloaded Deleted Updated Initialized But that has its own problems. Eventually someone is going to write something like this: where UpdateStatus = 'Initalized' (spelled wrong). Plus I hear that keying off of strings is not all that performant. So, is there any kind

WSDL, Enums and C#: It's still murky

北战南征 提交于 2019-12-01 16:51:52
I tried to look this up online, but all the WSDL examples seem to not really explain if I should mark things as basetype string in the WSDL or int... Basically, I'm trying to make my WSDL so that I can represent an Enumeration. I have a C# Enum in mind already that I want to match it up to... public enum MyEnum { Item1 = 0, Item2 = 1, Item3 = 2, SpecialItem = 99 } I'm not sure how my WSDL should look... I figure it's one of two, but even then I'm not 100% sure... <wsdl:types> <xsd:schema targetNamespace="http://www.mysite.com/MyApp" xmlns:xsd="http://www.w3.org/2001/XMLSchema" > <xsd

C# preventing Collection Was Modified exception

自古美人都是妖i 提交于 2019-12-01 15:33:20
Does foreach(T value in new List<T>(oldList) ) is dangerous (costly) when oldList contains 1 millions of object T ? More generaly what is the best way to enumerate over oldList given that elements can be added/removed during the enumeration... The general rule is, you should not modify the same collection in which you are enumerating. If you want to do something like that, keep another collection which will keep track of which elements to add/remove from the original collection and then after exiting from the loop, perform the add/remove operation on the original collection. Dirk Trilsbeek I

C# preventing Collection Was Modified exception

天涯浪子 提交于 2019-12-01 14:38:12
问题 Does foreach(T value in new List<T>(oldList) ) is dangerous (costly) when oldList contains 1 millions of object T ? More generaly what is the best way to enumerate over oldList given that elements can be added/removed during the enumeration... 回答1: The general rule is, you should not modify the same collection in which you are enumerating. If you want to do something like that, keep another collection which will keep track of which elements to add/remove from the original collection and then

Building object hierarchy from a 'namespace' string

北慕城南 提交于 2019-12-01 11:05:14
I'm trying to write a function that takes a string representing a namespace (e.g. "MyCompany.UI.LoginPage") and defines each segment of the namespace as an object if it doesn't already exist. For example, if "MyCompany.UI.LoginPage" wasn't an object, it would evaluate this: MyCompany = {}; MyCompany.UI = {}; MyCompany.UI.LoginPage = {}; I would like to do this by enumerating each character of the "namespace" (string) argument and defining each object as the enumeration reaches period characters. How can I enumerate the characters of a string in JavaScript? You can access the characters of a

Building object hierarchy from a 'namespace' string

五迷三道 提交于 2019-12-01 08:02:08
问题 I'm trying to write a function that takes a string representing a namespace (e.g. "MyCompany.UI.LoginPage") and defines each segment of the namespace as an object if it doesn't already exist. For example, if "MyCompany.UI.LoginPage" wasn't an object, it would evaluate this: MyCompany = {}; MyCompany.UI = {}; MyCompany.UI.LoginPage = {}; I would like to do this by enumerating each character of the "namespace" (string) argument and defining each object as the enumeration reaches period

Extract enumeration values from xsd schema file in .net

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 06:47:39
How programmatically extract enumeration constraint values of an element from xsd schema file using .net? for example I'd like to extract 'Audi', 'Golf' and 'BMW' from the following xsd: <xs:element name="car"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="Audi"/> <xs:enumeration value="Golf"/> <xs:enumeration value="BMW"/> </xs:restriction> </xs:simpleType> </xs:element> There is an XmlSchema class, but it looks pretty... "fun" to work with. Would xml querying be enough? XmlDocument doc = new XmlDocument(); doc.Load("Foo.xsd"); XmlNamespaceManager mgr = new

not a constant in Enum

我与影子孤独终老i 提交于 2019-12-01 06:02:38
I am using enumeration with switch case but I am getting the following error: NEWS FEED is not a constant in FragmentName This is my enum string constant, public enum FragmentName{ FRAGMENT_NEWSFEED("NEWS FEED"), FRAGMENT_MESSAGES("MESSAGES"), FRAGMENT_EVENTS("EVENTS"), FRAGMENT_WHOISAROUDNME("WHOS AROUND"); private final String text; private FragmentName(final String text) { this.text = text; } @Override public String toString() { return text; } } //This is my function from where i check for corresponding enum constant public void changeTitle(String title) { switch (Enums_String.FragmentName

How to add custom item to system menu in C++?

﹥>﹥吖頭↗ 提交于 2019-12-01 05:32:56
I need to enumerate all running applications. In particular, all top windows. And for every window I need to add my custom item to the system menu of that window. How can I accomplish that in C++? Update. I would be more than happy to have a solution for Windows, MacOS, and Ubuntu (though, I'm not sure if MacOS and Ubuntu have such thing as 'system menu'). efotinis For Windows, another way to get the top-level windows (besides EnumWindows, which uses a callback) is to get the first child of the desktop and then retrieve all its siblings: HWND wnd = GetWindow(GetDesktopWindow(), GW_CHILD);