Monday, December 21, 2009

eXpand presentation at XERP

XERP is an open source movement in order to create a .Net profitable enviroment. eXpand is serving the same goal and did a presentation of current state eXpand at 1st XERP meeting.

I have demo the creation of a simple domain without writing any code. The modules used in the session

WorldCreator for runtime Domain objects modelling + any custom scripting required to achieve the goal

AdditionalViewsControlProvider for disaplying controls and bound them to domain objects

ModelDifference module to configure the application model .

ModelArtifact to make conditional a behavior expressed by a controller

 

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Tuesday, December 8, 2009

Sneak Peak-->WorldCreator2 with Scripting and Templating

Based on the specs i posted here, I have created a working prototype

In the video bellow I demo how

  • you can model a classic Customer-Orders relationship at runtime
  • modify the template of Orders property to create also a new custom readonly property that will return the first object of Orders if found. (same way you could create any teamplate e.g calculated proiperty template)

You can reply in this post or through DeveXpress forums if you want to help in adding more specs and make WorldCreator a better module

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Wednesday, December 2, 2009

Lets do BDD with MSpec and WorldCreator2

WorldCreator module is an excellent module and can provide dynamic types through a UI without a need of a user that knows coding. But since we all know coding I thought I move on and write some specs for WorldCreator2 .

My first thoughts are to drop the reflection emit approach and go with the codedom one and support templating and scripting . So I have defined the following model

image

and wrote 50 specs, which i am posting bellow and invite all of you to comment , suggest enhance them

PersistentClassInfo Initialization, When initializing a Persis

tentClassInfo and default template exists
» should assign that template to classInfo

PersistentClassInfo Initialization, When initializing a PersistentClassInfo
» should create a default classInfo template if not exists
» should set template as default

PersistentClassInfo Initialization, When initializing a PersistentClassInfo and default template exists
» should assign that template to classInfo

PersistentClassInfo Initialization, When initializing a PersistentClassInfo
» should create a default classInfo template if not exists
» should set template as default

CompileEngine, When cannot compile a dynamic module
» should swallow exception
» should delegate any errors to assembly info compile errors property

CompileEngine specs, When compiling a dynamic assembly
» should not contain any compilation error
» should Create A Dynamic module

CompileEngine specs, When compiling class with members
» should have no compile errors
» should generate class type
» should have those members as proeprties

CompileEngine specs, When PersistentClassInfo BaseType Belongs to different assemmbly
» should compile with no errors
» should create a baseType descenant class

ExistentTypesMemberCreator, When Creating ExistentTypes CoreMembers that exist already
» should not throw any exceptions

ExistentTypesMemberCreator, When Creating ExistentTypes CoreMembers
» should find that member through xpdictionary
» should create typedattributes

ExistentTypesMemberCreator, When Creating ExistentTypes ReferenceMembers
» should find that member through xpdictionary
» should create typedattributes

ExistentTypesMemberCreator, When Creating ExistentTypes CollectionMembers
» should find that member through xpdictionary
» should create typedattributes

CodeTemplate, When changing template type of a CodeTemplate
» should find all default template usings from module resources and display them
» should find all default template from module resources and display them

PersistentTypeInfo, When peristent type code template change
» should delegate all props from code template to persistent type templateinfo object

PersistentTypeInfo Creation, When A persistentTypeInfo object is creating
» should initialize its template

PersistentTypeInfo, When Saving PersistentTypes
» should persist the referenceType
» should generate the class code

PersistentTypeInfo, When Deleting PersistentTypes
» should delete TemplateInfo as well

CodeEngine, When generating code from persistentMemberInfo
» should have memberInfo attributes generated

CodeEngine, When generating code from persistentClassinfo with no base type defined
» should use default Base type

CodeEngine, When generating code from persistentClassinfo
» should inject usings from all members into template usings section
» should inject usings from classinfo templateinfo into template usings section
» should inject code from all members in classinfo generated code
» should have class type typeattributes generated
» should have propertytype typeattributes generated
» should replace CLASSNAME with persistentClassInfo name
» should replace BASECLASSNAME with persistentClassInfo name
» should add all interfaces after baseclassName
» should replace PROPERTYNAME with persistentClassInfo name
» should replace PROPERTYTYPE with persistentClassInfo type

PersistentMemberInfo Initialization, When initializing a PersistentMemberInfo and default template exists
» should assign that template to classInfo

PersistentMemberInfo Initialization, When initializing a PersistentMemberInfo
» should create a default classInfo template if not exists

PersistentMemberInfo, When saving a memberinfo associated with classInfo
» should generate code for the memberInfo
» should generate associate classinfo generatedcode

XpoObjectMerger, When Merging Dynamic Types
» should call an update sql statement
» should create an ObjectType Column to Parent if parent has no records

WorldCreatorModule, When dynamic module cannot be created
» should save errors in persistent assembly info

WorldCreatorModule, When Settingup Module
» should contain dynamic modules within Application Modules collection
» should not load modelDiffs from dynamic assemblies (NOT IMPLEMENTED)
» should create Existent Classes Member

WorldCreatorModule, When Updating Model
» should display owner column to extended members list view
» should remove dynamic assemblies from Assemblies image Node

