Internally there was a race for the best-performing-solution on the following scenario:

A function has a string-parameter containing only digits. The function has to increment the value and return a string having the very same format.
For example: input is ’0100′ the returnvalue is ’0101′

Take this for granted:
- input is always numeric
- the incremented value will never have more chars then the input.

Requirements:
- increment the input-string by one
- padding must be dynamically, depending on the input-value (must also work for ’010′ and ’00100′)

And here is the result, starting with the fastest one:

  • return (int.Parse(input) + 1).ToString().PadLeft(input.Length, ’0′);
  • return (int.Parse(input) + 1).ToString(CultureInfo.InvariantCulture.NumberFormat).PadLeft(input.Length, ’0′);
  • return (Convert.ToInt32(input)+1).ToString(“D” + input.Length);

And the slowest one:

  • return (Convert.ToInt32(input) + 1).ToString(input.Aggregate(“”, (current, t) => current + “0″));

Summary:
- assigning values to variables is slow, so do it all within 1 line.
- using FormatProviders is slow.
- using linq is maximum slow.
- ‘Convert.ToInt32′ checks for NULL, then calls ‘int.Parse’, so better use int.Parse, if you don’t care for null.

Share and Enjoy:
  • Technorati
  • Digg
  • Facebook
  • del.icio.us
  • Live
  • Google Bookmarks
  • DotNetKicks
  • DZone
  • TwitThis
  • Blogosphere News
  • Blogplay
  • LinkedIn
  • MisterWong
  • MisterWong.DE
  • MSN Reporter
  • MyShare
  • RSS
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Tumblr
  • Twitter
  • Webnews.de
  • Yahoo! Bookmarks
  • Yigg

Note: this article will mention a free tool “Enar Spy” for Enterprise Architect. Get more information here: https://blog.lieberlieber.com/2011/09/22/enar-spy-update/


  • What are attributes?

In .NET attributes are used to combine code with declarations. e.g. is the class serializable, or is the property readonly.
Get more information here: codeproject

  • My Scenario:

In the internet you can find a couple of blogposts, dealing with setting attributes at runtime . I needed this to build a read-only property Grid, without modifying all the objects, I want to display.

Most information of this article is based on: dotnetfacts

In a short summary: the read-only attributes are set on all public properties except collections.  This is to keep the CollectionEditor button alive, which is disabled when setting readonly= true on collections too.

  • What I did:

You cannot create property-based attributes during runtime, but the readonly attribute exists for each property of your class by default. Even, if you do not add the Line “[ReadOnly(false)]“.
This is, why the following code-snippet works. It sets the readonly-attribute on each public property except collections.
change attributes at runtime

  • My Problem:

When assigning the class to the Property-Grid, all properties are displayed readonly. And next to collections you still have the button to investigate them.
But when opening the CollectionsEditor you might discover the following:

Although class “Connector” contains more properties than just a ToString-Method, it is treated like a string object.
For a tool like “Enar Spy” this is totally worthless, as you cannot investigate any collections.

  • Solution:

By accident, I found an article mentioning my problem in a single sentence:
“Add the readonly-attribute to your class’ properties declaration (= in source code). Because if you don’t, .NET will mix it up and do some crazy stuff.”
(Shame on me, I do not remember, where I found that hint!)

That’s why I ended up adding the line “[ReadOnly(false)]” to each property of each class I use in Enar Spy.

And guess what?
The propertyGrid’s collection editor now works like a charm:

This issue definitely needs some more investigation.

Does anybody have more information about this topic?

I appreciate each comment to this topic!

Share and Enjoy:
  • Technorati
  • Digg
  • Facebook
  • del.icio.us
  • Live
  • Google Bookmarks
  • DotNetKicks
  • DZone
  • TwitThis
  • Blogosphere News
  • Blogplay
  • LinkedIn
  • MisterWong
  • MisterWong.DE
  • MSN Reporter
  • MyShare
  • RSS
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Tumblr
  • Twitter
  • Webnews.de
  • Yahoo! Bookmarks
  • Yigg

This royalty free addin was built for Developers to speed up Enterprise Architect Development. It includes a couple of plugins and tools to ease the developer’s life by e.g. unvealing properties hidden by EA.

New in this version:

  • ElementDetails: all collections are loaded in-depth (except Element- or Package- Collections). Therefore you open an element and see it’s operations and their parameters.
    There’s also an option to display the database-record of the current element or package.
  • Filtergram: find objects in the current diagram by any property (only non-collections are supported yet)
  • eaLauncher: now supports addin-registrations in Local Machine hive introduced with EA 9.0.

For more details see the documentation.

If you already installed Version 1.0 (from here): there is no need to uninstall. Version 1.2.1 will replace previous versions automatically.

Requirements: .NET 3.5 & Enterprise Architect 8 or above.

Downloads are here:
Setup: v1.2.1
Documentation: Overview
Demo-Video: 1080i (taken from v1.0)

