예제 #1
0
        public static CaseStep Create(string formatType, string stepName, int index)
        {
            string typeName = string.Format(formatType, stepName);
            string code     = string.Format(ConfigUtils.GetSetting("CaseStep.Script.Format", "Case.Step{0}.cs"), stepName);
            var    instance = ScriptEngines.Execute(code, typeName);

            //var instance = type.CreateInstance<CaseStep>();
            if (instance == null)
            {
                throw new NullReferenceException(string.Format("Get CaseStep object is null, type:{1}, script code:{0}", code, typeName));
            }
            instance.Action    = stepName;
            instance.netWriter = new NetWriter();
            instance.netReader = new NetReader(new CustomHeadFormater());
            instance.indentify = index;
            if (instance.isCustom)
            {
                GameRanking.Pack.MessagePack headPack = new GameRanking.Pack.MessagePack()
                {
                    MsgId     = 1,
                    ActionId  = int.Parse(stepName),
                    SessionId = "",
                    UserId    = 0
                };
                byte[] header = ProtoBufUtils.Serialize(headPack);
                instance.netWriter.SetHeadBuffer(header);
                instance.netWriter.SetBodyData(null);
            }
            return(instance);
        }
예제 #2
0
        public static CaseStep Create(string formatType, string stepName,int index)
        {
            string typeName = string.Format(formatType, stepName);
            string code = string.Format(ConfigUtils.GetSetting("CaseStep.Script.Format", "Case.Step{0}.cs"), stepName);
            var instance = ScriptEngines.Execute(code, typeName);
            //var instance = type.CreateInstance<CaseStep>();
            if (instance == null)
            {
                throw new NullReferenceException(string.Format("Get CaseStep object is null, type:{1}, script code:{0}", code, typeName));
            }
            instance.Action = stepName;
            instance.netWriter = new NetWriter();
            instance.netReader = new NetReader(new CustomHeadFormater());
            instance.indentify = index;
            if (instance.isCustom)
            {

                GameRanking.Pack.MessagePack headPack = new GameRanking.Pack.MessagePack()
                {
                    MsgId = 1,
                    ActionId = int.Parse(stepName),
                    SessionId ="",
                    UserId =0
                };
                byte[] header = ProtoBufUtils.Serialize(headPack);
                instance.netWriter.SetHeadBuffer(header);
                instance.netWriter.SetBodyData(null);
            }
            return instance;
        }