| 1 | = Custom Commands = |
| 2 | |
| 3 | == The problem == |
| 4 | |
| 5 | The current ServerConnectionI interface is a monolithic interface. It is hard to add functionality that may not be possible on certain implementations. A flexible way to extend functionality is required. |
| 6 | |
| 7 | == The solution == |
| 8 | |
| 9 | Taking a page out of the FDO API, we will use a command-based API for defining custom functionality |
| 10 | |
| 11 | {{{ |
| 12 | |
| 13 | public interface ICommand |
| 14 | { |
| 15 | ... |
| 16 | IServerConnection Parent { get; } |
| 17 | } |
| 18 | |
| 19 | public interface IServerConnection |
| 20 | { |
| 21 | ... |
| 22 | |
| 23 | ICommand CreateCommand(int commandType); |
| 24 | |
| 25 | ... |
| 26 | } |
| 27 | |
| 28 | }}} |
| 29 | |
| 30 | A capability API will also be made available so that certain implementations can advertise what commands they support. |
| 31 | |
| 32 | Through this command mechanism, we can then define custom commands that certain implementations of IServerConnection may or may not choose to implement. |
| 33 | |
| 34 | For example, Bulk copying. |
| 35 | |
| 36 | {{{ |
| 37 | |
| 38 | // Copies features from one feature source to another |
| 39 | public interface IBulkCopy : ICommand |
| 40 | { |
| 41 | string SourceFeatureSource { get; set; } |
| 42 | |
| 43 | string TargetFeatureSource { get; set; } |
| 44 | |
| 45 | void AddMapping(BulkCopyMapping mapping); |
| 46 | |
| 47 | void Execute(IBulkCopyProgressCallback callback); |
| 48 | } |
| 49 | |
| 50 | public class BulkCopyMapping |
| 51 | { |
| 52 | public string SourceFeatureClass { get; set; } |
| 53 | public string TargetFeatureClass { get; set; } |
| 54 | |
| 55 | ... |
| 56 | } |
| 57 | |
| 58 | }}} |
| 59 | |
| 60 | Another example, re-projecting features |
| 61 | |
| 62 | {{{ |
| 63 | |
| 64 | // Selects features from the specified feature class and re-projects them to the |
| 65 | // target coordinate system. |
| 66 | public interface IReprojectFeatures : ICommand |
| 67 | { |
| 68 | public string SourceFeatureSource { get; set; } |
| 69 | |
| 70 | public string SourceFeatureClass { get; set; } |
| 71 | |
| 72 | public string Filter { get; set; } |
| 73 | |
| 74 | public string SourceCoordinateSystem { get; set; } |
| 75 | |
| 76 | public string TargetCoordinateSystem { get; set; } |
| 77 | |
| 78 | public void Execute(IReprojectFeaturesCallback callback); |
| 79 | } |
| 80 | |
| 81 | }}} |
| 82 | |
| 83 | These are just some examples off the top of my head, but a whole stack of geo-processing functionality could be made available through such an approach. |