/// <summary> /// Describes the schema of the underlying data and services as equivalent SmartObject types /// This method is called whenever a service instance is registered or a service instance /// is refreshed /// </summary> /// <returns>A string containing the schema XML. The string is returned by executing the base.DescribeSchema() method /// after adding ServiceObjects to the this.Service.ServiceObjects collection</returns> public override string DescribeSchema() { try { //1. GET SERVICE INSTANCE CONFIGURATION VALUES //we need to retrieve the Service Instance configuration settings before calling the DescribeSchema method, since //the specific configuration value we're retrieving will tell us where to find the XML file that we want to discover string xmlFilePath = this.Service.ServiceConfiguration["XMLFilePath"].ToString(); //2. SET UP SERVICE OBJECT TYPE MAPPINGS //set up the Service Object DataType Mappings for the service. This is a table which tells the service discovery method //how to map the native data types for the Provider to equivalent Service Object data types TypeMappings map = new TypeMappings(); // Add type mappings. map.Add("Int32", SoType.Number); map.Add("String", SoType.Text); map.Add("Boolean", SoType.YesNo); map.Add("Date", SoType.DateTime); // Add the type mappings to the Service Instance. this.Service.ServiceConfiguration.Add("Type Mappings", map); //3. DISCOVER THE SCHEMA OF THE UNDERLYING PROVIDER //here we will connect to the Provider and discover the schema. During the discovery phase, we will //add one or more ServiceObjects (SourceCode.SmartObjects.Services.ServiceSDK.Objects) to the Service Instance. //Each ServiceObject contains a collection of Properties of type SourceCode.SmartObjects.Services.ServiceSDK.Objects.Property //and a collection of Methods of type SourceCode.SmartObjects.Services.ServiceSDK.Objects.Method //see the DiscoverXMLFileSchema method for an example of iterating over the objects in the Provider and adding service objects DiscoverXMLFileSchema(xmlFilePath); //4. SET UP THE SERVICE INSTANCE (Optional) //Set up the default values for the Service Instance. The user will be able to override these values this.Service.Name = "K2LearningDynamicXMLService"; this.Service.MetaData.DisplayName = "K2Learning Custom Service Broker (Discovered Schema)"; this.Service.MetaData.Description = "This custom Service discovers a XML file and returns the items in the XML file as Service Objects"; // Indicate that the operation was successful. ServicePackage.IsSuccessful = true; } catch (Exception ex) { // Record the exception message and indicate that this was an error. ServicePackage.ServiceMessages.Add(ex.Message, MessageSeverity.Error); // Indicate that the operation was unsuccessful. ServicePackage.IsSuccessful = false; } return(base.DescribeSchema()); }
public ViewModelFactoryService() { TypeMappings.Add(typeof(LMTimelineEvent), typeof(LMTimelineEventVM)); TypeMappings.Add(typeof(ScoreButton), typeof(ScoreButtonVM)); TypeMappings.Add(typeof(PenaltyCardButton), typeof(PenaltyCardButtonVM)); TypeMappings.Add(typeof(LMPlayer), typeof(LMPlayerVM)); TypeMappings.Add(typeof(LMTeam), typeof(LMTeamVM)); TypeMappings.Add(typeof(LMProject), typeof(LMProjectVM)); }
/// <summary> /// Initializes a new instance of the <see cref="SqlServerDatabase"/> class. /// </summary> /// <param name="connectionString">Connection string.</param> public SqlServerDatabase(string connectionString) : base(ConnectionFactory.Value.CreateConnection(connectionString), GetMasterConnectionString(connectionString, "Initial Catalog", "master")) { this.connectionString = connectionString; TypeMappings.Add <bool>("bit"); TypeMappings.Add <byte>("tinyint"); TypeMappings.Add <char>("nchar(1)"); TypeMappings.Add <DateTime>("datetime"); TypeMappings.Add <decimal>("decimal(19,5)"); TypeMappings.Add <double>("float"); TypeMappings.Add <float>("real"); TypeMappings.Add <Guid>("uniqueidentifier"); TypeMappings.Add <int>("int"); TypeMappings.Add <long>("bigint"); TypeMappings.Add <short>("smallint"); TypeMappings.Add <string>("nvarchar(50)"); }
/// <summary> /// Initializes a new instance of the <see cref="MySqlDatabase"/> class. /// </summary> /// <param name="connectionString">Connection string.</param> public MySqlDatabase(string connectionString) : base(ConnectionFactory.Value.CreateConnection(connectionString), GetMasterConnectionString(connectionString, "Database", "mysql")) { this.connectionString = connectionString; TypeMappings.Add <bool>("bit"); TypeMappings.Add <byte>("tinyint unsigned"); TypeMappings.Add <char>("char(1)"); TypeMappings.Add <DateTime>("datetime"); TypeMappings.Add <decimal>("decimal(19,5)"); TypeMappings.Add <double>("double"); TypeMappings.Add <float>("double"); TypeMappings.Add <Guid>("char(36)"); TypeMappings.Add <int>("int"); TypeMappings.Add <long>("bigint"); TypeMappings.Add <short>("smallint"); TypeMappings.Add <string>("varchar(50)"); TypeMappings.Add <TimeSpan>("time(3)"); }
/// <summary> /// Initializes a new instance of the <see cref="PostgreSqlDatabase"/> class. /// </summary> /// <param name="connectionString">Connection string.</param> public PostgreSqlDatabase(string connectionString) : base(ConnectionFactory.Value.CreateConnection(connectionString), GetMasterConnectionString(connectionString, "Database", "postgres")) { this.connectionString = connectionString; // No type mapping for byte. TypeMappings.Add <bool>("boolean"); TypeMappings.Add <char>("character(1)"); TypeMappings.Add <DateTime>("timestamp without time zone"); TypeMappings.Add <decimal>("numeric(19,5)"); TypeMappings.Add <double>("double precision"); TypeMappings.Add <float>("real"); TypeMappings.Add <Guid>("uuid"); TypeMappings.Add <int>("integer"); TypeMappings.Add <long>("bigint"); TypeMappings.Add <short>("smallint"); TypeMappings.Add <string>("character varying(50)"); TypeMappings.Add <TimeSpan>("interval(6)"); }
/// <summary> /// Initializes a new instance of the <see cref="SqLiteDatabase"/> class. /// </summary> /// <param name="connectionString">Connection string.</param> public SqLiteDatabase(string connectionString) : base(ConnectionFactory.Value.CreateConnection(connectionString), null, (string)new DbConnectionStringBuilder { ConnectionString = connectionString }["Data Source"]) { this.connectionString = connectionString; TypeMappings.Add <bool>("boolean"); TypeMappings.Add <byte>("tinyint"); TypeMappings.Add <char>("character(1)"); TypeMappings.Add <DateTime>("datetime"); TypeMappings.Add <decimal>("decimal(19,5)"); TypeMappings.Add <double>("real"); TypeMappings.Add <float>("real"); TypeMappings.Add <Guid>("uniqueidentifier"); TypeMappings.Add <int>("integer"); TypeMappings.Add <long>("bigint"); TypeMappings.Add <short>("smallint"); TypeMappings.Add <string>("varchar(50)"); // No type mapping for TimesSpan. }
private static TypeMappings CreateTypeMappings() { TypeMappings map = new TypeMappings(); map.Add(typeof(System.Int16), SoType.Number); map.Add(typeof(System.Int32), SoType.Number); map.Add(typeof(System.Int64), SoType.Number); map.Add(typeof(System.UInt16), SoType.Number); map.Add(typeof(System.UInt32), SoType.Number); map.Add(typeof(System.UInt64), SoType.Number); map.Add(typeof(System.Boolean), SoType.YesNo); map.Add(typeof(System.Char), SoType.Text); map.Add(typeof(System.DateTime), SoType.DateTime); map.Add(typeof(System.Decimal), SoType.Decimal); map.Add(typeof(System.Single), SoType.Decimal); map.Add(typeof(System.Double), SoType.Decimal); map.Add(typeof(System.Guid), SoType.Guid); map.Add(typeof(System.Byte), SoType.File); map.Add(typeof(System.SByte), SoType.File); map.Add(typeof(System.String), SoType.Text); map.Add(typeof(Nullable<System.Int16>), SoType.Number); map.Add(typeof(Nullable<System.Int32>), SoType.Number); map.Add(typeof(Nullable<System.Int64>), SoType.Number); map.Add(typeof(Nullable<System.UInt16>), SoType.Number); map.Add(typeof(Nullable<System.UInt32>), SoType.Number); map.Add(typeof(Nullable<System.UInt64>), SoType.Number); map.Add(typeof(Nullable<System.Boolean>), SoType.YesNo); map.Add(typeof(Nullable<System.Char>), SoType.Text); map.Add(typeof(Nullable<System.DateTime>), SoType.DateTime); map.Add(typeof(Nullable<System.Decimal>), SoType.Decimal); map.Add(typeof(Nullable<System.Single>), SoType.Decimal); map.Add(typeof(Nullable<System.Double>), SoType.Decimal); map.Add(typeof(Nullable<System.Guid>), SoType.Guid); map.Add(typeof(Nullable<System.Byte>), SoType.File); map.Add(typeof(Nullable<System.SByte>), SoType.File); return map; }
/// <summary> /// Sets the type mappings used to map the underlying data's types to the appropriate K2 SmartObject types. /// </summary> public void SetTypeMappings() { // Variable declaration. TypeMappings map = new TypeMappings(); map.Add("Edm.Binary", SoType.Memo); map.Add("Edm.Boolean", SoType.YesNo); map.Add("Edm.Byte", SoType.Memo); map.Add("Edm.DateTime", SoType.DateTime); map.Add("Edm.DateTimeOffset", SoType.DateTime); map.Add("Edm.Time", SoType.DateTime); map.Add("Edm.Double", SoType.Decimal); map.Add("Edm.Decimal", SoType.Decimal); map.Add("Edm.Single", SoType.Decimal); map.Add("Edm.Guid", SoType.Guid); map.Add("Edm.Int16", SoType.Number); map.Add("Edm.Int32", SoType.Number); map.Add("Edm.Int64", SoType.Number); map.Add("Edm.String", SoType.Text); // Add the type mappings to the service instance. serviceBroker.Service.ServiceConfiguration.Add(__TypeMappings, map); }
private static TypeMappings CreateTypeMappings() { TypeMappings map = new TypeMappings(); map.Add(typeof(System.Int16), SoType.Number); map.Add(typeof(System.Int32), SoType.Number); map.Add(typeof(System.Int64), SoType.Number); map.Add(typeof(System.UInt16), SoType.Number); map.Add(typeof(System.UInt32), SoType.Number); map.Add(typeof(System.UInt64), SoType.Number); map.Add(typeof(System.Boolean), SoType.YesNo); map.Add(typeof(System.Char), SoType.Text); map.Add(typeof(System.DateTime), SoType.DateTime); map.Add(typeof(System.Decimal), SoType.Decimal); map.Add(typeof(System.Single), SoType.Decimal); map.Add(typeof(System.Double), SoType.Decimal); map.Add(typeof(System.Guid), SoType.Guid); //map.Add(typeof(System.Byte), SoType.File); //map.Add(typeof(System.SByte), SoType.File); map.Add(typeof(System.String), SoType.File); map.Add(typeof(System.String), SoType.Text); map.Add(typeof(Nullable <System.Int16>), SoType.Number); map.Add(typeof(Nullable <System.Int32>), SoType.Number); map.Add(typeof(Nullable <System.Int64>), SoType.Number); map.Add(typeof(Nullable <System.UInt16>), SoType.Number); map.Add(typeof(Nullable <System.UInt32>), SoType.Number); map.Add(typeof(Nullable <System.UInt64>), SoType.Number); map.Add(typeof(Nullable <System.Boolean>), SoType.YesNo); map.Add(typeof(Nullable <System.Char>), SoType.Text); map.Add(typeof(Nullable <System.DateTime>), SoType.DateTime); map.Add(typeof(Nullable <System.Decimal>), SoType.Decimal); map.Add(typeof(Nullable <System.Single>), SoType.Decimal); map.Add(typeof(Nullable <System.Double>), SoType.Decimal); map.Add(typeof(Nullable <System.Guid>), SoType.Guid); //map.Add(typeof(Nullable<System.Byte>), SoType.File); //map.Add(typeof(Nullable<System.SByte>), SoType.File); return(map); }
public LMPlayersCollectionVM() { TypeMappings.Add(typeof(LMPlayerVM), typeof(LMPlayer)); }