Hashing Algorithms

by abidins 21. October 2011 16:48

We never keep our confidential information or passwords in open format. That would be very risky, as it might be stolen by someone else. How do we keep our confidential information safe? The best and the easiest way to keep it safe is using some hashing algorithms. In .net, there are couple of hashing algorithms.

- MD5

- SHA1

- SHA256

- SHA384

- SHA512

Let s write a sample application to test these hashing algorithms

 

 

 

And the output of the program is as follows;

 

Tags:

Overview of MVVM(Model-View-ViewModel) Model

by abidins 8. August 2011 12:52

Maintainability, Scalability and extensibility  are 3 most important things when you develop an application. Software development team usually composed of at least 2-3 people and most of the time the code has been written exceeds couple of thousands of lines. Because of that, each team member has to agree upon some common rules and restrictions over the project. So, developers will provide a common solution if they face any problem during the development instead of providing a specific solution for his/her part. In order to make it easier, there are some software design patterns that have been proved as best solution can be used. MVVM model is one of those software design patterrns which provides the 3 most important things that we have mentioned above specifically in WPF and Silverlight applications. It was created by John Gossman and it can be thought as a variation of MVC pattern.

MVVM model aims to provide seperating UI elements (UserControl, Page, Control, Window etc.) and related code in code-behind file from each other. In traditional UI programming, the logic belongs to the UI element usually resides in code-behind file.On the other hand,in MVVM model, this will not be the case. The goal is to clear the logic from code-behind file.

View: UI Element in the program is called View in this model and View can be Silverlight Page, User Control, Window, Data Template etc. Why it is called View? because it always displays something when the program runs.

ViewModel: This is the type that contains all the business logic for the View. Shortly, it provides a connection between view and model and keeps the states. View Model Philosophy aims "In this class, just code the business logic without thinking about the controllers"

Model: Model is data that we will use in the application. Data can be an entity returned from WCF RIA services or POCO objects.

View knows about ViewModel but ViewModel does not know about View.

We can say that view knows everything about ViewModel Because elements in UI will be bind to member in view model but ViewModel cannot reach View at all.

ViewModel knows about Model but Model does not know about ViewModel

View Model is able to reach a member of a class and use it but there is no code in model related with view model.

Advantages of MVVM

- Developer gains an ability and discipline to focus on business logic

- There is no need to change anything in ViewModel unless the business logic is changed. It does not matter that any input-output element in view has been changed.

- Blendability of View is increased so that Expression Blend ability is better.

- Binding in XML is easier to controllers. Data Binding in code file will be easier without repating the same code in different places.

- Because the business logic is independent from UI, testing the software is much easier.

- MVVM makes the designer and developer working synchronously and efficiently in the same project.

 

Tags:

Named Update in WCF RIA Services

by abidins 12. July 2011 12:05
Domain services are Windows Communication Foundation (WCF) services that encapsulate the business logic of a WCF RIA Services application. A domain service exposes a set of related operations in the form of a service layer. When you define a domain service, you specify the data operations that are permitted through the domain service.
When designing a domain service, you should think of the domain service as a set of related tasks that you expect users to perform in your application. Typically, such tasks involve a small group of closely-related entities. For example, in an expense reporting application, you might expose entities for expense reports, line items, and details. You might, then, place entities for accounts and payments in a separate domain service[1].
Data Operations
You may add different data methods to a domain service that you want to expose like Query, Insert, Update, Delete. Besides these methods, you can also add more complicated operations, Invoke, Named Update. Named Update is to implement custom operations that do not fall into simple modification operations.
Convention
If you want to write a simple update method for ,lets say, Activity Entity, expected signature values should be as "public void UpdateActivity(Activity activity)".
It has to be like this for simple update operation for the Activity Entity. On the other hand, you can create an update method with different signature but some attribute has to be added to name of the update method. In that case, you dont have to follow the above convention. You can name your method as whatever you want. In below example, UsingCustomMethod attribute is set to true and as you noticed the name of the method is different.
 
And you can call this method in the code as follows;

So UsingCustomMethod attribute will give you the option to write more complicated operations.
References
 

How to Refresh User Control from another User Control in Silverlight

by abidins 10. May 2011 17:13

Refrehing the list or some other item in user control from child window is easy. All you need to do is wire up the child_closed event for child window and that s it. How about refreshing the list in another user control from this child window? There is no relation between the child window and the user control that we want to update. So, we cannot use child_closed event for that user control. Let s talk about the scenerio,

- Assigned Activites (User Control 1) , child window: CLM Activity

- Unassigned Activities (User Control 2)

- Activities ( User Control and it hosts UC1 and UC2)

What we want is, when we click ok button in "CLM Activity" child window, we will refresh UC1 and UC2.

- In Order to that,first, we ll define an event in assigned activities

- Then wire up this event to child window as follows. Child_Closed event is no longer need to be used

- Define OnPopupClosed event in assigned Activities user control. So, once the child window is closed, this event will be raised and Activities are refreshed in assigned activites screen.

- In Activities which is the host user control for the others, We ll wire up the same event handler for assigned activities.

- This event is also raised as well as OnPopupClosed event in Assigned Activities when the child windo is closed. RefreshSelf method refreshes the list in Unassigned Activities user control.

These are the steps to refresh the user control (unassigned activities ) from the other user control (assigned activities).

Adding a mouse over effect to an image

by abidins 18. April 2011 11:26

Expression Blend is a powerful tool. It will write the necessary code for you. It is very easy to add mouse over behavior to any kind of control with silverlight. In the below example, Our goal is to add "MouseOver" and "MouseLeave" behavior to an image. Here are the steps;

1.Write click over the file that you want to add behavior and select "Open in Expression blend..."

 

2.In the "States" tab of Expression Blend, click on "add states group" icon to create a visual state of the control.

3.Give a name to Visual State Group and specify the Default Transition

4. Click on Add State icon right next to Visual state group that you ve created and give a name to the state. If you notice, VisualState state recording is on. What ever the style you apply on the image is recorded in this period. When you done styling the image (ex: making the border thicker, making it invisible etc.) click on Base at the top to finish.

5. At the end we ll have two states defined (NormalSearch, MouseOverSearch)

6.Switch to Assets tab and in the Behaviors menu select "Go to State Action"

7. Drag and drop "Go to state action" over the image that you want to add behavior

8.Do the same thing for imgExpandHover image.

9.When [GoToStateAction] for imgExpand is selected go to properties at right side of the screen and select "MouseEnter" for event name and "MouseOverSearch" for State Name

10. For imgExpandHover  image,select "MouseLeave" as event name and "NormalSearch" for State Name

It will add all the necessary code automatically in .xaml file. We ve just created two states for two images. Initially, imgExpand is visible and imgExpandHover is invisible. In [GotoStateAction] part, events are defined for mouse enter and mouse leave behavior. What it does is, when you hover over the imgExpand, it ll be invisible and imgExpandHover image will be visible. When you do mouse leave from the image, imgExpand will be visible again and imgExpandHover will be invisible. imgExpandHover image has a border around it.So, when you mouse over the image you ll see that its border get thichker. That is basically what we wanted achieve.

Recent Posts