WorldCreatorModule, When Application Setup Is Completed
» should merge any mergable dynamic type

InterfaceInfo, When linking with a PersistentInterfaceInfo
» should create all missing persistent member infos

When creating members from interfaceinfo with collection members
» should throw exception

When creating members from interfaceinfo
» should create all missing core type persistent member infos (FAIL)
» should create all missing reference member infos (FAIL)

Xaf TypesInfo, When loading types from Dynamic Assemblies
» should not load all types

PersistentAttributeInfo, When saving ClassInfo attribute
» should generate code for the referenced class info (FAIL)

PersistentAttributeInfo, When saving memberInfo attribute
» should generate code for the referenced class info (FAIL)

» should swallow exception
» should delegate any errors to assembly info compile errors property

CompileEngine specs, When compiling a dynamic assembly
» should not contain any compilation error
» should Create A Dynamic module

CompileEngine specs, When compiling class with members
» should have no compile errors
» should generate class type
» should have those members as proeprties

CompileEngine specs, When PersistentClassInfo BaseType Belongs to different assemmbly
» should compile with no errors
» should create a baseType descenant class

ExistentTypesMemberCreator, When Creating ExistentTypes CoreMembers that exist already
» should not throw any exceptions

ExistentTypesMemberCreator, When Creating ExistentTypes CoreMembers
» should find that member through xpdictionary
» should create typedattributes

ExistentTypesMemberCreator, When Creating ExistentTypes ReferenceMembers
» should find that member through xpdictionary
» should create typedattributes

ExistentTypesMemberCreator, When Creating ExistentTypes CollectionMembers
» should find that member through xpdictionary
» should create typedattributes

CodeTemplate, When changing template type of a CodeTemplate
» should find all default template usings from module resources and display them
» should find all default template from module resources and display them

PersistentTypeInfo, When peristent type code template change
» should delegate all props from code template to persistent type templateinfo object

PersistentTypeInfo Creation, When A persistentTypeInfo object is creating
» should initialize its template

PersistentTypeInfo, When Saving PersistentTypes
» should persist the referenceType
» should generate the class code

PersistentTypeInfo, When Deleting PersistentTypes
» should delete TemplateInfo as well

CodeEngine, When generating code from persistentMemberInfo
» should have memberInfo attributes generated

CodeEngine, When generating code from persistentClassinfo with no base type defined
» should use default Base type

CodeEngine, When generating code from persistentClassinfo
» should inject usings from all members into template usings section
» should inject usings from classinfo templateinfo into template usings section
» should inject code from all members in classinfo generated code
» should have class type typeattributes generated
» should have propertytype typeattributes generated
» should replace CLASSNAME with persistentClassInfo name
» should replace BASECLASSNAME with persistentClassInfo name
» should add all interfaces after baseclassName
» should replace PROPERTYNAME with persistentClassInfo name
» should replace PROPERTYTYPE with persistentClassInfo type

PersistentMemberInfo Initialization, When initializing a PersistentMemberInfo and default template exists
» should assign that template to classInfo

PersistentMemberInfo Initialization, When initializing a PersistentMemberInfo
» should create a default classInfo template if not exists

PersistentMemberInfo, When saving a memberinfo associated with classInfo
» should generate code for the memberInfo
» should generate associate classinfo generatedcode

XpoObjectMerger, When Merging Dynamic Types
» should call an update sql statement
» should create an ObjectType Column to Parent if parent has no records

WorldCreatorModule, When dynamic module cannot be created
» should save errors in persistent assembly info

WorldCreatorModule, When Settingup Module
» should contain dynamic modules within Application Modules collection
» should not load modelDiffs from dynamic assemblies (NOT IMPLEMENTED)
» should create Existent Classes Member

WorldCreatorModule, When Updating Model
» should display owner column to extended members list view
» should remove dynamic assemblies from Assemblies image Node

WorldCreatorModule, When Application Setup Is Completed
» should merge any mergable dynamic type

InterfaceInfo, When linking with a PersistentInterfaceInfo
» should create all missing persistent member infos

When creating members from interfaceinfo with collection members
» should throw exception

When creating members from interfaceinfo
» should create all missing core type persistent member infos (FAIL)
» should create all missing reference member infos (FAIL)

Xaf TypesInfo, When loading types from Dynamic Assemblies
» should not load all types

PersistentAttributeInfo, When saving ClassInfo attribute
» should generate code for the referenced class info (FAIL)

PersistentAttributeInfo, When saving memberInfo attribute
» should generate code for the referenced class info (FAIL)

Technorati Tags: ,,

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Tuesday, November 24, 2009

Xaf Tip #11 MVC architecture to overcome cyclic reference

Cyclic reference is probably due to a flaw in design.

So what? We are not perfect

But we use Xaf, a model driven Application Framework from Devexpress and we can take advantage of that architecture so to overcome cyclic reference problems.

I think an example is the most appropriate here.

eXpand has a module called AdditionalViewControlsProvider , it can provide as the name says controls to views by setting some values on the model

image

image

and since its an eXpand module it references eXpand.ExpressApp assembly (core)

