dynamic

TypeBuilder - Adding attributes

感情迁移 提交于 2019-12-21 23:37:06
问题 I have a helper class that uses a TypeBuilder to construct a dynamic type. It is used as follows : var tbh = new TypeBuilderHelper("MyType"); tbh.AddProperty<float>("Number", 0.0f); tbh.AddProperty<string>("String", "defaultStringValue"); tbh.Close(); var i1 = tbh.CreateInstance(); var i2 = tbh.CreateInstance(); I now want to add support for property attributes (existing attribute types, not dynamically generated types), along the lines of : public class TypeBuilderHelper { public void

Error when trying to use a service in dynamically created component angular 5.1

不羁的心 提交于 2019-12-21 21:53:59
问题 When trying to use a service in dynamically created component We got this error at run time ERROR Error: Can't resolve all parameters for class_1: (?). at syntaxError (compiler.js:485) at CompileMetadataResolver._getDependenciesMetadata (compiler.js:15664) at CompileMetadataResolver._getTypeMetadata (compiler.js:15499) at CompileMetadataResolver.getNonNormalizedDirectiveMetadata (compiler.js:15007) at CompileMetadataResolver.loadDirectiveMetadata (compiler.js:14862) at eval (compiler.js:34233

How to avoid code repetition using a 3rd party web service - without using dynamic?

可紊 提交于 2019-12-21 21:42:06
问题 I'm using a 3rd party web service where all it's methods have the following signature: SomeResponseClass SomeMethod(SomeRequestClass request) Every method has it's own request class and it's own response class, However there are a few things that all requests have in common, and all responses have in common. Every request class has a couple of properties for identification: username and token , and every response class have a couple of properties to indicate if there was an error: status and

Anyone know an example algorithm for word segmentation using dynamic programming? [closed]

喜夏-厌秋 提交于 2019-12-21 21:34:24
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . If you search google for word segmentation there really are no very good descriptions of it and I'm just trying to fully understand the process a dynamic programming algorithm takes to find a segmentation of a string into individual words. Does anyone know a place where there is a good description of a word

jQuery reinitialize/refresh draggable/sortable elements dynamically

眉间皱痕 提交于 2019-12-21 21:28:03
问题 I have a few functions which I load in the ready() event. These basically make a list draggable, and other areas droppable/sortable. Eg. You can drag a clone into multiple areas (lists in divs), and within these multiple areas, you can sort/reorder them (but only within each area). This works perfectly. I have a button which dynamically creates a new area for items to be dropped into, then sorted. It creates the new area perfectly, but you cannot drop items into it, or then even make them

What does this key error mean when calling MethodInfo.MakeGenericMethod?

人走茶凉 提交于 2019-12-21 21:17:46
问题 Today I got this error from some old dynamic casting code (I have changed the last line and left out the rest of the stack trace): Item has already been added. Key in dictionary: 'Int32 Count[Object](System.Collections.Generic.IEnumerable`1[System.Object])' Key being added: 'Int32 Count[Object](System.Collections.Generic.IEnumerable`1[System.Object])' ---> System.ArgumentException: Item has already been added. Key in dictionary: 'Int32 Count[Object](System.Collections.Generic.IEnumerable`1

Unpivot table with multiple columns and dynamic column names

丶灬走出姿态 提交于 2019-12-21 20:24:17
问题 I am trying to unpivot a table with multiple rows and columns. Each row needs to be extratced to 2 rows with specific columns and the column names need to be renamed and a new column needs to added based on the columns selected! I am including before and after sample data and a script to setup the data. CREATE TABLE #tmpProducts ( ProductId INT, ProductName nVARCHAR(100), B2B_GrossRevenue DECIMAL(10,2), B2B_DirectCost DECIMAL(10,2), B2B_NetRevenue DECIMAL(10,2), B2C_GrossRevenue DECIMAL(10,2)

Use a string from a config file to initilize a generic type [duplicate]

旧巷老猫 提交于 2019-12-21 20:18:22
问题 This question already has answers here : Pass An Instantiated System.Type as a Type Parameter for a Generic Class (6 answers) Closed 5 years ago . I have a class: public class MyClass<T> I have a config file that I am reading that has, say, Guid for the type T . How do I do this, except using the string from the config file instead of the actual type (instead of hard-coding Guid )? MyClass<Guid> = new MyClass<Guid>(); 回答1: You need the fully qualified type name: var typeArgument = Type

Algorithm for merging overlapping intervals

一笑奈何 提交于 2019-12-21 19:58:50
问题 I have been searching for an efficient algorithm to merge overlapping intervals on a dynamic array of intervals. For example, (start time, end time) wise, [(1, 2), (4, 8), (3, 10)] becomes [(1, 2), (3, 10)] after merging because (4, 8) and (3, 10) are overlapped. Overlapping means any part of the two intervals share the same moment. I know when a full array is given the operation can be done with a stack after sorting the intervals on start time ascending order (reference: geeksforgeeks). But

Symfony2 dynamic form generation

核能气质少年 提交于 2019-12-21 19:50:54
问题 I have mysql 2 tables: user_profile_field and user_profile_data with following columns: user_profile_field: -id (integer) -field (string) -category(string) user_profile_data: -id (integer) -user_id (integer) -field_id (integer) references user_profile_field(id) -data (string) I also have defined 2 Doctrine entities that map this relation. I need dynamicaly to create a form for updating user_profile_data. The form input type for each row of user_profile_field depends on user_profile_field