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


C# IInventoryService.GetFolderItems方法代码示例

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


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

示例1: FindItemByPath

        /// <summary>
        /// Find an item given a PATH_DELIMITOR delimited path starting from this folder.
        ///
        /// This method does not handle paths that contain multiple delimitors
        ///
        /// FIXME: We do not yet handle situations where folders or items have the same name.  We could handle this by some
        /// XPath like expression
        ///
        /// FIXME: Delimitors which occur in names themselves are not currently escapable.
        /// </summary>
        /// 
        /// <param name="inventoryService">
        /// Inventory service to query
        /// </param>
        /// <param name="startFolder">
        /// The folder from which the path starts
        /// </param>
        /// <param name="path">
        /// <param name="path">
        /// The path to the required item.
        /// </param>
        /// <returns>null if the item is not found</returns>
        public static InventoryItemBase FindItemByPath(
            IInventoryService inventoryService, InventoryFolderBase startFolder, string path)
        {
            // If the path isn't just / then trim any starting extraneous slashes
            path = path.TrimStart(new char[] { PATH_DELIMITER });

            string[] components = SplitEscapedPath(path);
            components[0] = UnescapePath(components[0]);

            //string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None);

            if (components.Length == 1)
            {
            //                MainConsole.Instance.DebugFormat(
            //                    "FOUND SINGLE COMPONENT [{0}].  Looking for this in [{1}] {2}",
            //                    components[0], startFolder.Name, startFolder.ID);

                List<InventoryItemBase> items = inventoryService.GetFolderItems(startFolder.Owner, startFolder.ID);

            //                MainConsole.Instance.DebugFormat("[INVENTORY ARCHIVE UTILS]: Found {0} items in FindItemByPath()", items.Count);

                foreach (InventoryItemBase item in items)
                {
            //                    MainConsole.Instance.DebugFormat("[INVENTORY ARCHIVE UTILS]: Inspecting item {0} {1}", item.Name, item.ID);

                    if (item.Name == components[0])
                        return item;
                }
            }
            else
            {
            //                MainConsole.Instance.DebugFormat("FOUND COMPONENTS [{0}] and [{1}]", components[0], components[1]);

                InventoryCollection contents = inventoryService.GetFolderContent(startFolder.Owner, startFolder.ID);

                foreach (InventoryFolderBase folder in contents.Folders)
                {
                    if (folder.Name == components[0])
                        return FindItemByPath(inventoryService, folder, components[1]);
                }
            }

            // We didn't find an item or intermediate folder with the given name
            return null;
        }
开发者ID:WhiteCoreSim,项目名称:WhiteCore-Optional-Modules,代码行数:67,代码来源:InventoryArchiveUtils.cs

示例2: FindItemByPath

        /// <summary>
        ///     Find an item given a PATH_DELIMITOR delimited path starting from this folder.
        ///     This method does not handle paths that contain multiple delimiters
        ///     FIXME: We do not yet handle situations where folders or items have the same name.  We could handle this by some
        ///     XPath like expression
        ///     FIXME: Delimiters which occur in names themselves are not currently escapable.
        /// </summary>
        /// <param name="inventoryService">
        ///     Inventory service to query
        /// </param>
        /// <param name="startFolder">
        ///     The folder from which the path starts
        /// </param>
        /// <param name="path">
        ///     The path to the required item.
        /// </param>
        /// <returns>null if the item is not found</returns>
        public static InventoryItemBase FindItemByPath(
            IInventoryService inventoryService, InventoryFolderBase startFolder, string path)
        {
            // If the path isn't just / then trim any starting extraneous slashes
            path = path.TrimStart(new[] { PATH_DELIMITER });

            string[] components = SplitEscapedPath(path);
            components[0] = UnescapePath(components[0]);

            //string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None);

            if (components.Length == 1)
            {
                //MainConsole.Instance.DebugFormat(
                //    "FOUND SINGLE COMPONENT [{0}].  Looking for this in [{1}] {2}", components[0], startFolder.Name, startFolder.ID);

                List<InventoryItemBase> items = inventoryService.GetFolderItems(startFolder.Owner, startFolder.ID);

                //MainConsole.Instance.DebugFormat("[INVENTORY ARCHIVE UTILS]: Found {0} items in FindItemByPath()", items.Count);

                return items.FirstOrDefault(item => item.Name == components[0]);
            }
            else
            {
                //MainConsole.Instance.DebugFormat("FOUND COMPONENTS [{0}] and [{1}]", components[0], components[1]);

                InventoryCollection contents = inventoryService.GetFolderContent(startFolder.Owner, startFolder.ID);

                return (from folder in contents.Folders
                        where folder.Name == components[0]
                        select FindItemByPath(inventoryService, folder, components[1])).FirstOrDefault();
            }
        }
