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


C# Schema.IsGroup方法代码示例

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


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

示例1: WriteStruct

        public void WriteStruct(Schema.Node node, Stack<UnionStub> union)
        {
            if (node.IsGroup()) return;
            if (node.Union != [email protected]) return;
            var @struct = [email protected];
            // the nested type does not inherit the unions from the caller
            if (union.Count != 0)
            {
                union = new Stack<UnionStub>();
            }
            BeginClass(node).WriteLittleEndianCheck(node);

            var fields = @struct.fields;

            int bodyWords = 0, pointerWords = 0;
            Schema.CodeGeneratorRequest.ComputeSpace(this, node, ref bodyWords, ref pointerWords);
            HashSet<ulong> nestedDone = null;

            if (fields.IsValid())
            {
                foreach (var field in fields.OrderBy(x => x.codeOrder).ThenBy(x => x.name, Text.Comparer))
                {
                    bool pushed = false;
                    if (field.discriminantValue != Field.noDiscriminant)
                    {
                        // write with union-based restructions
                        union.Push(new UnionStub([email protected], field.discriminantValue));
                        pushed = true;
                    }

                    WriteFieldAccessor(node, field, union);

                    // declare the struct too, if we need to - noting that it includes union-context
                    Node child = default(Node);
                    switch (field.Union)
                    {
                        case Field.Unions.group:
                            child = Lookup(field.group.typeId);
                            break;
                        case Field.Unions.slot:
                            if (field.slot.type.Union == [email protected])
                                child = Lookup([email protected]);
                            break;
                    }
                    if (child.IsValid())
                    {
                        if (child.IsGroup())
                        {
                            if (nestedDone == null) nestedDone = new HashSet<ulong>();
                            if (nestedDone.Add(child.id))
                            {
                                WriteGroup(child, union);
                            }
                        }
                    }

                    if (pushed) union.Pop();
                }
            }
            //if (node.nestedNodes != null)
            //{
            //    foreach (var nestedNode in node.nestedNodes)
            //    {
            //        if (nestedDone == null || !nestedDone.Contains(nestedNode.id))
            //        {
            //            var found = Lookup(nestedNode.id);
            //            if (found != null && found.IsGroup())
            //            {
            //                WriteGroup(found, union);
            //                WriteGroupAccessor(node, found, LocalName(found.displayName, false), false);
            //            }
            //        }
            //    }
            //}
            if (@struct.discriminantCount != 0)
            {
                WriteDiscriminant(node, union);
            }

            DeclareFields(bodyWords, pointerWords);

            WriteNestedTypes(node, union);
            EndClass();
        }
开发者ID:GSerjo,项目名称:capnproto-net,代码行数:84,代码来源:CodeWriter.cs


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