There are two types of CIPl attributes you can attach to a C# class
You can get a list of the currently available CIP4ConnectionAttribute types by running
CIP4.Installer /action list
The application will return a list somewhat as follows - which of these you can use will depend on what you have installed in the local environment.
Available connection types and their parameters: ================================================ Sql: Database:String Host:String UserId:String Password:String CacheConnection:CIP4ConnectionAttribute MySql: Database:String Host:String UserId:String Password:String CacheConnection:CIP4ConnectionAttribute Mosso: UserName:String AccessKey:String CacheConnection:CIP4ConnectionAttribute S3: AccessKey:String SecretKey:String CacheConnection:CIP4ConnectionAttribute XmlFile: XmlFileName:String CacheConnection:CIP4ConnectionAttribute File: BaseDirectoryPath:String CacheConnection:CIP4ConnectionAttribute Dictionary: BaseDirectoryPath:String CacheConnection:CIP4ConnectionAttribute Cassandra: Keyspace:String ColumnFamily:String CacheConnection:CIP4ConnectionAttribute MongoDB: Server:String Port:Int32 Database:String CacheConnection:CIP4ConnectionAttribute Migrator: Target:CIP4ConnectionAttribute Source:CIP4ConnectionAttribute CacheConnection:CIP4ConnectionAttribute
There are three ways to provide connection values
The connection attribute can be defined in the class declaration using the usual C# conventions - for example
[CIP4Item(AddAllProperties=true, Collection="People"), CIP4DictionaryConnection(BaseDirectoryPath = "c:\\temp\\PeopleData")] public class PersonType { public static StrongWrapper<PersonType> Wrapper = new StrongWrapper<PersonType>(Globals.DefaultLogger); [CIP4ExternalID] public string Name { get; set; } public string Address { get; set; } }
The approach has limited value as it requires the various connection parameters to be defined as constants in the application source (C# attributes do not allow general expressions in attribute parameter assignments)
The connection attribute can be provided as a parameter to the wrapper - for example
StrongWrapper<PersonType> wrapper = new StrongWrapper<PersonType>( new CIP4DictionaryConnectionAttribute { BaseDirectoryPath = Path.Combine(Environment.CurrentDirectory, "PeopleData") }, Globals.DefaultLogger);
The connection attribute values can be provided by the GetValues delegate defined on the wrapper - for example
PersonType.Wrapper.GetValues = delegate(Dictionary<string, string> values) { values.Add("XmlFileName", "c:\\temp\\PeopleData\\People.xml"); return ProviderTypesEnum.XmlFile; };
This is the most awkward to use because you have to know what value to provide in the values dictionary for a given ProviderTypesEnum value - these values (including the appropriate enum value) can be obtained by running
CIP4.Installer /action list
The CIP4ConnectionAttribute class defines a function called ProviderTypesEnumFromString that will translate a string into a ProviderTypesEnum value.