[fdo-trac] #690: Use generic collection interfaces for managed
collections
FDO
trac_fdo at osgeo.org
Wed Sep 8 03:26:41 EDT 2010
#690: Use generic collection interfaces for managed collections
---------------------------+------------------------------------------------
Reporter: jng | Owner: gregboone
Type: enhancement | Status: new
Priority: major | Milestone: 3.6.0
Component: FDO API | Version:
Severity: 3 | Keywords:
External_id: |
---------------------------+------------------------------------------------
Most (all?) collection classes in the current .net wrapper API inherit
from {{{CollectionBase}}} which implements the untyped
{{{System.Collections.IList}}} interface.
Using the FDO .net API in a .net Framework >= 3.5 environment with C# 3.0
syntax is cumbersome because of the following issues:
1. Compiler type inference fails on foreach loops:
{{{
FeatureSchemaCollection featureSchemas = ...;
foreach(var schema in featureSchemas)
{
//schema will be inferred as System.Object instead of
OSGeo.FDO.Schema.FeatureSchema
}
}}}
2. LINQ to Objects usage such as the fragment below will fail:
{{{
FeatureSchema schema = ...;
var cls = schema.Classes.Where(x => x.Name ==
"MyFeatureClass").FirstOrDefault();
}}}
Currently the {{{Cast()}}} extension method has to be used to make these
collections LINQ friendly, resulting in ugly casting of each enumerated
object.
{{{
FeatureSchema schema = ...;
var cls = schema.Classes.Cast<ClassDefinition>().Where(x => x.Name ==
"MyFeatureClass").FirstOrDefault();
}}}
Having {{{CollectionBase}}} as a generic collection class implementing the
generic {{{IList<T>}}} interface will make the managed API more friendly
to C# 3.0 syntax.
--
Ticket URL: <http://trac.osgeo.org/fdo/ticket/690>
FDO <http://fdo.osgeo.org/>
Feature Data Objects
More information about the fdo-trac
mailing list