Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 2e9c43658e374d290a2de15d25134ac8 > files > 826

db4o-doc-8.0-1.fc15.i686.rpm

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="2" MadCap:lastHeight="120" MadCap:lastWidth="624" MadCap:disableMasterStylesheet="true" MadCap:tocPath="Platform Specific Issues" MadCap:InPreviewMode="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" MadCap:PathToHelpSystem="../../" MadCap:HelpSystemFileName="index.xml" MadCap:SearchType="Stem">
    <head><title>Silverlight</title>
        <script type="text/javascript">/* <![CDATA[ */
window.onload = function(){
	var pathToFlash = $('html').attr('MadCap:PathToHelpSystem') + 'Content/Resources/Code/ZeroClipboard.swf';
	ZeroClipboard.setMoviePath(pathToFlash);
			
	function bindToClipBord(element,content){
		var clip = new ZeroClipboard.Client();
		clip.setText(content);
		clip.glue(element);
	};
		
	if(location.protocol==='file:'){
		$('.copylink-marker').remove();
	} else{
			$('.copylink-marker').each(function(){
				var text = $(this).parent().parent().children('.prettyprint').html();
				$(this).hover(function(){
					bindToClipBord(this,text);
				},
				function(){});
			});	
	}		
	prettyPrint();	
};
                /* ]]> */</script>
        <link href="../SkinSupport/MadCap.css" rel="stylesheet" />
        <link href="../Resources/Stylesheets/OnlineStyle.css" rel="stylesheet" />
        <script src="../SkinSupport/MadCapAll.js">
        </script>
        <script src="../Resources/Code/prettify.js">
        </script>
        <script src="../Resources/Code/lang-vb.js">
        </script>
        <script src="../Resources/Code/jquery.min.js">
        </script>
        <script src="../Resources/Code/ZeroClipboard.js">
        </script>
    </head>
    <body>
        <p class="MCWebHelpFramesetLink" style="display: none;"><a href="../../index_CSH.html#platform_specific_issues/silverlight.htm" style="">Open topic with navigation</a>
        </p>
        <div class="MCBreadcrumbsBox"><span class="MCBreadcrumbsPrefix">You are here: </span><a class="MCBreadcrumbsLink" href="../platform_specific_issues.htm">Platform Specific Issues</a><span class="MCBreadcrumbsDivider"> &gt; </span><span class="MCBreadcrumbs">Silverlight</span>
        </div>
        <p>
            <script type="text/javascript">/*<![CDATA[*/document.write('<a href="' + location.href +'">');
				document.write("Direct Link");
			document.write('</a>');/*]]>*/</script>
        </p>
        <p>
        </p>
        <h1><a name="kanchor110"></a>Silverlight</h1>
        <p>db4o runs with some limitations on Microsoft's Silverlight. You can find the Silverlight assemblies in the db4o distribution, in the folder 'bin/silverlight'. </p>
        <h2>Feature Set</h2>
        <p>Currently only the core functionality is supported on Silverlight. The db4o core and the db4o LINQ provider run on Silverlight. Other features like the client-server mode are not supported. </p>
        <h2>Add Silverlight Support</h2>
        <p>To run db4o on Silverlight you need to use the Silverlight assemblies which are in the db4o distribution. Additionally you need to configure the Silverlight support in the db4o configuration. This also configured the <a href="#Isolated">isolated storage</a>. </p>
        <div class="codesnippet" MadCap:conditions="Primary.c#">
            <pre class="prettyprint" xml:space="preserve">IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration();
configuration.AddConfigurationItem(new SilverlightSupport());

IObjectContainer container = Db4oEmbedded.OpenFile(configuration, "database.db4o");</pre>
            <div class="codesnippet-meta">IOExamples.cs: Add Silverlight support
			<div class="codedownload"><a href="../CodeExamples/silverlight/configuration/io/Example-configuration-io-csharp.zip" class="codedownload" MadCap:conditions="Primary.Online">Download Code</a></div><div class="codedownload copylink-marker" MadCap:conditions="Primary.Online"><a href="#copy">Copy Code</a></div></div>
        </div>
        <div class="codesnippet" MadCap:conditions="Primary.VB.NET">
            <pre class="prettyprint lang-vb" MadCap:conditions="Primary.Online" xml:space="preserve">Dim configuration As IEmbeddedConfiguration = Db4oEmbedded.NewConfiguration()
configuration.AddConfigurationItem(New SilverlightSupport())

Dim container As IObjectContainer = Db4oEmbedded.OpenFile(configuration, "database.db4o")</pre>
            <div class="codesnippet-meta">IOExamples.vb: Add Silverlight support
			<div class="codedownload"><a href="../CodeExamples/silverlight/configuration/io/Example-configuration-io-vb.zip" class="codedownload" MadCap:conditions="Primary.Online">Download Code</a></div><div class="codedownload copylink-marker" MadCap:conditions="Primary.Online"><a href="#copy">Copy Code</a></div></div>
        </div>
        <h2>Persistent Object Limitations</h2>
        <p>Due to the restrictions of the Silverlight sandbox, it's impossible to inspect the private fields of an object. This means that the field of persistent objects need to be public!</p>
        <p>Also auto-properties cannot be stored. Auto properties use a regular, compiler generated private field to hold the data. Since db4o cannot access private fields, it also cannot access the data of auto-properties.</p>
        <div class="codesnippet" MadCap:conditions="Primary.c#">
            <pre class="prettyprint" xml:space="preserve">public class Person
{
    public string FirstName;
    public string SirName;
}</pre>
            <div class="codesnippet-meta">Person.cs: fields need to be public to be persisted
			<div class="codedownload"><a href="../CodeExamples/silverlight/model/Example-silverlight-model-csharp.zip" class="codedownload" MadCap:conditions="Primary.Online">Download Code</a></div><div class="codedownload copylink-marker" MadCap:conditions="Primary.Online"><a href="#copy">Copy Code</a></div></div>
        </div>
        <div class="codesnippet" MadCap:conditions="Primary.VB.NET">
            <pre class="prettyprint lang-vb" MadCap:conditions="Primary.Online" xml:space="preserve">Public Class Person
    Public FirstName As String
    Public SirName As String