after I release AdditionalViewControlsProvider I release also PropertyPathFilters which is using AdditionalViewControlsProvider module to display the extra criteria

image

but is hosted at eXpand.ExpressApp assembly (core) !!!

How in the heck did I do that?

Simple I knew that AdditionalViewControlsProvider is sawing controls only if message is set to something, so even if core did not have a reference to AdditionalViewControlsProvider I could set that attribute to the value i wanted like

ClassInfoNodeWrapper wrapper = GetClassInfoNodeWrapper();
DictionaryNode dictionaryNode = wrapper.Node.FindChildNode("AdditionalViewControls");
dictionaryNode.SetAttribute("Message",text);

and when I reference both eXpand.ExpressApp assembly (core) and AdditionalViewControlsProvider everything will work as expected.

And even if I try to use propertypathfilters without AdditionalViewControlsProvider I could easily throw a warning like

private void checkIfAdditionalViewControlsModuleIsRegister(){
    ClassInfoNodeWrapper wrapper = GetClassInfoNodeWrapper();
    DictionaryNode node = wrapper.Node.FindChildNode("AdditionalViewControls");
    if (node== null){
        throw new UserFriendlyException(new Exception("AdditionalViewControlsProvider module not found"));
    }
}
Technorati Tags:

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Thursday, November 19, 2009

BDD for Dynamic Types with mspec

This one will be my 2nd post about mspec. The first on can be found here.

I am still newbie in Mspec crazy syntax!! but have done a lot of TDD (after all BDD is TDD) , so my 1st effort of using mspec to describe all specifications (=expression of behaviors) for dynamic types module, along with some refactoring produced the following output

------ Test started: Assembly: eXpand.Tests.dll ------
ModuleCreator, When Creating Dynamic Module
»
should return a list of module base descenants
ExistentTypesMemberCreator, When Creating ExistentTypes CoreMembers that exist already
» should not throw any exceptions
ExistentTypesMemberCreator, When Creating ExistentTypes CoreMembers
»
should find that member through xpdictionary
» should create typedattributes ExistentTypesMemberCreator,
When Creating ExistentTypes ReferenceMembers
» should find that member through xpdictionary
» should create typedattributes ExistentTypesMemberCreator,
When Creating ExistentTypes CollectionMembers
» should find that member through xpdictionary
» should create typedattributes WorldCreatorModule,
When SettingUp Module
» should contain dynamic modules within Application Modules collection
» should not load modelDiffs from dynamic assemblies
» should create Existent Classes Member WorldCreatorModule,
When Updating Model
» should display owner column to extended members list view
» should remove dynamic assemblies from Assemblies image Node WorldCreatorModule,
When Application Setup Is Completed
» should merge any mergable dynamic type
PersistentClassInfoTypeBuilder specs, When Creating An Assembly
» should Create An Assembly In Current AppDomain
PersistentClassInfoTypeBuilder specs, When Defining A DynamicType
» should Create A Dynamic Type
» should have A Constructor with Session as parameter
PersistentClassInfoTypeBuilder specs, When Requesting A Property With Reflection
» should find a property
» should be of Correct Type
PersistentClassInfoTypeBuilder specs, When Invoking A Property
» should have value
PersistentClassInfoTypeBuilder specs, When Creating A reference Property of dynamic type
» should find the property thourgh reflection
» should be ofthe correct referenced type
PersistentClassInfoTypeBuilder specs, When Creating A reference Property of existent type
» should find the property thourgh reflection
» should be ofthe correct referenced type
PersistentClassInfoTypeBuilder specs, When Invoking A Dynamic Reference Property
» should have the correct value
PersistentClassInfoTypeBuilder specs, When Creating A Collection Property
» should find the propertyInfo through reflection
PersistentClassInfoTypeBuilder specs, When Invoking A Dynamic Collection Property
» should not have value
PersistentClassInfoTypeBuilder specs, When Applying Attributes To Properties
» should be discovarable thourgh reflection
PersistentClassInfoTypeBuilder specs, When Applying Attributes To Dynamic Classes
» should be discoverable through reflection
PersistentClassInfoTypeBuilder specs, When Associating 1 DynamicType With 1 Existent
» should create 2 types In Current domain
PersistentClassInfoTypeBuilder specs, When Changing A Dynamic property
» should raize changed event
PersistentClassInfoTypeBuilder specs, When Dynamic Type Inherits Existent Type
» should have as base Class the existent one
PersistentClassInfoTypeBuilder specs, When Dynamic Type inherits a Dynamic type
» should have as base class the dynamic one
PersistentClassInfoTypeBuilder specs, When DynamicType Implement An Interface
» should be Discoverable thourgh reflection
» should create non existent properties
PersistentClassInfoTypeBuilder specs, When Creating Types In A Non Xaf Context
» should create a Dynamic Type
XpoObjectMerger, When Merging Dynamic Types
» should updateXpdictionary Schema for each type
» should call an update sql statement
» should create an ObjectType Column to Parent
36 passed, 0 failed, 1 skipped, took 9,59 seconds (MSpec).

What do you think of the above specs? Can you understand all functionality supported by the dynamics types module (WorldCreator) from the above specs?

