src/Misc/EFTools/EntityDesign/VisualStudio/TextTemplating/SsdlToDdlActivity.cs
/// <summary>
///     Populates an <see cref="IDictionary{TKey, TValue}" /> that is used to provide inputs to a text template. This method can be overridden in derived classes to provide custom inputs.
///     These inputs are placed into the CallContext for use by the text template.
/// </summary>
/// <param name="context">The state of the current activity.</param>
/// <param name="inputs">A dictionary that relates input names to input values for use by a text template.</param>
Populates an  that is used to provide inputs to a text template. This method can be overridden in derived classes to provide custom inputs.
These inputs are placed into the CallContext for use by the text template.
Populates an that is used to provide inputs to a text template . This method can be overridden in derived classes to provide custom inputs . These inputs are placed into the CallContext for use by the text template .
protected override void OnGetTemplateInputs(NativeActivityContext context, IDictionary<string, object> inputs)
        {
            inputs.Add(EdmConstants.ssdlOutputName, SsdlInput.Get(context));
            inputs.Add(EdmConstants.existingSsdlInputName, ExistingSsdlInput.Get(context));
            var symbolResolver = context.GetExtension<SymbolResolver>();
            var edmParameterBag = symbolResolver[typeof(EdmParameterBag).Name] as EdmParameterBag;
            if (edmParameterBag == null)
            {
                throw new InvalidOperationException(Resources.DatabaseCreation_ErrorNoEdmParameterBag);
            }
            var targetFrameworkVersion = edmParameterBag.GetParameter<Version>(EdmParameterBag.ParameterName.TargetVersion);
            if (targetFrameworkVersion == null)
            {
                throw new InvalidOperationException(
                    String.Format(
                        CultureInfo.CurrentCulture, Resources.DatabaseCreation_ErrorNoParameterDefined,
                        EdmParameterBag.ParameterName.TargetVersion.ToString()));
            }
            if (false == EntityFrameworkVersion.IsValidVersion(targetFrameworkVersion))
            {
                throw new InvalidOperationException(
                    String.Format(CultureInfo.CurrentCulture, Resources.DatabaseCreation_ErrorInvalidTargetVersion, targetFrameworkVersion));
            }
            inputs.Add(EdmParameterBag.ParameterName.TargetVersion.ToString(), targetFrameworkVersion);
            var providerInvariantName = edmParameterBag.GetParameter<string>(EdmParameterBag.ParameterName.ProviderInvariantName);
            if (String.IsNullOrEmpty(providerInvariantName))
            {
                throw new InvalidOperationException(
                    String.Format(
                        CultureInfo.CurrentCulture, Resources.DatabaseCreation_ErrorNoParameterDefined,
                        EdmParameterBag.ParameterName.ProviderInvariantName.ToString()));
            }
            inputs.Add(EdmParameterBag.ParameterName.ProviderInvariantName.ToString(), providerInvariantName);
            var providerManifestToken = edmParameterBag.GetParameter<string>(EdmParameterBag.ParameterName.ProviderManifestToken);
            inputs.Add(EdmParameterBag.ParameterName.ProviderManifestToken.ToString(), providerManifestToken);
            var databaseSchemaName = edmParameterBag.GetParameter<string>(EdmParameterBag.ParameterName.DatabaseSchemaName);
            if (String.IsNullOrEmpty(databaseSchemaName))
            {
                throw new InvalidOperationException(
                    String.Format(
                        CultureInfo.CurrentCulture, Resources.DatabaseCreation_ErrorNoParameterDefined,
                        EdmParameterBag.ParameterName.DatabaseSchemaName.ToString()));
            }
            inputs.Add(EdmParameterBag.ParameterName.DatabaseSchemaName.ToString(), databaseSchemaName);
            var databaseName = edmParameterBag.GetParameter<string>(EdmParameterBag.ParameterName.DatabaseName);
            inputs.Add(EdmParameterBag.ParameterName.DatabaseName.ToString(), databaseName);
            var ddlTemplatePath = edmParameterBag.GetParameter<string>(EdmParameterBag.ParameterName.DDLTemplatePath);
            inputs.Add(EdmParameterBag.ParameterName.DDLTemplatePath.ToString(), ddlTemplatePath);
        }
