Select to view content in your preferred language

Can we get Intefaces on .Net API

2389
6
06-06-2012 05:49 AM
AndrewMcMenamin
Emerging Contributor
Hi,
I am trying to unit test code and while simple in ArcObjects I am struggling with the fgdb .net api because there appears to be no interfaces.
We rely on these to do dependency injection and mocking.

Does anyone know if there are any plans to add interfaces?

Thanks
0 Kudos
6 Replies
TomBreed
Emerging Contributor
Hi Andrew,

There are no current plans to add interfaces to the .net assembly. Perhaps you could develop a facade wrapping the api that is exposed through a set of interfaces? The number of types exposed through the API is not very large.

Wish I had a better answer for you,
Tom
0 Kudos
AndrewMcMenamin
Emerging Contributor
Thanks for the quick response. It is a shame as I think it makes the API far less usable.
Otherwise it is what I need as I don't want to go full ArcObjects / ArcEngine for my requirement.
For now we have just isolated the code and can create our own record as our data interface is simple and well-known.

I have tired the facade already as the next logical step.
There is a very odd behavior and we get a memory access exception if we tried to store the Row object in anything other than the RowCollection.

This is what we were trying to do - get all records and add the row into a facade and return as a list.
As soon as you try to access the row ie row.GetString("field") - fails.
We assume something is happening in he RowCollection class to reset the enumerator.

        RowCollection rowCollection = FeatureTable.Search("*", "", RowInstance.Recycle);

          // IList<IRowFacade> rowFacades = rowCollection.Select(row => new RowFacade(row)).Cast<IRowFacade>().ToList();
          
            IList<IRowFacade> rowFacades = new List<IRowFacade>();
          
            foreach (Row row in rowCollection)
            {
                rowFacades.Add(new RowFacade(row));

            }
0 Kudos
TomBreed
Emerging Contributor
Hi Andrew,

Looking over your example I noticed two things: first that you are performing your search using a recycling cursor, which reuses the underlying set of values as the rows are iterated. This bug would cause the issue you are seeing (each iteration causes the values in referencing rows to shift in concert).

However, while tracing through I noted that non-recycling cursors behave as recycling cursors. We'll be reviewing how to remedy this bug.

In the meantime my recommendation would be to treat the row in side the loop as ephemeral and copy its values out to your own cached value objects.

Tom
0 Kudos
AndrewMcMenamin
Emerging Contributor
Hi,
Yes that was our solution - we have created our own record to isolate the code.

Another question: This is a .Net4 solution - our other projects are in .Net3.5 and this is causing some issues.

Is there any possibility to get a .Net3.5 supported build?
0 Kudos
TomBreed
Emerging Contributor
Hi Andrew,

Sorry for the slow response. There are no current plans provide support for .Net 3.5 with the File Geodatabase API.

Best wishes,
Tom
0 Kudos
AlanVan_Looveren
New Contributor
Hi Andrew,
...
However, while tracing through I noted that non-recycling cursors behave as recycling cursors. We'll be reviewing how to remedy this bug.
...
Tom


Was this bug ever entered or resolved? If so, what is the ID?

Thanks in advance,
-Alan
0 Kudos