示例#1
0
        /// <summary>
        /// Removes a nested part object from the nested parts list by name
        /// </summary>
        /// <param name="nestedPartsList"></param>
        /// <param name="partName"></param>
        /// <returns></returns>
        public static bool RemoveByName(this ISNNestedPartsList nestedPartsList, string partName)
        {
            var result = false;
            var task   = nestedPartsList.OwnerObject.ParentObject as ISNTaskObj;

            if (task != null)
            {
                var part = task.PartsList.GetByName(partName);

                nestedPartsList.Reset();

                while (!nestedPartsList.EndOfList)
                {
                    var nestedPart = nestedPartsList.Current;

                    if (nestedPart.NestedPartID == part.PartID)
                    {
                        nestedPartsList.Remove();
                        result = true;
                        continue;
                    }

                    nestedPartsList.MoveNext();
                }
            }
            return(result);
        }
示例#2
0
        /// <summary>
        /// Gets a nested part object from the nested parts list by name
        /// </summary>
        /// <param name="nestedPartsList"></param>
        /// <param name="partName"></param>
        /// <returns></returns>
        public static List <ISNNestedPartObj> GetByName(this ISNNestedPartsList nestedPartsList, string partName)
        {
            var nestPartList = new List <ISNNestedPartObj>();
            var task         = nestedPartsList.OwnerObject.ParentObject as ISNTaskObj;

            if (task != null)
            {
                var part = task.PartsList.GetByName(partName);

                nestedPartsList.Reset();

                while (!nestedPartsList.EndOfList)
                {
                    var nestedPart = nestedPartsList.Current;

                    if (nestedPart.NestedPartID == part.PartID)
                    {
                        nestPartList.Add(nestedPart);
                    }

                    nestedPartsList.MoveNext();
                }

                return(nestPartList);
            }
            return(null);
        }