public AllowedDefinitionResult IsAllowed(AllowedDefinitionQuery context)
            {
                // get page of context
                var parent = context.Parent;

                while (!parent.IsPage)
                {
                    if (parent.Parent == null)
                    {
                        return(AllowedDefinitionResult.Deny);
                    }

                    parent = parent.Parent;
                }
                var parentType = parent.GetType();

                if (ChildType.IsAssignableFrom(context.ChildDefinition.ItemType))
                {
                    if (Attribute.Types != null && !Attribute.Types.Any(t => t.IsAssignableFrom(parentType)))
                    {
                        //Trace.TraceInformation(context.ChildDefinition.ItemType.Name + " denied on " + parentType.Name);
                        return(AllowedDefinitionResult.Deny);
                    }
                    //if (this.Attribute.TemplateKeys != null && !this.Attribute.TemplateKeys.Contains(context.ParentDefinition.TemplateKey))
                    //	return AllowedDefinitionResult.Deny;
                }
                return(AllowedDefinitionResult.DontCare);
            }
コード例 #2
0
 public override int GetHashCode()
 {
     return
         (ParentType.GetHashCode() ^
          ChildType.GetHashCode() ^
          Name.GetHashCode());
 }
コード例 #3
0
        internal static IEnumerable<IFileSystemInformation> EnumerateChildrenInternal(
            string directory,
            ChildType childType,
            string searchPattern,
            System.IO.SearchOption searchOption,
            FileAttributes excludeAttributes,
            IFileService fileService)
        {
            // We want to be able to see all files as we recurse and open new find handles (that might be over MAX_PATH).
            // We've already normalized our base directory.
            string extendedDirectory = Paths.AddExtendedPrefix(directory);

            // The assertion here is that we want to find files that match the desired pattern in all subdirectories, even if the
            // subdirectories themselves don't match the pattern. That requires two passes to avoid overallocating for directories
            // with a large number of files.

            // First look for items that match the given search pattern in the current directory
            using (FindOperation findOperation = new FindOperation(Paths.Combine(extendedDirectory, searchPattern)))
            {
                FindResult findResult;
                while ((findResult = findOperation.GetNextResult()) != null)
                {
                    bool isDirectory = (findResult.Attributes & FileAttributes.FILE_ATTRIBUTE_DIRECTORY) == FileAttributes.FILE_ATTRIBUTE_DIRECTORY;

                    if ((findResult.Attributes & excludeAttributes) == 0
                        && findResult.FileName != "."
                        && findResult.FileName != ".."
                        && ((isDirectory && childType == ChildType.Directory)
                            || (!isDirectory && childType == ChildType.File)))
                    {
                        yield return FileSystemInformation.Create(findResult, directory, fileService);
                    }
                }
            }

            if (searchOption != System.IO.SearchOption.AllDirectories) yield break;

            // Now recurse into each subdirectory
            using (FindOperation findOperation = new FindOperation(Paths.Combine(extendedDirectory, "*"), directoriesOnly: true))
            {
                FindResult findResult;
                while ((findResult = findOperation.GetNextResult()) != null)
                {
                    // Unfortunately there is no guarantee that the API will return only directories even if we ask for it
                    bool isDirectory = (findResult.Attributes & FileAttributes.FILE_ATTRIBUTE_DIRECTORY) == FileAttributes.FILE_ATTRIBUTE_DIRECTORY;

                    if ((findResult.Attributes & excludeAttributes) == 0
                        && isDirectory
                        && findResult.FileName != "."
                        && findResult.FileName != "..")
                    {
                        foreach (var child in EnumerateChildrenInternal(Paths.Combine(directory, findResult.FileName), childType, searchPattern,
                            searchOption, excludeAttributes, fileService))
                        {
                            yield return child;
                        }
                    }
                }
            }
        }
コード例 #4
0
        //public CatalogItemType[] GetAll()
        //{
        //    var rows = from row in CatalogItemTypes
        //               select row;

        //    return GetArray(rows);
        //}


        internal int CountChildren(CatalogItem catalogItem, bool recursive, ChildType childType)
        {
            if (CatalogItemType_GetByTypeID(catalogItem.ItemType).TypeCode == "FIL")
            {
                return(0); // A file cannot have any children
            }
            string typeCode = string.Empty;

            switch (childType)
            {
            case ChildType.File:
                typeCode = "FIL";
                break;

            case ChildType.Folder:
                typeCode = "FLD";
                break;
            }

            CatalogItem[] children = FindItems(catalogItem, typeCode, string.Empty, string.Empty, true);

            if (children != null)
            {
                return(children.Length);
            }

            return(0);
        }