开发者ID:Virtual-Universe,项目名称:Virtual-Universe,代码行数:50,代码来源:InventoryArchiveUtils.cs

示例3: FindItemByPath

        /// <summary>
        /// Find an item given a PATH_DELIMITOR delimited path starting from this folder.
        ///
        /// This method does not handle paths that contain multiple delimitors
        ///
        /// FIXME: We do not yet handle situations where folders or items have the same name.  We could handle this by some
        /// XPath like expression
        ///
        /// FIXME: Delimitors which occur in names themselves are not currently escapable.
        /// </summary>
        /// 
        /// <param name="inventoryService">
        /// Inventory service to query
        /// </param>
        /// <param name="startFolder">
        /// The folder from which the path starts
        /// </param>
        /// <param name="path">
        /// <param name="path">
        /// The path to the required item.
        /// </param>
        /// <returns>null if the item is not found</returns>
        public static InventoryItemBase FindItemByPath(
            IInventoryService inventoryService, InventoryFolderBase startFolder, string path)
        {
            string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None);

            if (components.Length == 1)
            {
                List<InventoryItemBase> items = inventoryService.GetFolderItems(startFolder.Owner, startFolder.ID);
                foreach (InventoryItemBase item in items)
                {
                    if (item.Name == components[0])
                        return item;
                }
            }
            else
            {
                InventoryCollection contents = inventoryService.GetFolderContent(startFolder.Owner, startFolder.ID);                
                
                foreach (InventoryFolderBase folder in contents.Folders)
                {
                    if (folder.Name == components[0])
                        return FindItemByPath(inventoryService, folder, components[1]);
                }
            }

            // We didn't find an item or intermediate folder with the given name
            return null;
        }        
开发者ID:Ideia-Boa,项目名称:diva-distribution,代码行数:50,代码来源:InventoryArchiveUtils.cs

示例4: FindItemByPath

        /// <summary>
        /// Find an item given a PATH_DELIMITOR delimited path starting from this folder.
        ///
        /// This method does not handle paths that contain multiple delimitors
        ///
        /// FIXME: We do not yet handle situations where folders or items have the same name.  We could handle this by some
        /// XPath like expression
        ///
        /// FIXME: Delimitors which occur in names themselves are not currently escapable.
        /// </summary>
        /// 
        /// <param name="inventoryService">
        /// Inventory service to query
        /// </param>
        /// <param name="startFolder">
        /// The folder from which the path starts
        /// </param>
        /// <param name="path">
        /// <param name="path">
        /// The path to the required item.
        /// </param>
        /// <returns>null if the item is not found</returns>
        public static InventoryItemBase FindItemByPath(
            IInventoryService inventoryService, InventoryFolderBase startFolder, string path)
        {
            string[] components = SplitEscapedPath(path);
            components[0] = UnescapePath(components[0]);
                            
            //string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None);

            if (components.Length == 1)
            {
//                m_log.DebugFormat("FOUND SINGLE COMPONENT [{0}]", components[0]);
                
                List<InventoryItemBase> items = inventoryService.GetFolderItems(startFolder.Owner, startFolder.ID);
                foreach (InventoryItemBase item in items)
                {
                    if (item.Name == components[0])
                        return item;
                }
            }
            else
            {
//                m_log.DebugFormat("FOUND COMPONENTS [{0}] and [{1}]", components[0], components[1]);
                
                InventoryCollection contents = inventoryService.GetFolderContent(startFolder.Owner, startFolder.ID);
                
                foreach (InventoryFolderBase folder in contents.Folders)
                {
                    if (folder.Name == components[0])
                        return FindItemByPath(inventoryService, folder, components[1]);
                }
            }

            // We didn't find an item or intermediate folder with the given name
            return null;
        }
开发者ID:AlphaStaxLLC,项目名称:taiga,代码行数:57,代码来源:InventoryArchiveUtils.cs


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