dynamic

Null-coalescing operator returning null for properties of dynamic objects

前提是你 提交于 2019-12-28 20:35:46
问题 I have recently found a problem with the null-coalescing operator while using Json.NET to parse JSON as dynamic objects. Suppose this is my dynamic object: string json = "{ \"phones\": { \"personal\": null }, \"birthday\": null }"; dynamic d = JsonConvert.DeserializeObject(json); If I try to use the ?? operator on one of the field of d, it returns null: string s = ""; s += (d.phones.personal ?? "default"); Console.WriteLine(s + " " + s.Length); //outputs 0 However, if I assign a the dynamic

xsl:variable as xpath value for other xsl tag

断了今生、忘了曾经 提交于 2019-12-28 13:44:12
问题 I'm having issues with xsl:variable . I want to create a variable with a value that depends on the value of another XML node attribute. This working good. But when I try to create a variable with a string value that represents XPath, it just doesn't work when I try to use it as XPath in a later XSL tag. <xsl:variable name="test"> <xsl:choose> <xsl:when test="node/@attribute=0">string/represent/xpath/1</xsl:when> <xsl:otherwise>string/represent/xpath/2</xsl:otherwise> </xsl:choose> </xsl

using variables within a jquery selector

China☆狼群 提交于 2019-12-28 13:08:13
问题 I'm trying to build a dynamic jquery selector with the following code: var section_id = "{segment_3}"; var num_children = $('#'+ section_id + ' ul').children().size(); where segment_3 is a value I successfully retrieve from the url string, which, for example, might return the value of "section_one" But when trying to create the variable num_children, this reference doesn't work. How do I construct the code to build a dynamic reference? Thanks for any help. 回答1: Assuming var section_id =

Event not working on dynamically created element

六眼飞鱼酱① 提交于 2019-12-28 06:48:07
问题 I'm pulling my hair out trying to figure out why the mouseover event won't work with the .on handler with a dynamically created element from ajax. The only thing that seems to work is the code with .live but I understand that it is deprecated. $(".dropdown ul li").live("mouseover", function() { alert('mouseover works'); }); However, when I try using .on, it will not work - no matter what variations I try (document.ready, .mouseover, etc etc) $(".dropdown ul li").on("mouseover", function() {

Creating delegates dynamically with parameter names

最后都变了- 提交于 2019-12-28 06:15:29
问题 Hi I'm trying to create a function that dynamically creates a delegate with the same return value and the same parameters as a MethodInfo it receives as parameter and also and this is very important the same parameter names! What I did so far is create a function that returns a lambda that receives the same parameter types and has the same return value as the MethodInfo but it doesn't have the parameter names: static void Example() { Person adam = new Person(); MethodInfo method = typeof

Creating delegates dynamically with parameter names

南楼画角 提交于 2019-12-28 06:15:08
问题 Hi I'm trying to create a function that dynamically creates a delegate with the same return value and the same parameters as a MethodInfo it receives as parameter and also and this is very important the same parameter names! What I did so far is create a function that returns a lambda that receives the same parameter types and has the same return value as the MethodInfo but it doesn't have the parameter names: static void Example() { Person adam = new Person(); MethodInfo method = typeof

R Knitr PDF: Is there a posssibility to automatically save PDF reports (generated from .Rmd) through a loop?

混江龙づ霸主 提交于 2019-12-28 05:47:44
问题 I would like to create a loop, which allows me to automatically save PDF reports, which were generated from a .Rmd file. For instance, if a variable "ID" has 10 rows, I would like R to automatically save me 10 reports, into a specific directory. These reports shall vary based on the ID selected. A previous post (Using loops with knitr to produce multiple pdf reports... need a little help to get me over the hump) has dealt with the creation of multiple pdf reports generated from .Rnw files. I

Calculate total width of Children with jQuery

喜夏-厌秋 提交于 2019-12-28 05:33:08
问题 I've tried finding an understandable answer to this, but given up. In order to have dymnamic content (like blog posts and images) in a horizontal website (like on thehorizontalway.com) you must set a fixed width for the BODY in pixles, right? Because you use floated elements inside it that otherwise would break and wrap down the page, depending on the browsers width. EDIT! This specific value can be calculated with jQuery , thanks for that :) In this example, an additional value is added to

C# Dynamic Keyword — Run-time penalty?

回眸只為那壹抹淺笑 提交于 2019-12-28 02:55:28
问题 Does defining an instance as dynamic in C# mean: The compiler does not perform compile-time type checking, but run-time checking takes place like it always does for all instances. The compiler does not perform compile-time type checking, but run-time checking takes place, unlike with any other non-dynamic instances. Same as 2, and this comes with performance penalty (trivial? potentially significant?). 回答1: The question is very confusing. Does defining an instance as dynamic in C# mean: By

Will the dynamic keyword in C#4 support extension methods?

ε祈祈猫儿з 提交于 2019-12-27 11:45:54
问题 I'm listening to a talk about C#4 's dynamic keyword and I'm wondering... Will this feature be orthogonal to other .NET features, for example will it support extension methods? public static class StrExtension { public static string twice(this string str) { return str + str; } } ... dynamic x = "Yo"; x.twice(); // will this work? Note: This question was asked before C#4 was shipped which is why it's phrased in the future tense. 回答1: From the "New Features in C# 4" word doc: Dynamic lookup