Want to see some code for the spec “When Creating A reference Property of dynamic type”?

image
Is that descriptive or what?
I suggest you use TestDriven.Net to run your specs since it provides support debugging and TypeMock out of the box
And some more mspec goodies from @agross.
Download A fully working app covered with mspec for your reference

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

eXpand source code has moved to GitHub

why we moved to GitHub?

The main reason is speed. With Git u get the chance to work locally make your operations at your H/D and push any of those changes to GitHub anytime you want. And even that is  faster cause Git does not rely of Differences (Deltas) to work, it is just sending snapshot of the current file system.

Another reason is that the tools for Gitting are pretty stable right now so there is no need to master Unit Shell in order to use it. So you can find TortoiseGit which is TortosieSvn port, Also GitExtensions are doing a very good job with Git – Visual studio integration.

Another very impressive feature of GitHub is the collaboration between users. For example you may want to develop upon eXpand in your own way and without being a member of the project and git hub gives a cool way to visualize that

see Say hello to the Network Graph Visualizer

or you may want at future to merge with eXpand main line or another developer line , its entirely up to u.

And for those of you that do not want or care about using Git in your daily work, GitHub provides a compressed archive of sources to download and use by just clicking a download link Dutton.

see also how

How to get eXpand latest version
Technorati Tags: ,

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Monday, November 16, 2009

Dynamic types in any application?

WorldCreator a module designed to work with Xaf can really work without it!!!!

Suppose you have a non xaf application and you use Xpo as your dataLayer and you want dynamic types then WorldCreator can for sure help you.

You just reference WorldCreator and eXpand.BaseImpl assemblies and use an approach similar to the specs bellow

[Test]
public void Can_Create_Types_In_A_Non_Xaf_Context() {
    new PersistentClassInfo(Session.DefaultSession){Name = "Test"}.Save();
    var typeCreator =
        new TypeCreator(
            new TypesInfo(new List<Type> {
                                             typeof (PersistentClassInfo),
                                             typeof (ExtendedCollectionMemberInfo),
                                             typeof (ExtendedReferenceMemberInfo),
                                             typeof (ExtendedCoreTypeMemberInfo),
                                             typeof (InterfaceInfo)
                                         }), new UnitOfWork(Session.DefaultSession.DataLayer));

    Type dynamicModule = typeCreator.GetDynamicModule();

    Assert.IsNotNull(dynamicModule);
    Assert.IsNotNull(dynamicModule.Assembly.GetTypes().Where(type => type.Name=="Test").FirstOrDefault());
}
Technorati Tags: ,

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Tuesday, November 10, 2009

Dynamic Types and Interfaces

Its now possible to implement existent interfaces for your dynamic types .

How?

Setup your InterfaceSources at your model

image

Populate them through InterfaceInfo Listview

image

and make your dynamic classes to implement them

image

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Monday, November 9, 2009

Filtering a listview of objects according to their childs

 The Problem 1
A common requirement in any OOP application is the ability to filter a listview of objects according to their childs in whatever level they belong.

eXpand can solve the above by the use of propertypath filters. So in an Customer—>Orders--->OrderLines relationship

the filter bellow are enough to filter your customer list view according to any property value of their Orders child collection

image

with the one bellow you can filter customer list view by any property value of orderlines collection of customers orders collection

image

In the video bellow i demo

1. the above functionality that is hosted at eXpand.ExpresApp assembly,
2. eXpand.ViewVariants module for creating views without the model editor (that is badly needed now that we can have multiple filters on a view)
3. A more complex filtering scenario using recursive filtering (provided by eXpand.TreeListEditors.Win) and a combination of filtering

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Tuesday, November 3, 2009

Dynamic Type Merging

I hope you all vote on DeveExrpess Issue that will allow us to validate runtime extended existent types. But even if you did not there is an alternative way that my friend Emilio shared with us.

I want to add runtime members for my existent Customer class for which records already exist in the DB and also use the validation system

You can create a new dynamic type that inherit your customer class decorate it with the MapInheritance attribute and set the MergedObjectType same as BaseType

Download working sample app with source code here

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Monday, November 2, 2009

Dynamic Types with WorldCreator source code is out

WorldCreator is a xaf module that provide dynamic persistent types for your application and runtime members for your existing classes. That means that you can define dynamic types at runtime through a UI (xaf views) save them in the database and let your imagination free !!!

Installation
Very simple you just register the selected assemblies bellow

image image

 

and add the required classes you want from .Persistent.BaseImpl

image

At my previous post IOC by BaseImpl I have explain the use of DevExpress.Persistent.BaseImpl assembly so in the same concept eXpand now has its own eXpand.Persistent.BaseImpl that will host a default implementation of persistent interfaces used from eXpand

image

As you can see at the above image there are to types of prefixes on those classes

Persistent—>Using those classes you describe your dynamic types
Extended-->Using those classes you add runtime types to your existent classes

I have already demo how you can model a domain at Yes Xaf can do it before lunch!!! so I am not going to repeat my self on that. Instead I will speak about some new features

Support for Custom attributes

As you see in the above image there is a PersistentMetaData namespace that hosts attributes. I did not implement all XPO,Xaf attributes