Your Feedback is welcome! Mail to us, or drop a comment in this topic’s details.

Share and Enjoy:
  • Technorati
  • Digg
  • Facebook
  • del.icio.us
  • Live
  • Google Bookmarks
  • DotNetKicks
  • DZone
  • TwitThis
  • Blogosphere News
  • Blogplay
  • LinkedIn
  • MisterWong
  • MisterWong.DE
  • MSN Reporter
  • MyShare
  • RSS
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Tumblr
  • Twitter
  • Webnews.de
  • Yahoo! Bookmarks
  • Yigg

Click-once was not designed for registering com-components. These things are part of the work Windows Installer is meant for.
To use ActiveX in click-once applications too, remember these words: “Reg-Free COM“.

Here’s a short summary of what to do in a .NET project:

  • register the ActiveX Control on the developer’s machine.
  • add the control to a form
  • visual studio will add a reference to it.
    in solution explorer navigate there, and set it’s properties to “isolated” and “copy local”.
  • compile the project. VS will create a manifest to allow the usage of the activeX without registering it.
  • copy the activeX control to your output folder
  • Test it by compiling your app, unregister the control, and start your app.
    Lucky you, it will operate as desired.

Requirements: Windows XP and above, Visual Studio 2005 and above.

Note: Not every component is meant for Reg-Free COM, but in most cases it works.
And: it must be registered on the computer, the app is compiled on.

Get more information here (msdn magazin).

Share and Enjoy:
  • Technorati
  • Digg
  • Facebook
  • del.icio.us
  • Live
  • Google Bookmarks
  • DotNetKicks
  • DZone
  • TwitThis
  • Blogosphere News
  • Blogplay
  • LinkedIn
  • MisterWong
  • MisterWong.DE
  • MSN Reporter
  • MyShare
  • RSS
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Tumblr
  • Twitter
  • Webnews.de
  • Yahoo! Bookmarks
  • Yigg

Coding for Enterprise Architect often requires lookup of data not exposed by the GUI. So the coder ends up opening SQL Management Studio or MS Access to lookup data directly from the database tables.
EnAr Spy was built to ease lookups; here at LieberLieber, it reached essential-tool status rapidly.

EnAr Spy integrates into Enterprise Architect as a custom Add-In. Once installed, the developer needs to rightclick the item he wants to investigate, to get a view containing all properties and collections.

Also included in the current version:
- execute SQL directly out of Enterprise Architect
- lookup information from repository object
- remove Version-Control from the project.

Best of all: EnAr Spy is free of charge; just download and install.

Requirements: .NET 2.0 & Enterprise Architect 8 or above.

Please note, that we will not take any responsibility on possible data loss or damage to any software or hardware.

Downloads are here:

Setup: EnArSpy 1.1.122
Dokumentation: PDF 
Demonstration: Video (1080i)

Share and Enjoy:
  • Technorati
  • Digg
  • Facebook
  • del.icio.us
  • Live
  • Google Bookmarks
  • DotNetKicks
  • DZone
  • TwitThis
  • Blogosphere News
  • Blogplay
  • LinkedIn
  • MisterWong
  • MisterWong.DE
  • MSN Reporter
  • MyShare
  • RSS
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Tumblr
  • Twitter
  • Webnews.de
  • Yahoo! Bookmarks
  • Yigg

Im ersten Teil „Business Solutions entwickeln mit OCF“ wurde beschrieben, wie einfach man zu einem fertigen Grundgerüst für eine Business Solution kommt und wie man mit Hilfe des Entity Wizard alle benötigten Klassen für einen neuen Businessobjekttyp bekommt.

Die konkrete Implementierung einer beispielhaften Businesslogik ist das Thema dieses Artikels. Mit OCF lässt sich jede Art von Businesslogik umsetzen, jedoch wird die Umsetzung von Anwendungen für den Verwaltungssektor besonders unterstützt. Im letzten Artikel wurde schon kurz beschrieben, welche Entity Typen der Wizard anbietet. Businessobject, BaseDocument und Businesscase sind Typen, die in eGov-Fachanwendungen sehr häufig vorkommen. Businessobject ist das Basisobjekt eines jeden Geschäftsobjektes, enthält u.a. ein Property Identificationstring zur Darstellung der Aktenzahl bzw. Geschäftszahl. BaseDocument und Businesscase (Geschäftsfall) sind Ableitungen.

Im Beispiel werden 2 Entities erzeugt: File (Akt) und Document. File wird auf Basis des Entity Typs „Archive Object“ erzeugt, Document mit „Base Document“. Document erhält zusätzlich noch einen Foreign Key, der auf „File“ verweist.

clip_image002

clip_image004Damit erhält man alle benötigten Klassen.

Im Design Modus des LinqToSql Mapping Files „Entities.dbml“ fügt man jetzt manuell eine Association zwischen „File“ und „Document“ ein. Damit wird „File“, also der „Akt“, zum Container für Dokumente. Ein typischer Use Case im Verwaltungsbereich.

