當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。