protected override void OnGetTemplateInputs ( NativeActivityContext context , IDictionary < string , object > inputs ) { inputs . Add ( EdmConstants . ssdlOutputName , SsdlInput . Get ( context ) ) ; inputs . Add ( EdmConstants . existingSsdlInputName , ExistingSsdlInput . Get ( context ) ) ; var symbolResolver = context . GetExtension < SymbolResolver > ( ) ; var edmParameterBag = symbolResolver [ typeof ( EdmParameterBag ) . Name ] as EdmParameterBag ; if ( edmParameterBag == null ) { throw new InvalidOperationException ( Resources . DatabaseCreation_ErrorNoEdmParameterBag ) ; } var targetFrameworkVersion = edmParameterBag . GetParameter < Version > ( EdmParameterBag . ParameterName . TargetVersion ) ; if ( targetFrameworkVersion == null ) { throw new InvalidOperationException ( String . Format ( CultureInfo . CurrentCulture , Resources . DatabaseCreation_ErrorNoParameterDefined , EdmParameterBag . ParameterName . TargetVersion . ToString ( ) ) ) ; } if ( false == EntityFrameworkVersion . IsValidVersion ( targetFrameworkVersion ) ) { throw new InvalidOperationException ( String . Format ( CultureInfo . CurrentCulture , Resources . DatabaseCreation_ErrorInvalidTargetVersion , targetFrameworkVersion ) ) ; } inputs . Add ( EdmParameterBag . ParameterName . TargetVersion . ToString ( ) , targetFrameworkVersion ) ; var providerInvariantName = edmParameterBag . GetParameter < string > ( EdmParameterBag . ParameterName . ProviderInvariantName ) ; if ( String . IsNullOrEmpty ( providerInvariantName ) ) { throw new InvalidOperationException ( String . Format ( CultureInfo . CurrentCulture , Resources . DatabaseCreation_ErrorNoParameterDefined , EdmParameterBag . ParameterName . ProviderInvariantName . ToString ( ) ) ) ; } inputs . Add ( EdmParameterBag . ParameterName . ProviderInvariantName . ToString ( ) , providerInvariantName ) ; var providerManifestToken = edmParameterBag . GetParameter < string > ( EdmParameterBag . ParameterName . ProviderManifestToken ) ; inputs . Add ( EdmParameterBag . ParameterName . ProviderManifestToken . ToString ( ) , providerManifestToken ) ; var databaseSchemaName = edmParameterBag . GetParameter < string > ( EdmParameterBag . ParameterName . DatabaseSchemaName ) ; if ( String . IsNullOrEmpty ( databaseSchemaName ) ) { throw new InvalidOperationException ( String . Format ( CultureInfo . CurrentCulture , Resources . DatabaseCreation_ErrorNoParameterDefined , EdmParameterBag . ParameterName . DatabaseSchemaName . ToString ( ) ) ) ; } inputs . Add ( EdmParameterBag . ParameterName . DatabaseSchemaName . ToString ( ) , databaseSchemaName ) ; var databaseName = edmParameterBag . GetParameter < string > ( EdmParameterBag . ParameterName . DatabaseName ) ; inputs . Add ( EdmParameterBag . ParameterName . DatabaseName . ToString ( ) , databaseName ) ; var ddlTemplatePath = edmParameterBag . GetParameter < string > ( EdmParameterBag . ParameterName . DDLTemplatePath ) ; inputs . Add ( EdmParameterBag . ParameterName . DDLTemplatePath . ToString ( ) , ddlTemplatePath ) ; }
Populates an  that is used to provide inputs to a text template.
Populates an that is used to provide inputs to a text template .
// Find the TargetVersion parameter // Validate the TargetVersion parameter and add it as an input // Add the Provider invariant name // Add the Provider manifest token (optional) // Add the Database Schema Name // Add the Database Name (Note: it's OK for this to be null e.g. some providers do not provide this) // Add the DDL Template Path (optional)
context
NativeActivityContext
The state of the current activity.
The state of the current activity .
inputs
IDictionary<string, object>
A dictionary that relates input names to input values for use by a text template.
A dictionary that relates input names to input values for use by a text template .