clip_image006

Als nächstes folgen ein paar notwendige Anpassungen. Der DataContract „File“ muss um ein Property „Documents“ erweitert werden.

image

Die Klasse “FileTranslator”, die das Business Entity „File“ in den DataContract „File“ übersetzt, muss ebenfalls angepasst werden, damit etwa beim Abfragen eines Aktes die verlinkten Dokumente gleich mitgeliefert werden.

image

Damit sind die Vorbereitungen fertig und man kann die Service Methoden implementieren, beispielhaft die Methoden „CreateFile“, „CreateDocument“ und „GetFileByID“.

Dazu öffnet man das Interface „IBusinessService“ im Contracts-Projekt und ergänzt die Methoden.

image

Die Implementierung des ServiceContracts könnte so aussehen:

image

Damit ist die Implementierung der Businesslogik fertig. Nach dem Update der Service Referenz im Client-Projekt, kann man auf die Service Methoden zugreifen und ein kleines Testprogramm schreiben.

image

Damit hat man bereits das Grundgerüst einer „ELAK konformen Fachanwendung“. Eine interessante Erweiterung des Beispiels wäre die Anbindung an den Dms Service Ocf|Dms. Jedes Document Objekt wäre dann mit einem Content verlinkt.

Share and Enjoy:
  • Technorati
  • Digg
  • Facebook
  • del.icio.us
  • Live
  • Google Bookmarks
  • DotNetKicks
  • DZone
  • TwitThis
  • Blogosphere News
  • Blogplay
  • LinkedIn
  • MisterWong
  • MisterWong.DE
  • MSN Reporter
  • MyShare
  • RSS
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Tumblr
  • Twitter
  • Webnews.de
  • Yahoo! Bookmarks
  • Yigg

Die LieberLieber Software GmbH liefert mit dem Open Components Framework (OCF) ein Entwicklungswerkzeug zur Generierung von Business Solutions. Die Architektur von OCF ist SOA basiert, also serviceorientiert. Ein vollständiger Datenlayer erleichtert die Umsetzung der gewünschten Businesslogik.

Setup: Nach der Installation stehen das Solution Template “OCF Business Solution” und der Entity Generierungsassistent “OCF Entity Wizard” zur Verfügung.

image 

Aufbau: Eine Business Solution wird nach einem vorgegebenen Pattern gebaut. Sie besteht nach der Generierung über das Template aus drei Projekten. Die Basis der Business Solution bildet ein WCF Service (Businessobjekt Service), der den wesentlichen Teil der Businesslogik enthält. Das Contracts-Projekt enthält die ServiceContracts und DataContracts. Das Client Projekt ist eine WPF Applikation mit einer Service Referenz auf den Businessobjekt Service.

Businesslogik: Für jede Entity werden eine Klasse im LinqToSql Objekt Modell (dbml file), eine DataContract Klasse, ein Repository (Entity factory) und ein Translator (übersetzt Entity in DataContract bzw. vice versa) benötigt. Diese Infrastruktur wird auf Wunsch generiert. Jedes generierte Repository ist von einem Basis Repository abgeleitet (Generic Repository, BusinessObject Repository, …). Das gleiche gilt für die anderen generierten Klassen. Etwa bei Wahl des Templates „Business Object“ wird das neue Repository vom BusinessObject Repository und der DataContract vom Basis DataContract „Business Object“ abgeleitet. Bei der Entity Klasse wird in diesem Fall das Interface IBusinessObject implementiert.

clip_image007

Für die Erzeugung dieser Infrastruktur gibt es den OCF Entity Wizard. Über den Menüeintrag „Create OCF Entity“ im Kontextmenü des Service Projekts startet man den Wizard. Sollen die Entity Klasse als auch die Tabelle in der Datenbank automatisch erzeugt werden, wählt man „Create new entity“. Im nächsten Schirm wählt man den Namen der neuen Entity, den Entity Typ (Objekttyp Template) und optional zusätzliche Felder aus. Es gibt zur Zeit fünf Entity Typen: Base Object, Archive Object, Business Object, Base Document und Business Case.

image

Mit Abschluss des Wizards werden die neuen Klassen erzeugt und man kann loslegen mit der Implementierung der eigenen Businesslogik.

Mehr dazu auf http://www.lieberlieber.com/Ocf.

Share and Enjoy:
  • Technorati
  • Digg
  • Facebook
  • del.icio.us
  • Live
  • Google Bookmarks
  • DotNetKicks
  • DZone
  • TwitThis
  • Blogosphere News
  • Blogplay
  • LinkedIn
  • MisterWong
  • MisterWong.DE
  • MSN Reporter
  • MyShare
  • RSS
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Tumblr
  • Twitter
  • Webnews.de
  • Yahoo! Bookmarks
  • Yigg