Пример #1
0
        /// <summary>
        /// Resolves the Uri to a Dom object using the parent's collection's resolvers</summary>
        /// <returns>Dom object, referenced by the Uri, or null if uri can't be resolved</returns>
        public void Resolve()
        {
            if (m_target == null)
            {
                var gameDocRegistry = Globals.MEFContainer.GetExportedValue <GameDocumentRegistry>();

                Uri ur = Uri;
                if (ur == null)
                {
                    m_error = "ref attribute is null";
                }
                else if (!File.Exists(ur.LocalPath))
                {
                    m_error = "File not found: " + ur.LocalPath;
                }
                else if (gameDocRegistry.FindDocument(ur) != null)
                {
                    m_error = "Causes circular ref: " + ur.LocalPath;
                }
                else
                {
                    SchemaLoader schemaloader = Globals.MEFContainer.GetExportedValue <SchemaLoader>();
                    GameDocument gameDoc      = GameDocument.OpenOrCreate(ur, schemaloader);
                    m_target = gameDoc.As <IGame>();
                    ((Game)m_target).SetParent(this);
                }
            }
        }