indexer

Property bag for C# class

偶尔善良 提交于 2019-12-04 12:02:08
Accessing c# class properties like javascript language would make life a lot easier. How we can do it in C#? For example: someObject["Property"]="simple string"; Console.WriteLine(someObject["FirstName"]); r.zarei Here is how you can enable property-bag-like functionality in your classes by adding a few lines of code: partial class SomeClass { private static readonly PropertyDescriptorCollection LogProps = TypeDescriptor.GetProperties(typeof(SomeClass)); public object this[string propertyName] { get { return LogProps[propertyName].GetValue(this); } set { LogProps[propertyName].SetValue(this,

how to write a function to take any object with an index operator

余生颓废 提交于 2019-12-04 06:53:04
问题 I think I have asked this in the context of C++ (Can't find it in my question history!!) in the past and the solution was to use a template function. As C++ template resolve at compile time, it works. But for C#, it doesn't. public Hashtable ConvertToHashtable<T>(T source) where T has an index operator { Hashtable table = new Hashtable(); table["apple"] = source["apple"]; return table; } One usage at the moment is to convert the result in OleDbReader to hashtable, but I am forseeing the need

.NET 4.0 Indexer with ObservableCollection

旧巷老猫 提交于 2019-12-03 21:55:35
What is the .NET C# syntax for an ObservableCollection with an indexer? I would like an ObservableColletion and refer to the items by ordinal position or a string name. I know you the use this to denote an indexer but I don't know how to put that in an ObservableCollection. Thanks Thanks for the 4 answers. I know how create and ObservableCollection and I know how to create an indexer. I don't know how to combine them. I am asking for sample code for an ObservableCollection with an ordinal and string index. Thank again ObservableCollection inherits from Collection, so it already has position

How do I implement a sectioned list in Android?

拈花ヽ惹草 提交于 2019-12-03 11:19:15
问题 I have a search feature which displays results in a ListView. I'm finding it difficult to implement an alphabetical sectioned list. Please give me idea of how to do it. 回答1: You can find bunch of this topic using Google. Here some best tutorial in my opinion. Basically you use SectionIndexer to create an index and show(or hide) view in getView method of your adapter. 1, ListView Tips & Tricks #2: Sectioning your ListView by Cyril Mottier. 2, Pinned Header ListView as in the Contacts app by

CDT An internal error occurred during: “Setting up indexer”

核能气质少年 提交于 2019-12-03 08:41:54
I use Eclipse with CDT to build C++ code. After loading my workspace I get the following message: An internal error occurred during: "Setting up indexer". Here is the log: eclipse.buildId=I20110613-1736 java.version=1.6.0_24 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US Command-line arguments: -os linux -ws gtk -arch x86 !ENTRY org.eclipse.core.jobs 4 2 2012-10-30 16:46:09.940 !MESSAGE An internal error occurred during: "Setting up indexer". !STACK 0 java.lang.ArrayIndexOutOfBoundsException: 18 at org.eclipse.cdt.internal.core.pdom.db.Database

how to write a function to take any object with an index operator

社会主义新天地 提交于 2019-12-02 12:55:48
I think I have asked this in the context of C++ (Can't find it in my question history!!) in the past and the solution was to use a template function. As C++ template resolve at compile time, it works. But for C#, it doesn't. public Hashtable ConvertToHashtable<T>(T source) where T has an index operator { Hashtable table = new Hashtable(); table["apple"] = source["apple"]; return table; } One usage at the moment is to convert the result in OleDbReader to hashtable, but I am forseeing the need for more source types soon. There are no generic type constraints for operators in C# - it is one of

Eclipse 3.7 cannot resolve Types in C++ Editor

喜夏-厌秋 提交于 2019-12-01 16:32:16
I recently changed from Eclipse 3.6 to Eclipse 3.7 , which I am using for C++ development in Ubuntu 11.04 . With Version 3.6 I had no big troubles, except that I always had some issues with the indexer. Now with Version 3.7 it begins marking unresolved Types as Errors. Since the indexer seems to dislike me even more, my Eclipse apparently doesn't know types like uint16_t or size_t . In contrary to the displayed errors in the code editor, my compiler has no problems with compiling the code and resolving all symbols and types, so this seems to be a problem of the IDE itself. Are there any ways

Dynamic linq: Is there a way to access object data by index?

試著忘記壹切 提交于 2019-12-01 08:10:05
I need some in-memory filtering with Dynamic Linq. My objects have only a indexer: public object this[int index] { } The access to my data is like: object[0], object[1],... So my query is like this: // get FilterText from user at runtime // eg. filterText can be: [0] > 100 and [1] = "wpf" collection.AsQueryable().where(filterText); Is there any way to do this? I have some news for you. It is actually possible... BUT! (Yes, there´s a but). I assume you are using the dynamic Linq library. You must then use the "it"-keyword to be able to specify the current object to which you wish to apply your

Magento Catalog URL rewrites stuck on processing

我怕爱的太早我们不能终老 提交于 2019-11-30 19:36:53
As the title says my Catalog URL rewrites indexer is stuck on processing. I've tried everything and I just can't find a solution to this. Does anyone know a solid fix for this? I've tried truncating core_url_rewrite table and deleting the locks but it still sits on processing. When running it through the admin the page just conitnues loading even though it appears to have finished when I so a count of the table. Forgive me for asking this again but I'm at a total loss and after days hunting for solutions on the www I've come up blank. Thanks If your putty gets closed from "software caused

How to exclude files from Eclipse indexing (Static Code Analysis)?

帅比萌擦擦* 提交于 2019-11-30 14:52:41
问题 I have a makefile project comprised of many source, header and other files, which I am trying to convert to an Eclipse "native" project. The problem that the Indexer reports errors and warning on files that exist in the directories but are excluded form the build. As a consequence, large parts of my directory tree are marked with the red x sign. How can I make the Indexer to ignore specific file and/or directories? Note: when defining a directory as "Derived" it is excluded form further