But its very easy to do so or to implement your own custom attribute, see for example PersistentCustomAttribute bellow

[DefaultProperty("PropertyName")]
public class PersistentCustomAttribute : PersistentAttributeInfo
{
    public PersistentCustomAttribute(Session session) : base(session) {
    }

    private string  _value;

    public PersistentCustomAttribute() {
    }
    private string _propertyName;
    public string PropertyName
    {
        get
        {
            return _propertyName;
        }
        set
        {
            SetPropertyValue("PropertyName", ref _propertyName, value);
        }
    }
    public string Value
    {
        get
        {
            return _value;
        }
        set
        {
            SetPropertyValue("Value", ref _value, value);
        }
    }
    public override AttributeInfo Create() {
        return new AttributeInfo(typeof(CustomAttribute).GetConstructor(new[] { typeof(string), typeof(string) }), PropertyName,Value);
    }
}

the trick is at create method, there you pass the constructor of the attribute you want to create and an array of arguments for that constructor and you are done!! One more attribute supported

so if anyone implement any more attributes I would be glad to host them in eXpand.

image

Inheritance
image

In the above image you see how you could extend your User class

You can inherit from Dynamic or existent class

Runtime member for existent Types

image

In the above image you can see how you can extend current user with an aggregated association collection.

Be carefull
If you create runtime members on existent classes and try to apply any validation rule on those members your application will throw an exception at start up. I have register an issue on that on DevExpress support so if you would like to implemented real soon from Dx please vote on it

After Dx implements that you can use the model to tell for which classes you want to describe their runtime member

image

WorldCreator is part of eXpand framework and you can get it here

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Friday, October 30, 2009

IOC by BaseImpl

In this post I am going to provide some why’s on DevExpress.ExpressApp.BaseImpl assembly.

Why it is not signed?

It is not strongly typed signed cause no module is referencing it. By doing so DevExpress encourages users to modify that assembly up to their needs. BaseImpl is only referenced at your front end. Most of Xafers i know have their own version of baseImpl .

If you have your own version of baseimpl development of your domain classes would be much easier
eg.instead of writing code to add a new property to a user though a controller , you could just describe/add that property to user class.

Why persistent classes are there

Xaf has been design to provide a an IOC approach to us. By that I mean that Xaf modules not use or know anything about persistent classes but only for interfaces that are hosted at DevExpress.ExpressApp.Base assembly which is signed and Dv discourages us from modifying.

So when you design a reusable module you should work with interfaces not with real objects

Drawbacks

The only drawback i found is that you cannot use linq to xpo cause you do not know the types only interfaces , maybe dx will provide a smarter way in doing so when they release their DC components

The following should also be true your BaseImpl assembly can reference your modules but your modules as I said cannot reference the Baseimpl.

After realizing what I said above the most obvious question came into my mind

WHY OTHER ORM NOT SUPPORTED?

modules know only interfaces and core can also be configured to use your own datalayer, objectspaceprovider so maybe some people out there have already manage to do so. Sounds achievable!!!

Technorati Tags: ,

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Thursday, October 22, 2009

Merge UserModel with Application Model

By Martin Praxmarer

Tired of making all DetailView Layout and ListView Layout in the ModelEditor instead at Runtime where you immediatly see the results?

The Solution is eXpands ModelDiffs Module.

Setup:

Create a new User and give it a name like “ModelAdmin”. Next Create a new Role “ModelAdmin Role” – and create a new Model Combine Permission. Set the Modifier to “Allow”, and set the Difference Name to the Name of your Application Model:

image

Now assign the created User to this new Role. Last step is to open the User Difference Model, and set the Model to “Non Persistent” since we dont want to save User changes here. Thats it.

Now you can start your Application, make changes in Detail- and ListViews, and when you exit the Application all changes are merged to the Model which you have defined in your Model Combine Permission!

Cool eh?

Technorati Tags:

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Wednesday, October 21, 2009

Yes Xaf can do it before lunch!!!

Maybe not with the build in modules and not exactly before lunch but the difference between traditional programming and Xafing is really great.

I am going to continue my posts on WorldCreator module and going to inform you about the progress up to here.

  • New persistent objects have been designed and added to eXpand.BaseImpl assembly in order module consumers to be able to change that implementation
  • The code that creates the Dynamic types and synchronies Xpo dictionary and model dictionary  at application startup is there as well
  • Sample application installation created and can be download, so I can get some feedback on it from anyone will play with it

Not Implemented
Create Dynamic types without restarting the application
Not tested for web 
Cannot create associations between Dynamic Types and existent types yet
Scripting not supported yet

Your feedback/help on this one is greatly appreciated

Download Sample Application file1 , file2

UserName:Sam
Pass: empty

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Xaf Tip #10 New DevExpress Xaf module

Today i ll reveal a big and mysterious secret. It seems that DevExpress has a new module that very few people know about it.

