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.
CIP4.Installer version 4.0.5.0 Copyright 2010 Channel Intelligence Inc Available connection types and their parameters: ================================================ Sql: Database:String Host:String UserId:String Password:String ApplicationName:String Cache:CIP4ConnectionAttribute MySql: Database:String Host:String UserId:String Password:String Cache:CIP4ConnectionAttribute Mosso: UserName:String AccessKey:String Cache:CIP4ConnectionAttribute S3: AccessKey:String SecretKey:String Cache:CIP4ConnectionAttribute XmlFile: XmlFileName:String Cache:CIP4ConnectionAttribute File: BaseDirectoryPath:String CompressData:Boolean SerializerKind:SerializerKindEnum Cache:CIP4ConnectionAttribute Dictionary: BaseDirectoryPath:String Temporary:Boolean Cache:CIP4ConnectionAttribute Cassandra: Keyspace:String ColumnFamily:String Cache:CIP4ConnectionAttribute MongoDB: Server:String Port:Int32 Database:String Timeout:Int32 Cache:CIP4ConnectionAttribute Migrator: Target:CIP4ConnectionAttribute Source:CIP4ConnectionAttribute Cache:CIP4ConnectionAttribute MultiThread: NumberOfThreads:Int32 Target:CIP4ConnectionAttribute Cache:CIP4ConnectionAttribute MassTransit: TimeOutInMilliSecs:Int32 BusId:String Target:CIP4ConnectionAttribute Cache:CIP4ConnectionAttribute Slice: Basket:String BasketIndex:String Cache: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.