dynamic

How to build group-by dynamically on a list of dictionaries

眉间皱痕 提交于 2019-12-19 11:18:49
问题 I am trying to perform a groupby on an IEnumerable. The problem is that I do not know at compile-time which fields i want to groupby. I have found another post on stack that explains how to do this when the class is known and has properties, but in my case i am dealing with a dictionary and the keys are also only known at run-time. My code would resemble something like this (i know this doesn't compile...): private object GetValuesGroupedBy(List<string> groupbyNames, List<string>

What is the simplest way to display (and change) an image resource on a WPF dialog (using C++/CLI)?

早过忘川 提交于 2019-12-19 11:02:32
问题 I have a C++/CLI GUI application and I want to display an image as a visual aid for the user to see what step in a procedure they're at. This image will need to be changed each time the user selects the new step. Currently I'm using a picture box and have an image loaded from the disk at run time. So there are a few things I need to know here: Is a picture box the best thing to use for this purpose or is there another control that would better suit? How do embed the images in the executable

c++ plugin : pass object across boundary (emulating it)

心不动则不痛 提交于 2019-12-19 10:53:12
问题 Since we shouldn't pass anything else than Plain Old Data-structure[1] across a plug-in boundary, I came up with to following idea in order to pass an object : expose all the public method in the plugin "C" interface, and on the application side, wrap the plugin in an object. (See the following example) My question is : Is there a better way to do this ? [EDIT] See my edit below with a probably better solution using standard-layout object. Here is a toy example illustrating the idea : I want

Is there a way to perform a chained null check in a dynamic/expando?

我怕爱的太早我们不能终老 提交于 2019-12-19 10:22:11
问题 C# has the usefull Null Conditional Operator. Well explained in this answer too. I was wondering if it is possible to do a similar check like this when my object is a dynamic/expando object. Let me show you some code: Given this class hierarchy public class ClsLevel1 { public ClsLevel2 ClsLevel2 { get; set; } public ClsLevel1() { this.ClsLevel2 = new ClsLevel2(); // You can comment this line to test } } public class ClsLevel2 { public ClsLevel3 ClsLevel3 { get; set; } public ClsLevel2() {

Dynamically creating a spinner and setting its Value from SQLite

柔情痞子 提交于 2019-12-19 10:14:21
问题 Found my problem check under "Update" for the code Okay, I have a problem loading the right value from Sqlite into my Spinner. Here is how my app is constructed my onCreate() sets up a spinner called spinTypes by: public class MyClass extends Activity{ // local members . . . . . . //spinner private Spinner spinTypes, spinNames = null; // string array decl. private String [] types, names1, names2, names3 = null; // array adapters for string arrays private ArrayAdapter<String> typesAdapter,

How to create a generic List with a dynamic object type

点点圈 提交于 2019-12-19 09:38:38
问题 I want to create a generic list of the Type object. I have ... Type type = typeof(Foo); object model = GetModel(); Now I want to create a new List<Foo>((Foo)model) Is this possible in C#? 回答1: Type listT = typeof(List<>).MakeGenericType(new[]{type}); object list = Activator.CreateInstance(listT); 来源: https://stackoverflow.com/questions/3712732/how-to-create-a-generic-list-with-a-dynamic-object-type

jquery dynamic binding .on() select parents or children?

六眼飞鱼酱① 提交于 2019-12-19 09:27:34
问题 For example, $( "#dataTable tbody tr" ).on( "click", function() { alert( $( this ).text() ); }); $( "#dataTable tbody" ).on( "click", "tr", function() { alert( $( this ).text() ); }); .on() binds "tr" with click event handler. The first one select children and register click event handler directly. The second one select parent "tbody", and select children "tr" as an argument. Are they both dynamic binding? Do they have the same effect? What is the difference between these two? 回答1: No, only

How to display the content of asp.net cache?

ε祈祈猫儿з 提交于 2019-12-19 08:03:01
问题 We have an asp.net MVC web application which uses the HttpRuntime.Cache object to keep some static lookup values. We want to be able to monitor what's being cached in real time to allow us to pinpoint some possible caching issues. Since this object isn't strongly typed when reading from it, we need to dynamically cast each entries to it's concrete type. Most of the cached items are of IEnumerable where T can be any classes we use in our project or new ones that could eventually be added as

How to display the content of asp.net cache?

你离开我真会死。 提交于 2019-12-19 08:02:15
问题 We have an asp.net MVC web application which uses the HttpRuntime.Cache object to keep some static lookup values. We want to be able to monitor what's being cached in real time to allow us to pinpoint some possible caching issues. Since this object isn't strongly typed when reading from it, we need to dynamically cast each entries to it's concrete type. Most of the cached items are of IEnumerable where T can be any classes we use in our project or new ones that could eventually be added as

Passing Static arrays as parameters for Dynamic arrays in Delphi

我们两清 提交于 2019-12-19 07:27:14
问题 I have this array: const / var _Data : array [0..4] of array [0..3] of Double = ((0,0,0,0), (0,0,1,1), (1,0,1,0), (1,1,0,0), (1,1,1,1)); I wanna pass it as param value for this procedure: procedure NN.NetTraining(Data: TDoubleMatrix); Where: TDoubleArray = array of Double; TDoubleMatrix = array of TDoubleArray; Is There some manner to cast or convert this static array into dynamic array in Delphi (2009) ? Thanks in advance. 回答1: While this does not do exactly what you want (for reasons given