SelectChildren() public method

public SelectChildren ( XPathNodeType type ) : XPathNodeIterator
type XPathNodeType
return XPathNodeIterator
Ejemplo n.º 1
2
		protected override void ParseConfiguration(XPathNavigator configurationElement, IXmlNamespaceResolver xmlNamespaceResolver, ContentType contentType)
		{
            //<MinValue>-6</MinValue>
			//<MaxValue>42</MaxValue>
			foreach (XPathNavigator node in configurationElement.SelectChildren(XPathNodeType.Element))
			{
				switch (node.LocalName)
				{
					case MinValueName:
                        int minValue;
                        if (Int32.TryParse(node.InnerXml, out minValue))
                            _minValue = minValue;
						break;
					case MaxValueName:
						int maxValue;
						if (Int32.TryParse(node.InnerXml, out maxValue))
							_maxValue = maxValue;
						break;
                    case ShowAsPercentageName:
                        bool perc;
                        if (Boolean.TryParse(node.InnerXml, out perc))
                            _showAsPercentage = perc;
                        break;
				}
			}
		}
Ejemplo n.º 2
0
        [Test] //ExSkip
        public void NodeXPathNavigator()
        {
            // Create a blank document
            Document doc = new Document();

            // A document is a composite node so we can make a navigator straight away
            System.Xml.XPath.XPathNavigator navigator = doc.CreateNavigator();

            // Our root is the document node with 1 child, which is the first section
            Assert.AreEqual("Document", navigator.Name);
            Assert.AreEqual(false, navigator.MoveToNext());
            Assert.AreEqual(1, navigator.SelectChildren(XPathNodeType.All).Count);

            // The document tree has the document, first section, body and first paragraph as nodes, with each being an only child of the previous
            // We can add a few more to give the tree some branches for the navigator to traverse
            DocumentBuilder docBuilder = new DocumentBuilder(doc);

            docBuilder.Write("Section 1, Paragraph 1. ");
            docBuilder.InsertParagraph();
            docBuilder.Write("Section 1, Paragraph 2. ");
            doc.AppendChild(new Section(doc));
            docBuilder.MoveToSection(1);
            docBuilder.Write("Section 2, Paragraph 1. ");

            // Use our navigator to print a map of all the nodes in the document to the console
            StringBuilder stringBuilder = new StringBuilder();

            MapDocument(navigator, stringBuilder, 0);
            Console.Write(stringBuilder.ToString());
        }
        /// <summary>
        /// Creates a notification channel from the XML representation.
        /// </summary>
        /// <param name="navigator">The navigator to read the information from. </param>
        /// <returns>The notification channel.</returns>
        /// 
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="navigator"/> parameter is <b>null</b>.
        /// </exception>
        /// 
        /// <exception cref="InvalidOperationException">
        /// The notification channel defined in the XML is not recognized.
        /// </exception>
        public static NotificationChannel Deserialize(XPathNavigator navigator)
        {
            Validator.ThrowIfNavigatorNull(navigator);

            // find out what kind of node we have, and go from there...
            NotificationChannel channel = null;
            foreach (XPathNavigator typeSpecificNav in navigator.SelectChildren(XPathNodeType.Element))
            {
                switch (typeSpecificNav.Name)
                {
                    case "http-notification-channel":
                        channel = new HttpNotificationChannel();
                        channel.ParseXml(navigator);
                        break;

                    default:
                        throw new InvalidOperationException(
                            String.Format(
                                CultureInfo.InvariantCulture,
                                ResourceRetriever.GetResourceString("UnrecognizedNotificationChannelType"),
                                typeSpecificNav.Name));
                }
            }

            return channel;
        }
Ejemplo n.º 4
0
        private DelegateCollection ReadDelegates(XPathNavigator specs)
        {
            DelegateCollection delegates = new DelegateCollection();

            foreach (XPathNavigator node in specs.SelectChildren("function", String.Empty))
            {
                var name = node.GetAttribute("name", String.Empty);

                // Check whether we are adding to an existing delegate or creating a new one.
                Delegate d = null;
                if (delegates.ContainsKey(name))
                {
                    d = delegates[name];
                }
                else
                {
                    d = new Delegate();
                    d.Name = name;
                    d.Version = node.GetAttribute("version", String.Empty);
                    d.Category = node.GetAttribute("category", String.Empty);
                    d.DeprecatedVersion = node.GetAttribute("deprecated", String.Empty);
                    d.Deprecated = !String.IsNullOrEmpty(d.DeprecatedVersion);
                    d.Obsolete = node.GetAttribute("obsolete", String.Empty);
                }

                foreach (XPathNavigator param in node.SelectChildren(XPathNodeType.Element))
                {
                    switch (param.Name)
                    {
                        case "returns":
                            d.ReturnType.CurrentType = param.GetAttribute("type", String.Empty);
                            break;

                        case "param":
                            Parameter p = new Parameter();
                            p.CurrentType = param.GetAttribute("type", String.Empty);
                            p.Name = param.GetAttribute("name", String.Empty);

                            string element_count = param.GetAttribute("elementcount", String.Empty);
                            if (String.IsNullOrEmpty(element_count))
                                element_count = param.GetAttribute("count", String.Empty);
                            if (!String.IsNullOrEmpty(element_count))
                                p.ElementCount = Int32.Parse(element_count);

                            p.Flow = Parameter.GetFlowDirection(param.GetAttribute("flow", String.Empty));

                            d.Parameters.Add(p);
                            break;
                    }
                }

                delegates.Add(d);
            }

            return delegates;
        }
