Ejemplo n.º 1
0
    public static bool load(string filePath, IMessage message)
    {
        try
        {
            FileStream fs = new FileStream(filePath, FileMode.Open);
//                      CodedInputStream ctx = new CodedInputStream(fs);
            message.MergeFrom(fs);
        }
        catch (Exception e)
        {
            GSLogTool.exception("GSProtoBuffTool.init", e, string.Format("load file:{0} failed", filePath));
            message = null;
        }

        if (message == null)
        {
            GSLogTool.eFormat("GSProtoBuffTool.init", "filePath:{0} failed", filePath);
            return(false);
        }
        else
        {
            GSLogTool.dFormat("GSProtoBuffTool.init", "filePath:{0} success", filePath);
            return(true);
        }
    }
Ejemplo n.º 2
0
    public void changeTo(string name, params object[] parameters)
    {
        if (GSTest.GSDEBUG)
        {
            GSLogTool.wFormat("GSStateM.changeTo", "name:{0} parameters:{1}", name, parameters);
        }
        else
        {
            GSLogTool.dFormat("GSStateM.changeTo", "name:{0} parameters:{1}", name, parameters);
        }
        if (!mStates.ContainsKey(name))
        {
            GSLogTool.eFormat("GSStateM.changeTo", "name:{} not exit", name);
            return;
        }

        if (mCurState != null)
        {
            mCurState.onExit();
        }

        mCurState = mStates[name];

        mCurState.onEnter(parameters);
    }
Ejemplo n.º 3
0
    public void remove(string name)
    {
        GSLogTool.dFormat("GSStateM.remove", "name:{0}", name);
        if (!mStates.ContainsKey(name))
        {
            GSLogTool.eFormat("GSStateM.remove", "name:{} not exit", name);
            return;
        }

        mStates.Remove(name);
    }
Ejemplo n.º 4
0
    public static void save(string fileName, IMessage message)
    {
        if (GSFileTool.getFileExit(fileName))
        {
            GSFileTool.deleteFile(fileName);
        }
        using (var output = File.Create(fileName))
        {
            message.WriteTo(output);
        }

        GSLogTool.dFormat("GSProtoBuffTool.save", "保存成功:{0}", fileName);
    }
Ejemplo n.º 5
0
    public void add(GSState state)
    {
        GSLogTool.dFormat("GSStateM.add", "state:{0}", state);
        string name = state.Name;

        if (mStates.ContainsKey(name))
        {
            GSLogTool.eFormat("GSStateM.add", "name:{} already exit", name);
            return;
        }

        mStates.Add(name, state);
    }