Beispiel #1
0
        /// <summary>
        ///     This method will reload the artifact from the XLinq tree. This *DOES NOT* do a 'deep reloading', i.e. reloading from disk.
        /// </summary>
        internal virtual void ReloadArtifact()
        {
            try
            {
                IsArtifactReloading = true;

                // clear out the artifact set of our information
                ArtifactSet.RemoveArtifact(this);
                ArtifactSet.Add(this);

                // reparse this artifact
                State = EFElementState.None;
                Parse(new List <XName>());
                if (State == EFElementState.Parsed)
                {
                    XmlModelHelper.NormalizeAndResolve(this);
                }

                // this will do some analysis to determine if the artifact is safe for the designer, or should be displayed in the xml editor
                DetermineIfArtifactIsDesignerSafe();

                FireArtifactReloadedEvent();

                _requiresReloading = false;
                IsDirty            = false;
            }
            finally
            {
                IsArtifactReloading = false;
            }
        }
        private static ArtifactSet ExtractArtifactSet(XElement testCaseNode)
        {
            var propertiesContainer = testCaseNode.Element("properties");

            if (propertiesContainer == null)
            {
                return(null);
            }

            var artifactSessionFolderNode = propertiesContainer
                                            .Elements("property")
                                            .SingleOrDefault(element => element.GetAttributeValueOrDefault("name") == "ArtifactSessionFolder");

            if (artifactSessionFolderNode == null)
            {
                return(null);
            }

            var artifactSessionFolder = artifactSessionFolderNode.GetAttributeValueOrDefault("value");
            var artifactSet           = new ArtifactSet(artifactSessionFolder);

            var artifactNodes = artifactSessionFolderNode
                                .ElementsAfterSelf()
                                .Where(property => property.GetAttributeValueOrDefault("name").StartsWith("Artifact"));

            foreach (var artifactNode in artifactNodes)
            {
                artifactSet.Artifacts.Add(new Artifact(artifactNode.GetAttributeValueOrDefault("value")));
            }
            return(artifactSet);
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public static void InsertAllFactors()
        {
            var sessProv = new SessionProvider();

            var descMap = new Dictionary <WordNetEngine.SynSetRelation, DescriptorTypeId>();

            descMap.Add(WordNetEngine.SynSetRelation.Hypernym, DescriptorTypeId.IsA);

            using (ISession sess = sessProv.OpenSession()) {
                sess.CreateSQLQuery("DELETE FROM " + typeof(Factor).Name).UniqueResult();
                BuildWordNet.SetDbStateBeforeBatchInsert(sess);
            }

            ArtifactSet artSet;

            using (ISession sess = sessProv.OpenSession()) {
                artSet = new ArtifactSet(sess);
            }

            var sf = new SemanticFactors(artSet);

            sf.Start();

            var lf = new LexicalFactors(artSet);

            lf.Start();

            var cf = new CustomFactors(artSet);

            cf.Start();

            using (ISession sess = sessProv.OpenSession()) {
                BuildWordNet.SetDbStateAfterBatchInsert(sess);
            }
        }
Beispiel #4
0
        // <summary>
        //     This will do analysis to determine if a document should be opened
        //     only in the XmlEditor.
        // </summary>
        internal override void DetermineIfArtifactIsDesignerSafe()
        {
            VsUtils.EnsureProvider(this);

            base.DetermineIfArtifactIsDesignerSafe();
            //
            // TODO:  we need to figure out how to deal with errors from the wizard.
            //        when we clear the error list below, we lose errors that we put into the error
            //        list when running the wizard.
            //

            //
            // Now update the VS error list with all of the errors we want to display, which are now in the EFArtifactSet.
            //
            var errorInfos = ArtifactSet.GetAllErrors();

            if (errorInfos.Count > 0)
            {
                var currentProject = VSHelpers.GetProjectForDocument(Uri.LocalPath, PackageManager.Package);
                if (currentProject != null)
                {
                    var hierarchy = VsUtils.GetVsHierarchy(currentProject, Services.ServiceProvider);
                    if (hierarchy != null)
                    {
                        var fileFinder = new VSFileFinder(Uri.LocalPath);
                        fileFinder.FindInProject(hierarchy);

                        Debug.Assert(fileFinder.MatchingFiles.Count <= 1, "Unexpected count of matching files in project");

                        // if the EDMX file is not part of the project.
                        if (fileFinder.MatchingFiles.Count == 0)
                        {
                            var docData = VSHelpers.GetDocData(PackageManager.Package, Uri.LocalPath) as IEntityDesignDocData;
                            ErrorListHelper.AddErrorInfosToErrorList(errorInfos, docData.Hierarchy, docData.ItemId);
                        }
                        else
                        {
                            foreach (var vsFileInfo in fileFinder.MatchingFiles)
                            {
                                if (vsFileInfo.Hierarchy == VsUtils.GetVsHierarchy(currentProject, Services.ServiceProvider))
                                {
                                    var errorList = ErrorListHelper.GetSingleDocErrorList(vsFileInfo.Hierarchy, vsFileInfo.ItemId);
                                    if (errorList != null)
                                    {
                                        errorList.Clear();
                                        ErrorListHelper.AddErrorInfosToErrorList(errorInfos, vsFileInfo.Hierarchy, vsFileInfo.ItemId);
                                    }
                                    else
                                    {
                                        Debug.Fail("errorList is null!");
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public LexicalFactors(ArtifactSet pArtSet)
        {
            vArtSet   = pArtSet;
            vSessProv = new SessionProvider();

            SemanticFactors.AssertWord(vArtSet, AntonymWordId, "antonym");
            SemanticFactors.AssertWord(vArtSet, DerivationWordId, "derivation");
            SemanticFactors.AssertWord(vArtSet, PertainWordId, "pertain");
            SemanticFactors.AssertWord(vArtSet, ParticipleWordId, "participle");
        }
Beispiel #6
0
        public async Task <ActionResult <ArtifactSet> > GetArtifactSet(string setId)
        {
            ArtifactSet artifactSet = await _databaseService.GetArtifactSet(setId);

            if (artifactSet != null)
            {
                return(artifactSet);
            }
            return(NoContent());
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public static void AssertWord(ArtifactSet pArtSet, int pWordId, string pExpectArtifactName)
        {
            Artifact a = pArtSet.WordIdMap[pWordId];

            Console.WriteLine("AssertWord " + pWordId + ": " + a.Name);

            if (a.Name != pExpectArtifactName)
            {
                throw new Exception("Incorrect word '" + a.Name + "', expected '" + pExpectArtifactName + "'.");
            }
        }
        private ArtifactSet ReadArtifactSet(DbDataReader sqlReader)
        {
            ArtifactSet artifactSet = new ArtifactSet();

            artifactSet.Id             = sqlReader["ArtifactSetTable.id"].ToString();
            artifactSet.Name           = sqlReader["ArtifactSetTable.name"].ToString();
            artifactSet.MaxRarity      = sqlReader.GetInt32("ArtifactSetTable.max_rarity");
            artifactSet.TwoPieceBonus  = sqlReader["ArtifactSetTable.two_piece_bonus"].ToString();
            artifactSet.FourPieceBonus = sqlReader["ArtifactSetTable.four_piece_bonus"].ToString();

            return(artifactSet);
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public CustomFactors(ArtifactSet pArtSet)
        {
            vArtSet   = pArtSet;
            vSessProv = new SessionProvider();

            SemanticFactors.AssertWord(vArtSet, PartOfSpeechWordId, "part of speech");
            SemanticFactors.AssertWord(vArtSet, NounWordId, "noun");
            SemanticFactors.AssertWord(vArtSet, VerbWordId, "verb");
            SemanticFactors.AssertWord(vArtSet, AdjectiveWordId, "adjective");
            SemanticFactors.AssertWord(vArtSet, AdverbWordId, "adverb");

            SemanticFactors.AssertWord(vArtSet, SynsetWordId, "synset");
            SemanticFactors.AssertWord(vArtSet, WordNet31WordId, "WordNet3.1");
        }
Beispiel #10
0
        public static bool LoadArtifactToSlot(BinaryReader reader, H3Map map, HeroInstance hero, int slotIndex)
        {
            int artmask = 0xffff;

            if (map.Header.Version == EMapFormat.ROE)
            {
                artmask = 0xff;
            }

            int aid = reader.ReadUInt16();

            bool isArt = (aid != artmask);

            if (isArt)
            {
                Console.WriteLine("loadArtifactToSlot: id={0}, slot={1}", aid, slotIndex);

                ArtifactSet artifactSet = hero.Data.Artifacts;

                EArtifactId artifactId = (EArtifactId)aid;
                H3Artifact  artifact   = new H3Artifact(artifactId);

                if (artifact.IsBig() && slotIndex > 19)
                {
                    return(false);
                }

                EArtifactPosition slot = (EArtifactPosition)slotIndex;
                if (aid == 0 && slot == EArtifactPosition.MISC5)
                {
                    //TODO: check how H3 handles it -> art 0 in slot 18 in AB map
                    slot = EArtifactPosition.SPELLBOOK;
                }

                // this is needed, because some H3M maps (last scenario of ROE map) contain invalid data like misplaced artifacts
                //// auto artifact = CArtifactInstance::createArtifact(map, aid);
                //// auto artifactPos = ArtifactPosition(slot);

                if (artifactSet.CanPutAt(artifactId, slot))
                {
                    artifactSet.PutAt(artifactId, slot);
                }


                return(true);
            }

            return(false);
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public SemanticFactors(ArtifactSet pArtSet)
        {
            vArtSet   = pArtSet;
            vSessProv = new SessionProvider();

            AssertWord(vArtSet, MemberWordId, "member");
            AssertWord(vArtSet, PartWordId, "part");
            AssertWord(vArtSet, SubstanceWordId, "substance");
            AssertWord(vArtSet, SimilarWordId, "similar");
            AssertWord(vArtSet, RelatedWordId, "related");
            AssertWord(vArtSet, TopicWordId, "topic");
            AssertWord(vArtSet, UsageWordId, "usage");
            AssertWord(vArtSet, RegionWordId, "region");
            AssertWord(vArtSet, SubsetWordId, "subset");
            AssertWord(vArtSet, CauseWordId, "cause");
        }
        /// <summary>
        ///     Reload the EntityDesignArtifact and DiagramArtifact (if available).
        /// </summary>
        internal override void ReloadArtifact()
        {
            try
            {
                IsArtifactReloading = true;

                // clear out the artifact set of our information
                ArtifactSet.RemoveArtifact(this);
                ArtifactSet.Add(this);

                // Reparse the artifact.
                State = EFElementState.None;
                Parse(new List <XName>());
                if (State == EFElementState.Parsed)
                {
                    XmlModelHelper.NormalizeAndResolve(this);
                }

                // NOTE: DiagramArtifact must be reloaded after EntityDesignArtifact finishes reloading but before we fire artifact reloaded event.
                if (DiagramArtifact != null)
                {
                    DiagramArtifact.ReloadArtifact();
                }

                // this will do some analysis to determine if the artifact is safe for the designer, or should be displayed in the xml editor
                DetermineIfArtifactIsDesignerSafe();

                FireArtifactReloadedEvent();

                RequireDelayedReload = false;
                IsDirty = false;
            }
            finally
            {
                IsArtifactReloading = false;
            }
        }