code-generation

C# code generation / removing redundant code

I have some simple code in a class: private ITemplate _content1 = null; [TemplateContainer(typeof(ContentContainer))] public ITemplate Content1 { get { return _content1; } set { _content1 = value; } } I need about 15 of these content containers. I could just copy and paste this block 15 times and change the number, but...

Looking to Create Custom Domain Specific Language that Outputs HTML

I'm looking to create my own custom domain specific language that outputs HTML. Basically, I want to be able to create quizzes using my own markup, but have that compiled / generated into HTML. For example: > What is your favorite color? * Blue * Green * Red should output <form action="" method="post"> <ul> <li>What is your favori...

Is there away to generate Variables' names dynamically in Java?

Let's say that I need to generate variables to hold some input from the user (I don't know how many they are). Without using Array, ArrayList (and other kind of lists and maps) can my code generate (lets say) String variables X times with names like (String var001, String var002, String var003, etc)? If yes, please provide sample code. ...

How do I get Eclipse to resolve classes generated with Maven 2?

I'm using Google Protocol Buffers to generate some Java classes for my project. Using Maven 2 and its "antrun" plugin, these classes are freshly generated before compile, output to target/generated-sources and put on the classpath during the build. So building the project from the POM is no problem. However, Eclipse doesn't know how to ...

Visual Studio Code Generation, project-based content

I'm interested in doing a bit of code-generation based on certain files being present in the .csproj. What extensibility methods are available to me that I could generate a .cs file that would be compiled along with my project? Caveat: I immediately thought of using T4 templates for the task. However, this solution must be supportable...

Dynamically generate classes at runtime in php?

Here's what I want to do: $clsName = substr(md5(rand()),0,10); //generate a random name $cls = new $clsName(); //create a new instance function __autoload($class_name) { //define that instance dynamically } Obviously this isn't what I'm actually doing, but basically I have unknown names for a class and based on the name, I want to ...

Creating a class for an interface at runtime, in C#

I'm looking at taking a set of objects, let's say there's 3 objects alive at the moment, which all implement a common interface, and then wrap those objects inside a fourth object, also implementing the same interface. The fourth object's implementations of methods and properties would simply call the relevant bits on those 3 underlying...

Converting simple C++ code to C# automatically

I have a file in C++ containing constant definitions, I want to use the same definitions in a C# project. Since both projects are part of a bigger project, I want if there is a change (addition/deletion) in the C++ file it should get reflected in corresponding C# file too. I want to keep the 2 files in sync. I was wondering if there is a...

Create hash from string and int

I remember eclipse and idea have this template to automatically create an object's hashCode based on its attributes. One of the strategies if a number and a string is used is something like this. return stringValue.hashCode() + intValue * 32; Ooor something like that. I don't have nor eclipse or idea at hand and I would like to cr...

Updating attribute based on radio selection

I have a table with question_id , nominees and vote_count in which the values for question_id and nominees are populated from other tables with vote_count as zero. ex: question_id nominees vote_count 1 tamil 0 1 selvi 0 2 aaaa 0 ...

Running hibernate tool annotation generation without the "catalog" attribute

when i run my hibernate tools it reads from the db and create java classes for each tables, and a java class for composite primary keys. that's great. the problem is this line @Table(name="tst_feature" ,catalog="tstdb" ) while the table name is required, the "catalog" attribute is not required. sometimes i want to use "tstdb", so...

How to get strongly typed local resources in a VS2008 ASP Web Site?

If I create a Web Application project in visual studio 2008 I can add a resource file for a page and using the Access Modifier drop down in the resource file editor to let visual studio generate the code so that the local resources are strongly typed. However if I create a Web Site project this combo box is disabled. Is there anyway to a...

how can i compare the selected values with the existing one in rails

I have a view like this, <% count = 1 %> <% for voting in @voting %> <% if voting.question_id.eql?(count) %> <%= radio_button( count, voting.vote_count, :radio_id => voting.nominees ) %> <%= voting.nominees %> <% end %> <% if voting.nominees.eql?(radio_id) %> <% voting.update_attribute('vote_count...

how to pass hash as radio button option

am passing the hash as radio button option .. like { 1=>["a", "b"], 2=>["c"], 3=>["a", "d", "f", "g"], 4=>["q"]} but for the first option am getting radio button, for other values am not getting it am getting like this 1--- o a b 2---- o c 3--- o a b c can anybody give some idea about, how to pass hash as radio button o...

C# Code generator that can speeds up the development of a DB driven software?

Hi, I'm new to c# and .net development. I'm looking for a C# code generator that can generate the code for CRUD operations and entity objects against tables in a database. It needs to be: Support Oracle database; The generated code must be simple and easy to use. Thank you very much in advance! ...

how to loop inside every tables/columns in a dbml file to create new partial class with more information about every columns.

I have a class that add extra information about a column for linq2sql (see code below) right now, I have to explicitly tell what column I want that info on, how would you put that code with a loop on every column in every table from a dbml file? I was doing my test on a very very small DB, now I have to implement it on a much more bigg...

Code Generation from XML Files in Visual Studio

I have xml files called 1.template, 2.template, 3.template, etc. (The number refers to the application's ID number inside our company.) I have one XML template file per application and rarely have more that one application in a solution. I have a generic configuration reader called "ConfigurationReader". I have projects in both C# and ...

Anybody know of any T4 templates for generating classes from xsd?

I'm looking at some work updating classes generated from xsds. I think this would be a great use of T4 templates, but I don't see any examples of people doing this. Essentially, I'd like to do what Linq to XSD has done, but without including alpha build targets in a production solution. Any relevant links out there? Now a wiki. St...

Does anyone know of any VB.Net code generation plug-ins for StarUML?

Simple question really. No elaboration required. I have found similar tools for Java, C#, C++ and other languages but not VB.Net. Thanks ...

Code stubbing with Visual Studio 2010 UML modeling

Currently I'm exploring my way through all the new features added to the Visual Studio 2010 Beta 1 IDE and I found a feature that will hopefully be of great help to me. The UML Modeling tool in the Architecture Edition. I wanted to create a new test project, nothing special. I started out with creating just a standard UML Logical Class D...