コード例 #1
0
ファイル: XmlPartFilter.cs プロジェクト: killbug2004/WSProf
        private bool IsExcluded(TriggeringNodeDefinition tnd)
        {
            if (exclusionList == null)
                return false;
            string contentID = MetadataExcluder.ContentTypeToID(tnd.ContentType);
            if (contentID.Length == 0)
                return false;
            string exclusionValue = string.Empty;
            foreach (Exclusion ex in exclusionList)
            {
                if (ex.Name == contentID)
                    exclusionValue = ex.Value as string;
            }
            if (exclusionValue.Length == 0)
                return false;
            char[] seps = new char[] { ';' };
            List<string> exclusions = new List<string>(exclusionValue.Split(seps));
            if (exclusions.Contains(tnd.nodeName))
                return true;

            return false;
        }
コード例 #2
0
 internal void Add(TriggeringNodeDefinition triggeringNodeDefinition)
 {
     if (m_bNormalizedNames)
         throw new InvalidOperationException("Not allowed to add more definitions after name normalization");
     m_triggers.Add(triggeringNodeDefinition);
     if (!m_nodeNames.ContainsKey(triggeringNodeDefinition.nodeName))
         m_nodeNames.Add(triggeringNodeDefinition.nodeName, true);
 }
コード例 #3
0
ファイル: StyleSheet.cs プロジェクト: killbug2004/WSProf
        private List<TriggeringNodeDefinition> BuildTriggeringNodeDefsForStyle(Style s, TriggerCollection triggers)
        {
            List<TriggeringNodeDefinition> results = new List<TriggeringNodeDefinition>();
            TriggeringNodeDefinition tnd = null;

            foreach (XmlNodeInformation ni in s.GetProperties())
            {
                List<TriggeringNodeDefinition> thisNodetriggers =  triggers.WhatDoesThisNodeTrigger(ni, null, null);

                if ((thisNodetriggers != null) && (thisNodetriggers.Count > 0))
                {
                    foreach (TriggeringNodeDefinition etnd in thisNodetriggers)
                    {
                        if (etnd.GetDescriptors().Count > 1)
                            throw new InvalidOperationException(); // we weren't expecting this
                        EffectDescriptor td = etnd.GetDescriptors()[0].Clone();
                        if (ni.GetAttributeValue("val") == "0")
                            td.DefaultPolarity = false;
                        if (tnd != null)
                        {
                            if (tnd.ContentType == td.ContentType)
                                tnd.AddDescriptor(td);
                            else
                                tnd = null;
                        }

                        if (tnd == null)
                        {
                            AttributeFilter af = new ValueAttributeEqualityFilter(s.Id);
                            tnd = new TriggeringNodeDefinition(NamespaceId.w, s.GetReferenceNodeName(), af, td);
                            results.Add(tnd);
                        }
                    }
                }
            }

            return results;
        }
コード例 #4
0
        private static TriggeringNodeDefinition BuildTrackChangeDef(string typeName, string nodeName, bool bRemoveContent)
        {

            EffectDescriptor td = new EffectDescriptor();
            td.ContentType = ContentType.TrackChange;
            td.AddAdditionalInfoDescriptor(new AdditionalInfoDescriptor("Type", typeName, AdditionalInfoDescriptor.MappingType.FixedValue));
            td.AddAdditionalInfoDescriptor(new AdditionalInfoDescriptor("Author", "author", AdditionalInfoDescriptor.MappingType.AttribValue));
            td.DeleteNodeContent = bRemoveContent;

            TriggeringNodeDefinition result = new TriggeringNodeDefinition(NamespaceId.w, nodeName, null, null, td);
            return result;


        }
コード例 #5
0
 private TriggeringNodeDefinition BuildMockTriggerNodeThing()
 {
     EffectDescriptor td = new EffectDescriptor();
     td.AdditionalLevels = 2;
     td.ContentType = ContentType.SmallText;
     TriggeringNodeDefinition result = new TriggeringNodeDefinition(NamespaceId.w, "vanish", null, null, td);
     return result;
 }
コード例 #6
0
        public void TestFilterOutNodesWithContentByName()
        {
            using (Stream from = File.Open(TESTFILE_DIR + "Comments3.xml", FileMode.Open))
            {
                if (File.Exists(TESTFILE_DIR + "Comments3_result.xml"))
                    File.Delete(TESTFILE_DIR + "Comments3_result.xml");
                using (Stream to = File.Open(TESTFILE_DIR + "Comments3_result.xml", FileMode.CreateNew))
                {

                    StateMachineBasedXmlFilter xfb = new StateMachineBasedXmlFilter(new CommonNamespaces(OpenXmlFormat.Transitional));
                    xfb.ConnectToInputStream(from);
                    xfb.ConnectToOutputStream(to);

                    EffectDescriptor td = new EffectDescriptor();
                    td.BlockType = Effect.BlockType.Content;
                    TriggeringNodeDefinition tnd = new TriggeringNodeDefinition(NamespaceId.w, "t", null, null, td);

                    xfb.AddNodeToTriggerList(tnd);

                    xfb.Execute();
                }
            }
            Assert.IsTrue(XmlDocumentComparison.AreEquivalent(TESTFILE_DIR + "Comments3_wanted.xml",
                                                              TESTFILE_DIR + "Comments3_result.xml"));
        }