dynamic

C# Json Convert any dynamic object to key value pairs

落爺英雄遲暮 提交于 2019-12-10 11:41:43
问题 I am writing a tool that will take an inbound Json object, and convert it to key-value records (sometimes called flattening, maybe). The aim is to avoid the tool breaking if it gets a very large or very nested Json object, so I would like to avoid recursion. An example object might be like this (below), containing nested arrays, empty values, you name it, literally any legal json... { "firstName": "John", "lastName": "Smith", "isAlive": true, "age": 25, "address": { "streetAddress": "21 2nd

Post from dynamic form to dynamic iframe in Chrome opens a new window

痴心易碎 提交于 2019-12-10 11:36:15
问题 I am doing some tests to create a JavaScript widget that allows communication across domain. I have a script tag that could be placed on any site that will inject a dynamic form and iframe into their page. The idea I had was to set the dynamic form's target attribute to the name of the dynamic iframe, so that data can be posted from a third party site to my backend for processing. Put it together and works great in Firefox, but in Chrome the submission forces a new window to open. If I use a

array_intersect() with dynamic length of arguments

落花浮王杯 提交于 2019-12-10 11:29:24
问题 I've got an array of arrays that may have a different count of elements when the script is run. $strict = [ [0] => ['one', 'two', 'three', 'four'], [1] => ['one', 'two', 'four', 'eight'], [2] => ['two', 'four', 'ten', 'twenty'], /* [x] => [. . .] */ ]; $result = array_intersect($strict[0], $strict[1], $strict[2]); print_r($result); //shows ['two', 'four']; I want to do something like this though: $result = array_intersect($strict); Where I pass in a dynamic length array of arrays and array

Set gridview column width programmatically in asp.net

喜你入骨 提交于 2019-12-10 11:27:41
问题 Need to set the column width of a gridview in asp.net programmatically. ** Autogenerated Columns (i.e., AutogenerateColumns = "true"). I tried the following; protected void gv_RowCreated(object sender, GridViewRowEventArgs e) { e.Row.Cells[2].Width = Unit.Pixel(200); } but no use. 回答1: This is my GridView1 on aspx file <asp:GridView ID="GridView1" runat="server" AllowSorting="True" Font-Size="Small" Width="800px" OnRowDataBound="GridView1_RowDataBound" > <Columns> <asp:CommandField SelectText

How to attach event to dynamic object or COM object

大憨熊 提交于 2019-12-10 11:06:10
问题 I think this article has the same problem with me. However, there's no workable solution for my case. I'm using Windows Media Player ActiveX in my program. For some reason, I don't want to add a reference of it and convert to AxHost automatically by IDE. I create the instance by Activator and ProgID protected const string WMP_PROG_ID = "WMPlayer.OCX.7"; private dynamic _wmp; protected virtual bool init(){ try{ _wmp = Activator.CreateInstance(Type.GetTypeFromProgID(WMP_PROG_ID)); } catch{

Deep find or search the key at any level in JSON and replace its value in c#

回眸只為那壹抹淺笑 提交于 2019-12-10 11:05:45
问题 I am also struck in a sort of problem. I am able to convert the nested JSON into key-Value , but Now I want to convert it into back its orignal json format. As of my problem I can't use the C# Object Model to do this, because the JSON file that I have is dynamic and its structure changes over the period of time. So I am looking for the solution by which we can serialize and deserialize the JSON via updated Key-Value pair. Any help would be great relief. TIA. Sample JSON Code: { "firstName":

LoopBack: How to Dynamically Create Custom REST Endpoints In Code (On The Fly)

你离开我真会死。 提交于 2019-12-10 10:55:18
问题 We are using the LoopBack REST framework to expose our database (and business logic). We need to allow our customers to create custom tables in the database (single and multi-tenant) which can be accessed via a REST endpoint. All customers need to use the same common (production) REST endpoints which will be on exposed on multiple servers. However, custom tables and associated REST endpoints need to be accessible to only the customers that created them. Which means we cannot write the model

Pass a dynamic variable in a static parameter of a method in C# 4

天涯浪子 提交于 2019-12-10 10:45:21
问题 This is what I am trying to do: public void method(int myVal, string myOtherVal) { // doing something } dynamic myVar = new SomeDynamicObjectImplementer(); method(myVar.IntProperty, myVar.StringProperty); Note that my properties are also DynamicObjects. My problem is that the TryConvert method is never called and that I get a runtime error saying the method signature is invalid. The following is working great: string strVar = myVar.StringProperty; int intVar = myVar.IntProperty; And I would

How do I make a multidimensional array of undetermined size a member of a class in c++?

。_饼干妹妹 提交于 2019-12-10 10:33:43
问题 I am looking at the multidimensional array library from boost, and I'm having trouble figuring out a way to declare a multi_array member in the header file with an undefined shape, like " A " in the example below: Class.h std::size_t nX; std::size_t nY; std::size_t nZ; boost::multi_array<double, 3> A; which is later instantiated to a certain size in the source file: Class.c++ nX = 3 nY = 4 nZ = 2 A = boost::multi_array<double, 3>(boost::extents[nX][nY][nZ]); but this gives me an unequal shape

Programmatically Creating Image Button in WPF

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 10:31:28
问题 I want to create a Windows Toolbar (something like RocketDock) which dynamically creates buttons from serialized classes, but I can't figure out how to dynamically set the image. As an aside, how should a image be serialized (i want to serialize the image with the storage class, instead of loading it from the original png file location each time)? I found the following code to create a dependency property public class ImageButton { #region Image dependency property public static readonly