dynamic

Generic type inference not working with dynamic?

空扰寡人 提交于 2019-12-10 08:23:12
问题 I have recently been playing with Massive, a Micro-ORM which returns collections of IEnumerable<dynamic>. I discovered an unexpected issue when I tried to query one of those collections using LINQ. While the compiler seems to have no issues whatsoever to work out that string.Format returns a string even when one of the arguments passed to it is declared as dynamic... dynamic dynamicString = "d"; // just using a string here for simplicity, same problem occurs with any other type string

force eclipse to ignore character encoding attribute

故事扮演 提交于 2019-12-10 08:14:14
问题 I'm working with a web framework that uses a dynamic character encoding in its html templates, like this: <meta charset="${_response_encoding}"> The problem is when I try to edit this file in Eclipse, Eclipse thinks this is a literal encoding type, and thus refuses to open the file, saying: "Unsupported Character Encoding" Character encoding "${_response_encoding}" is not supported by this platform. Is there any way to tell Eclipse to stop trying to be "smart" (because it plainly isn't) and

Dynamic method calling in VB without reflection

岁酱吖の 提交于 2019-12-10 04:37:04
问题 I want to format any numeric type using a method call like so: Option Infer On Option Strict Off Imports System.Runtime.CompilerServices Namespace GPR Module GPRExtensions <Extension()> Public Function ToGPRFormattedString(value) As String ' Use VB's dynamic dispatch to assume that value is numeric Dim d As Double = CDbl(value) Dim s = d.ToString("N3") Dim dynamicValue = value.ToString("N3") Return dynamicValue End Function End Module End Namespace Now, from various discussions around the web

Zurb Foundation: How do you make buttons smaller on resize to a smaller screen?

最后都变了- 提交于 2019-12-10 04:22:44
问题 In Zurb Foundation 4, is there a way to automatically switch to the smaller button style when the browser is resized smaller or on a smaller screen? For example when the screen is a standard desktop screen do this: <a href="#" class="primary button">Button 1</a> When the screen is resized smaller, do this: <a href="#" class="small primary button">Button 1</a> I have a button group of 6 buttons in a horizontal row and would like to use the small button class when the screen is resized smaller

Dynamic JSF (2.0) commandButtons - set action with arguments

做~自己de王妃 提交于 2019-12-10 04:17:14
问题 I'm trying to add JSF <h:commandButtons> dynamically to my webpage, and so far I have them displaying, but I cannot set the action with parameters, like I could in a static page: action="#{bean.function(parameter)}" . (this is of course using EL-2.2) Looking around I find that I have to create a MethodExpression , but this is obscure to me and I haven't been able to find much information on this. If someone could shine a light through the fog and explain how this can be done, it would be

Determining the expected type of a DynamicObject member access

南笙酒味 提交于 2019-12-10 02:15:43
问题 Is it possible to determine what type a dynamic member access expects? I've tried dynamic foo = new MyDynamicObject(); int x = foo.IntValue; int y = (int)foo.IntValue; And in the TryGetMember intercept GetMemberBinder.ReturnType is object either way. I also implemented TryConvert wondering if it might get invoked to do the conversion, but it never is hit. Is there some other override I'm missing that lets me determine what Type the caller wants so that I can do the appropriate conversion? 回答1

Writing `eval()` in C

假装没事ソ 提交于 2019-12-10 02:09:54
问题 I've been trying to make an eval function in C for a while. At the moment, my idea is to make a hash String -> function pointer with all the standard library C functions, and all the functions that I make, that way I could handle function invocations (on already defined functions). However, defining functions with strings (i.e, calling eval("int fun(){return 1;}") ) is still a problem, I don't know how I could handle this on runtime, does anyone have any idea? Variable definitions don't seem

Can the “dynamic” type vary safely in a generic collection<dynamic>?

孤街浪徒 提交于 2019-12-10 01:59:01
问题 Based on my answer to this question, I want to check something on my understanding of the upcoming dynamic type for C# 4. In this case, we have a collection that represents fields in a record pulled from an unknown database table. Older code (pre-.Net 4) requires such a collection hold items of type Object . Merits of a such a collection aside, I'm wondering about what happens when you change Object to dynamic . On the one hand, I expect that since things for dynamic types are all worked out

Error: An expression tree may not contain a dynamic operation

孤人 提交于 2019-12-10 01:44:33
问题 I use Asp.Net 4 and C#, I use EF 4. I have this query, I receive an error: An expression tree may not contain a dynamic operation dynamic o = e.Item.DataItem; var imagesContent = context.CmsImagesContents.FirstOrDefault(img => img.ContentId == o.ContentId); It seems is imposible to Cast a Dynamic Type using a Lamba Expression. How I can fix the problem, and able to use my object o in my Lamba ? Thanks PS: e.Item.DataItem is of Type CmsContent and o.ContentId is of type Int 回答1: Unboxing the

Set class inheritance after class delcaration OR setting class inheritance on const_set class

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 01:21:44
问题 If a class has been previously defined how can I tell it to inherit from a class Parent For instance: class Parent .. end class Klass .. end Now I want it to inherit from Parent I cant re-open the class and set it because I will get a class mismatch error class Klass < Parent .. end Specifically I am trying to find out how to set the class inheritance on a class im creating through Object.const_set klass = Object.const_set('Klass', Class.new) How can I tell Klass to inherit from class Parent?