Project Structure for EF / Silverlight Application

I am currently working on finding a good project structure for a three-level solution to avoid unnecessary work in a new project.

The project will consist of a core product that has

  • a model that contains the first EF code models.
  • which has business logic and server communication logic.
  • client repository project
  • silverlight project with views and overview models (would like to use caliburn.micro here)

The problem is that the client may have special requirements that can lead to changes in all of the above projects. So I thought that I could just use the basic structure and create the same structure for the client. If there are no changes, I would just have empty classes that simply extended the base class and didn't add anything.

This leads me to the following issues:

  • Is it a problem in the Entity Framework (code first) to have base classes in one project (which is already fully functional) and have another project that can extend model classes with a new field?
  • XAML ? , , , , .

, .

: , , .

Entity Framework:

, . , - :

public class CoreAddress{
  [Key]
  public int AdrId{get; set;}
  public string Street {get;set;}
}

public class CustomerAddress : CoreAddress{
  public string StreetNumber {get; set;}
}

, , - DbContext:

(this as IObjectContextAdapter).ObjectContext.MetadataWorkspace.LoadFromAssembly(typeof(<entity from other assembly>).Assembly);

XAML

XAML, Caliburn.Micro( MEF), .

UserControls, ContentControl, MEF. , ViewModels. - , ContentControl ViewModel ( , ). ViewModel ContentControl ExportMetadata, 1. UserControl, , , , .

:

:

<UserControl x:Class="SilverlightApplication5.TestView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot" Background="White">
        <StackPanel>
            <ContentControl x:Name="Item"/>
            <TextBox x:Name="TextItem" Text="asdf"/>
        </StackPanel>

    </Grid>
</UserControl>

public class TestViewModel : Screen
    {
        private object viewModel;
        private Lazy<IMyViewModel, IPluginMetadata>[] _orderEditorFactory;

        [ImportMany(typeof(IMyViewModel), AllowRecomposition = true)]
        public Lazy<IMyViewModel, IPluginMetadata>[] OrderEditorFactory
        {
            get { return _orderEditorFactory; }
            set
            {
                _orderEditorFactory = value;
                Item = _orderEditorFactory.OrderByDescending(lazy => lazy.Metadata.Priority).First().Value;

            }
        }
    private object _item;

        public object Item
        {
            get { return _item; }
            set
            {
                _item = value;
                NotifyOfPropertyChange(() => Item);
            }
        }
    }

:

<UserControl x:Class="SilverlightClassLibrary2.MainControlView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
    <StackPanel>
        <TextBlock x:Name="Test" Text="Text from Core control"/>
    </StackPanel>
</UserControl>

[Export(typeof (IMyViewModel))]
[ExportMetadata("Name", "Pluginc")]
[ExportMetadata("Priority", 30)]
public class MainControlViewModel : Screen, IHarnessAware, IMyViewModel
{

}

:

<UserControl x:Class="SilverlightClassLibrary1.CustomView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot" Background="White">
        <RadioButton x:Name="Test" Content="{Binding Path=Test}"/>
    </Grid>
</UserControl>

[Export(typeof(IMyViewModel))]
[ExportMetadata("Name", "Plugind")]
[ExportMetadata("Priority", 2)]
public class CustomViewModel : MainControlViewModel, IHarnessAware, IMyViewModel
{
}

:

public interface IMyViewModel
{

}

ExportMetadata:

   public interface 
        IPluginMetadata
    {
        string Name { get; }
        [DefaultValue(0)]
        int Priority { get; }
    }

, , , , , .

+3
1

: , . , , , ..

, , . , , .

, , , .

XAML: IMHO, , , , . , , .

0

All Articles