Sophie

Sophie

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

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="Basics Operations &amp; Concepts|Activation|Transparent Activation|Collections" MadCap:InPreviewMode="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" MadCap:PathToHelpSystem="../../../../../" MadCap:HelpSystemFileName="index.xml" MadCap:SearchType="Stem">
    <head><title>Enhance Collections</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#basics/activation_concept/transparent_activation_framework/collections/enhance_collections.htm" style="">Open topic with navigation</a>
        </p>
        <div class="MCBreadcrumbsBox"><span class="MCBreadcrumbsPrefix">You are here: </span><a class="MCBreadcrumbsLink" href="../../../../basics.htm">Basics Operations &amp; Concepts</a><span class="MCBreadcrumbsDivider"> &gt; </span><a class="MCBreadcrumbsLink" href="../../../activation.htm">Activation</a><span class="MCBreadcrumbsDivider"> &gt; </span><a class="MCBreadcrumbsLink" href="../../transparent_activation_framework.htm">Transparent Activation</a><span class="MCBreadcrumbsDivider"> &gt; </span><span class="MCBreadcrumbs">Enhance Collections</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>Enhance Collections</h1>
        <p>You can use the normal <span class="PrimaryPlattform">.NET</span>-collections in your code and then replace the implementations with the enhancement-tools. <a href="../ta_enhanced_example.htm" target="" title="" alt="" class="MCXref">See "TA Enhanced Example"</a></p>
        <p>The enhancement tools will search for instantiations of collections and replace it with an appropriate transparent activation aware collection. </p>
        <div MadCap:conditions="Primary..NET">
            <p>However this has some implications. The original collection-classes are all sealed and not designed for extension. This means that a complete different implementation is used and has consequences.</p>
            <h2>Can Be Enhanced: When Using Interfaces In Declaration</h2>
            <p>The best case is when collection-interface is used, like IList instead of the concrete class. For example a field-declaration like this:</p>
            <div class="codesnippet" MadCap:conditions="Primary.c#">
                <pre class="prettyprint" xml:space="preserve">public class CanBeEnhanced
{
    private IList&lt;string&gt; _names = new List&lt;string&gt;();

    public bool ContainsName(string item)
    {
        return _names.Contains(item);
    }

    public void AddName(string item)
    {
        _names.Add(item);
    }
}</pre>
                <div class="codesnippet-meta">EnhancementLimitations.cs: Can be enhanced by the db4o-tools
			<div class="codedownload"><a href="../../../../CodeExamples/ta/collectionEnhanceIssues/Example-ta-collectionEnhanceIssues-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 CanBeEnhanced
    Private _names As IList(Of String) = New List(Of String)()

    Public Function ContainsName(ByVal item As String) As Boolean
        Return _names.Contains(item)
    End Function

    Public Sub AddName(ByVal item As String)
        _names.Add(item)
    End Sub
End Class</pre>
                <div class="codesnippet-meta">EnhancementLimitations.vb: Can be enhanced by the db4o-tools
			<div class="codedownload"><a href="../../../../CodeExamples/ta/collectionEnhanceIssues/Example-ta-collectionEnhanceIssues-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>
            <p>Are correctly translated by the enhancement tools to:</p>
            <div class="codesnippet" MadCap:conditions="Primary.c#">
                <pre class="prettyprint" xml:space="preserve">public class CanBeEnhanced
{
    private IList&lt;string&gt; _names = new ActivatableList&lt;string&gt;();

    public bool ContainsName(string item)
    {
        return _names.Contains(item);
    }

    public void AddName(string item)
    {
        _names.Add(item);
    }
}</pre>
                <div class="codesnippet-meta">EnhancementLimitations.cs: Is enhanced to
			<div class="codedownload"><a href="../../../../CodeExamples/ta/collectionEnhanceIssues/Example-ta-collectionEnhanceIssues-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 CanBeEnhanced
    Private _names As IList(Of String) = New ActivatableList(Of String)()

    Public Function ContainsName(ByVal item As String) As Boolean
        Return _names.Contains(item)
    End Function

    Public Sub AddName(ByVal item As String)
        _names.Add(item)
    End Sub
End Class</pre>
                <div class="codesnippet-meta">EnhancementLimitations.vb: Is enhanced to
			<div class="codedownload"><a href="../../../../CodeExamples/ta/collectionEnhanceIssues/Example-ta-collectionEnhanceIssues-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>Cannot Be Enhanced: When Using Concrete Class  In Declaration</h2>
            <p>When you use the concrete types in field declarations, the enhancer-tools will produce a warning and doesn't change the implementation. The example below cannot be enhanced, because it uses the concrete type.</p>
            <div class="codesnippet" MadCap:conditions="Primary.c#">
                <pre class="prettyprint" xml:space="preserve">public class CannotBeEnhanced
{
    // cannot be enhanced, because it uses the concrete type
    private List&lt;string&gt; _names = new List&lt;string&gt;();

    public bool ContainsName(string item)
    {
        return _names.Contains(item);
    }

    public void AddName(string item)
    {
        _names.Add(item);
    }
}</pre>
                <div class="codesnippet-meta">EnhancementLimitations.cs: Cannot be enhanced by the db4o-tools
			<div class="codedownload"><a href="../../../../CodeExamples/ta/collectionEnhanceIssues/Example-ta-collectionEnhanceIssues-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 CannotBeEnhanced
    ' cannot be enhanced, because it uses the concrete type
    Private _names As New List(Of String)()

    Public Function ContainsName(ByVal item As String) As Boolean
        Return _names.Contains(item)
    End Function

    Public Sub AddName(ByVal item As String)
        _names.Add(item)
    End Sub
End Class</pre>
                <div class="codesnippet-meta">EnhancementLimitations.vb: Cannot be enhanced by the db4o-tools
			<div class="codedownload"><a href="../../../../CodeExamples/ta/collectionEnhanceIssues/Example-ta-collectionEnhanceIssues-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>Casts are dangerous</h2>
            <p>The enhancement tools replace the implementation of collections. When you code has an assumptions about the concrete types and tries to cast, it may fail. In general try to avoid casting to concrete types and use interfaces instead.</p>
        </div>
        <script type="text/javascript" src="../../../../SkinSupport/MadCapBodyEnd.js">
        </script>
    </body>
</html>