I happen to notice it when i try to run feature center demo, cause I have recompile my sources I got a compilation error (have not recompile the secret hidden module ImageSourceBrowser.Win that's why)

image

For you that do not have recompile your sources there is a new module waiting for you.

What it does?

Do not know :(.

I tried searching but nothing so better you ask DevExpress about it

Technorati Tags:

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Thursday, October 15, 2009

Sneak Peak: Dynamic Types with World Creator module

Dynamic Types is one of the most wanted feature in any framework. Luckily me I met Emilio DabDoub of Signia software and one of the Coordinators of XERP project and he hire me to port an old code that he had that could provide that feature and much more into xaf. Also he agreed to publish that module into eXpand.

Technorati Tags: ,

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Wednesday, October 14, 2009

Saving settings to database instead of cookies

 

THE PROBLEM –> HTTP 400 Bad Request (The data is invalid)

Xaf provides peristent of your web listview setting to cookies using Options | SaveListViewStateInCookies attribute in the Application Model. But due to the limit in request buffer size of IIS your web browser will receive a HTTP 400 Bad Request (The data is invalid) when you overcome it.

DevExrpess suggest you either persist individual listviews in order you never overcome that limit or as Microsoft also suggested here to add a registry value to raize that limit.

SOLUTION

ModelDifference module provides the Options | SaveListViewStateInDataStore that can persist your listview settings to your user model and thus to the database and since your model is persistent also at database

Technorati Tags: ,,

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Monday, October 12, 2009

DxCore addin to drop database at design time

When using ORM tools like XPO and even more when using application frameworks like Xaf since they create the database for you you often change your objects so much that you have to drop the database in order your ORM to create it again, in order to avoid any kind of conflict.

Tired of doing that I wrote a small DxCore addin and added to expand addins. To use it you have to configure it by telling which connection string will use from your application configuration file

 image

image

and bind the dropDatabase command to any shortcut key you like

image

eXpand is available at http://code.google.com/p/expandframework/

Technorati Tags: ,

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Thursday, October 8, 2009

One way associations

If you are tired of writing both parts of an association or if you want to add an association to an object that you do not own check eXpand’s ProvidedAssociation attribute.

Creating OneTo Many

public class Employee:BaseObject
{
    public Employee(Session session) : base(session)
    {
    }
    private EmplyoeeContract _EmplyoeeContract;
    [ProvidedAssociation]
    [Association("EmplyoeeContract-Employees")]
    public EmplyoeeContract EmplyoeeContract
    {
        get
        {
            return _EmplyoeeContract;
        }
        set
        {
            SetPropertyValue("EmplyoeeContract", ref _EmplyoeeContract, value);
        }
    }
}

in the above code i have decorated EmplyoeeContract with ProvidedAssociation and that is the only needed to create an collection of Employess at EmplyoeeContract class for use in both runtime and designtime.

public class Employee:BaseObject
{
    public Employee(Session session) : base(session)
    {
    }
    [Association("Employee-EmplyoeeContracts")]
    [ProvidedAssociation]
    public XPCollection<EmplyoeeContract> EmplyoeeContracts
    {
        get
        {
            return GetCollection<EmplyoeeContract>("EmplyoeeContracts");
        }
    }
}

in the above code I decorate a colection thus saying to eXpand to create a reference object of type Employee at EmplyoeeContract type

Many To Many

public class Employee:BaseObject
{
    public Employee(Session session) : base(session)
    {
    }
    [Association("Employee-EmplyoeeContracts")]
    [ProvidedAssociation(RelationType.ManyToMany)]
    public XPCollection<EmplyoeeContract> EmplyoeeContracts
    {
        get
        {
            return GetCollection<EmplyoeeContract>("EmplyoeeContracts");
        }
    }
}

to make that happen just used RelationType.ManyToMany with ProvidedAssociation

What about adding more attributes to the other type than the Association attribute?

for eg how about making in the first example to make the collection of the other part aggregated?

public class Employee:BaseObject
{
    public Employee(Session session) : base(session)
    {
    }
    
    public static IEnumerable<Attribute> MoreAttributes
    {
        get { yield return new AggregatedAttribute(); }
    }
    
    private EmplyoeeContract _EmplyoeeContract;
    [ProvidedAssociation("Employees",RelationType.Undefined, "MoreAttributes")]
    [Association("EmplyoeeContract-Employees")]
    public EmplyoeeContract EmplyoeeContract
    {
        get
        {
            return _EmplyoeeContract;
        }
        set
        {
            SetPropertyValue("EmplyoeeContract", ref _EmplyoeeContract, value);
        }
    }
}
ps: In order ProvidedAssociation to do its magic you have to use eXpand.ExpressApp.dll
image

see also : How to get eXpand latest version

Technorati Tags: ,

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Wednesday, October 7, 2009

ModelDifference Module

DictionaryDifferenceStore has been refactored and added the following features

  • Localization Support
  • Multiple application support
  • Ability to change application model without restarting
  • User,Role differences for web and win environments
  • Persist web settings instead of cookies to the database
  • Ability to work as a standalone module without  having to inherit eXpand.ExpressApp.Win.WinComponent/WebComponent as you saw in previous videos

Martin Praxmarer provided great help in that refactoring and I am going to host him here to speak on some of the above subjects and I ll speak on the rest

Here are the issues implemented / fixed issues

see also:How to get eXpand latest version

Technorati Tags: ,

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Monday, October 5, 2009

How to get eXpand latest version

I have some bad and some good news.

The bad first, until we manage to have full continuous integration in order eXpand new features to be immediately available (nightly builds) we are not going to make any more releases. eXpand release policy will be the same as DevExpress that is we make a release exactly after DevExpress

And now for the good. eXpand will provide build scripts that you can use them to compile the source code. The trunk of source code will contain the most current work.

So you first download the code by going to http://github.com/eXpand/eXpand 

image

and along with the code a set of batch files will be downloaded.

image

You just double click at buildall.bat and eXpand will be compiled and register to the gac. To unregister it use the clear.bat.

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Thursday, October 1, 2009

Free Microsoft Visual Studio, SQL Server, Windows Server and more

 

  1. Your company builds web sites and web application on behalf of others.
  2. Your company currently has less than 10 employees.

THEN THE FOLLOWING IS GIVEN FOR FREE TO YOU

  • 3 licenses of Visual Studio 2008 Professional Edition
  • 1 license of Expression Studio 3 (which includes Expression Blend, Sketchflow, and Web)
  • 2 licenses of Expression Web 3
  • 4 processor licenses of Windows Web Server 2008 R2
  • 4 processor licenses of SQL Server 2008 Web Edition
  • DotNetPanel control panel (enabling easy remote/hosted management of your servers)

 

VERY VERY COOL anoucement today by ScottGu as part of the WebsiteSpark program

Technorati Tags: ,

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Sunday, September 27, 2009

BDD in a few hours

What is all that fuzz about BDD? BDD stands for behavior driver design and its about learning to pass the knowledge that you have as a developer to your clients cause as everyone can understand that there is no value if you and your application can do amazing things if your clients have no idea on it.

I am not going to tell you more on that but I am going to provide a series of link of people that speak on both subjects

  • 1st of all you should listen to this great podcast that will explain to you the differences of BDD with TDD and why you should follow that process. Its a long one but I found it very very interesting
Scott Bellware on BDD and Lean Development

Smart and experienced guys in the above podbast eh ? ok after watching the above I am pretty sure that you are convinced that this is the way. Basically it told you what I have stated with bold at the beginning. So where to start what tools to use?.

 

  • then you should watch Rob Conery presenting MSpec here Download it here plus read those 2 posts of him
Learning Behavior Driven Development (BDD)
Make BDD Your BFF

My choise after reading those whould be to go with MSpec and if you want to ease the migration to the new BDD style for your existing TDD proccess better have a look at this series of posts BDD from scratch

I hope you find the above resources enough convincing to get you started on your BDD journey.

ps:If you try MSpec approach on x64 machine in order to integrate TestDriven with MSpec you should change the installation registry file to the following

Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Wow6432Node\MutantDesign\TestDriven.NET\TestRunners\MSpec]
"Application"=""
"AssemblyPath"="[YOURDOWNLOADPATH]\\MSpec\\Build\\Debug\\Machine.Specifications.TDNetRunner.dll"
"TargetFrameworkAssemblyName"="Machine.Specifications"
"TypeName"="Machine.Specifications.TDNetRunner.SpecificationRunner"
@="5"


Technorati Tags: ,,,

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Thursday, September 24, 2009

Xaf Tip # 7 Dangerous Switch

My good friend Martin Praxmarer while we are working on some cool feature for the new ModelDifference eXpand module pointed out the existence of an evil switch

Suppose your team is responsible for creating a module with some kind of Permission so when the system is granted that permission a block of code will be executed, something like

if (SecuritySystem.IsGranted(new MyPermission())){
    //do something

}

and then you pass your module to another team or another consumer and he decides to use the “EVIL ONE” property that is exposed by DevExpress.ExpressApp.Security.SecurityBase class is name IsGrantedForNonExistentPermission and can be changed easily as shown in the next image

image

What it does? As its name states inverse the behavior of the SecuritySystem.IsGranted method.
Default values for SecurityComplex is false but if the consumer of your module set it to true for his own reasons and you have not assign that permission to any role then unwanted code will be executed at your module which is very very very bad. In the scenario we are working on it will corrupt the model!!

So you have to be careful when you write code that uses the IsGranted method cause someone may inverse that behavior

A solution will be to create your own IsGranted method when you do not want that to happen like

public bool IsGranted(IPermission permission){            
    var securityComplex = ((SecurityComplex) SecuritySystem.Instance);
    bool isGrantedForNonExistentPermission = securityComplex.IsGrantedForNonExistentPermission;
    securityComplex.IsGrantedForNonExistentPermission = false;
    bool granted = SecuritySystem.IsGranted(permission);
    securityComplex.IsGrantedForNonExistentPermission=isGrantedForNonExistentPermission;
    return granted;
}

see you at next tip

Technorati Tags: ,,

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Monday, September 21, 2009

How to zero your application startup time

For this question don’t we all of us spend a lot of time ? But I think it is allowed to use a trick to spend our selves that time.

Add to your model to attributes NotifyIcon, MinimizeOnClose. Since I am using Xaf I am going to present that with it but the code should be very similar to any other windows application

so here are our attributes

image

NotifyIcon: will add a tray icon for your app at the system tray with a context menu that will allow you to terminate your application and display it when you double click the icon

image

public partial class NotifyIconController : WindowController

{

    public const string NotifyIconAttributeName = "NotifyIcon";

    public NotifyIconController()

    {

        InitializeComponent();

        RegisterActions(components);

    }

    protected override void OnFrameAssigned()

    {

        base.OnFrameAssigned();

        Frame.TemplateChanged+=FrameOnTemplateChanged;

 

    }

 

    private void FrameOnTemplateChanged(object sender, EventArgs args){

        if (Frame.Context == TemplateContext.ApplicationWindow && Application.Info.GetChildNode("Options").GetAttributeBoolValue(NotifyIconAttributeName))

        {

            var form = Frame.Template as XtraForm;

            if (form != null)

            {

                IContainer  container=new Container();

 

                var strip = new ContextMenuStrip(container);

                strip.Items.Add(GetMenuItem("Maximize",(o,eventArgs) => changeFormVisibility(form)));

                strip.Items.Add(GetMenuItem("Minimize",(o,eventArgs) => changeFormVisibility(form)));

                if (Application is ILogOut)

                    strip.Items.Add(GetMenuItem("LogOut", (o, eventArgs) => ((ILogOut) Application).Logout()));

                strip.Items.Add(GetMenuItem("Exit", (o, eventArgs) => Application.Exit()));

 

                var notifyIcon1 = new NotifyIcon(container){Visible = true, ContextMenuStrip = strip};

                setIcon(notifyIcon1);

                notifyIcon1.DoubleClick += (o, eventArgs) => changeFormVisibility(form);

            }

        }

    }

 

    private ToolStripMenuItem GetMenuItem(string text, EventHandler clickHandler){

        var item = new ToolStripMenuItem(text);

        item.Click+=clickHandler;

        return item;

    }

 

 

    private void changeFormVisibility(XtraForm form){

        if (form.Visible)

            form.Hide();

        else

            form.Show();

    }

 

    private void setIcon(NotifyIcon notifyIcon1){

        string path = Path.Combine(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath),"ExpressApp.ico");

        if (File.Exists(path))

            notifyIcon1.Icon=new Icon(path);

        else{

            Stream resourceStream = typeof(eXpandSystemModule).Assembly.GetManifestResourceStream("eXpand.ExpressApp.Resources.ExpressApp.ico");

            if (resourceStream != null) notifyIcon1.Icon = new Icon(resourceStream);

        }

    }

 

 

    public override Schema GetSchema()

    {

        const string CommonTypeInfos = @"<Element Name=""Application"">

                                            <Element Name=""Options"">

                                                <Attribute Name=""" +NotifyIconAttributeName+ @""" Choice=""False,True""/>

                                            </Element>

                                        </Element>";

        return new Schema(new DictionaryXmlReader().ReadFromString(CommonTypeInfos));

    }

 

}

