src/Misc/EFTools/XmlCore/Model/ModelManager.cs
/// <summary>
///     Load an artifact with a give URI.
///     Depending on the artifactset mode, a new artifact set might be created for the newly created artifact(s).
/// </summary>
/// <param name="fileUri"></param>
/// <param name="xmlModelProvider"></param>
/// <returns></returns>
Load an artifact with a give URI.
Depending on the artifactset mode, a new artifact set might be created for the newly created artifact(s).
Load an artifact with a give URI . Depending on the artifactset mode a new artifact set might be created for the newly created artifact ( s ) .
private IList<EFArtifact> Load(Uri fileUri, XmlModelProvider xmlModelProvider)
        {
            lock (this)
            {
                List<EFArtifact> artifacts = null;
                EFArtifactSet artifactSet = null;
                try
                {
                    artifacts = _artifactFactory.Create(this, fileUri, xmlModelProvider) as List<EFArtifact>;
                    if (artifacts == null
                        && artifacts.Count <= 0)
                    {
                        Debug.Assert(false, "Could not create EFArtifact using current factory");
                        return null;
                    }
                    else if (artifacts.Where(a => a.Uri == fileUri).FirstOrDefault() == null)
                    {
                        Debug.Assert(false, "Artifact Factory does not created an artifact with URI:" + fileUri.LocalPath);
                        return null;
                    }
                    EFArtifactSet efArtifactSet = null;
                    foreach (var artifact in artifacts)
                    {
                        Debug.Assert(
                            _artifact2ArtifactSets.ContainsKey(artifact) == false, "Unexpected entry for artifact in artifact2ArtifactSet");
                        if (_artifact2ArtifactSets.ContainsKey(artifact) == false)
                        {
                            if (efArtifactSet == null)
                            {
                                efArtifactSet = _artifactSetFactory.CreateArtifactSet(artifact);
                            }
                            RegisterArtifact(artifact, efArtifactSet);
                        }
                    }
                    artifactSet = GetArtifactSet(fileUri);
                    ParseArtifactSet(artifactSet);
                    NormalizeArtifactSet(artifactSet);
                    ResolveArtifactSet(artifactSet);
                    artifacts.ForEach((a) => { a.OnLoaded(); });
                }
                catch (Exception)
                {
                    if (artifacts != null)
                    {
                        artifacts.ForEach(
                            artifact =>
                                {
                                    artifact.Dispose();
                                    ClearArtifact(artifact.Uri);
                                });
                    }
                    throw;
                }
                return artifacts;
            }
        }
private IList < EFArtifact > Load ( Uri fileUri , XmlModelProvider xmlModelProvider ) { lock ( this ) { List < EFArtifact > artifacts = null ; EFArtifactSet artifactSet = null ; try { artifacts = _artifactFactory . Create ( this , fileUri , xmlModelProvider ) as List < EFArtifact > ; if ( artifacts == null && artifacts . Count <= 0 ) { Debug . Assert ( false , " " ) ; return null ; } else if ( artifacts . Where ( a => a . Uri == fileUri ) . FirstOrDefault ( ) == null ) { Debug . Assert ( false , " " + fileUri . LocalPath ) ; return null ; } EFArtifactSet efArtifactSet = null ; foreach ( var artifact in artifacts ) { Debug . Assert ( _artifact2ArtifactSets . ContainsKey ( artifact ) == false , " " ) ; if ( _artifact2ArtifactSets . ContainsKey ( artifact ) == false ) { if ( efArtifactSet == null ) { efArtifactSet = _artifactSetFactory . CreateArtifactSet ( artifact ) ; } RegisterArtifact ( artifact , efArtifactSet ) ; } } artifactSet = GetArtifactSet ( fileUri ) ; ParseArtifactSet ( artifactSet ) ; NormalizeArtifactSet ( artifactSet ) ; ResolveArtifactSet ( artifactSet ) ; artifacts . ForEach ( ( a ) => { a . OnLoaded ( ) ; } ) ; } catch ( Exception ) { if ( artifacts != null ) { artifacts . ForEach ( artifact => { artifact . Dispose ( ) ; ClearArtifact ( artifact . Uri ) ; } ) ; } throw ; } return artifacts ; } }
Load an artifact with a give URI.
Load an artifact with a give URI .
// Case where the artifact factory failed to instantiate artifact(s). // Case where artifact factory failed to load the artifact with give URI. // Initialize each artifact in the list. // Tell the artifacts that they are loaded and ready // an exception occurred during loading, dispose each artifact in the list and rethrow. // call dispose & clear the artifact.  We need both since the the entry may not be  // in the _artifactsByUri table. 
None
fileUri
Uri
None
xmlModelProvider
XmlModelProvider
None