dynamic

Expression and delegate in c#

北战南征 提交于 2019-12-11 10:18:01
问题 I have below code that is a pseudo-code. I want to make this function can accept a Expresstion type, compile this expression and invoke it with proper parameters. public static void f<T>(Expression<T> exp, params dynamic[] d) { Console.WriteLine("begin"); exp.Compile().Invoke(d[0],d[1].....);//this is pseudo-code Console.WriteLine("end"); } I'm sure the T is an Action type. (T can be Action , Action<int> ,etc.). The parameter d is a array of dynamic type, which is sent to invoke. But I don't

How protect dynamic char from being overwritten by second dynamic char?

ぐ巨炮叔叔 提交于 2019-12-11 10:15:32
问题 #include <stdio.h> #include <stdlib.h> #include <string.h> char print_two(char *reg, char *s) { int i, l_s = (int) strlen(s), l_reg = (int) strlen(reg); for(i = 0; i < l_reg; i++) { printf("\n %c \n", reg[i]); } return 0; } int main(void) { char reg; printf("Give a rule: "); scanf("%s", &reg); char s; printf("Give a string: "); scanf("%s", &s); print_two(&reg, &s); return 0; } Program start: Give a rule: qwert Give a string: asdf result: d q a s d f How I can avoid overwrite reg by s ? I

Program Crashes When Dynamically generated radiobuttons are created in WPF

假如想象 提交于 2019-12-11 10:08:44
问题 I am a C++ developer and I recently moved to C#. I am working on a wpf app using MVVM pattern. I have a groupboxbox in my xaml file which I have divided into two columns. One column contains the dynamically generated set of radiobuttons and other colums contains a label and many comboboxes. XAML: <GroupBox Header="Daughter Cards" Height="Auto" HorizontalAlignment="Stretch" Margin="20,5,20,20" Name="groupBox2" VerticalAlignment="Stretch" Width="Auto"> <Grid> <Grid.ColumnDefinitions>

Rails - Dynamic routing based on host & ID

六眼飞鱼酱① 提交于 2019-12-11 10:03:03
问题 I have a rails application that contains many user pages. When a user wants to point a domain at this page, how would I do that? Right now I've tested out this, and it works - root :to => "controller#show", :id => 4, :constraints => {:host => "www.exampleurl.com"} but need to convert this to be dynamic, so that after I migrate a column into the model called domain it checks domain and serves it the proper ID. something like - root :to => 'controller#show', :id => ':id', :constraints => {:host

Receiving dynamically changing classes

拟墨画扇 提交于 2019-12-11 09:57:57
问题 In my system I have 16 different classes alike used for statistics. They look like the following public class myClass : myInheritage { private static myClass _instance; public static myClass Instance { get { return _instance ?? (_instance = new myClass(); } } public static void Reset() { _instance = null; } } They are all made into singletons myInheritage looks like this: public class myInheritage { int data = 0; public myInheritage() { } public int Data { get { return data; } set { data+=

Dynamically adding a url into a script tag in AngularJs

筅森魡賤 提交于 2019-12-11 09:55:25
问题 I'm implementing a payment gateway into my SPA built with angularjs. The problem is that this payment gateway requires you to include a script with a id of the payment. this is my current setup.... (note the controller just runs some server-side script, it returns all information about the payment I just need to get the id) Here is my controller: (function (){ var PaymentGateController = function ($scope, $rootScope, $state, paymentFactory, $sce) { $scope.ready = false; paymentFactory

How to get a working dynamic javascript reference in an SVG

谁说我不能喝 提交于 2019-12-11 09:49:53
问题 What I am trying to do is to set the Javascript script reference in an embedded SVG document dynamically from Javascript code within the HTML. I assumed it would be just as easy as dynamically appending a node to an appropriate place in the embedded SVG document. I found that the node was actually added at runtime (can check this with Firefox Inspect Element), but the Javascript code contained in the reference is not executed when it needs to be. Anybody have an idea about this? Does anything

Dynamically populate dynamically created select list

白昼怎懂夜的黑 提交于 2019-12-11 09:49:46
问题 I'm having a bit of difficulty here; I am using js to dynamically create select boxes, but I need Ajax to fill them with options. So far, my code is returning undefined, and I frankly don't know what to do here. My php returns the info fine, but the js isn't parsing it. Another set of eyes, or another brain full of knowledge would be appreciated here; function getSkilllist(group) { if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); }

How can I dynamically add a URL into javascript, to get a second page's div to display on the first page?

时光怂恿深爱的人放手 提交于 2019-12-11 09:46:33
问题 Ok, so this what I have that works, for the starting code: $(document).ready(function(){ $('.currentpagediv').load('http://theurl.com/page2/somethingsomewhere.html .secondpagedivclass'); }); What this does, is find the div on the current page, <div class="currentpagediv"> , and add in the second page ( http://theurl.com/page2/somethingsomewhere.html ) div <div class="secondpagedivclass"> So for example, say I have a page like this: <html> <body> <div class="currentpagediv"> </div> </body> <

Android get location of dynamicly added views

邮差的信 提交于 2019-12-11 09:43:39
问题 In my application in onCreate() method I need add to TableLayout certain number of rows and buttons for each row (for example 5x5, which means that I must add 5 rows and 5 buttons for each row) then I get something like square. This number I get from previous activity by intent . Then I need change size of buttons to maximum, depending on TableLayout width (which I get by ViewTreeObserver ), which is mach_parent . So size of each button will be btnWidth = btnHeight = (int) tlWidth / n . After