コード例 #5
0
        /// <summary>
        /// 步骤1 简单工厂有一个静态方法,通过接收客户端的参数来决定创建哪一个类型对象
        /// </summary>
        /// <param name="child"></param>
        /// <returns>步骤3 不确定简单工厂返回的对象是哪一种具体的类型,所以使用父类作为返回类型</returns>
        internal static Parent Create(ChildType child)
        {
            Parent parent = null;

            try
            {
                //步骤2  所有简单工厂能创建的对象,有同一个父类或接口
                //在此示例,ChildA,ChildB,ChildC拥有共同的父类Parent
                if (child == ChildType.A)
                {
                    return(new ChildA());
                }
                else if (child == ChildType.B)
                {
                    return(new ChildB());
                }
                else if (child == ChildType.C)
                {
                    return(new ChildC());
                }
                else
                {
                    throw new Exception("不识别的Child类型");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(parent);
        }
コード例 #6
0
ファイル: ChildType.cs プロジェクト: dsonbill/GeodesicGrid
 public static ChildType Flip(this ChildType dir)
 {
     if (dir == ChildType.Straight)
     {
         return(ChildType.Straight);
     }
     return(dir == ChildType.Down ? ChildType.Up : ChildType.Down);
 }
コード例 #7
0
 public IEnumerable <IFileSystemInformation> EnumerateChildren(
     ChildType childType  = ChildType.File,
     string searchPattern = "*",
     System.IO.SearchOption searchOption        = System.IO.SearchOption.TopDirectoryOnly,
     System.IO.FileAttributes excludeAttributes = System.IO.FileAttributes.Hidden | System.IO.FileAttributes.System | System.IO.FileAttributes.ReparsePoint)
 {
     return(EnumerateChildrenInternal(this.Path, childType, searchPattern, searchOption, excludeAttributes, this.FileService));
 }
コード例 #8
0
 internal override ValueNode CreateSerializerOverride(ValueNode parent)
 {
     if (ChildType.GetTypeInfo().IsPrimitive)
     {
         return(new PrimitiveListValueNode(parent, Name, this));
     }
     return(new ListValueNode(parent, Name, this));
 }
コード例 #9
0
ファイル: ShellItem.cs プロジェクト: ronmark1/ClearCanvas-1
 public IEnumerable <Pidl> EnumerateChildPidls(ChildType types, bool includeHiddenItems)
 {
     Native.SHCONTF flags = 0;
     flags |= ((types & ChildType.Files) == ChildType.Files) ? Native.SHCONTF.SHCONTF_NONFOLDERS : 0;
     flags |= ((types & ChildType.Folders) == ChildType.Folders) ? Native.SHCONTF.SHCONTF_FOLDERS : 0;
     flags |= (includeHiddenItems) ? Native.SHCONTF.SHCONTF_INCLUDEHIDDEN : 0;
     return(this.EnumerateChildPidls(flags));
 }
コード例 #10
0
ファイル: ChildTests.cs プロジェクト: magenta-aps/cprbroker
 public void ToPersonFlerRelationType_InvalidPnr_OK(
     [Values("1234", "0")] string pnr)
 {
     var ret = ChildType.ToPersonFlerRelationType(new ChildType[] { new ChildType()
                                                                    {
                                                                        ChildPNR = pnr
                                                                    } }, cpr => Guid.NewGuid());
 }
コード例 #11
0
 public IEnumerable<IFileSystemInformation> EnumerateChildren(
     ChildType childType = ChildType.File,
     string searchPattern = "*",
     System.IO.SearchOption searchOption = System.IO.SearchOption.TopDirectoryOnly,
     System.IO.FileAttributes excludeAttributes = System.IO.FileAttributes.Hidden | System.IO.FileAttributes.System | System.IO.FileAttributes.ReparsePoint)
 {
     return EnumerateChildrenInternal(this.Path, childType, searchPattern, searchOption, excludeAttributes, this.FileService);
 }
コード例 #12
0
 private Cell getChild(ChildType direction, int level)
 {
     if (index < 2)
     {
         throw new ArgumentException("Cannot find child of a polar cell");
     }
     return(new Cell((index - 2) * 3 + (byte)direction, level - 1));
 }
コード例 #13
0
 public override ValueNode CreateSerializerOverride(ValueNode parent)
 {
     if (ChildType.GetTypeInfo().IsPrimitive)
     {
         return(new PrimitveArrayValueNode(parent, Name, this));
     }
     return(new ArrayValueNode(parent, Name, this));
 }
コード例 #14
0
        internal static IEnumerable<IFileSystemInformation> EnumerateChildrenInternal(
            string directory,
            ChildType childType,
            string searchPattern,
            System.IO.SearchOption searchOption,
            System.IO.FileAttributes excludeAttributes,
            IFileService fileService)
        {
            var firstFile = NativeMethods.FileManagement.FindFirstFile(Paths.Combine(directory, searchPattern));
            var findInfo = firstFile;

            if (firstFile != null)
            {
                // Look for specified file/directories
                do
                {
                    bool isDirectory = findInfo.Attributes.HasFlag(System.IO.FileAttributes.Directory);

                    if ((findInfo.Attributes & excludeAttributes) == 0
                        && findInfo.FileName != "."
                        && findInfo.FileName != ".."
                        && ((isDirectory && childType == ChildType.Directory)
                            || (!isDirectory && childType == ChildType.File)))
                    {
                        yield return FileSystemInformation.Create(findInfo, fileService);
                    }

                    findInfo = NativeMethods.FileManagement.FindNextFile(firstFile);
                } while (findInfo != null);

                firstFile.FindHandle.Close();
            }

            if (searchOption != System.IO.SearchOption.AllDirectories) yield break;

            // Need to recurse to find additional matches
            firstFile = NativeMethods.FileManagement.FindFirstFile(Paths.Combine(directory, "*"), directoriesOnly: true);
            if (firstFile == null) yield break;
            findInfo = firstFile;

            do
            {
                if ((findInfo.Attributes & excludeAttributes) == 0
                    && findInfo.Attributes.HasFlag(System.IO.FileAttributes.Directory)
                    && findInfo.FileName != "."
                    && findInfo.FileName != "..")
                {
                    IFileSystemInformation childDirectory = Create(findInfo, fileService);
                    foreach (var child in EnumerateChildrenInternal(childDirectory.Path, childType, searchPattern, searchOption, excludeAttributes, fileService))
                    {
                        yield return child;
                    }
                }
                findInfo = NativeMethods.FileManagement.FindNextFile(firstFile);
            } while (findInfo != null);

            firstFile.FindHandle.Close();
        }
コード例 #15
0
ファイル: XmlHelper.cs プロジェクト: wangyakai01/APSIMClassic
        public static XmlNode FindByType(XmlNode Node, string TypePath)
        {
            // ----------------------------------------------------
            // Find a child with the specified TypePath. TypePath
            // can be a single child type or a path delimited with
            // '/' characters e.g. ChildNode/SubChildNode or /RootNode/ChildNode
            // Returns null if no child found.
            // ----------------------------------------------------
            if (Node == null)
            {
                return(null);
            }
            if (TypePath == "")
            {
                throw new Exception("Cannot call FindByType with a blank path");
            }
            if (TypePath[0] == Delimiter)
            {
                Node = Node.OwnerDocument.DocumentElement;
                int    Pos      = TypePath.IndexOf(Delimiter, 1);
                string RootName = TypePath.Substring(1, Pos - 1);
                if (RootName.ToLower() != Type(Node).ToLower())
                {
                    return(null);
                }
                TypePath = TypePath.Substring(Pos + 1);
            }

            string ChildType, Remainder;
            int    PosDelimiter = TypePath.IndexOf(Delimiter);

            if (PosDelimiter != -1)
            {
                ChildType = TypePath.Substring(0, PosDelimiter);
                Remainder = TypePath.Substring(PosDelimiter + 1);
            }
            else
            {
                ChildType = TypePath;
                Remainder = "";
            }
            foreach (XmlNode Child in Node.ChildNodes)
            {
                if (Type(Child).ToLower() == ChildType.ToLower())
                {
                    if (Remainder == "")
                    {
                        return(Child);
                    }
                    else
                    {
                        return(FindByType(Child, Remainder));
                    }
                }
            }
            return(null);
        }
コード例 #16
0
        public void can_set_the_value_of_an_inherited_property()
        {
            var component = new ChildType();
            var descriptor = PropertyDescriptor.For(component.GetType().GetProperty("Property"));

            Assert.Equal(0, component.Property);
            descriptor.SetValue(component, 1);
            Assert.Equal(1, component.Property);
        }
コード例 #17
0
        private Cell approachSlow(ChildType direction, int levels)
        {
            var cell = this;

            for (var i = 0; i < levels; i++)
            {
                cell = cell.getChild(direction);
            }
            return(cell);
        }
コード例 #18
0
ファイル: ChildTests.cs プロジェクト: magenta-aps/cprbroker
            public void ToPersonFlerRelationType_Normal_NullEndDate(
                [Values("1234567890", "123456789")] string pnr)
            {
                var ret = ChildType.ToPersonFlerRelationType(new ChildType[] { new ChildType()
                                                                               {
                                                                                   ChildPNR = pnr
                                                                               } }, cpr => Guid.NewGuid());

                Assert.Null(ret[0].Virkning.TilTidspunkt.ToDateTime());
            }
コード例 #19
0
ファイル: NeuronService.cs プロジェクト: fga012/cortex-diary
 internal static NeuronDto CreateNeuron(string name, ChildType type, NeuronDto parentDto = null)
 {
     return(new NeuronDto(
                Guid.NewGuid().GetHashCode(),
                parentDto == null ? 0 : parentDto.Id,
                Guid.NewGuid().ToString(),
                parentDto == null ? string.Empty : parentDto.NeuronId,
                name,
                type
                ));
 }
コード例 #20
0
        // Faster equivalent of approachSlow()
        private Cell approach(ChildType direction, int levels)
        {
            if (levels == 0)
            {
                return(this);
            }
            if (index < 2)
            {
                throw new ArgumentException("Cannot find child of a polar cell");
            }
            var a = (uint)Misc.IntPow(3, (uint)levels);

            return(new Cell(this.index * a - (uint)((5 * (4 << (2 * this.Level)) * (a - (1 << (2 * levels))) - ((byte)direction - 4) * (a - 1)) / 2)));
        }
コード例 #21
0
    GridViewRow createChildRow(string requestId = "", ChildType childType = ChildType.WorkItem)
    {
        GridViewRow row       = new GridViewRow(0, 0, DataControlRowType.DataRow, DataControlRowState.Selected);
        TableCell   tableCell = null;

        try
        {
            row.CssClass         = "gridBody";
            row.Style["display"] = "none";
            row.ID = string.Format("gridChild_{0}_{1}", requestId, childType.ToString());
            row.Attributes.Add("requestId", requestId);
            row.Attributes.Add("childType", childType.ToString());
            row.Attributes.Add("Name", string.Format("gridChild_{0}", requestId));

            //add the table cells
            for (int i = 0; i < DCC.Count; i++)
            {
                tableCell      = new TableCell();
                tableCell.Text = "&nbsp;";

                if (i == DCC.IndexOf("X"))
                {
                    //set width to match parent
                    tableCell.Style["width"] = "12px";
                }
                else if (i == DCC.IndexOf("WORKREQUESTID"))
                {
                    tableCell.Style["padding"]        = "0px";
                    tableCell.Style["vertical-align"] = "top";
                    tableCell.ColumnSpan = DCC.Count - 1;
                    //add the frame here
                    tableCell.Controls.Add(createChildFrame(requestId: requestId, childType: childType));
                }
                else
                {
                    tableCell.Style["display"] = "none";
                }

                row.Cells.Add(tableCell);
            }
        }
        catch (Exception ex)
        {
            LogUtility.LogException(ex);
            row = null;
        }

        return(row);
    }
コード例 #22
0
 public AllowedDefinitionResult IsAllowed(AllowedDefinitionQuery context)
 {
     if (ChildType.IsAssignableFrom(context.ChildDefinition.ItemType))
     {
         if (this.Attribute.Types != null && !this.Attribute.Types.Any(t => t.IsAssignableFrom(context.ParentDefinition.ItemType)))
         {
             return(AllowedDefinitionResult.Deny);
         }
         if (this.Attribute.TemplateKeys != null && !this.Attribute.TemplateKeys.Contains(context.ParentDefinition.TemplateKey))
         {
             return(AllowedDefinitionResult.Deny);
         }
     }
     return(AllowedDefinitionResult.DontCare);
 }
コード例 #23
0
 public IEnumerable<IFileSystemInformation> EnumerateChildren(
     ChildType childType = ChildType.File,
     string searchPattern = "*",
     SearchOption searchOption = SearchOption.TopDirectoryOnly,
     FileAttributes excludeAttributes = FileAttributes.Hidden | FileAttributes.System | FileAttributes.ReparsePoint)
 {
     if (childType == ChildType.Directory)
     {
         return EnumerateDirectories(searchPattern, searchOption, excludeAttributes);
     }
     else
     {
         return EnumerateFiles(_directoryInfo, searchPattern, searchOption, excludeAttributes);
     }
 }
コード例 #24
0
 public IEnumerable <IFileSystemInformation> EnumerateChildren(
     ChildType childType              = ChildType.File,
     string searchPattern             = "*",
     SearchOption searchOption        = SearchOption.TopDirectoryOnly,
     FileAttributes excludeAttributes = FileAttributes.Hidden | FileAttributes.System | FileAttributes.ReparsePoint)
 {
     if (childType == ChildType.Directory)
     {
         return(EnumerateDirectories(searchPattern, searchOption, excludeAttributes));
     }
     else
     {
         return(EnumerateFiles(_directoryInfo, searchPattern, searchOption, excludeAttributes));
     }
 }
コード例 #25
0
ファイル: ShellItem.cs プロジェクト: ronmark1/ClearCanvas-1
        public IEnumerable <ShellItem> EnumerateChildren(ChildType types, bool includeHiddenItems)
        {
            Native.SHCONTF flags = 0;
            flags |= ((types & ChildType.Files) == ChildType.Files) ? Native.SHCONTF.SHCONTF_NONFOLDERS : 0;
            flags |= ((types & ChildType.Folders) == ChildType.Folders) ? Native.SHCONTF.SHCONTF_FOLDERS : 0;
            flags |= (includeHiddenItems) ? Native.SHCONTF.SHCONTF_INCLUDEHIDDEN : 0;

            List <ShellItem> children = new List <ShellItem>();

            foreach (Pidl pidl in EnumerateChildPidls(flags))
            {
                children.Add(new ShellItem(pidl, this));
                pidl.Dispose();
            }
            return(children);
        }
コード例 #26
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <remarks></remarks>
        public frmDeriveData()
        {
            // This call is required by the designer.
            InitializeComponent();

            // Add any initialization after the InitializeComponent() call.
            //
            this.BackgroundWorker1.WorkerReportsProgress      = true;
            this.BackgroundWorker1.WorkerSupportsCancellation = true;
            //
            this.txtbxSavePath.Text = Path.Combine(
                System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory, Environment.SpecialFolderOption.None),
                "数据提取.xlsx");
            this.F_ChildType       = ChildType.Excel;
            this.F_regexComponents = new[] { 1, 2, 3, 4 };
        }
コード例 #27
0
        private static bool CanInline(ChildType parentChildType, ChildEntry child)
        {
            if (child.ChildType == parentChildType)
            {
                if (child.ChildType == ChildType.Sequence ||
                    child.ChildType == ChildType.Choice)
                {
                    if (child.MinOccurs == 1 && child.MaxOccurs == 1)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
コード例 #28
0
        public override void GetOutPut(TextWriter tw)
        {
            StringBuilder s = new StringBuilder();

            s.Append("<html>\r\n");
            s.Append("<head>\r\n");
            s.Append("<META http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\r\n");
            s.Append("<title>Interface Index");
            s.Append("</title>\r\n");
            s.Append("<link href=\"StructureDescription.css\" rel=\"stylesheet\" type=\"text/css\">\r\n");
            s.Append("</head>\r\n");
            s.Append("<body>\r\n");
            s.Append("<h1>Interface Index</h1>\r\n");
            s.Append("<table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" bordercolor=\"#000000\"><tbody>\r\n");
            s.Append("<tr class=\"tableHeader\">\r\n");
            s.Append("<th class=\"tableHeaderColumn\">Document</th>\r\n");
            s.Append("<th class=\"tableHeaderColumn\">Structure</th>\r\n");
            s.Append("</tr>\r\n");

            // Once for each Interface

            foreach (InterfaceType it in messageDef.interfaces)
            {
                s.Append("<tr class=\"tableRow\">\r\n");
                s.Append("<td class=\"tableRowColumn\">\r\n");
                s.Append(it.name);
                s.Append("</td>\r\n");
                s.Append("<td class=\"tableRowColumn\">\r\n");

                ChildType ct = new ChildType();
                ct.name       = it.structure;
                ct.minOccurrs = "1";
                ct.maxOccurrs = "1";
                AddStructure(ct, s);
                s.Append("</td>\r\n");
            }

            s.Append("</table>\r\n");
            s.Append("</body>\r\n</html>\r\n");

            tw.Write(s.ToString());
        }
コード例 #29
0
        private ChildEntry AddLeaf(ChildType childType, XmlSchemaObject parent, XmlSchemaParticle particle)
        {
            if (_childEntryStack.Count == 0)
            {
                var root = new List <ChildEntry>();
                _childEntryStack.Push(root);
            }

            var childEntry = new ChildEntry
            {
                ChildType = childType,
                MinOccurs = particle == null ? 1 : particle.MinOccurs,
                MaxOccurs = particle == null ? 1 : particle.MaxOccurs,
                Particle  = particle,
                Parent    = parent
            };

            _childEntryStack.Peek().Add(childEntry);
            return(childEntry);
        }
コード例 #30
0
        private XmlElement MakeTimelineKeyNode(XmlDocument scml, Element element, int frameId, int rate,
                                               FileIdProvider fileIdProvider, ChildType childType)
        {
            var key = scml.CreateElement(string.Empty, "key", string.Empty);

            key.SetAttribute("id", frameId.ToString());
            key.SetAttribute("time", (frameId * rate).ToString());
            switch (childType)
            {
            case ChildType.Sprite:
                key.AppendChild(MakeObjectNode(scml, element, fileIdProvider));
                break;

            case ChildType.Bone:
                key.AppendChild(MakeBoneNode(scml, element));
                break;
            }

            return(key);
        }
コード例 #31
0
    HtmlIframe createChildFrame(string requestId = "", ChildType childType = ChildType.WorkItem)
    {
        HtmlIframe childFrame = new HtmlIframe();

        if (string.IsNullOrWhiteSpace(requestId))
        {
            return(null);
        }

        childFrame.ID = string.Format("frameChild_{0}_{1}", requestId, childType.ToString());
        childFrame.Attributes.Add("requestId", requestId);
        childFrame.Attributes.Add("childType", childType.ToString());
        childFrame.Attributes["frameborder"] = "0";
        childFrame.Attributes["scrolling"]   = "no";
        childFrame.Attributes["src"]         = "javascript:''";
        childFrame.Style["height"]           = "30px";
        childFrame.Style["width"]            = "100%";
        childFrame.Style["border"]           = "none";

        return(childFrame);
    }
コード例 #32
0
        Child GetChild(ChildType type)
        {
            while (nextChildIndex < children.Count && children[nextChildIndex].Type != type)
            {
                // TODO: This shape is out of order
                nextChildIndex++;
            }

            if (nextChildIndex >= children.Count)
            {
                FrameworkElement shape;
                switch (type)
                {
                case ChildType.Rectangle: shape = new Shapes.Rectangle(); break;

                case ChildType.Ellipse: shape = new Shapes.Ellipse(); break;

                case ChildType.Path: shape = new Shapes.Path(); break;

                case ChildType.Image: shape = new Image(); break;

                case ChildType.Text: shape = new TextBlock(); break;

                default: throw new NotSupportedException(type + " not supported");
                }
                var ch = new Child {
                    Type  = type,
                    Shape = shape,
                };
                children.Add(ch);
                nextChildIndex = children.Count;
                return(ch);
            }
            else
            {
                var ch = children[nextChildIndex];
                nextChildIndex++;
                return(ch);
            }
        }
コード例 #33
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Path.Length != 0)
            {
                hash ^= Path.GetHashCode();
            }
            if (ChildType.Length != 0)
            {
                hash ^= ChildType.GetHashCode();
            }
            if (ChildName.Length != 0)
            {
                hash ^= ChildName.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
コード例 #34
0
        internal static IEnumerable <IFileSystemInformation> EnumerateChildrenInternal(
            string directory,
            ChildType childType,
            string searchPattern,
            System.IO.SearchOption searchOption,
            FileAttributes excludeAttributes,
            IFileService fileService)
        {
            // We want to be able to see all files as we recurse and open new find handles (that might be over MAX_PATH).
            // We've already normalized our base directory.
            string extendedDirectory = Paths.AddExtendedPrefix(directory);

            var transformFilter = new FindTransformFilter(excludeAttributes, fileService);
            FindOperation <IFileSystemInformation> findOperation = new FindOperation <IFileSystemInformation>(
                extendedDirectory,
                searchPattern,
                recursive: searchOption == System.IO.SearchOption.AllDirectories ? true : false,
                transformFilter,
                transformFilter);

            return(findOperation);
        }
コード例 #35
0
        public void AddStructure(ChildType ct, StringBuilder s)
        {
            StructureType structure = null;

            foreach (StructureType st in messageDef.structures)
            {
                if (st.name != ct.name)
                {
                    continue;
                }

                structure = st;
                break;
            }

            if (structure != null)
            {
                s.Append("<ul>\r\n");
                s.Append("<li type=\"disc\"><a href=\"");
                s.Append(structure.name);
                s.Append(".html\">");
                s.Append(structure.name);
                s.Append("</a> (");
                s.Append(ct.minOccurrs);
                s.Append("..");
                s.Append(ct.maxOccurrs);
                s.Append(")\r\n");

                if (structure.children != null)
                {
                    foreach (ChildType c in structure.children)
                    {
                        AddStructure(c, s);
                    }
                }

                s.Append("</li></ul>\r\n");
            }
        }
コード例 #36
0
        private static bool CanInline(ChildType parentChildType, ChildEntry child)
        {
            if (child.ChildType == parentChildType)
            {
                if (child.ChildType == ChildType.Sequence ||
                    child.ChildType == ChildType.Choice)
                {
                    if (child.MinOccurs == 1 && child.MaxOccurs == 1)
                        return true;
                }
            }

            return false;
        }
コード例 #37
0
ファイル: ShellItem.cs プロジェクト: nhannd/Xian
		public IEnumerable<Pidl> EnumerateChildPidls(ChildType types, bool includeHiddenItems)
		{
			Native.SHCONTF flags = 0;
			flags |= ((types & ChildType.Files) == ChildType.Files) ? Native.SHCONTF.SHCONTF_NONFOLDERS : 0;
			flags |= ((types & ChildType.Folders) == ChildType.Folders) ? Native.SHCONTF.SHCONTF_FOLDERS : 0;
			flags |= (includeHiddenItems) ? Native.SHCONTF.SHCONTF_INCLUDEHIDDEN : 0;
			return this.EnumerateChildPidls(flags);
		}
コード例 #38
0
ファイル: ShellItem.cs プロジェクト: nhannd/Xian
		public IEnumerable<Pidl> EnumerateChildPidls(ChildType types)
		{
			return this.EnumerateChildPidls(types, true);
		}
コード例 #39
0
ファイル: ShellItem.cs プロジェクト: nhannd/Xian
		public IEnumerable<ShellItem> EnumerateChildren(ChildType types, bool includeHiddenItems)
		{
			Native.SHCONTF flags = 0;
			flags |= ((types & ChildType.Files) == ChildType.Files) ? Native.SHCONTF.SHCONTF_NONFOLDERS : 0;
			flags |= ((types & ChildType.Folders) == ChildType.Folders) ? Native.SHCONTF.SHCONTF_FOLDERS : 0;
			flags |= (includeHiddenItems) ? Native.SHCONTF.SHCONTF_INCLUDEHIDDEN : 0;

			List<ShellItem> children = new List<ShellItem>();
			foreach (Pidl pidl in EnumerateChildPidls(flags))
			{
				children.Add(new ShellItem(pidl, this));
				pidl.Dispose();
			}
			return children;
		}
コード例 #40
0
ファイル: ShellItem.cs プロジェクト: nhannd/Xian
		public IEnumerable<ShellItem> EnumerateChildren(ChildType types)
		{
			return this.EnumerateChildren(types, true);
		}
コード例 #41
0
ファイル: Parameter.cs プロジェクト: GUrbiola/Ez_SQL
 public Parameter()
 {
     _Kind = ChildType.Parameter;
 }
コード例 #42
0
ファイル: Field.cs プロジェクト: GUrbiola/Ez_SQL
 public Field()
 {
     _Kind = ChildType.Field;
 }
コード例 #43
0
ファイル: Catalog.cs プロジェクト: rraguso/protone-suite
        //public CatalogItemType[] GetAll()
        //{
        //    var rows = from row in CatalogItemTypes
        //               select row;

        //    return GetArray(rows);
        //}


        internal int CountChildren(CatalogItem catalogItem, bool recursive, ChildType childType)
        {
            if (CatalogItemType_GetByTypeID(catalogItem.ItemType).TypeCode == "FIL")
                return 0; // A file cannot have any children

            string typeCode = string.Empty;
            switch (childType)
            {
                case ChildType.File:
                    typeCode = "FIL";
                    break;

                case ChildType.Folder:
                    typeCode = "FLD";
                    break;

            }

            CatalogItem[] children = FindItems(catalogItem, typeCode, string.Empty, string.Empty, true);

            if (children != null)
                return children.Length;

            return 0;
        }
コード例 #44
0
        internal BuildItemGroupChildXml(XmlElement element, ChildType childTypeExpected)
        {
            ErrorUtilities.VerifyThrow(element != null, "Need an XML node.");
            ErrorUtilities.VerifyThrowNoAssert(childTypeExpected != ChildType.Invalid, "Can't expect invalid childtype");
            ProjectXmlUtilities.VerifyThrowProjectValidNameAndNamespace(element);

            this.element = element;
    
            // Loop through each of the attributes on the item element.
            foreach (XmlAttribute attribute in element.Attributes)
            {
                switch (attribute.Name)
                {
                    case XMakeAttributes.include:
                        this.includeAttribute = attribute;
                        break;

                    case XMakeAttributes.exclude:  
                        this.excludeAttribute = attribute;
                        break;

                    case XMakeAttributes.condition:
                        this.conditionAttribute = attribute;
                        break;

                    case XMakeAttributes.xmlns:
                        // We already verified that the namespace is correct
                        break;

                    case XMakeAttributes.remove:
                        this.removeAttribute = attribute;
                        break;

                    case XMakeAttributes.keepMetadata:
                    case XMakeAttributes.removeMetadata:
                    case XMakeAttributes.keepDuplicates:
                        // Ignore these - they are part of the new OM.
                        break;

                    default:
                        ProjectXmlUtilities.ThrowProjectInvalidAttribute(attribute);
                        break;
                }
            }

            this.childType = ChildType.Invalid;

            // Default to modify, if that's one of the child types we are told to expect.
            if ((childTypeExpected & ChildType.BuildItemModify) == ChildType.BuildItemModify)
            {
                this.childType = ChildType.BuildItemModify;
            }

            if (this.includeAttribute != null)
            {
                ProjectXmlUtilities.VerifyThrowProjectInvalidAttribute((childTypeExpected & ChildType.BuildItemAdd) == ChildType.BuildItemAdd, includeAttribute);
                ProjectErrorUtilities.VerifyThrowInvalidProject(Include.Length > 0, element, "MissingRequiredAttribute", XMakeAttributes.include, element.Name);
                ProjectXmlUtilities.VerifyThrowProjectInvalidAttribute(removeAttribute == null, removeAttribute);
                this.childType = ChildType.BuildItemAdd;
            }

            if (this.excludeAttribute != null)
            {
                ProjectXmlUtilities.VerifyThrowProjectInvalidAttribute((childTypeExpected & ChildType.BuildItemAdd) == ChildType.BuildItemAdd, excludeAttribute);
                ProjectErrorUtilities.VerifyThrowInvalidProject(Include.Length > 0, element, "MissingRequiredAttribute", XMakeAttributes.include, element.Name);
                ProjectXmlUtilities.VerifyThrowProjectInvalidAttribute(removeAttribute == null, removeAttribute);
                this.childType = ChildType.BuildItemAdd;
            }

            if (this.removeAttribute != null)
            {
                ProjectXmlUtilities.VerifyThrowProjectInvalidAttribute((childTypeExpected & ChildType.BuildItemRemove) == ChildType.BuildItemRemove, removeAttribute);
                ProjectErrorUtilities.VerifyThrowInvalidProject(Remove.Length > 0, element, "MissingRequiredAttribute", XMakeAttributes.remove, element.Name);
                ProjectXmlUtilities.VerifyThrowProjectInvalidAttribute(includeAttribute == null, includeAttribute);
                ProjectXmlUtilities.VerifyThrowProjectInvalidAttribute(excludeAttribute == null, excludeAttribute);
                this.childType = ChildType.BuildItemRemove;
            }

            if (this.childType == ChildType.Invalid)
            {
                // So the xml wasn't consistent with any of the child types that we were told to expect.
                // Figure out the most reasonable message to produce.
                if ((childTypeExpected & ChildType.BuildItemAdd) == ChildType.BuildItemAdd)
                {
                    ProjectErrorUtilities.VerifyThrowInvalidProject(Include.Length > 0, element, "MissingRequiredAttribute", XMakeAttributes.include, element.Name);
                }
                else if ((childTypeExpected & ChildType.BuildItemRemove) == ChildType.BuildItemRemove)
                {
                    ProjectErrorUtilities.VerifyThrowInvalidProject(Remove.Length > 0, element, "MissingRequiredAttribute", XMakeAttributes.remove, element.Name);
                }
                else
                {
                    ErrorUtilities.ThrowInternalError("Unexpected child type");
                }
            }

            // Validate each of the child nodes beneath the item.
            List<XmlElement> children = ProjectXmlUtilities.GetValidChildElements(element);

            if (this.childType == ChildType.BuildItemRemove && children.Count != 0)
            {
                ProjectErrorUtilities.ThrowInvalidProject(element, "ChildElementsBelowRemoveNotAllowed", children[0].Name);
            }

            foreach (XmlElement child in children)
            {
                ProjectXmlUtilities.VerifyThrowProjectValidNameAndNamespace(child);

                ProjectErrorUtilities.VerifyThrowInvalidProject(!FileUtilities.IsItemSpecModifier(child.Name), child, "ItemSpecModifierCannotBeCustomMetadata", child.Name);
                ProjectErrorUtilities.VerifyThrowInvalidProject(XMakeElements.IllegalItemPropertyNames[child.Name] == null, child, "CannotModifyReservedItemMetadata", child.Name);
            }
        }
コード例 #45
0
        private ChildEntry AddLeaf(ChildType childType, XmlSchemaObject parent, XmlSchemaParticle particle)
        {
            if (_childEntryStack.Count == 0)
            {
                var root = new List<ChildEntry>();
                _childEntryStack.Push(root);
            }

            var childEntry = new ChildEntry
                             {
                                 ChildType = childType,
                                 MinOccurs = particle == null ? 1 : particle.MinOccurs,
                                 MaxOccurs = particle == null ? 1 : particle.MaxOccurs,
                                 Particle = particle,
                                 Parent = parent
                             };
            _childEntryStack.Peek().Add(childEntry);
            return childEntry;
        }
コード例 #46
0
 public ParentChildIndex(IElasticConfiguration configuration): base(configuration, "parentchild", 1) {
     AddType(Parent = new ParentType(this));
     AddType(Child = new ChildType(this));
 }
コード例 #47
0
        ////public AstXNameBindingAttribute() 
        ////{
            //// Can we grab default name and type off of property that this attribute is applied to?
        ////}

        public AstXNameBindingAttribute(string name, ChildType childType)
        {
            Name = name;
            ChildType = childType;
        }
コード例 #48
0
		Child GetChild (ChildType type)
		{
			while (nextChildIndex < children.Count && children[nextChildIndex].Type != type) {
				// TODO: This shape is out of order
				nextChildIndex++;
			}

			if (nextChildIndex >= children.Count) {
				FrameworkElement shape;
				switch (type) {
					case ChildType.Rectangle: shape = new Shapes.Rectangle (); break;
					case ChildType.Ellipse: shape = new Shapes.Ellipse (); break;
					case ChildType.Path: shape = new Shapes.Path (); break;
					case ChildType.Image: shape = new Image (); break;
					case ChildType.Text: shape = new TextBlock (); break;
					default: throw new NotSupportedException (type + " not supported");
				}
				var ch = new Child {
					Type = type,
					Shape = shape,
				};
				children.Add (ch);
				nextChildIndex = children.Count;
				return ch;
			}
			else {
				var ch = children[nextChildIndex];
				nextChildIndex++;
				return ch;
			}
		}
コード例 #49
0
 private void PushNode(ChildType childType, XmlSchemaObject parent, XmlSchemaParticle particle)
 {
     var childEntry = AddLeaf(childType, parent, particle);
     Push(childEntry.Children);
 }
コード例 #50
0
        public void Test()
        {
            StructType s2 = new StructType(5);
            s2.Increment();
            AssertEqual(new StackFrame(), 6, s2.Value);

            StructType.StaticValue = 5;
            StructType.StaticIncrement();
            AssertEqual(new StackFrame(), 6, StructType.StaticValue);

            d = new D(DMethod);
            d+=new D(DMethod);
            d-=new D(DMethod);
            d = ReturnDMethod(d);
            s2 = d(d(new StructType[]{s2}))[0];
            AssertEqual(new StackFrame(), 6, StructType.StaticValue);

            uint i = this;
            AssertEqual(new StackFrame(), 1u, i);

            i = this + 2u;
            AssertEqual(new StackFrame(), 3u, i);

            try{ throw new MyException();}
            catch{}

            int[] results = DoubleValues(new int[]{1, 2, 3});
            AssertEqual(new StackFrame(), 4, results[1]);

            results = Sums(new int[,]{{1,2}, {3,4}});
            AssertEqual(new StackFrame(), 7, results[1]);

            int[,] otherResults = DoubleValues(new int[,]{{1,2}, {3,4}});
            AssertEqual(new StackFrame(), 4, otherResults[0, 1]);

            AssertEqual(new StackFrame(), Values.One, Echo (Values.One));

            int first = 3, second = 4;
            Swap(ref first, ref second);
            AssertEqual(new StackFrame(), 3, second);

            BaseType bt = new ChildType();
            AssertEqual(new StackFrame(), 4, bt.Compute(1));

            AssertEqual(new StackFrame(), 4, LockingMethod());

            try{
                LockingThrowingMethod();
                AssertTrue(new StackFrame(), false);
            }
            catch{}
        }