dynamic

Importing data and variable names from a text file in Python

北战南征 提交于 2019-12-09 00:04:36
问题 I have a text file containing simulation data (60 columns, 100k rows): a b c 1 11 111 2 22 222 3 33 333 4 44 444 ... where in the first row are variable names, and beneath (in columns) is the corresponding data (float type). I need to use all these variables with their data in Python for further calculations. For example, when I insert: print(b) I need to receive the values from the second column. I know how to import data: data=np.genfromtxt("1.txt", unpack=True, skiprows = 1) Assign

templateUrl with a function in angular2

≡放荡痞女 提交于 2019-12-08 21:44:34
问题 Well... in angular 1.x.y is angular.module('myApp', []).directive('myDirective', function(){ return { templateUrl : function(tElement, iAttrs){ return 'http://' + iAttrs.myDirective // More... } } }); But.. In Angular2 @Component({ selector: 'my-Directive', templateUrl: 'http://???' }) class HelloWorld { } Well, in the doc say only a String . As it is handled to be a function in angular2 ? 回答1: I had to implement something similar and my solution was the same as Thomas Gassmann's comment

C#4 dynamic keyword - why not?

元气小坏坏 提交于 2019-12-08 21:25:36
问题 After reading many of the replies to this thread, I see that many of those who dislike it cite the potential for abuse of the new keyword. My question is, what sort of abuse? How could this be abused so badly as to make people vehemently dislike it? Is it just about purism? Or is there a real pitfall that I'm just not seeing? 回答1: Some see it as a tool that will be abused. Like "Option Strict Off" and "On Error Resume Next" in VB which "pure" languages like C# and Java have never had. Many

dynamic object - runtime reports field not present but can see it in debugger?

时光毁灭记忆、已成空白 提交于 2019-12-08 21:03:34
问题 EDIT : restarting visual studio fixed this issue with no code changes. I have a ConfigSection handler that uses dynamic types and an expando object. The test fails reporting 'object' does not contain a definition for 'SportName' . I have tried to replicate in a console taking the ConfigSection handler out of the equation but what looks like the equivalent code works fine. I'm stumped. See below for test, ConfigurationSectionHandler and config xml public class SportSection :

C# dynamic generic list

匆匆过客 提交于 2019-12-08 20:07:11
问题 I want to create a generic List<> whose type is declared at runtime. I can do the following, but since it's dynamic, I suspect there is a speed penalty. I'm writing a wrapper to an exotic database, so speed is critical. List<dynamic> gdb = new List<dynamic>() I read this post in dynamic generic types, but can't get it to work. Specifically, the object is not appearing as a List and hence has no add method. Type ac; switch (trail[dataPos].Type) { case GlobalsSubscriptTypes.Int32: ac = typeof

Implication of using dynamic Expression<Func<T,X>> in NHibernate

社会主义新天地 提交于 2019-12-08 20:00:36
Basically in my application, I am using the following code to build my expression depending on the selection on the page. Expression<Func<T, bool>> expr = PredicateBuilder.True<T>(); expr = expr.And(b => b.Speed >= spec.SpeedRangeFrom && b.Speed <= spec.SpeedRangeTo); ... It has the tendency to end up with a long expression with multiple "or" and "and" conditions. Once I have finished building the expression, I passed it on to my repository which looks like the following: var results = Session.Query<T>().Where(expr).ToList(); The problem with that is it took so long to return me the result. I

SqlFunctions.StringConvert and Dynamic linq

为君一笑 提交于 2019-12-08 19:52:28
I have an Int64 field that I want to convert in my EF Dynamic Linq query. This because I want to use teh Contains function to check if the Int64 contains a certain serie of numbers. So I use the SqlFunctions.StringConvert like SqlFunctions.StringConvert(MyField).Contains("2012") The Dynamic library raises a ParseException: No applicable method 'StringConvert' exists in type 'SqlFunctions'. I changed this array in the Dynamic library so the SqlFunctions would be defined: static readonly Type[] predefinedTypes = { typeof(Object), ... typeof(Math), typeof(Convert), typeof(EntityFunctions), typeof

Calling a generic method with interface instances

◇◆丶佛笑我妖孽 提交于 2019-12-08 19:40:13
问题 As a followup question to this one public interface IFeature { } public class FeatureA : IFeature { } IFeature a = new FeatureA(); Activate(a); private static void Activate<TFeature>(TFeature featureDefinition) where TFeature : IFeature { } I undestand, that once the FeatureA is casted to IFeature the generic method will always get IFeature as type parameter. We have a service with provides us with a list features ( List<IFeature> ). If we want to iterate over those features, passing each in

problems with postbacks events from dynamic controls in ASP.Net

家住魔仙堡 提交于 2019-12-08 19:31:34
I am currently working on a page that has a user control that builds a dynamic table. The control is originally loaded on the Page_Init event, and any time that an event is raised that changes the dynamic control the table is reloaded. The problem here is that if the control is changed between between loads, the events from the control do not fire. For instance, there are originally two rows in the table. An item is added to the table during the postback and now there are four rows (this table adds two rows at a time). Each row has one or two buttons. When the page is loaded and sent back to

How to dynamically change Cordova whitelist?

╄→尐↘猪︶ㄣ 提交于 2019-12-08 19:25:51
问题 We have an application that has multiple whitelabel solutions for clients - meaning they are hosted under their own domain. We have one Cordova app and we want that users can visit all these sites with this app, but I don't want to redeploy everytime we sign a new client. is there a way to get to load the whitelist through a url or something? This would mean we can add domains on the fly through our database. is there a huge security risk when you whitelist all urls? https://cordova.apache