Jump to content


how to use hooks


  • Please log in to reply
7 replies to this topic

#1 Guest_david carter_*

Guest_david carter_*
  • Guests

Posted 12 August 2005 - 08:06 AM

I have just gone onto looking at hooks. In the example below I am just
trying to set 2 values on the object. Clearly I am doing this incorrectly.
The examples on the web site decompose all of the fields, but now it is just
passing a single object.

Any advice would be greatly appreciated.

I am also getting the hooks files overwritten after I have changed them,

when re-generating within Tier Developer/

#2 Guest_Paul_*

Guest_Paul_*
  • Guests

Posted 12 August 2005 - 08:07 AM

The generated code passes parameters to Custom Hooks only if you have defined it for Bulk Operations. For standard methods the passing parameter is the object itself. You can however, change this pattern by modifying the Custom Hook templates.

TierDeveloper prompts you to overwrite the existing Custom Hook classes (if it already exists) where you can skip by saying "no" so it won't get overwritten. Since TierDeveloper generates custom hook classes in a separate folder called "Hooks" you can make backup of these classes, before regenerating the components, so that you won't lost your custom code.

#3 Guest_DamonCarr_*

Guest_DamonCarr_*
  • Guests

Posted 10 November 2005 - 11:03 AM

We have our own custom Framework which has added in Instrumentation, IDisposable, and Abstract Classes are the main element with concrete classes generated that inherit from the abstract main classes.

All work is done in the Concrete Class with a modification to all of the methods in the abstract class (before concrete) to virtual so anything can be overridden and you can add code just like in hooks.

However these new classes are not getting added to my VS solution. Here is what I have:

<fileset dir="${PatternSourceDir}/Components" destdir="${ComponentDir}" genUniCode="true">
<file name="Component_cs.ts" out="${Project.CurrentObject.Name}Abstract.cs" if="(Project.CurrentObject.Type != eAxCustomInfo) And (Project.CurrentObject.Type != eAxCustomInfoUnmapped)"/>
<file name="ComponentFactory_cs.ts" out="${Project.CurrentObject.Name}Factory.cs" if="(Project.CurrentObject.Type != eAxCustomInfo) And (Project.CurrentObject.Type != eAxCustomInfoUnmapped)"/>
<file name="ComponentCollection_cs.ts" out="${Project.CurrentObject.Name}Collection.cs" if="(Project.CurrentObject.Type != eAxCustomInfo) And (Project.CurrentObject.Type != eAxCustomInfoUnmapped)"/>
<file name="ComponentFactory_Assembly_cs.ts" out="${Project.CurrentObject.Name}Factory.cs" if="(Project.CurrentObject.Type == eAxCustomInfo) OR (Project.CurrentObject.Type == eAxCustomInfoUnmapped)"/>
<file name="ConcreteComponent_cs.ts" out="${Project.CurrentObject.Name}.cs" if="(Project.CurrentObject.Type != eAxCustomInfo) And (Project.CurrentObject.Type != eAxCustomInfoUnmapped)"/>
</fileset>


The ConcreteComponent_cs.ts classes are not added to the project. Also the hooks are blown away every time as are these concrete classes which should NEVER be blown away once generated..

How can I solve these problems?

Kind Regards,

Damon Carr, CTO
agilefactor
www.agilefactor.com

#4 Guest_Paul_*

Guest_Paul_*
  • Guests

Posted 11 November 2005 - 09:11 AM

The template properties that you've mentioned below are only intended for code generation. Here you just mention the number of templates that TierDeveloper will process for code generation.

To add your new class to VS.NET solution you need to customize the VS Project template that is Project.cs_csproj.ts. You will find this under the folder "Project".

Also, When you generate components TierDeveloper prompts you if you want to overwrite the existing hooks. You can choose no to skip overwriting your custom code.

#5 Guest_DamonCarr_*

Guest_DamonCarr_*
  • Guests

Posted 15 November 2005 - 11:56 AM

Can you explain how one is prompted on hook re-generation? No matter what I do in 5.0.4 the hooks are blown away. You allude in the docs to a way to copy this and the restore it. I don't want to do that, I want it to not touch hooks that have custom code..

What am I doing wrong? NOTE: This is using your standard C# Component Generation.

Kind Regards,
Damon Carr

#6 Guest_Paul_*

Guest_Paul_*
  • Guests

Posted 17 November 2005 - 02:57 AM

We have changed the code generation paradigm a little bit in version 5.0 and by default TD clears the hook files before generating the code. This was done intentionally to avoid any code confusions since VB and C# components are generated in the same folder.

You just need to modify the target GenerateCode so that it do not clears the hooks before generating the components. If you add the dependency CleanBeforeGenerate on the target GenerateCode your hooks files will be treated as safe and won't be overwritten when you regenerate the code. The dependency CleanBeforeGenerate ensures that you want to clean the hooks before generating the components.

To fix this, please go to targets in TemplateIDE, double click GenerateCode and modify the following line (if it is not already there)

target name="GenerateCode" depends="CleanBeforeGenerate, initComponents , TypedDataSet, SpScripts , Hooks" >

Just remove the CleanBeforeGenerate from the above line. I hope it will work.

#7 Guest_scottd_*

Guest_scottd_*
  • Guests

Posted 29 December 2006 - 11:02 AM

We have changed the code generation paradigm a little bit in version 5.0 and by default TD clears the hook files before generating the code. This was done intentionally to avoid any code confusions since VB and C# components are generated in the same folder.

You just need to modify the target GenerateCode so that it do not clears the hooks before generating the components. If you add the dependency CleanBeforeGenerate on the target GenerateCode your hooks files will be treated as safe and won't be overwritten when you regenerate the code. The dependency CleanBeforeGenerate ensures that you want to clean the hooks before generating the components.

To fix this, please go to targets in TemplateIDE, double click GenerateCode and modify the following line (if it is not already there)

target name="GenerateCode" depends="CleanBeforeGenerate, initComponents , TypedDataSet, SpScripts , Hooks" >

Just remove the CleanBeforeGenerate from the above line. I hope it will work.

Can you give me detail how to get into this script? I'm using version 5.2.

#8 Guest_Paul_*

Guest_Paul_*
  • Guests

Posted 10 January 2007 - 08:42 AM

TierDeveloper 5.2 is not similar to 5.0. Target named as “Generate Code” is not present in version 5.2.

Is there any specific reason you want to use Generate Code option, I may be able to give you different ideas if I know what you have in mind.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users