MinimizeOnClose: attribute will prevent your application from closing

public partial class MinimizeOnCloseController : WindowController

{

    private static bool editing;

    public const string MinimizeOnCloseAttributeName = "MinimizeOnClose";

    public MinimizeOnCloseController()

    {

        InitializeComponent();

        RegisterActions(components);

    }

    protected override void OnFrameAssigned()

    {

        base.OnFrameAssigned();

        Frame.TemplateChanged += FrameOnTemplateChanged;

    }

 

    private void FrameOnTemplateChanged(object sender, EventArgs args)

    {

        if (Frame.Context == TemplateContext.ApplicationWindow &&

            Application.Info.GetChildNode("Options").GetAttributeBoolValue(MinimizeOnCloseAttributeName)){

            var form = Frame.Template as XtraForm;

            if (form != null){

                form.FormClosing += FormOnFormClosing;

                SimpleAction action =

                Frame.GetController<DevExpress.ExpressApp.Win.SystemModule.EditModelController>().Action;

                action.Executing+=(o,eventArgs) =>  editing = true;

                action.ExecuteCompleted += (o, eventArgs) => editing = false;

            }

        }

    }

 

    private void FormOnFormClosing(object sender, FormClosingEventArgs e){

        if (!editing && e.CloseReason == CloseReason.UserClosing)

        {

            if (Application != null) e.Cancel = Application.Model.RootNode.GetAttributeBoolValue(MinimizeOnCloseAttributeName, true);

            if (e.Cancel)

                ((XtraForm)sender).Hide();

        }

    }

 

 

    public override Schema GetSchema()

    {

        const string CommonTypeInfos = @"<Element Name=""Application"">

                                            <Element Name=""Options"">

                                                <Attribute Name=""" + MinimizeOnCloseAttributeName + @""" Choice=""False,True""/>

                                            </Element>

                                        </Element>";

        return new Schema(new DictionaryXmlReader().ReadFromString(CommonTypeInfos));

    }

 

}

Now your application never closes and user can display its UI instantaneously but just double clicking the tray icon

Those 2 controllers are already at eXpand and in next version i think i add a LoadWithWindows attribute that will zero my application load time

Technorati Tags: ,,,

Subscribe to XAF feed
Subscribe to community feed

DiggIt!