src/Shared/EntityFramework/Core/Metadata/Edm/MetadataCache.cs
// <summary>
// A helper function for splitting up a string that is a concatenation of strings delimited by the metadata
// path separator into a string list. The resulting list sorted SSDL, MSL, CSDL, if possible.
// </summary>
// <param name="paths"> The paths to split </param>
// <returns> An array of strings </returns>
A helper function for splitting up a string that is a concatenation of strings delimited by the metadata
path separator into a string list. The resulting list sorted SSDL, MSL, CSDL, if possible.
A helper function for splitting up a string that is a concatenation of strings delimited by the metadata path separator into a string list . The resulting list sorted SSDL MSL CSDL if possible .
private static List<MetadataArtifactLoader> SplitPaths(string paths)
        {
            DebugCheck.NotEmpty(paths);
            var uriRegistry = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
            var dataDirPaths = new List<string>();
            var indexStart = paths.IndexOf(DataDirectory, StringComparison.OrdinalIgnoreCase);
            while (indexStart != -1)
            {
                var prevSeparatorIndex = indexStart == 0
                                             ? -1
                                             : paths.LastIndexOf(
                                                 MetadataPathSeparator,
                                                 indexStart - 1,  start looking here
                                                 StringComparison.Ordinal
                                                   );
                var macroPathBeginIndex = prevSeparatorIndex + 1;
                 The '|DataDirectory|' macro is composable, so identify the complete path, like
                 '|DataDirectory|\item1\item2'. If the macro appears anywhere other than at the
                 beginning, splice out the entire path, e.g. 'C:\item1\|DataDirectory|\item2'. In this
                 latter case the macro will not be expanded, and downstream code will throw an exception.
                var indexEnd = paths.IndexOf(
                    MetadataPathSeparator,
                    indexStart + DataDirectory.Length,
                    StringComparison.Ordinal);
                if (indexEnd == -1)
                {
                    dataDirPaths.Add(paths.Substring(macroPathBeginIndex));
                    paths = paths.Remove(macroPathBeginIndex);  update the concatenated list of paths
                    break;
                }
                dataDirPaths.Add(paths.Substring(macroPathBeginIndex, indexEnd - macroPathBeginIndex));
                 Update the concatenated list of paths by removing the one containing the macro.
                paths = paths.Remove(macroPathBeginIndex, indexEnd - macroPathBeginIndex);
                indexStart = paths.IndexOf(DataDirectory, StringComparison.OrdinalIgnoreCase);
            }
             Split the string on the separator and remove all spaces around each parameter value
            var results = paths.Split(new[] { MetadataPathSeparator }, StringSplitOptions.RemoveEmptyEntries);
             Now that the non-macro paths have been identified, merge the paths containing the macro
             into the complete list.
            if (dataDirPaths.Count > 0)
            {
                dataDirPaths.AddRange(results);
                results = dataDirPaths.ToArray();
            }
            var csdlLoaders = new List<MetadataArtifactLoader>();
            var mslLoaders = new List<MetadataArtifactLoader>();
            var ssdlLoaders = new List<MetadataArtifactLoader>();
            var loaders = new List<MetadataArtifactLoader>();
            for (var i = 0; i < results.Length; i++)
            {
                 Trim out all the spaces for this parameter and add it only if it's not blank
                results[i] = results[i].Trim();
                if (results[i].Length > 0)
                {
                    var loader = MetadataArtifactLoader.Create(
                        results[i],
                        MetadataArtifactLoader.ExtensionCheck.All,  validate the extension against all acceptable values
                        null,
                        uriRegistry);
                    if (results[i].EndsWith(XmlConstants.CSpaceSchemaExtension, StringComparison.OrdinalIgnoreCase))
                    {
                        csdlLoaders.Add(loader);
                    }
                    else if (results[i].EndsWith(XmlConstants.CSSpaceSchemaExtension, StringComparison.OrdinalIgnoreCase))
                    {
                        mslLoaders.Add(loader);
                    }
                    else if (results[i].EndsWith(XmlConstants.SSpaceSchemaExtension, StringComparison.OrdinalIgnoreCase))
                    {
                        ssdlLoaders.Add(loader);
                    }
                    else
                    {
                        loaders.Add(loader);
                    }
                }
            }
            loaders.AddRange(ssdlLoaders);
            loaders.AddRange(mslLoaders);
            loaders.AddRange(csdlLoaders);
            return loaders;
        }