Ejemplo n.º 5
0
        private static string GetElementValue(string elementname, XPathNavigator node)
        {
            XPathNodeIterator element = node.SelectChildren(elementname, "");

            if (element.Count > 0)
            {
                element.MoveNext();
                return element.Current.Value;
            }
            return String.Empty;
        }
Ejemplo n.º 6
0
 protected override void ParseConfiguration(XPathNavigator configurationElement, IXmlNamespaceResolver xmlNamespaceResolver, ContentType contentType)
 {
     //<ExpectedXmlNamespace>htp://example.com/namespace</ExpectedXmlNamespace>
     foreach (XPathNavigator element in configurationElement.SelectChildren(XPathNodeType.Element))
     {
         if (element.LocalName != ExpectedXmlNamespaceName)
             continue;
         _expectedXmlNamespace = element.InnerXml;
         return;
     }
 }
        /// <summary>
        /// Parses child TestUnit nodes.
        /// </summary>
        /// <param name="nav">The parent XPathNavigator which hosts TestUnit nodes.</param>
        /// <param name="parent">The parent TestSuite to which TestUnits are attached to.</param>
        /// <param name="collection">The TestResultCollection which will host the result.</param>
        private static void ParseTestUnitsReport(XPathNavigator nav, TestSuite parent, TestResultCollection collection)
        {
            foreach (XPathNavigator child in nav.SelectChildren(Xml.TestSuite, string.Empty))
            {
                ParseTestSuiteReport(child, parent, collection);
            }

            foreach (XPathNavigator child in nav.SelectChildren(Xml.TestCase, string.Empty))
            {
                ParseTestCaseReport(child, parent, collection);
            }
        }
Ejemplo n.º 8
0
 protected override void ParseConfiguration(XPathNavigator configurationElement, IXmlNamespaceResolver xmlNamespaceResolver, ContentType contentType)
 {
     foreach (XPathNavigator element in configurationElement.SelectChildren(XPathNodeType.Element))
     {
         switch(element.LocalName)
         {
             case IsTextConfigString:
                 _isText = element.InnerXml == "true";
                 break;
         }
     }
 }
        protected virtual void Parse(XPathNavigator navigator)
        {
            sessionFactoryName = navigator.GetAttribute(CfgXmlHelper.SessionFactoryNameAttribute, "");
              XPathNodeIterator xpni = navigator.SelectChildren(CfgXmlHelper.PropertiesNodeName, CfgXmlHelper.CfgSchemaXMLNS);
              while (xpni.MoveNext())
              {
            string propName = xpni.Current.GetAttribute(CfgXmlHelper.PropertyNameAttribute, "");
            string propValue = xpni.Current.Value;

            if (!string.IsNullOrEmpty(propName) && !string.IsNullOrEmpty(propValue))
              properties[propName] = propValue;
              }
        }
Ejemplo n.º 10
0
        protected override void ParseConfiguration(XPathNavigator configurationElement, IXmlNamespaceResolver xmlNamespaceResolver, ContentType contentType)
        {
            base.ParseConfiguration(configurationElement, xmlNamespaceResolver, contentType);

            foreach (XPathNavigator node in configurationElement.SelectChildren(XPathNodeType.Element))
            {
                switch (node.LocalName)
                {
                    case UrlFormatName:
                        ParseEnumValue(node.InnerXml, ref _format);
                        break;
                }
            }
        }
Ejemplo n.º 11
0
		protected override void ParseConfiguration(XPathNavigator configurationElement, IXmlNamespaceResolver xmlNamespaceResolver, ContentType contentType)
		{
			base.ParseConfiguration(configurationElement, xmlNamespaceResolver, contentType);

			//<Regex>^[a-zA-Z0-9]*$</Regex>
			foreach (XPathNavigator element in configurationElement.SelectChildren(XPathNodeType.Element))
			{
				switch (element.LocalName)
				{
					case RegexName:
						_regex = element.InnerXml;
						break;
				}
			}
		}
