code-generation

What's the easiest way to generate code dynamically in .NET 4.5?

本小妞迷上赌 提交于 2019-11-29 14:32:13
问题 I'm writing a specific kind of object-mapper. Basically I want to convert from a DataTable that has the fields a , b and c to an object that has properties a , b and c (the class of the object will be written by hand). There will be many different DataTables and many different classes that they will need to map to, so I want to make a generic mechanism that performs this data copying. Basically, I want the following function: public T Map<T>(DataTable t) where T: new() { ... } Now, I can do

Sitecore Glass Mapper always null

血红的双手。 提交于 2019-11-29 14:20:25
I am using Sitecore Glass Mapper for a new project I'm setting up. We are using Sitecore 7.2, latest version of Team Development for Sitecore (TDS) code generation and the latest version of glass. The code I am trying to execute: var b = new SitecoreContext(); var c = b.GetCurrentItem<T01_Homepage>(); b is not null. c is null. var d = b.GetItem<T01_Homepage>("path") d is null. I added my assembly in GlassMapperScCustom: public static IConfigurationLoader[] GlassLoaders(){ var attributes = new AttributeConfigurationLoader(new[] { "Company.Framework.Websites.Corporate", "Company.Framework.Core",

Generating assembly code from C# code?

人走茶凉 提交于 2019-11-29 10:39:56
Is there any way to generate assembly code from C# code? I know that it is possible with C code with GAS, but does anybody know if it's possible with C#? C# is normally compiled to the .NET bytecode (called CIL or MSIL ) and then JIT ("Just In Time") compiled to native code when the program is actually run. There exist ahead of time compilers for C# like Mono's AOT , so you could possibly compile a C# program through one of those and then disassemble it. The result is likely to be very difficult to follow. More likely, you may want to look at the bytecodes which are somewhat higher level than

How to generate object @Entities from database?

﹥>﹥吖頭↗ 提交于 2019-11-29 10:28:01
I want to generate JPA's @Entity s from database (but I want it to be object oriented). for Example @Entity @Table(name = "badges") public class Badges implements java.io.Serializable { private Integer id; private User user; private String name; private String date; It would be cool if it also support ManyToOne, OneToMany, Parent and ManyToMany. P.S. I tried JBoss Tools(Hibernate Tools) and I did not work for me. Use JBoss Tools (formerly hibernate tools). Quote from their site: Reverse Engineering: The most powerful feature of Hibernate Tools is a database reverse engineering tool that can

XSD tool appends “Specified” to certain properties/fields when generating C# code

*爱你&永不变心* 提交于 2019-11-29 09:34:16
I got a strange behaviour with the XSD generator I can't really explain. I got an XSD like this: <xs:complexType name="StageSequenceElement" mixed="false"> <xs:complexContent> <xs:extension base="CoreObject"> <xs:sequence> <xs:element name="Description" type="xs:string" minOccurs="0"> <xs:annotation> <xs:documentation>Some Doc</xs:documentation> </xs:annotation> </xs:element> <xs:element name="StageRef" type="ObjectReference"> <xs:annotation> <xs:documentation>...</xs:documentation> </xs:annotation> </xs:element> <xs:element name="MinDuration_100ms" type="xs:int" nillable="true" minOccurs="0">

free SQL Server stored procedure generator? [closed]

扶醉桌前 提交于 2019-11-29 08:46:29
I have seen some SQL Server stored procedure code generator which generates scripts on selecting a table. Kindly recommend a free tool that generate SQL Server SP but what I am looking for is: It generate scripts in db, where user may not have to copy the code and execute the script in db. It can generate SP for a selected schema, I mean user may not need to select a table one by one, just on selecting db it may generate scripts for all tables. Thanks Try http://www.codeproject.com/KB/database/Store_Procedure_Generator.aspx SSMS Tools Pack has a nice fit with your requirements. It has also

Add documentation to generated code in entity framework model first

无人久伴 提交于 2019-11-29 08:13:39
I have been using Entity Framework model first since VS 2010. When I build my project, EF generates a Model.Designer.cs file containing all entities. This designer file also contains the documentation added to the entities in the EDMX file. When I created a new EF model first project in VS 2012, a Model.tt file is added to my EDMX file. This T4 template generates a single file for every entity in my model. Unfortunately, the documentation from the EDMX file is not used in the generated code. I really like having my model documented so IntelliSense shows up when using it. The only workaround I

Does Android ART support runtime dynamic class loading just like Dalvik?

依然范特西╮ 提交于 2019-11-29 05:49:28
Currently, it's possible to dynamically load .dex classfiles into Android's Dalvik VM. This could probably also be used for dynamic code generation at runtime . Is this still possible with the upcoming ART runtime ? It seems to work just like it did with Dalvik. Thanks to matiash for referencing the I/O 2014 talk! I've watched the video recording of it, and here is what the developers have to say on runtime code loading (taken from the transcript): [Question from the audience:] So I was wondering how ART is going to jive[?] with byte code injection that might happen right after compilation or

Is it possible to change IntelliJ's code generation template for equals() and hashCode()

Deadly 提交于 2019-11-29 05:30:33
Is it possible to change the code generation template for equals() and hashCode() ? I would like the generated code to use the Java 7 Objects class for theses methods. As of release 14.1 of the Ultimate Edition it is possible to customize the Code generation template of equals()/hashCode() without the use of any third party plugin. Press "Alt + Insert" (Generate...), choose "equals() and hashCode()" and you will be able to select one of the predefined templates or a customized template of your own. UPDATE: have a look at the answer from @datentyp. Leaving mine for those stuck on the old

AOP or APT for overriding methods from super classes

江枫思渺然 提交于 2019-11-29 05:13:19
I have a large library of wicket components that are annotated with a custom annotation @ReferencedResource or another annotation @ReferencedResources , that has a ReferencedResouce[] value() parameter to allow multiple annotations. Here is a sample code snippet: @ReferencedResources({ @ReferencedResource(value = Libraries.MOO_TOOLS, type = ResourceType.JAVASCRIPT), @ReferencedResource(value = "behaviors/promoteSelectOptions", type = ResourceType.JAVASCRIPT) }) public class PromoteSelectOptionsBehavior extends AbstractBehavior{ ... } So far, I use apt to check that the referenced resources