Desktop version

Nov 6, 2010 at 7:39 AM

Just for fun I ported it to the desktop in 5 minutes! :)
First I did a copy of the csproj (in the same directory so both project share same files) and tweaked it to target the client framework 

Then I to change "Database/BaseDatabaseInstance.cs" and "Database/LogManager.cs" not to use the dispatcher but intead call a new class "Dispatch" I wrote to call the dispatcher the same way on both WPF & Silverlight.

And.. it compiles!
(now I probably have to tweak it further as I want the DB to support normal files as well as IsolatedStorage on the desktop...)

 Dispatch.cs

using System;
using System.Windows;

namespace Wintellect.Sterling.Database
{
	class Dispatch
	{
		public static void Invoke(Action raise)
		{
#if SILVERLIGHT
            var dispatcher = Deployment.Current.Dispatcher;
#else
			var dispatcher = Application.Current.Dispatcher;
#endif
			if (dispatcher.CheckAccess())
			{
				raise();
			}
			else
			{
				dispatcher.BeginInvoke(raise);
			}
		}
	}
}

Lloyd.Sterling

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>9.0.30729</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{403E97AC-21A3-4B56-A946-221D4F5536B2}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>Wintellect.Sterling</RootNamespace>
    <AssemblyName>Wintellect.Sterling</AssemblyName>
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    <TargetFrameworkProfile>Client</TargetFrameworkProfile>
  </PropertyGroup>
  <!-- This property group is only here to support building this project using the 
       MSBuild 3.5 toolset. In order to work correctly with this older toolset, it needs 
       to set the TargetFrameworkVersion to v3.5 -->
  <PropertyGroup Condition="'$(MSBuildToolsVersion)' == '3.5'">
    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="mscorlib" />
    <Reference Include="PresentationFramework" />
    <Reference Include="system" />
    <Reference Include="System.Core" />
    <Reference Include="System.Xaml" />
    <Reference Include="System.Xml" />
    <Reference Include="System.Net" />
    <Reference Include="WindowsBase" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Database\BaseDatabaseInstance.cs" />
    <Compile Include="Database\Dispatch.cs" />
    <Compile Include="Database\Extensions.cs" />
    <Compile Include="Database\ITableDefinition.cs" />
    <Compile Include="Database\LogManager.cs" />
    <Compile Include="Database\TableDefinition.cs" />
    <Compile Include="Events\SterlingOperationArgs.cs" />
    <Compile Include="Exceptions\Exceptions.Designer.cs">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>Exceptions.resx</DependentUpon>
    </Compile>
    <Compile Include="Exceptions\SterlingActivationException.cs" />
    <Compile Include="Exceptions\SterlingDatabaseNotFoundException.cs" />
    <Compile Include="Exceptions\SterlingDuplicateDatabaseException.cs" />
    <Compile Include="Exceptions\SterlingDuplicateIndexException.cs" />
    <Compile Include="Exceptions\SterlingDuplicateTypeException.cs" />
    <Compile Include="Exceptions\SterlingIndexNotFoundException.cs" />
    <Compile Include="Exceptions\SterlingIsolatedStorageException.cs" />
    <Compile Include="Exceptions\SterlingLoggerNotFoundException.cs" />
    <Compile Include="Exceptions\SterlingNoTableDefinitionsException.cs" />
    <Compile Include="Exceptions\SterlingNotReadyException.cs" />
    <Compile Include="Exceptions\SterlingNullException.cs" />
    <Compile Include="Exceptions\SterlingSerializerException.cs" />
    <Compile Include="Exceptions\SterlingTableNotFoundException.cs" />
    <Compile Include="Indexes\IIndexCollection.cs" />
    <Compile Include="Indexes\IndexCollection.cs" />
    <Compile Include="Indexes\IndexCollection2.cs" />
    <Compile Include="Indexes\TableIndex.cs" />
    <Compile Include="Indexes\TableIndex2.cs" />
    <Compile Include="IsolatedStorage\IsoStorageHelper.cs" />
    <Compile Include="IsolatedStorage\PathProvider.cs" />
    <Compile Include="ISterlingDatabase.cs" />
    <Compile Include="Database\SterlingDatabase.cs" />
    <Compile Include="ISterlingDatabaseInstance.cs" />
    <Compile Include="ISterlingLock.cs" />
    <Compile Include="Keys\IKeyCollection.cs" />
    <Compile Include="Keys\KeyCollection.cs" />
    <Compile Include="Keys\TableKey.cs" />
    <Compile Include="Serialization\AggregateSerializer.cs" />
    <Compile Include="Serialization\BaseSerializer.cs" />
    <Compile Include="Serialization\DefaultSerializer.cs" />
    <Compile Include="Serialization\ExtendedSerializer.cs" />
    <Compile Include="Serialization\ISterlingSerializer.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    <Compile Include="Serialization\SerializationCache.cs" />
    <Compile Include="Serialization\SerializationHelper.cs" />
    <Compile Include="SterlingDefaultLogger.cs" />
    <Compile Include="SterlingEngine.cs" />
    <Compile Include="SterlingFactory.cs" />
    <Compile Include="SterlingLogLevel.cs" />
    <Compile Include="Events\SterlingOperation.cs" />
  </ItemGroup>
  <ItemGroup />
  <ItemGroup>
    <EmbeddedResource Include="Exceptions\Exceptions.resx">
      <Generator>PublicResXFileCodeGenerator</Generator>
      <LastGenOutput>Exceptions.Designer.cs</LastGenOutput>
    </EmbeddedResource>
  </ItemGroup>
  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>