Ejemplo n.º 12
0
        protected override void ParseConfiguration(XPathNavigator configurationElement, IXmlNamespaceResolver xmlNamespaceResolver, ContentType contentType)
        {
            base.ParseConfiguration(configurationElement, xmlNamespaceResolver, contentType);

            foreach (XPathNavigator node in configurationElement.SelectChildren(XPathNodeType.Element))
            {
                switch (node.LocalName)
                {
                    case FormatName:
                        if (!string.IsNullOrEmpty(node.InnerXml))
                            _format = node.InnerXml;
                        break;
                }
            }
        }
Ejemplo n.º 13
0
 protected override void ParseConfiguration(XPathNavigator configurationElement, IXmlNamespaceResolver xmlNamespaceResolver, ContentType contentType)
 {
     //<MinValue>-6</MinValue>
     //<MaxValue>42</MaxValue>
     foreach (XPathNavigator node in configurationElement.SelectChildren(XPathNodeType.Element))
     {
         switch (node.LocalName)
         {
             case EvenOnlyName:
                 bool evenOnlyValue;
                 if (Boolean.TryParse(node.InnerXml, out evenOnlyValue))
                     _evenOnly = evenOnlyValue;
                 break;
         }
     }
     base.ParseConfiguration(configurationElement, xmlNamespaceResolver, contentType);
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Read all the actions that are children of the actions node
        /// passed in and return a populated IResourceActions collection
        /// </summary>
        /// <param name="actionsNode">The actions node to be read</param>
        /// <returns>Populated IResourceActions collection</returns>
        private IResourceActions ReadActions(XPathNavigator actionsNode)
        {
            IResourceActions resourceActions = new ResourceActions();

            XPathNodeIterator actionNodes = actionsNode.SelectChildren(@"Action", RESOURCE_NAMESPACE_URI);
            if (actionNodes != null && actionNodes.Count > 0)
            {
                while (actionNodes.MoveNext())
                {
                    XPathNavigator actionNode = actionNodes.Current;

                    // If the action is already in the resource actions, then
                    // overwrite it i.e. remove it first then add it in again
                    // OK so do it better and more efficiently later
                    IResourceAction resourceAction = ReadAction(actionNode);
                    if (resourceActions.Contains(resourceAction))
                    {
                        resourceActions.Remove(resourceAction);
                    }
                    resourceActions.Add(resourceAction);
                    // determine the custom data ui handler, probably should be done elsewhere
                    // merged with action loading actually
                    string customUItypeName = (resourceAction as ResourceAction).CustomDataTypeUITypeName;
                    if (customUItypeName != null)
                    {
                        string path = AssemblyLocation.GetPathForActionAssembly(resourceAction.Assembly);
                        try
                        {
                            Assembly assembly = AssemblyLocation.LoadAssemblyFromName(path);
                            resourceAction.CustomDataTypeUI = assembly.CreateInstance(customUItypeName) as ICustomDataType;
                        }
                        catch (Exception e)
                        {
							StringBuilder sb = new StringBuilder();
							sb.Append("XmlResourceReader.ReadAction, trying to load ICustomDataType. ");
							sb.Append("Ignore exception - custom UI may fail to load because the designer is being used ");
							sb.Append("from a workstation that doesnt have the action installed. This will be reflected in the designer UI to its user.");
							Logger.LogDebug(sb.ToString());                            
							Logger.LogDebug(e);
                        }   
                    }
                }
            }

            return resourceActions;
        }
Ejemplo n.º 15
0
        public virtual BaseIterator EvaluateNodeSet(BaseIterator iter)
        {
            XPathResultType returnType = this.GetReturnType(iter);

            switch (returnType)
            {
            case XPathResultType.NodeSet:
            case XPathResultType.Navigator:
            case XPathResultType.Any:
            {
                object            obj = this.Evaluate(iter);
                XPathNodeIterator xpathNodeIterator = obj as XPathNodeIterator;
                BaseIterator      baseIterator      = null;
                if (xpathNodeIterator != null)
                {
                    baseIterator = (xpathNodeIterator as BaseIterator);
                    if (baseIterator == null)
                    {
                        baseIterator = new WrapperIterator(xpathNodeIterator, iter.NamespaceManager);
                    }
                    return(baseIterator);
                }
                XPathNavigator xpathNavigator = obj as XPathNavigator;
                if (xpathNavigator != null)
                {
                    XPathNodeIterator xpathNodeIterator2 = xpathNavigator.SelectChildren(XPathNodeType.All);
                    baseIterator = (xpathNodeIterator2 as BaseIterator);
                    if (baseIterator == null && xpathNodeIterator2 != null)
                    {
                        baseIterator = new WrapperIterator(xpathNodeIterator2, iter.NamespaceManager);
                    }
                }
                if (baseIterator != null)
                {
                    return(baseIterator);
                }
                if (obj == null)
                {
                    return(new NullIterator(iter));
                }
                returnType = Expression.GetReturnType(obj);
                break;
            }
            }
            throw new XPathException(string.Format("expected nodeset but was {1}: {0}", this.ToString(), returnType));
        }
        public IList<string> GrabBackDropUrls(XPathNavigator nav)
        {
            List<string> urls = new List<string>();
            XPathNodeIterator nIter = nav.SelectChildren("backdrop", "");
            if (nav.MoveToFollowing("backdrop", ""))
            {
                XPathNavigator localNav = nav.CreateNavigator();
                nav.MoveToParent();
                for (int i = 0; i < nIter.Count; i++)
                {
                    if (localNav.GetAttribute("size", "").ToUpperInvariant().Equals("original".ToUpperInvariant()))
                        urls.Add(localNav.Value);

                    localNav.MoveToNext();
                }
            }
            return urls;
        }
Ejemplo n.º 17
0
        protected void Parse(XPathNavigator navigator)
        {
            XPathNodeIterator xpni = navigator.SelectChildren(XmlConstants.Property, XmlConstants.SchemaXMLNS);
            while (xpni.MoveNext())
            {
                string propName = xpni.Current.GetAttribute(XmlConstants.Property_Name_Attribute, string.Empty);
                int propEditLevel = 0;
                Int32.TryParse(xpni.Current.GetAttribute(XmlConstants.Property_EditLevel_Attribute, string.Empty), out propEditLevel);
                string propOptionValues =
                    xpni.Current.GetAttribute(XmlConstants.Property_OptionValues_Attribute, string.Empty);
                string propValue = xpni.Current.Value;
                if (!string.IsNullOrEmpty(propName) && !string.IsNullOrEmpty(propValue))
                {
                    Property p = new Property(propName, propValue, propEditLevel, propOptionValues);
                    properties.Add(p);
                }

            }
        }
Ejemplo n.º 18
0
        protected override void ParseConfiguration(XPathNavigator configurationElement, IXmlNamespaceResolver xmlNamespaceResolver, ContentType contentType)
        {
            base.ParseConfiguration(configurationElement, xmlNamespaceResolver, contentType);

            foreach (XPathNavigator element in configurationElement.SelectChildren(XPathNodeType.Element))
            {
                switch (element.LocalName)
                {
                    case RangeName:
                        int range;
                        _range = Int32.TryParse(element.InnerXml, out range) ? range : DefaultRange;
                        break;
                    case SplitName:
                        int split;
                        _split = Int32.TryParse(element.InnerXml, out split) ? split : DefaultSplit;
                        break;
                }
            }
        }
Ejemplo n.º 19
0
        protected override void ParseConfiguration(System.Xml.XPath.XPathNavigator configurationElement, System.Xml.IXmlNamespaceResolver xmlNamespaceResolver, Schema.ContentType contentType)
        {
            base.ParseConfiguration(configurationElement, xmlNamespaceResolver, contentType);

            foreach (XPathNavigator node in configurationElement.SelectChildren(XPathNodeType.Element))
            {
                switch (node.LocalName)
                {
                case VisiblePermissionCountName:
                    int visiblePermissionCount;
                    if (Int32.TryParse(node.InnerXml, out visiblePermissionCount))
                    {
                        _visiblePermissionCount = visiblePermissionCount;
                    }
                    break;
                }
            }

            _options = PermissionType.PermissionTypes.Select(t => new ChoiceOption((t.Name).ToString(), "$ Portal, Permission_" + t.Name)).Take(VisiblePermissionCount ?? DefaultVisiblePermissionCount).ToList();
        }
Ejemplo n.º 20
0
		protected override void ParseConfiguration(XPathNavigator configurationElement, IXmlNamespaceResolver xmlNamespaceResolver, ContentType contentType)
		{
			//<MinLength>0..sok</MinLength>
			//<MaxLength>0..sok<MaxLength>
			foreach (XPathNavigator element in configurationElement.SelectChildren(XPathNodeType.Element))
			{
				switch (element.LocalName)
				{
					case MaxLengthName:
						int maxLength;
						if (int.TryParse(element.InnerXml, out maxLength))
							_maxLength = maxLength;
						break;
					case MinLengthName:
						int minLength;
						if (int.TryParse(element.InnerXml, out minLength))
							_minLength = minLength;
						break;
				}
			}
		}
Ejemplo n.º 21
0
        /// <summary>
        /// Devuelve el valor del primer noso hijo solicitado.
        /// </summary>
        /// <param name="navigator">Navegador del documento XML.</param>
        /// <param name="child">Nodo hijo solicitado.</param>
        /// <returns>El valor del nodo hijo solicitado.</returns>
        public static string GetChildValue(this XPathNavigator navigator, string child)
        {
            if (navigator == null)
            {
                throw new ArgumentNullException(nameof(navigator));
            }

            if (child == null)
            {
                throw new ArgumentNullException(nameof(child));
            }

            if (child == string.Empty)
            {
                throw new ArgumentException(nameof(child));
            }

            XPathNodeIterator children = navigator.SelectChildren(child, string.Empty);

            children.MoveNext();
            return(children.Current.Value);
        }
Ejemplo n.º 22
0
        protected override void ParseConfiguration(XPathNavigator configurationElement, IXmlNamespaceResolver xmlNamespaceResolver, ContentType contentType)
        {
            base.ParseConfiguration(configurationElement, xmlNamespaceResolver, contentType);

            foreach (XPathNavigator node in configurationElement.SelectChildren(XPathNodeType.Element))
            {
                switch (node.LocalName)
                {
                    case TextTypeName:
                        ParseEnumValue(node.InnerXml, ref _textType);
                        break;
                    case RowsName:
                        int rows;
                        if (int.TryParse(node.InnerXml, out rows))
                            _rows = rows;
                        break;
                    case AppendModificationsName:
                        if (!string.IsNullOrEmpty(node.InnerXml))
                            _appendModifications = node.InnerXml.ToLower().CompareTo("true") == 0;
                        break;
                }
            }
        }
Ejemplo n.º 23
0
        public ExamineBackedMedia(XPathNavigator xpath)
        {
            if (xpath == null) throw new ArgumentNullException("xpath");
            Name = xpath.GetAttribute("nodeName", "");
            Values = new Dictionary<string, string>();
            var result = xpath.SelectChildren(XPathNodeType.Element);
            //add the attributes e.g. id, parentId etc
            if (result.Current.HasAttributes)
            {
                if (result.Current.MoveToFirstAttribute())
                {
                    Values.Add(result.Current.Name, result.Current.Value);
                    while (result.Current.MoveToNextAttribute())
                    {
                        Values.Add(result.Current.Name, result.Current.Value);
                    }
                    result.Current.MoveToParent();
                }
            }
            while (result.MoveNext())
            {
                if (result.Current != null && !result.Current.HasAttributes)
                {
                    string value = result.Current.Value;
                    if (string.IsNullOrEmpty(value))
                    {
                        if (result.Current.HasAttributes || result.Current.SelectChildren(XPathNodeType.Element).Count > 0)
                        {
                            value = result.Current.OuterXml;
                        }
                    }
                    Values.Add(result.Current.Name, value);
                }

            }
            WasLoadedFromExamine = false;
        }
        /// <summary>
        /// Create an instance of a Subscription by deserializing the subscription XML.
        /// </summary>
        /// <remarks>
        /// The returned type will be a type derived from Subscription, such as the <see cref="HealthRecordItemChangedSubscription"/> class. 
        /// </remarks>
        /// <param name="subscriptionNavigator">The xml representation to deserialize.</param>
        /// <returns>The subscription.</returns>
        /// 
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="subscriptionNavigator"/> parameter is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ArgumentException">
        /// The <paramref name="subscriptionNavigator"/> parameter XML does not contain 
        /// a subscription node.
        /// </exception>
        ///
        /// <exception cref="InvalidOperationException">
        /// The <paramref name="subscriptionNavigator"/> parameter XML has an unrecognized 
        /// subscription type.
        /// </exception>
        public static Subscription Deserialize(XPathNavigator subscriptionNavigator)
        {
            Validator.ThrowIfNavigatorNull(subscriptionNavigator);

            // find out what kind of node we have, and go from there...
            Subscription subscription = null;
            CommonSubscriptionData commonSubscriptionData = null;
            foreach (XPathNavigator typeSpecificNav in subscriptionNavigator.SelectChildren(XPathNodeType.Element))
            {
                switch (typeSpecificNav.Name)
                {
                    case "record-item-changed-event":
                        subscription = new HealthRecordItemChangedSubscription(null);
                        subscription.ParseXml(subscriptionNavigator);
                        break;

                    case "common":
                        commonSubscriptionData = new CommonSubscriptionData();
                        commonSubscriptionData.ParseXml(subscriptionNavigator);
                        break;

                    default:
                        throw new InvalidOperationException(
                            String.Format(
                                CultureInfo.InvariantCulture,
                                ResourceRetriever.GetResourceString("UnrecognizedSubscriptionType"),
                                typeSpecificNav.Name));
                }
            }
            if (subscription != null)
            {
                subscription.CommonSubscriptionData = commonSubscriptionData;
            }

            return subscription;
        }
Ejemplo n.º 25
0
		private Dictionary<string, FieldDescriptor> ParseFieldElements(XPathNavigator fieldsElement, IXmlNamespaceResolver nsres)
		{
			Dictionary<string, FieldDescriptor> fieldDescriptorList = new Dictionary<string, FieldDescriptor>();
            ContentType listType = ContentType.GetByName("ContentList");
			foreach (XPathNavigator fieldElement in fieldsElement.SelectChildren(XPathNodeType.Element))
			{
				FieldDescriptor fieldDescriptor = FieldDescriptor.Parse(fieldElement, nsres, listType);
				fieldDescriptorList.Add(fieldDescriptor.FieldName, fieldDescriptor);
			}
			return fieldDescriptorList;
		}
Ejemplo n.º 26
0
		private Dictionary<string, FieldDescriptor> ParseContentTypeElement(XPathNavigator contentTypeElement, IXmlNamespaceResolver nsres)
		{
			Dictionary<string, FieldDescriptor> result = null;
			foreach (XPathNavigator subElement in contentTypeElement.SelectChildren(XPathNodeType.Element))
			{
				switch (subElement.LocalName)
				{
                    case "DisplayName":
                        _displayName = subElement.Value;
				        break;
					case "Description":
						_description = subElement.Value;
						break;
					case "Icon":
						_icon = subElement.Value;
						break;
					case "Fields":
						result = ParseFieldElements(subElement, nsres);
						break;
                    case "Actions":
                        //_actions = null;
                        //ParseActions(subElement, nsres);
                        Logger.WriteWarning("Ignoring obsolete Actions element in List definition: " + this.Name);
                        break;
                    default:
                        throw new NotSupportedException(String.Concat("Unknown element in ContentListDefinition: ", subElement.LocalName));
				}
			}
			return result;
		}
Ejemplo n.º 27
0
 protected RuleWithSubRules(XPathNavigator node, object aSetId)
 {
     PopulateSubNodes(node.SelectChildren(XPathNodeType.Element), aSetId);
 }
        public bool Load(XPathNavigator source, XmlNamespaceManager manager)
        {
            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(source, "source");

            //------------------------------------------------------------
            //	Attempt to extract syndication information
            //------------------------------------------------------------
            ResourceName = source.LocalName;
            Namespace = source.NamespaceURI;

            string value;
            Key = source.TryGetAttribute("key", Framework.Common.SData.Namespace, out value) ? value : null;
            Uri = source.TryGetAttribute("uri", Framework.Common.SData.Namespace, out value) && !string.IsNullOrEmpty(value) ? new Uri(value) : null;
            Uuid = source.TryGetAttribute("uuid", Framework.Common.SData.Namespace, out value) && !string.IsNullOrEmpty(value) ? new Guid(value) : (Guid?) null;
            Descriptor = source.TryGetAttribute("descriptor", Framework.Common.SData.Namespace, out value) ? value : null;
            Lookup = source.TryGetAttribute("lookup", Framework.Common.SData.Namespace, out value) ? value : null;
            IsDeleted = source.TryGetAttribute("isDeleted", Framework.Common.SData.Namespace, out value) && !string.IsNullOrEmpty(value) ? XmlConvert.ToBoolean(value) : (bool?) null;

            return source.SelectChildren(XPathNodeType.Element)
                .Cast<XPathNavigator>()
                .GroupBy(item => item.LocalName)
                .All(group => LoadItem(group.Key, group, manager));
        }
        internal static ItemType InferItemType(XPathNavigator item)
        {
            string value;

            if (item.TryGetAttribute("nil", Framework.Common.XSI.Namespace, out value) && XmlConvert.ToBoolean(value))
            {
                return ItemType.Property;
            }

            if (item.HasAttribute("key", Framework.Common.SData.Namespace) ||
                item.HasAttribute("uuid", Framework.Common.SData.Namespace) ||
                item.HasAttribute("lookup", Framework.Common.SData.Namespace) ||
                item.HasAttribute("descriptor", Framework.Common.SData.Namespace))
            {
                return ItemType.Object;
            }

            if (item.HasAttribute("url", Framework.Common.SData.Namespace) ||
                item.HasAttribute("uri", Framework.Common.SData.Namespace) ||
                item.HasAttribute("deleteMissing", Framework.Common.SData.Namespace))
            {
                return ItemType.PayloadCollection;
            }

            if (item.IsEmptyElement)
            {
                // workaround: Older versions of the SIF generate payload collections as empty namespace-less elements
                return string.IsNullOrEmpty(item.NamespaceURI) ? ItemType.PayloadCollection : ItemType.Property;
            }

            var children = item.SelectChildren(XPathNodeType.Element).Cast<XPathNavigator>();
            var childCount = children.Count();

            if (childCount == 0)
            {
                return ItemType.Property;
            }

            if (childCount > 1 && children.Select(child => child.LocalName).Distinct().Count() == 1)
            {
                if (children.All(child => InferItemType(child) == ItemType.Object))
                {
                    return ItemType.PayloadCollection;
                }
                if (children.All(child => InferItemType(child) == ItemType.Property))
                {
                    return ItemType.SimpleCollection;
                }
            }

            return ItemType.Object;
        }
Ejemplo n.º 30
0
		protected override void ParseConfiguration(XPathNavigator configurationElement, IXmlNamespaceResolver xmlNamespaceResolver, ContentType contentType)
		{
			//...xmlns="http://schemas.sensenet.com/SenseNet/ContentRepository/SearchExpression"
			//....
			//<Configuration>
			//    <AllowMultiple>true<AllowMultiple>
			//    <AllowedTypes>
			//        <Type>Folder</Type>
			//        <Type>File</Type>
			//    </AllowedTypes>
			//    <SelectionRoot>
			//        <Path>/Root/.../1</Path>
			//        <Path>/Root/.../2</Path>
			//    <SelectionRoot>
			//    <Query>
			//        <q:And>
			//          <q:String op="StartsWith" property="Path">.</q:String>
			//          <q:String op="NotEqual" property="Name">Restricted</q:String>
			//        </q:And>
			//    </Query>
			//</Configuration>
			foreach (XPathNavigator element in configurationElement.SelectChildren(XPathNodeType.Element))
			{
				switch (element.LocalName)
				{
					case AllowMultipleName:
						_allowMultiple = element.InnerXml == "true";
						break;
					case AllowedTypesName:
						_allowedTypes = new List<string>();
						foreach (XPathNavigator typeElement in element.SelectChildren(TypeName, element.NamespaceURI))
						{
							string typeName = typeElement.InnerXml; 
							_allowedTypes.Add(typeName);
						}
						break;
					case SelectionRootName:
						_selectionRoots = new List<string>();
						foreach (XPathNavigator pathElement in element.SelectChildren(PathName, element.NamespaceURI))
						{
							string path = pathElement.InnerXml;
							if (path != ".")
							{
								try
								{
									RepositoryPath.CheckValidPath(path);
								}
								catch (InvalidPathException e) //rethrow
								{
									throw new InvalidPathException(String.Concat("Given path is invalid in SelectionRoot element. ContentType: ", contentType.Name,
										", Field name: '", this.Name, "', path: '", path, "'. Reason: ", e.Message));
								}
							}
							_selectionRoots.Add(path);
						}
						break;
					case QueryName:
						var sb = new StringBuilder();
                        sb.Append("<SearchExpression xmlns=\"").Append(NodeQuery.XmlNamespace).Append("\">");
						sb.Append(element.InnerXml);
						sb.Append("</SearchExpression>");
						_query = NodeQuery.Parse(sb.ToString());
						break;
                    case FieldNameName:
				        _fieldName = element.InnerXml;
				        break;
				}
			}
		}
Ejemplo n.º 31
0
		private void SelectChildrenNS (XPathNavigator nav)
		{
			nav.MoveToFirstChild (); // root
			XPathNodeIterator iter = nav.SelectChildren ("foo", "urn:foo");
			Assert.AreEqual (2, iter.Count, "#1");
		}
Ejemplo n.º 32
0
        public static CubicGrid Load(XPathNavigator nav)
        {
            int3 Dimensions = new int3(int.Parse(nav.GetAttribute("Width", ""), CultureInfo.InvariantCulture),
                                       int.Parse(nav.GetAttribute("Height", ""), CultureInfo.InvariantCulture),
                                       int.Parse(nav.GetAttribute("Depth", ""), CultureInfo.InvariantCulture));

            float[,,] Values = new float[Dimensions.Z, Dimensions.Y, Dimensions.X];

            foreach (XPathNavigator nodeNav in nav.SelectChildren("Node", ""))
            {
                //try
                {
                    int X = int.Parse(nodeNav.GetAttribute("X", ""), CultureInfo.InvariantCulture);
                    int Y = int.Parse(nodeNav.GetAttribute("Y", ""), CultureInfo.InvariantCulture);
                    int Z = int.Parse(nodeNav.GetAttribute("Z", ""), CultureInfo.InvariantCulture);
                    float Value = float.Parse(nodeNav.GetAttribute("Value", ""), CultureInfo.InvariantCulture);

                    Values[Z, Y, X] = Value;
                }
                //catch { }
            }

            return new CubicGrid(Values);
        }
Ejemplo n.º 33
0
        /// <summary>
        /// Add the excluded minify paths from the configSection
        /// </summary>
        /// <param name="node"></param>
        private void LoadMinifyExcludedPaths(XPathNavigator node)
        {
            HttpContext context = HttpContext.Current;

            if (context == null  || node == null)
                return;

            string currentPath = Util.GetCurrentPath(context);
            XPathNodeIterator childrens = node.SelectChildren(XPathNodeType.All);
            foreach (XPathNavigator child in childrens)
            {
                if (!string.IsNullOrEmpty(child.GetAttribute("key", string.Empty)))
                {
                    string relativePath = child.GetAttribute("key", string.Empty);
                    string absoluteFile;
                    if (relativePath[0].Equals('~'))
                    {
                        absoluteFile = context.Server.MapPath(relativePath);
                    }
                    else
                    {
                        absoluteFile = context.Server.MapPath(currentPath + relativePath);
                    }
                    _minifyExcludePaths.Add(absoluteFile, true);
                }
            }
        }
Ejemplo n.º 34
0
        /// <summary>
        /// Add the excluded post params values from the configSection
        /// </summary>
        /// <param name="node"></param>
        private void LoadExcludedPostParamValues(XPathNavigator node)
        {
            if (node == null)
                return;

            XPathNodeIterator childrens = node.SelectChildren(XPathNodeType.All);
            foreach (XPathNavigator child in childrens)
            {
                if (!string.IsNullOrEmpty(child.GetAttribute("key", string.Empty)))
                    _postParamsExcludeValues.Add(child.GetAttribute("key", string.Empty));
            }
        }
Ejemplo n.º 35
0
        protected override void ParseConfiguration(System.Xml.XPath.XPathNavigator configurationElement, System.Xml.IXmlNamespaceResolver xmlNamespaceResolver, ContentType contentType)
        {
            base.ParseConfiguration(configurationElement, xmlNamespaceResolver, contentType);

            //<Enabled>true|false</Enabled>
            //<AdminEmail>[email protected]</AdminEmail>
            //<RequireUniqueEmail>true|false</RequireUniqueEmail>
            //<MailDefinition>...</MailDefinition>
            //<IsBodyHtml>true|false</IsBodyHtml>
            //<MailSubject>...</MailSubject>
            //<MailPriority>Low|Normal|High</MailPriority>
            //<MailFrom>[email protected]</MailFrom>
            foreach (XPathNavigator node in configurationElement.SelectChildren(XPathNodeType.Element))
            {
                switch (node.LocalName)
                {
                case EnabledName:
                    bool enabled;
                    if (Boolean.TryParse(node.InnerXml, out enabled))
                    {
                        _enabled = enabled;
                    }
                    break;

                case AdminEmailName:
                    _adminEmail = node.InnerXml;
                    break;

                case RequireUniqueEmailName:
                    bool requireUniqueEmail;
                    if (Boolean.TryParse(node.InnerXml, out requireUniqueEmail))
                    {
                        _requireUniqueEmail = requireUniqueEmail;
                    }
                    break;

                case MailDefinitionName:
                    _mailDefinition = node.InnerXml;
                    break;

                case IsBodyHtmlName:
                    bool isBodyHtml;
                    if (Boolean.TryParse(node.InnerXml, out isBodyHtml))
                    {
                        _isBodyHtml = isBodyHtml;
                    }
                    break;

                case MailSubjectName:
                    _mailSubject = node.InnerXml;
                    break;

                case MailPriorityName:
                    if (node.InnerXml == Enum.GetName(typeof(MailPriority), MailPriority.Low))
                    {
                        _mailPriority = MailPriority.Low;
                    }
                    else if (node.InnerXml == Enum.GetName(typeof(MailPriority), MailPriority.Normal))
                    {
                        _mailPriority = MailPriority.Normal;
                    }
                    else if (node.InnerXml == Enum.GetName(typeof(MailPriority), MailPriority.High))
                    {
                        _mailPriority = MailPriority.High;
                    }
                    else
                    {
                        _mailPriority = MailPriority.Normal;
                    }
                    break;

                case MailFromName:
                    _mailFrom = node.InnerXml;
                    break;
                }
            }
        }