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


C# MessageStructure.PushIntoStack方法代码示例

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


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

示例1: DoSerialize

        private static byte[] DoSerialize(params BaseEntity[] entityList)
        {
            var rootWriter = new MessageStructure();
            rootWriter.PushIntoStack(entityList.Length);
            object fieldValue = null;
            foreach (var entity in entityList)
            {
                var schema = entity.GetSchema();
                if (schema == null)
                {
                    continue;
                }
                var recordWriter = new MessageStructure();
                recordWriter.PushIntoStack(schema.EntityName);
                //write columns
                var columns = schema.GetColumns();
                foreach (var column in columns)
                {
                    fieldValue = entity.GetPropertyValue(column.Name);
                    if (EntitySchemaSet.IsSupportType(column.ColumnType))
                    {
                        recordWriter.PushIntoStack(column.ColumnType, fieldValue);
                    }
                    else if (column.HasChild)
                    {
                        PushChildStack(recordWriter, column, fieldValue);
                    }
                }

                rootWriter.PushIntoStack(recordWriter);
            }

            var head = new MessageHead(SyncActionId);
            rootWriter.WriteBuffer(head);
            return rootWriter.PopBuffer();
        }
开发者ID:houguohua,项目名称:Scut,代码行数:36,代码来源:EntitySyncManger.cs

示例2: PushChildStack

        private static void PushChildStack(MessageStructure parent, SchemaColumn parentColumn, object value)
        {
            if (parentColumn.IsDictionary)
            {
                var column = parentColumn.Children[1];
                dynamic dict = value;
                dynamic keys = dict.Keys;
                int count = dict.Count;
                parent.PushIntoStack(count);
                foreach (var key in keys)
                {
                    object item = dict[key];
                    var itemWriter = new MessageStructure();
                    itemWriter.PushIntoStack(key);
                    if (EntitySchemaSet.IsSupportType(column.ColumnType))
                    {
                        itemWriter.PushIntoStack(column.ColumnType, item);
                    }
                    else if (column.HasChild)
                    {
                        PushChildStack(itemWriter, column, item);
                    }
                    parent.PushIntoStack(itemWriter);
                }
            }
            else if (parentColumn.IsList)
            {
                var column = parentColumn.Children[0];
                dynamic list = value;
                int count = list.Count;
                parent.PushIntoStack(count);
                foreach (var item in list)
                {
                    var itemWriter = new MessageStructure();
                    if (EntitySchemaSet.IsSupportType(column.ColumnType))
                    {
                        itemWriter.PushIntoStack(column.ColumnType, item);
                    }
                    else if (column.HasChild)
                    {
                        PushChildStack(itemWriter, column, item);
                    }
                    parent.PushIntoStack(itemWriter);
                }
            }
            else
            {
                //child entity object
                parent.PushIntoStack(1);
                var typeAccessor = ObjectAccessor.Create(value, true);
                var itemWriter = new MessageStructure();
                foreach (var column in parentColumn.Children)
                {
                    try
                    {
                        var fieldValue = typeAccessor[column.Name];
                        if (EntitySchemaSet.IsSupportType(column.ColumnType))
                        {
                            itemWriter.PushIntoStack(column.ColumnType, fieldValue);
                        }
                        else if (column.HasChild)
                        {
                            PushChildStack(itemWriter, column, fieldValue);
                        }
                    }
                    catch
                    {
                    }
                }
                parent.PushIntoStack(itemWriter);

            }
        }
开发者ID:houguohua,项目名称:Scut,代码行数:73,代码来源:EntitySyncManger.cs

示例3: ResponseError

 /// <summary>
 /// 
 /// </summary>
 /// <param name="response"></param>
 /// <param name="actionGetter"></param>
 /// <param name="errorCode"></param>
 /// <param name="errorInfo"></param>
 public virtual void ResponseError(BaseGameResponse response, ActionGetter actionGetter, int errorCode, string errorInfo)
 {
     string st = actionGetter.GetSt();
     ProtocolVersion prtcl = actionGetter.GetPtcl();
     MessageHead head = new MessageHead(actionGetter.GetMsgId(), actionGetter.GetActionId(), st, errorCode, errorInfo);
     MessageStructure sb = new MessageStructure();
     if (prtcl >= ProtocolVersion.ExtendHead)
     {
         sb.PushIntoStack(0); //不输出扩展头属性
     }
     sb.WriteBuffer(head);
     response.BinaryWrite(sb.PopBuffer());
 }
开发者ID:LeeWangyeol,项目名称:Scut,代码行数:20,代码来源:ActionDispatcher.cs


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