当前位置: 首页>>代码示例>>C#>>正文


C# IPath.GetType方法代码示例

本文整理汇总了C#中IPath.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IPath.GetType方法的具体用法?C# IPath.GetType怎么用?C# IPath.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPath的用法示例。


在下文中一共展示了IPath.GetType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SelectEnumerable

        public IEnumerable<object> SelectEnumerable(IPath path, object data)
        {
            IInterrogator interrogator = InterrogatorFactory.CreateInteregator(data.GetType());
            INavigator navigator = interrogator.CreateNavigator(data, path.GetType());

            if (navigator == null)
            {
                throw new Exception(string.Concat("Couldn't create a navigator for the path '", path.ToString(), "'."));
            }

            IEnumerable<object> values = navigator.SelectEnumerable(path);

            navigator.Dispose();

            return values;
        }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:16,代码来源:DataBrowser.cs

示例2: SelectScalar

        public object SelectScalar(IPath path)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            var pocoPath = path as PocoPath;

            if (pocoPath == null)
            {
                throw new Exception(string.Format("Path of type '{0}' expected, path of type '{1}' received.",
                    typeof (PocoPath), path.GetType()));
            }

            object currentData = Data;

            if (path.ActualPath == PocoPath.SeperatorSymbol)
            {
                currentData = Data.ToString();
            }
            else if (path.ActualPath == PocoPath.EnumerableSymbol + PocoPath.SeperatorSymbol)
            {
                var enumerableData = currentData as IEnumerable;

                if (enumerableData == null)
                {
                    currentData = null;
                }
                else
                {
                    IEnumerator enumerator = enumerableData.GetEnumerator();
                    enumerator.Reset();
                    while (enumerator.MoveNext())
                    {
                        currentData = enumerator.Current;
                    }
                }
            }
            else
            {
                List<IPathSegment> pathSegments = pocoPath.GetSegements().ToList();
                int segmentIndex = 0;

                while (currentData != null && segmentIndex < pathSegments.Count)
                {
                    if (pathSegments[segmentIndex].IsEnumarable)
                    {
                        IEnumerable enumerableData = GetEnumerableValueForPathSegment(pathSegments[segmentIndex],
                            currentData);

                        if (enumerableData == null)
                        {
                            currentData = null;
                        }
                        else
                        {
                            IEnumerator enumerator = enumerableData.GetEnumerator();
                            enumerator.Reset();
                            while (enumerator.MoveNext())
                            {
                                currentData = enumerator.Current;
                            }
                        }
                    }
                    else
                    {
                        currentData = GetScalarValueForPathSegement(pathSegments[segmentIndex], currentData);
                    }

                    segmentIndex++;
                }
            }

            return currentData;
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:76,代码来源:PocoNavigator.cs

示例3: SelectEnumerable

        public IEnumerable<object> SelectEnumerable(IPath path)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            var pocoPath = path as PocoPath;

            if (pocoPath == null)
            {
                throw new Exception(string.Format("Path of type '{0}' expected, path of type '{1}' received.",
                    typeof (PocoPath), path.GetType()));
            }

            List<object> returnData;

            if (path.ActualPath == PocoPath.SeperatorSymbol)
            {
                returnData = new List<object> {Data};
            }
            else if (path.ActualPath == PocoPath.EnumerableSymbol + PocoPath.SeperatorSymbol)
            {
                var enumerableData = Data as IEnumerable;
                returnData = new List<object>();

                if (enumerableData != null)
                {
                    IEnumerator enumerator = enumerableData.GetEnumerator();
                    enumerator.Reset();
                    while (enumerator.MoveNext())
                    {
                        returnData.Add(enumerator.Current);
                    }
                }
            }
            else
            {
                returnData = SelectEnumberable(pocoPath.GetSegements().ToList(), Data).ToList();
            }

            return returnData;
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:43,代码来源:PocoNavigator.cs