End Class</pre>
            <div class="codesnippet-meta">Person.vb: fields need to be public to be persisted
			<div class="codedownload"><a href="../CodeExamples/silverlight/model/Example-silverlight-model-vb.zip" class="codedownload" MadCap:conditions="Primary.Online">Download Code</a></div><div class="codedownload copylink-marker" MadCap:conditions="Primary.Online"><a href="#copy">Copy Code</a></div></div>
        </div>
        <h2>Queries</h2>
        <p>You can use <a href="../basics/querying/linq.htm">LINQ</a> to query your objects in Silverlight. Note that the Silverlight version uses the Mono.Cecil.dll and the Cecil.FlowAnalysis.dll assembly for the LINQ-implementation. </p>
        <div class="codesnippet" MadCap:conditions="Primary.c#">
            <pre class="prettyprint" xml:space="preserve">var persons = from Person p in container
              where p.FirstName.Contains("Roman")
              select p;

foreach (Person person in persons)
{
    // do something with the person
}</pre>
            <div class="codesnippet-meta">QueriesInSilverlight.cs: Queries in Silverlight
			<div class="codedownload"><a href="../CodeExamples/silverlight/model/Example-silverlight-model-csharp.zip" class="codedownload" MadCap:conditions="Primary.Online">Download Code</a></div><div class="codedownload copylink-marker" MadCap:conditions="Primary.Online"><a href="#copy">Copy Code</a></div></div>
        </div>
        <div class="codesnippet" MadCap:conditions="Primary.VB.NET">
            <pre class="prettyprint lang-vb" MadCap:conditions="Primary.Online" xml:space="preserve">Dim persons = From p As Person In container _
              Where p.FirstName.Contains("Roman") _
              Select p
For Each p As Person In persons
    ' do something with the person
Next</pre>
            <div class="codesnippet-meta">QueriesInSilverlight.vb: Queries in Silverlight
			<div class="codedownload"><a href="../CodeExamples/silverlight/model/Example-silverlight-model-vb.zip" class="codedownload" MadCap:conditions="Primary.Online">Download Code</a></div><div class="codedownload copylink-marker" MadCap:conditions="Primary.Online"><a href="#copy">Copy Code</a></div></div>
        </div>
        <h2><a name="Isolated"></a>Isolated Storage</h2>
        <p>By default you cannot access the file system in Silverlight, but only a special isolated storage. Therefore you need to use the isolated storage when you're configuring the IO system. By default this storage is limited to 1 MByte of data. You <a href="http://msdn.microsoft.com/en-us/library/system.io.isolatedstorage.isolatedstoragefile.increasequotato(v=VS.95).aspx">can increase it with</a> the users consent.</p>
        <p>When the Silverlight application runs outside the browser with enough privileges you can use the regular storage. However by default the isolated storage should be used.</p>
        <div class="codesnippet" MadCap:conditions="Primary.c#">
            <pre class="prettyprint" xml:space="preserve">IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration();
configuration.File.<span class="MCPopup"><a href="javascript:void(0);" class="MCPopupSpot" onclick="FMCPopup( event, this ); return false;" MadCap:src="../configuration/file/storage.htm">Storage<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" class="MCExpandingIcon" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" /></a></span> = new IsolatedStorageStorage();

IObjectContainer container = Db4oEmbedded.OpenFile(configuration, "database.db4o");</pre>
            <div class="codesnippet-meta">IOExamples.cs: use the isolated storage on silverlight
			<div class="codedownload"><a href="../CodeExamples/silverlight/configuration/io/Example-configuration-io-csharp.zip" class="codedownload" MadCap:conditions="Primary.Online">Download Code</a></div><div class="codedownload copylink-marker" MadCap:conditions="Primary.Online"><a href="#copy">Copy Code</a></div></div>
        </div>
        <div class="codesnippet" MadCap:conditions="Primary.VB.NET">
            <pre class="prettyprint lang-vb" MadCap:conditions="Primary.Online" xml:space="preserve">Dim configuration As IEmbeddedConfiguration = Db4oEmbedded.NewConfiguration()
configuration.File.Storage = New IsolatedStorageStorage()

Dim container As IObjectContainer = Db4oEmbedded.OpenFile(configuration, "database.db4o")</pre>
            <div class="codesnippet-meta">IOExamples.vb: use the isolated storage on silverlight
			<div class="codedownload"><a href="../CodeExamples/silverlight/configuration/io/Example-configuration-io-vb.zip" class="codedownload" MadCap:conditions="Primary.Online">Download Code</a></div><div class="codedownload copylink-marker" MadCap:conditions="Primary.Online"><a href="#copy">Copy Code</a></div></div>
        </div>
        <script type="text/javascript" src="../SkinSupport/MadCapBodyEnd.js">
        </script>
    </body>
</html>