enumeration

Extract enumeration values from xsd schema file in .net

烈酒焚心 提交于 2019-12-01 05:13:38
问题 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> 回答1: There is an XmlSchema class, but it looks pretty... "fun" to work with. Would xml querying

Await list of async predicates, but drop out on first false

泄露秘密 提交于 2019-12-01 04:58:41
Imagine the following class: public class Checker { public async Task<bool> Check() { ... } } Now, imagine a list of instances of this class: IEnumerable<Checker> checkers = ... Now I want to control that every instance will return true : checkers.All(c => c.Check()); Now, this won't compile, since Check() returns a Task<bool> not a bool . So my question is: How can I best enumerate the list of checkers? And how can I shortcut the enumeration as soon as a checker returns false ? (something I presume All( ) does already) dcastro And how can I shortcut the enumeration as soon as a checker

.Net enumerate winforms font styles?

拜拜、爱过 提交于 2019-12-01 04:21:43
I have been searching around for a way to list the valid font styles for a given font using the .Net framework (even if I have to pinvoke gdi32 or some other API) since not all fonts fall into the System.Drawing.FontStyle enum values (Bold, Italic, Regular, Strikeout, Underline). A perfect example of a font that does not fit the bill is Segoe UI, which is a TrueType Microsoft font, with font styles of: Regular, Semibold, Light, Bold, Italic, and BoldItalic. Another example is Arial which has: Regular, Narrow, Italic, Bold, Bold Italic, Narrow Bold, Narrow Bold Italic, and Narrow Italic. In

Loop through irregular enumeration in Delphi

老子叫甜甜 提交于 2019-12-01 04:06:47
1) Does anyone know if it is possible to loop through an irregular enumeration in Delphi (XE)? Looping over a normal enumeration is ok. From Delphi Basics : var suit : (Hearts, Clubs, Diamonds, Spades); begin // Loop 3 times For suit := Hearts to Diamonds do ShowMessage('Suit = '+IntToStr(Ord(suit))); end; But, if 'suit' instead is declared as var suit : (Hearts=1, Clubs, Diamonds=10, Spades); it loops 10 times. Not suprising, but I would like to loop 3. The only solution I've found so far is converting an enumeration to a set and use the 'for ... in'-loop like on delphi.about.com . So, if

How to enumerate all available network interfaces? [duplicate]

て烟熏妆下的殇ゞ 提交于 2019-12-01 03:18:08
This question already has an answer here: How to enumerate network adapters and get their MAC addresses in Win32 API C++? 1 answer How to enumerate all network interfaces currently available on the computer (including virtual, non-connected, loopback etc)? I need to know their IP4/6, Mask, Gateway, DNS, WINS etc Language: C++, WinAPI System: Windows 2000 and higher (including Win7) Have a look at http://www.codeproject.com/KB/IP/netcfg.aspx . It's a giant example of what you want to do. It sounds like you want a combination of a few different functions. To get a list of adapters with their

not a constant in Enum

南笙酒味 提交于 2019-12-01 03:08:58
问题 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

WinRT: App to enumerate files outside libraries and known folders

こ雲淡風輕ζ 提交于 2019-12-01 02:44:20
问题 I am working on a Metro app that shows the content of a given folder in a ListView control. MS decided that developers don't need the System.IO.Directory class and removed it entirely from the framework. I am looking for a replacement to enumerate files in C# in a metro style app. I have checked all the enumeration samples provided by MS and they all seem to only enumerate the Windows Libraries using the KnownFolders class, something like: StorageFolder picturesFolder = KnownFolders

Await list of async predicates, but drop out on first false

♀尐吖头ヾ 提交于 2019-12-01 02:36:17
问题 Imagine the following class: public class Checker { public async Task<bool> Check() { ... } } Now, imagine a list of instances of this class: IEnumerable<Checker> checkers = ... Now I want to control that every instance will return true : checkers.All(c => c.Check()); Now, this won't compile, since Check() returns a Task<bool> not a bool . So my question is: How can I best enumerate the list of checkers? And how can I shortcut the enumeration as soon as a checker returns false ? (something I

Make using statement usable for multiple disposable objects

て烟熏妆下的殇ゞ 提交于 2019-12-01 02:01:41
I have a bunch of text files in a folder, and all of them should have identical headers. In other words the first 100 lines of all files should be identical. So I wrote a function to check this condition: private static bool CheckHeaders(string folderPath, int headersCount) { var enumerators = Directory.EnumerateFiles(folderPath) .Select(f => File.ReadLines(f).GetEnumerator()) .ToArray(); //using (enumerators) //{ for (int i = 0; i < headersCount; i++) { foreach (var e in enumerators) { if (!e.MoveNext()) return false; } var values = enumerators.Select(e => e.Current); if (values.Distinct()

Need to make an enumeration of type double in c#

时光毁灭记忆、已成空白 提交于 2019-12-01 01:16:36
How can I create an enum of type double? Is it possible or do I have to create some kind of collection and hash? user76035 You can't make it an enumeration. http://msdn.microsoft.com/en-us/library/y94acxy2.aspx One of possibilities: public static class MyPseudoEnum { public static readonly double FirstVal = 0.3; public static readonly double SecondVal = 0.5; } I guess it depends on how much trouble you want to go to. You can convert a double to a long, so if you converted your double values to long integers in a separate program, and output the constant values, you could then use them in your