示例4: SelectScalar

        public object SelectScalar(IPath path)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            var xmlPath = path as XmlPath;

            if (xmlPath == null)
            {
                throw new Exception(string.Format("Path of type '{0}' expected, path of type '{1}' received.",
                    typeof (XmlPath), path.GetType()));
            }

            var document = Data as XDocument;

            if (document == null)
            {
                throw new Exception(string.Format("Type of {0} was expected for data, type of {1} was found instead.",
                    typeof (XDocument), Data.GetType()));
            }

            string returnData = string.Empty;
            XElement currentElement = document.Root;

            if (path.ActualPath == XmlPath.NodeSeperatorSymbol)
            {
                if (currentElement != null)
                {
                    returnData = currentElement.ToString();
                }
            }
            else
            {
                var pathSegments = new List<XmlPathSegment>(xmlPath.GetSegements().OfType<XmlPathSegment>());
                int segmentIndex = 0;

                while (currentElement != null && segmentIndex < pathSegments.Count)
                {
                    if (segmentIndex == 0 && currentElement.Name != pathSegments[segmentIndex].ActualSegment && currentElement.Name.LocalName!=pathSegments[segmentIndex].ActualSegment)
                    {
                        currentElement = null;
                        returnData = null;
                    }
                    else if (segmentIndex == 0 && pathSegments.Count == 1 &&
                             currentElement.Name == pathSegments[segmentIndex].ActualSegment)
                    {
                        returnData = currentElement.Value;
                    }
                    else if (segmentIndex > 0)
                    {
                        if (pathSegments[segmentIndex].IsAttribute)
                        {
                            XAttribute attribute = currentElement.Attribute(pathSegments[segmentIndex].ActualSegment);

                            if (attribute != null)
                            {
                                currentElement = null;
                                returnData = attribute.Value;
                            }
                        }
                        else
                        {
                            var actualSegment = pathSegments[segmentIndex].ActualSegment;
                            var newCurrentElement =
                                currentElement.Elements(actualSegment).LastOrDefault();
                            // Travis.Frisinger : 09/10/2012 - Fix for null element, naughty Brendan ;)
                            if (newCurrentElement != null)
                            {
                                returnData = newCurrentElement.Value;
                                currentElement = newCurrentElement;
                            }
                            else
                            {
                                newCurrentElement = currentElement.Elements().LastOrDefault(element => element.Name.LocalName.Equals(actualSegment, StringComparison.InvariantCultureIgnoreCase));
                                if (newCurrentElement != null)
                                {
                                    returnData = newCurrentElement.Value;
                                    currentElement = newCurrentElement;
                                }
                                else
                                {
                                    returnData = string.Empty;
                                }
                            }
                        }
                    }

                    segmentIndex++;
                }
            }

            return returnData;
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:95,代码来源:XmlNavigator.cs

示例5: SelectEnumerable

        public IEnumerable<object> SelectEnumerable(IPath path)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            var xmlPath = path as XmlPath;

            if (xmlPath == null)
            {
                throw new Exception(string.Format("Path of type '{0}' expected, path of type '{1}' received.",
                    typeof (XmlPath), path.GetType()));
            }

            var document = Data as XDocument;

            if (document == null)
            {
                throw new Exception(string.Format("Type of {0} was expected for data, type of {1} was found instead.",
                    typeof (XDocument), Data.GetType()));
            }

            List<object> returnData = null;
            XElement currentElement = document.Root;

            if (path.ActualPath == XmlPath.NodeSeperatorSymbol)
            {
                if (currentElement != null)
                {
                    returnData = new List<object> {currentElement.ToString()};
                }
            }
            else
            {
                var pathSegments = new List<IPathSegment>(xmlPath.GetSegements());
                returnData =
                    new List<object>(SelectEnumberable(pathSegments.Skip(1).ToList(), pathSegments.FirstOrDefault(),
                        currentElement));
            }

            return returnData;
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:43,代码来源:XmlNavigator.cs

示例6: SelectScalar

        public object SelectScalar(IPath path)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            var jsonPath = path as JsonPath;

            if (jsonPath == null)
            {
                throw new Exception(string.Format("Path of type '{0}' expected, path of type '{1}' received.",
                    typeof (JsonPath), path.GetType()));
            }

            var currentData = Data as JToken;

            if (currentData == null)
            {
                throw new Exception(string.Format("Type of {0} was expected for data, type of {1} was found instead.",
                    typeof (JToken), Data.GetType()));
            }

            if (path.ActualPath == JsonPath.SeperatorSymbol)
            {
                //nothing to do here yet
            }
            else if (path.ActualPath == JsonPath.EnumerableSymbol + JsonPath.SeperatorSymbol)
            {
                var enumerableData = currentData as IEnumerable;


                IEnumerator enumerator = enumerableData.GetEnumerator();
                enumerator.Reset();
                while (enumerator.MoveNext())
                {
                    currentData = enumerator.Current as JToken;
                }
            }
            else
            {
                List<IPathSegment> pathSegments = jsonPath.GetSegements().ToList();
                int segmentIndex = 0;

                while (currentData != null && segmentIndex < pathSegments.Count)
                {
                    if (pathSegments[segmentIndex].IsEnumarable)
                    {
                        IEnumerable enumerableData = GetEnumerableValueForPathSegment(pathSegments[segmentIndex],
                            currentData);

                        if (enumerableData == null)
                        {
                            currentData = null;
                        }
                        else
                        {
                            IEnumerator enumerator = enumerableData.GetEnumerator();
                            enumerator.Reset();
                            while (enumerator.MoveNext())
                            {
                                currentData = enumerator.Current as JToken;
                            }
                        }
                    }
                    else
                    {
                        currentData = GetScalarValueForPathSegement(pathSegments[segmentIndex], currentData);
                    }

                    segmentIndex++;
                }
            }

            string returnVal = "";

            if (currentData != null)
            {
                returnVal = currentData.ToString();
            }

            return returnVal;
        }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:83,代码来源:JsonNavigator.cs


注:本文中的IPath.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。