dynamic

Is it possible run python in .NET application?

笑着哭i 提交于 2019-12-22 04:55:21
问题 In .NET application is possible save C# code in text file or database as string and run dynamically on the fly. This method is useful in many case such as business rule engine or user defined calculation engine and etc. Here is a nice example: using System; using System.Collections.Generic; using System.Linq; using Microsoft.CSharp; using System.CodeDom.Compiler; class Program { static void Main(string[] args) { var csc = new CSharpCodeProvider(new Dictionary<string, string>() { {

Why does C# dynamic resolves internal properties but not methods?

ぃ、小莉子 提交于 2019-12-22 04:50:59
问题 I have a library with the following classes: public interface IEntity { string Foo { get; } void Bar(int x); } public class EntityFactory { public static IEntity createEntity() { return new Entity(); } } internal class Entity : DynamicObject, IEntity { public void Bar(int x) { Console.WriteLine("inside Bar"); Console.WriteLine("bar {0}", x); } public string Foo { get { Console.WriteLine("inside Foo getter"); return "foo"; } } public override bool TryInvokeMember(InvokeMemberBinder binder,

Is it possible to create properties on the fly, with a .NET dynamic object? [duplicate]

无人久伴 提交于 2019-12-22 04:48:10
问题 This question already has answers here : Adding unknown (at design time) properties to an ExpandoObject (5 answers) Closed 5 years ago . I'm trying to create a some Json in my MVC app and I only want to include the properties from my source object, if it has some properties values, set. eg. public class Foo { public string Aaaa { get; set; } public string Bbbb { get; set; } public int? Ccccc { get; set; } public Lol Dddd { get; set; } } // Example Outputs. Aaaa and Ccccc have values only:

How do I test for typeof(dynamic)?

送分小仙女□ 提交于 2019-12-22 04:21:51
问题 I've got a generic method TResult Foo<TSource, TResult>(IEnumerable<TSource> source) and if TResult is declared as dynamic I want to execute a different code path than for other type declarations. For regular types you can do stuff like: if (typeof(TResult) == typeof(int)) return ExpressionFactory.CreateExpandoFunction<TSource, TResult>(); But if (typeof(TResult) == typeof(dynamic)) does not compile. Is there anyway to make this sort of determination at runtime when the method is called with

How do I test for typeof(dynamic)?

送分小仙女□ 提交于 2019-12-22 04:21:06
问题 I've got a generic method TResult Foo<TSource, TResult>(IEnumerable<TSource> source) and if TResult is declared as dynamic I want to execute a different code path than for other type declarations. For regular types you can do stuff like: if (typeof(TResult) == typeof(int)) return ExpressionFactory.CreateExpandoFunction<TSource, TResult>(); But if (typeof(TResult) == typeof(dynamic)) does not compile. Is there anyway to make this sort of determination at runtime when the method is called with

symfony set the cookie_domain dynamically

不羁的心 提交于 2019-12-22 04:16:21
问题 I have a single app that ca serve multiple domains. I'm having a problem with the framework.session.cookie_domain I'd like the session to be kept between subdomain, so far so good with cookie_domain set right Where i have a problem is that i'd like the cookie_domain parameter set dynamically as i don't know in advance which domain the request is coming from. I tried in the AppKernel.php to do something like : $domain = substr($_SERVER['HTTP_HOST'], strpos($_SERVER['HTTP_HOST'], '.')); ini_set

How do you make dynamic bindings in Guice that require an injected Instance?

不羁的心 提交于 2019-12-22 04:05:36
问题 I'd like to create a Module that dynamically binds instances to named annotations. The use case is I would like to automatically bind the values in my configuration with the key in the properties file being the @Named value. However the configuration is bound in a different module so I need the config to be injected. Solutions I've looked at are: Binding in the configure() method. This method is not injected into and I can not get the base configuration. Using a Provider/@Provides. Providers

Dynamic django forms - Variable fields

邮差的信 提交于 2019-12-22 01:16:13
问题 I have some models; Vocabularies (tags lists), Labels (tags) and different articles types. These article types have some vocabs enabled, and some not, for instance: Image can tagged with terms from A, B and a news article with terms from A or C. This however only exists at the database level. What i'm trying to do is to output fields depending on if a vocab is enabled for a content type or not, like this: Determine if this content type is connected to a vocabulary. Load the vocabularies

Oracle SQL Left join same table unknown amount of times

南楼画角 提交于 2019-12-22 00:45:30
问题 I have this table | old | new | |------|-------| | a | b | | b | c | | d | e | | ... | ... | | aa | bb | | bb | ff | | ... | ... | | 11 | 33 | | 33 | 523 | | 523 | 4444 | | 4444 | 21444 | The result I want to achieve is | old | newest | |------|--------| | a | e | | b | e | | d | e | | ... | | | aa | ff | | bb | ff | | ... | | | 11 | 21444 | | 33 | 21444 | | 523 | 21444 | | 4444 | 21444 | I can hard code the query to get the result that I want. SELECT older.old, older.new, newer.new firstcol,

UITableView - dynamic cell height controlled by cell itself

好久不见. 提交于 2019-12-22 00:15:40
问题 I have the following setup: UITableView with custom UITableViewCell implementation. In each cell I have a UILabel and a UIButton. When the table is first displayed, in each of the cells, the UILabel has the number of lines set to 1 and all cells have fixed height (60 px in my case). When the button in the cell is tapped, then the UILabel's number of lines is set to 0 and word wrap is turned on, effectively expanding the table cell. Now, the issue is that only the implementation of