src/Misc/EFTools/EntityDesign/VisualStudio/Package/ConnectionManager.cs
// <summary>
//     Helper function to construct the metadata, depending on what type of application and output path
// </summary>
Helper function to construct the metadata, depending on what type of application and output path
Helper function to construct the metadata depending on what type of application and output path
private static string GetConnectionStringMetadata(
            IEnumerable<string> metadataFiles, Project project, VisualStudioProjectSystem applicationType, string metadataProcessingType)
        {
            var outputPath = GetOutputPath(project, applicationType);
            if (null == outputPath)
            {
                outputPath = String.Empty;
            }
            else if (!outputPath.EndsWith("\\", StringComparison.OrdinalIgnoreCase))
            {
                outputPath += "\\";
            }
            outputPath = outputPath.Replace("\\", "/");
            if (metadataFiles == null
                || !metadataFiles.Any())
            {
                if (metadataProcessingType == ConnectionDesignerInfo.MAP_EmbedInOutputAssembly
                    || applicationType == VisualStudioProjectSystem.Website)
                {
                    return EmbedAsResourcePrefix;
                }
                if (applicationType == VisualStudioProjectSystem.WebApplication)
                {
                    return "~/" + outputPath;
                }
                else
                {
                    return ".";
                }
            }
            else
            {
                var md = new StringBuilder();
                var i = 0;
                var metadataFileCount = metadataFiles.Count();
                foreach (var f in metadataFiles)
                {
                    if (applicationType == VisualStudioProjectSystem.WebApplication
                        && metadataProcessingType == ConnectionDesignerInfo.MAP_CopyToOutputDirectory)
                    {
                        md.Append(f.Replace(".\\", "~/" + outputPath));
                    }
                    else if (applicationType == VisualStudioProjectSystem.Website)
                    {
                         The 3.5 runtime's Build Provider will include the web site's virtual root in the resource name.  This can change when
                         a web app is deployed, so we must use res:\\* for the connection string when targeting netfx 3.5.
                        if (NetFrameworkVersioningHelper.TargetNetFrameworkVersion(project, PackageManager.Package)
                            == NetFrameworkVersioningHelper.NetFrameworkVersion3_5)
                        {
                            return EmbedAsResourcePrefix;
                        }
                        else
                        {
                            md.Append(EmbedAsResourcePrefix);
                            md.Append("/");
                            if (f[0] == '.'
                                && f[1] == Path.DirectorySeparatorChar)
                            {
                                var folderAndFile = f.Substring(2);
                                md.Append(folderAndFile.Replace(Path.DirectorySeparatorChar, '.'));
                            }
                            else
                            {
                                Debug.Fail("Unexpected start characters in metadata file");
                                return EmbedAsResourcePrefix;
                            }
                        }
                    }
                    else
                    {
                        if (metadataProcessingType == ConnectionDesignerInfo.MAP_EmbedInOutputAssembly)
                        {
                            md.Append(EmbedAsResourcePrefix);
                            md.Append("/");
                            md.Append(f.Replace(Path.DirectorySeparatorChar, '.').TrimStart('.'));
                        }
                        else if (metadataProcessingType == ConnectionDesignerInfo.MAP_CopyToOutputDirectory)
                        {
                            md.Append(f);
                        }
                    }
                    if (i++ < metadataFileCount - 1)
                    {
                         Character used by framework to separate paths to artifacts in the Entity Connection String
                        md.Append("|");
                    }
                }
                return md.ToString();
            }
        }
private static string GetConnectionStringMetadata ( IEnumerable < string > metadataFiles , Project project , VisualStudioProjectSystem applicationType , string metadataProcessingType ) { var outputPath = GetOutputPath ( project , applicationType ) ; if ( null == outputPath ) { outputPath = String . Empty ; } else if ( ! outputPath . EndsWith ( " \\ " , StringComparison . OrdinalIgnoreCase ) ) { outputPath += " \\ " ; } outputPath = outputPath . Replace ( " \\ " , " " ) ; if ( metadataFiles == null || ! metadataFiles . Any ( ) ) { if ( metadataProcessingType == ConnectionDesignerInfo . MAP_EmbedInOutputAssembly || applicationType == VisualStudioProjectSystem . Website ) { return EmbedAsResourcePrefix ; } if ( applicationType == VisualStudioProjectSystem . WebApplication ) { return " " + outputPath ; } else { return " " ; } } else { var md = new StringBuilder ( ) ; var i = 0 ; var metadataFileCount = metadataFiles . Count ( ) ; foreach ( var f in metadataFiles ) { if ( applicationType == VisualStudioProjectSystem . WebApplication && metadataProcessingType == ConnectionDesignerInfo . MAP_CopyToOutputDirectory ) { md . Append ( f . Replace ( " \\ " , " " + outputPath ) ) ; } else if ( applicationType == VisualStudioProjectSystem . Website ) { if ( NetFrameworkVersioningHelper . TargetNetFrameworkVersion ( project , PackageManager . Package ) == NetFrameworkVersioningHelper . NetFrameworkVersion3_5 ) { return EmbedAsResourcePrefix ; } else { md . Append ( EmbedAsResourcePrefix ) ; md . Append ( " " ) ; if ( f [ 0 ] == ' ' && f [ 1 ] == Path . DirectorySeparatorChar ) { var folderAndFile = f . Substring ( 2 ) ; md . Append ( folderAndFile . Replace ( Path . DirectorySeparatorChar , ' ' ) ) ; } else { Debug . Fail ( " " ) ; return EmbedAsResourcePrefix ; } } } else { if ( metadataProcessingType == ConnectionDesignerInfo . MAP_EmbedInOutputAssembly ) { md . Append ( EmbedAsResourcePrefix ) ; md . Append ( " " ) ; md . Append ( f . Replace ( Path . DirectorySeparatorChar , ' ' ) . TrimStart ( ' ' ) ) ; } else if ( metadataProcessingType == ConnectionDesignerInfo . MAP_CopyToOutputDirectory ) { md . Append ( f ) ; } } if ( i ++ < metadataFileCount - 1 ) { md . Append ( " " ) ; } } return md . ToString ( ) ; } }
Helper function to construct the metadata, depending on what type of application and output path
Helper function to construct the metadata depending on what type of application and output path
// fix up outputPath  // construct metadata portion of connection string // web-app's need to have the outputPath (usually "bin") appended // if this is a web app, then change relative path to virtual path // // The 3.5 runtime's Build Provider will include the web site's virtual root in the resource name.  This can change when // a web app is deployed, so we must use res:\\* for the connection string when targeting netfx 3.5. // // Character used by framework to separate paths to artifacts in the Entity Connection String
metadataFiles
IEnumerable<string>
project
Project
applicationType
VisualStudioProjectSystem
metadataProcessingType
string