private static List < MetadataArtifactLoader > SplitPaths ( string paths ) { DebugCheck . NotEmpty ( paths ) ; var uriRegistry = new HashSet < string > ( StringComparer . OrdinalIgnoreCase ) ; var dataDirPaths = new List < string > ( ) ; var indexStart = paths . IndexOf ( DataDirectory , StringComparison . OrdinalIgnoreCase ) ; while ( indexStart != - 1 ) { var prevSeparatorIndex = indexStart == 0 ? - 1 : paths . LastIndexOf ( MetadataPathSeparator , indexStart - 1 , StringComparison . Ordinal ) ; var macroPathBeginIndex = prevSeparatorIndex + 1 ; var indexEnd = paths . IndexOf ( MetadataPathSeparator , indexStart + DataDirectory . Length , StringComparison . Ordinal ) ; if ( indexEnd == - 1 ) { dataDirPaths . Add ( paths . Substring ( macroPathBeginIndex ) ) ; paths = paths . Remove ( macroPathBeginIndex ) ; break ; } dataDirPaths . Add ( paths . Substring ( macroPathBeginIndex , indexEnd - macroPathBeginIndex ) ) ; paths = paths . Remove ( macroPathBeginIndex , indexEnd - macroPathBeginIndex ) ; indexStart = paths . IndexOf ( DataDirectory , StringComparison . OrdinalIgnoreCase ) ; } var results = paths . Split ( new [ ] { MetadataPathSeparator } , StringSplitOptions . RemoveEmptyEntries ) ; if ( dataDirPaths . Count > 0 ) { dataDirPaths . AddRange ( results ) ; results = dataDirPaths . ToArray ( ) ; } var csdlLoaders = new List < MetadataArtifactLoader > ( ) ; var mslLoaders = new List < MetadataArtifactLoader > ( ) ; var ssdlLoaders = new List < MetadataArtifactLoader > ( ) ; var loaders = new List < MetadataArtifactLoader > ( ) ; for ( var i = 0 ; i < results . Length ; i ++ ) { results [ i ] = results [ i ] . Trim ( ) ; if ( results [ i ] . Length > 0 ) { var loader = MetadataArtifactLoader . Create ( results [ i ] , MetadataArtifactLoader . ExtensionCheck . All , null , uriRegistry ) ; if ( results [ i ] . EndsWith ( XmlConstants . CSpaceSchemaExtension , StringComparison . OrdinalIgnoreCase ) ) { csdlLoaders . Add ( loader ) ; } else if ( results [ i ] . EndsWith ( XmlConstants . CSSpaceSchemaExtension , StringComparison . OrdinalIgnoreCase ) ) { mslLoaders . Add ( loader ) ; } else if ( results [ i ] . EndsWith ( XmlConstants . SSpaceSchemaExtension , StringComparison . OrdinalIgnoreCase ) ) { ssdlLoaders . Add ( loader ) ; } else { loaders . Add ( loader ) ; } } } loaders . AddRange ( ssdlLoaders ) ; loaders . AddRange ( mslLoaders ) ; loaders . AddRange ( csdlLoaders ) ; return loaders ; }
A helper function for splitting up a string that is a concatenation of strings delimited by the metadata
path separator into a string list.
A helper function for splitting up a string that is a concatenation of strings delimited by the metadata path separator into a string list .
// This is the registry of all URIs in the global collection. // If the argument contains one or more occurrences of the macro '|DataDirectory|', we // pull those paths out so that we don't lose them in the string-splitting logic below. // Note that the macro '|DataDirectory|' cannot have any whitespace between the pipe  // symbols and the macro name. Also note that the macro must appear at the beginning of  // a path (else we will eventually fail with an invalid path exception, because in that // case the macro is not expanded). If a real/physical folder named 'DataDirectory' needs // to be included in the metadata path, whitespace should be used on either or both sides // of the name. // // start looking here // The '|DataDirectory|' macro is composable, so identify the complete path, like // '|DataDirectory|\item1\item2'. If the macro appears anywhere other than at the // beginning, splice out the entire path, e.g. 'C:\item1\|DataDirectory|\item2'. In this // latter case the macro will not be expanded, and downstream code will throw an exception. // // update the concatenated list of paths // Update the concatenated list of paths by removing the one containing the macro. // // Split the string on the separator and remove all spaces around each parameter value // Now that the non-macro paths have been identified, merge the paths containing the macro // into the complete list. // // Trim out all the spaces for this parameter and add it only if it's not blank // validate the extension against all acceptable values
An array of strings
An array of strings
paths
string
The paths to split
The paths to split