コード例 #1
0
        protected override void ConfigureObjectCollector()
        {
            if (base.ObjectCollector == null)
            {
                var newXPathOperator = new XPathOperator()
                {
                    FileContentProvider = CustomFileProvider
                };
                var objCollector = new XmlFileContentObjectCollector()
                {
                    XPathOperator = newXPathOperator, Platform = this.Platform
                };

                base.ObjectCollector = objCollector;
            }

            if (base.ItemTypeGenerator == null)
            {
                var pathOperatorEvaluator = new PathOperatorEvaluator(CustomFileProvider, Platform);
                var itemTypeGenerator     = new XmlFileContentItemTypeGenerator(pathOperatorEvaluator);

                base.ItemTypeGenerator = itemTypeGenerator;
            }
        }
コード例 #2
0
        private void CheckFlaggedProperties(MetabaseSessionConfiguration metabaseSession)
        {
            if (string.IsNullOrWhiteSpace(metabaseSession.Value))
                return;

            if (this.IsFlaggedProperty(metabaseSession))
            {
                int propertyValue = 0;
                var flags = metabaseSession.Value.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var flag in flags)
                {
                    var xPathFlagNode =  string.Format("//*[@InternalName='{0}']", flag.Trim());
                    var flagNode = new XPathOperator().applyXpath(this.XmlMBSchema, xPathFlagNode, true);
                    var flagValue = int.Parse(new XPathOperator().applyXpath(flagNode.First(), "//*/@Value", false).First());
                    propertyValue += flagValue;
                }

                metabaseSession.Value = propertyValue.ToString();
            }
        }
コード例 #3
0
 private string TryToGetAttributeValueFromMetabaseFragment(string metabaseXmlFragment, string attributeName, bool retryToGetValue)
 {
     var xPathOperator = new XPathOperator();
     try
     {
         var xpathExpression = string.Format("//*/@{0}", attributeName);
         return xPathOperator.applyXpath(metabaseXmlFragment, xpathExpression).FirstOrDefault();
     }
     catch (XPathNoResultException)
     {
         try
         {
             if (retryToGetValue)
                 return xPathOperator.applyXpath(metabaseXmlFragment, "//*/@Value").FirstOrDefault();
             
             return null;
         }
         catch (XPathNoResultException)
         {
             return null;
         }
     }
 }
コード例 #4
0
        private MetabaseSessionConfiguration GetMetabasePropertyFromMBSchema(string id)
        {
            var xpathExpression = string.Format("//*[@ID='{0}']", id);
            try
            {
                var propertyNode = new XPathOperator().applyXpath(XmlMBSchema, xpathExpression, true).FirstOrDefault();
                if (!string.IsNullOrEmpty(propertyNode))
                {
                    var name = TryToGetAttributeValueFromMetabaseFragment(propertyNode, "InternalName", true);
                    var type = TryToGetAttributeValueFromMetabaseFragment(propertyNode, "Type", true);
                    var userType = TryToGetAttributeValueFromMetabaseFragment(propertyNode, "UserType", true);
                    return new MetabaseSessionConfiguration(name, id, type, userType);
                }

                return null;
            }
            catch (XPathNoResultException)
            {
                try
                {
                    var propertyNode = new XPathOperator().applyXpath(XmlMetabaseContent, xpathExpression, true).FirstOrDefault();
                    var name = TryToGetAttributeValueFromMetabaseFragment(propertyNode, "Name", false);
                    var type = TryToGetAttributeValueFromMetabaseFragment(propertyNode, "Type", false);
                    var userType = TryToGetAttributeValueFromMetabaseFragment(propertyNode, "UserType", false);
                    return new MetabaseSessionConfiguration(name, id, type, userType);
                }
                catch (XPathNoResultException)
                {
                    return null;
                }
            }
        }
コード例 #5
0
 private string GetXmlFragmentForLocation(string location)
 {
     var xpathToGetAllIIisConfigurationByLocation = string.Format("//*[@Location = \"{0}\"]", location);
     var allIisProperties = new XPathOperator().applyXpath(MetabaseFileContent, xpathToGetAllIIisConfigurationByLocation, true);
     return string.Join(Environment.NewLine, allIisProperties);
 }