Click here to Skip to main content
15,891,657 members
Articles / Web Development / ASP.NET

Signum Framework Principles

Rate me:
Please Sign up or sign in to vote.
4.74/5 (27 votes)
25 Jul 2011CPOL18 min read 99.3K   1.1K   86  
Explains the philosophy behind Signum Framework, an ORM with a full LINQ Provider that encourages an entities-first approach.
using System;
using System.IO;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using Signum.Utilities.DataStructures;

namespace Signum.Windows
{
	public partial class EntityButtons
	{
        public static readonly DependencyProperty OrientationProperty =
            DependencyProperty.Register("Orientation", typeof(Orientation), typeof(EntityButtons), new UIPropertyMetadata(Orientation.Horizontal));
        public Orientation Orientation
        {
            get { return (Orientation)GetValue(OrientationProperty); }
            set { SetValue(OrientationProperty, value); }
        }

        public static readonly DependencyProperty CreateProperty =
       DependencyProperty.Register("Create", typeof(bool), typeof(EntityButtons), new UIPropertyMetadata(true));
        public bool Create
        {
            get { return (bool)GetValue(CreateProperty); }
            set { SetValue(CreateProperty, value); }
        }

        public static readonly DependencyProperty ViewProperty =
            DependencyProperty.Register("View", typeof(bool), typeof(EntityButtons), new UIPropertyMetadata(true));
        public bool View
        {
            get { return (bool)GetValue(ViewProperty); }
            set { SetValue(ViewProperty, value); }
        }

        public static readonly DependencyProperty FindProperty =
            DependencyProperty.Register("Find", typeof(bool), typeof(EntityButtons), new UIPropertyMetadata(true));
        public bool Find
        {
            get { return (bool)GetValue(FindProperty); }
            set { SetValue(FindProperty, value); }
        }

        public static readonly DependencyProperty RemoveProperty =
            DependencyProperty.Register("Remove", typeof(bool), typeof(EntityButtons), new UIPropertyMetadata(true));
        public bool Remove
        {
            get { return (bool)GetValue(RemoveProperty); }
            set { SetValue(RemoveProperty, value); }
        }


        public static readonly RoutedEvent CreatingEvent = EventManager.RegisterRoutedEvent(
            "Creating", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(EntityButtons));
        public event RoutedEventHandler Creating
        {
            add { AddHandler(CreatingEvent, value); }
            remove { RemoveHandler(CreatingEvent, value); }
        }

        public static readonly RoutedEvent ViewingEvent = EventManager.RegisterRoutedEvent(
            "Viewing", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(EntityButtons));
        public event RoutedEventHandler Viewing
        {
            add { AddHandler(ViewingEvent, value); }
            remove { RemoveHandler(ViewingEvent, value); }
        }

        public static readonly RoutedEvent FindingEvent = EventManager.RegisterRoutedEvent(
            "Finding", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(EntityButtons));
        public event RoutedEventHandler Finding
        {
            add { AddHandler(FindingEvent, value); }
            remove { RemoveHandler(FindingEvent, value); }
        }

        public static readonly RoutedEvent RemovingEvent = EventManager.RegisterRoutedEvent(
            "Removing", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(EntityButtons));
        public event RoutedEventHandler Removing
        {
            add { AddHandler(RemovingEvent, value); }
            remove { RemoveHandler(RemovingEvent, value); }
        }

		public EntityButtons()
		{
			this.InitializeComponent();
            AddHandler(Button.ClickEvent, new RoutedEventHandler(ButtonClick));  		
        }

        public void ButtonClick(object sender, RoutedEventArgs e)
        {
            Button bt = (Button)e.OriginalSource;
            if (bt == btCreate) RaiseEvent(new RoutedEventArgs(CreatingEvent));
            else if (bt == btView) RaiseEvent(new RoutedEventArgs(ViewingEvent));
            else if (bt == btFind) RaiseEvent(new RoutedEventArgs(FindingEvent));
            else if (bt == btRemove) RaiseEvent(new RoutedEventArgs(RemovingEvent));
            else throw new NotImplementedException();
            e.Handled = true; 
        }
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Signum Software
Spain Spain
I'm Computer Scientist, one of the founders of Signum Software, and the lead developer behind Signum Framework.

www.signumframework.com

I love programming in C#, Linq, Compilers, Algorithms, Functional Programming, Computer Graphics, Maths...

Comments and Discussions