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


C# PyObject.As方法代码示例

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


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

示例1: Decode

        public bool Decode( PyObject data)
        {
            if (data.Type != PyObjectType.Tuple)
            {
                Log.Error("VipKeyCommand", "Wrong type");
                return false;
            }

            PyTuple tmp = data.As<PyTuple>();

            if (tmp.Items.Count != 3)
            {
                Log.Error("VipKeyCommand", "Wrong size, expected 3 but got " + tmp.Items.Count);
                return false;
            }

            if (tmp.Items[0].Type != PyObjectType.None)
            {
                Log.Error("VipKeyCommand", "Wrong type for item 1");
                return false;
            }

            if (tmp.Items[1].Type != PyObjectType.String)
            {
                Log.Error("VipKeyCommand", "Wrong type for item 2");
                return false;
            }

            if (tmp.Items[2].Type != PyObjectType.String)
            {
                Log.Error("VipKeyCommand", "Wrong type for item 3");
                return false;
            }

            PyString command = tmp.Items[1].As<PyString>();

            if (command.Value != "VK")
            {
                Log.Error("VipKeyCommand", "Wrong command name, expected VK but got \"" + command.Value + "\"");
                return false;
            }

            /* We cant check the vipKey, because the client sends different vipKeys, who know why ?
            PyString vipKey = tmp.Items[2].As<PyString>();

            if (vipKey.Value != vipkey)
            {
                Log.Error("VipKeyCommand", "Wrong vipKey value, expected \"" + vipkey + "\" but got \"" + vipKey.Value + "\"");
                return false;
            }*/

            return true;
        }
开发者ID:Reve,项目名称:EVESharp,代码行数:53,代码来源:VipKeyCommand.cs

示例2: Decode

        public bool Decode(PyObject info)
        {
            if (info.Type != PyObjectType.ObjectData)
            {
                Log.Error("NodeInfo", "Wrong type for ObjectData");
                return false;
            }

            PyObjectData data = info.As<PyObjectData>();

            if (data.Name != "machoNet.nodeInfo")
            {
                Log.Error("NodeInfo", "Wrong object name, expected machoNet.nodeInfo but got " + data.Name);
                return false;
            }

            if (data.Arguments.Type != PyObjectType.Tuple)
            {
                Log.Error("NodeInfo", "Wrong type for ObjectData arguments, expected Tuple");
                return false;
            }

            PyTuple args = data.Arguments.As<PyTuple>();

            if (args.Items[0].Type != PyObjectType.Long)
            {
                Log.Error("NodeInfo", "Wrong type for tuple0 item0, expected int");
                return false;
            }

            nodeID = args.Items[0].As<PyInt>().Value;

            if (args.Items[1].Type != PyObjectType.List)
            {
                Log.Error("NodeInfo", "Wrong type for tuple0 item1, expected list");
                return false;
            }

            solarSystems = args.Items[1].As<PyList>();

            return true;
        }
开发者ID:Reve,项目名称:EVESharp,代码行数:42,代码来源:NodeInfo.cs

示例3: Decode

        public bool Decode(PyObject data)
        {
            if (data.Type != PyObjectType.Tuple)
            {
                Log.Error("QueueCheckCommand", "Wrong type");
                return false;
            }

            PyTuple tmp = data.As<PyTuple>();

            if (tmp.Items.Count != 2)
            {
                Log.Error("QueueCheckCommand", "Wrong size, expected 2 but got " + tmp.Items.Count);
                return false;
            }

            if (tmp.Items[0].Type != PyObjectType.None)
            {
                Log.Error("QueueCheckCommand", "Wrong type for item 1");
                return false;
            }

            if (tmp.Items[1].Type != PyObjectType.String)
            {
                Log.Error("QueueCheckCommand", "Wrong type for item 2");
                return false;
            }

            PyString command = tmp.Items[1].As<PyString>();

            if (command.Value != "QC")
            {
                Log.Error("QueueCheckCommand", "Wrong value for command, expected \"QC\" but got \"" + command.Value + "\"");
                return false;
            }

            return true;
        }
开发者ID:Reve,项目名称:EVESharp,代码行数:38,代码来源:QueueCheckCommand.cs

示例4: Decode

        public bool Decode(PyObject data)
        {
            if (data.Type != PyObjectType.ObjectEx)
            {
                Log.Error("PyException", "Wrong container type");
                return false;
            }

            PyObjectEx p = data.As<PyObjectEx>();

            if (p.IsType2 == true)
            {
                Log.Error("PyException", "Wrong PyObjectEx type, expected Normal, but got Type2");
                return false;
            }

            if (p.Header.Type != PyObjectType.Tuple)
            {
                Log.Error("PyException", "Wrong item 1 type");
                return false;
            }

            PyTuple args = p.Header.As<PyTuple>();
            if (args.Items.Count != 3)
            {
                Log.Error("PyException", "Wrong tuple 1 item count, expected 3 but got " + args.Items.Count);
                return false;
            }

            if (args.Items[0].Type != PyObjectType.Token)
            {
                Log.Error("PyException", "Wrong tuple item 1 type");
                return false;
            }

            PyToken type = args.Items[0].As<PyToken>();
            exception_type = type.Token;

            if (exception_type.StartsWith("exceptions.") == false)
            {
                Log.Warning("PyException", "Trying to decode a non-exception packet: " + exception_type);
                return false;
            }

            if (args.Items[1].Type != PyObjectType.Tuple)
            {
                Log.Error("PyException", "Wrong tuple item 2 type");
                return false;
            }

            PyTuple msg = args.Items[1].As<PyTuple>();

            if (msg.Items.Count != 1)
            {
                Log.Error("PyException", "Wrong item 2 tuple count, expected 1 but got " + msg.Items.Count);
                return false;
            }

            if (msg.Items[0].Type != PyObjectType.String)
            {
                Log.Error("PyException", "Wrong tuple 2 item 1 type");
                return false;
            }

            PyString msg_data = msg.Items[0].As<PyString>();

            message = msg_data.Value;

            if (args.Items[2].Type != PyObjectType.Dict)
            {
                Log.Error("PyException", "Wrong tuple 1 item 3 type");
                return false;
            }

            PyDict info = args.Items[2].As<PyDict>();

            if (info.Contains("origin") == false)
            {
                Log.Error("PyException", "Dict item 1 doesnt has key origin");
                return false;
            }

            origin = info.Get("origin").As<PyString>().Value;

            if (info.Contains("reasonArgs") == false)
            {
                Log.Error("PyException", "Dict item 1 doesn has key reasonArgs");
                return false;
            }

            reasonArgs = info.Get("reasonArgs").As<PyDict>();

            if (info.Contains("clock") == false)
            {
                Log.Error("PyException", "Dict item 1 doesnt has key clock");
                return false;
            }

            clock = info.Get("clock").IntValue;

//.........这里部分代码省略.........
开发者ID:VizanArkonin,项目名称:EVEmu-live-packet-editor,代码行数:101,代码来源:PyException.cs

示例5: Decode

        public bool Decode(PyObject from)
        {
            if (from.Type != PyObjectType.ObjectData)
            {
                return false;
            }

            PyObjectData obj = from.As<PyObjectData>();

            if (obj.Name != "macho.MachoAddress")
            {
                return false;
            }

            if (obj.Arguments.Type != PyObjectType.Tuple)
            {
                return false;
            }

            PyTuple args = obj.Arguments.As<PyTuple>();
            if (args.Items.Count < 3)
            {
                return false;
            }

            if (args.Items[0].Type != PyObjectType.String)
            {
                return false;
            }

            PyString typei = args.Items[0].As<PyString>();

            switch (typei.Value)
            {
                case "A":
                    if (args.Items.Count != 3)
                    {
                        return false;
                    }

                    if (!DecodeService(args.Items[1]) || !DecodeCallID(args.Items[2]))
                    {
                        return false;
                    }

                    type = AddrType.Any;
                    break;

                case "N":
                    if (args.Items.Count != 4)
                    {
                        return false;
                    }

                    if (!DecodeTypeID(args.Items[1]) || !DecodeService(args.Items[2]) || !DecodeCallID(args.Items[3]))
                    {
                        return false;
                    }

                    type = AddrType.Node;

                    break;

                case "C":
                    if (args.Items.Count != 4)
                    {
                        return false;
                    }

                    if (!DecodeTypeID(args.Items[1]) || !DecodeCallID(args.Items[2]) || !DecodeService(args.Items[3]))
                    {
                        return false;
                    }

                    type = AddrType.Client;

                    break;

                case "B":
                    if (args.Items.Count != 4)
                    {
                        return false;
                    }

                    type = AddrType.Broadcast;

                    if (args.Items[1].Type != PyObjectType.String)
                    {
                        return false;
                    }

                    if (args.Items[3].Type != PyObjectType.String)
                    {
                        return false;
                    }

                    PyString bid = args.Items[1].As<PyString>();
                    PyString idt = args.Items[3].As<PyString>();

                    service = bid.Value;
//.........这里部分代码省略.........
开发者ID:VizanArkonin,项目名称:EVEmu-live-packet-editor,代码行数:101,代码来源:PyAddress.cs

示例6: DecodeTypeID

        private bool DecodeTypeID(PyObject data)
        {
            if (( data.Type == PyObjectType.IntegerVar) || ( data.Type == PyObjectType.Long) )
            {
                typeID = (ulong)data.As<PyInt>().Value;
            }
            else if (data.Type == PyObjectType.None)
            {
                typeID = 0;
            }
            else
            {
                return false;
            }

            return true;
        }
开发者ID:VizanArkonin,项目名称:EVEmu-live-packet-editor,代码行数:17,代码来源:PyAddress.cs

示例7: DecodeService

        private bool DecodeService(PyObject data)
        {
            if (data.Type == PyObjectType.String)
            {
                service = data.As<PyString>().Value;
            }
            else if (data.Type == PyObjectType.None)
            {
                service = "";
            }
            else
            {
                return false;
            }

            return true;
        }
开发者ID:VizanArkonin,项目名称:EVEmu-live-packet-editor,代码行数:17,代码来源:PyAddress.cs

示例8: Decode

        public bool Decode(PyObject data)
        {
            if (data.Type != PyObjectType.Tuple)
            {
                Log.Error("AuthenticationReq", "Wrong type");
                return false;
            }

            PyTuple tmp = data.As<PyTuple>();

            if (tmp.Items.Count != 2)
            {
                Log.Error("AuthenticationReq", "Wrong size, expected 2 but got " + tmp.Items.Count);
                return false;
            }

            if (tmp.Items[0].Type != PyObjectType.String)
            {
                Log.Error("AuthenticationReq", "Wrong type for item 1");
                return false;
            }

            if (tmp.Items[1].Type != PyObjectType.Dict)
            {
                Log.Error("AuthenticationReq", "Wrong type for item 2");
                return false;
            }

            PyDict info = tmp.Items[1].As<PyDict>();

            if (info.Contains("boot_version") == false)
            {
                Log.Error("AuthenticationReq", "Dict item 1 doesnt has key boot_version");
                return false;
            }

            boot_version = info.Get("boot_version").As<PyFloat>().Value;

            if (info.Contains("boot_region") == false)
            {
                Log.Error("AuthenticationReq", "Dict item 1 doesnt has key boot_region");
                return false;
            }

            boot_region = info.Get("boot_region").As<PyString>().Value;

            if (info.Contains("user_password") == false)
            {
                Log.Error("AuthenticationReq", "Dict item 1 doesnt has key user_password");
                return false;
            }

            if (info.Get("user_password").Type == PyObjectType.None)
            {
                user_password = null;
            }
            else
            {
                // user_password = info.Get("user_password").As<PyString>().Value;
                PyObjectEx obj = info.Get("user_password").As<PyObjectEx>();
                user_password = obj.Header.As<PyTuple>().Items[0].As<PyTuple>().Items[1].As<PyString>().Value;
            }

            if (info.Contains("user_affiliateid") == false)
            {
                Log.Error("AuthenticationReq", "Dict item 1 doesnt has key user_affiliateid");
                return false;
            }

            user_affiliateid = info.Get("user_affiliateid").As<PyInt>().Value;

            if (info.Contains("user_password_hash") == false)
            {
                Log.Error("AuthenticationReq", "Dict item 1 doesnt has key user_password_hash");
                return false;
            }

            if (info.Get("user_password_hash").Type == PyObjectType.None)
            {
                user_password_hash = null;
            }
            else
            {
                user_password_hash = info.Get("user_password_hash").As<PyString>().Value;
            }

            if (info.Contains("macho_version") == false)
            {
                Log.Error("AuthenticationReq", "Dict item 1 doesnt has key macho_version");
                return false;
            }

            macho_version = info.Get("macho_version").As<PyInt>().Value;

            if (info.Contains("boot_codename") == false)
            {
                Log.Error("AuthenticationReq", "Dict item 1 doesnt has key boot_codename");
                return false;
            }

//.........这里部分代码省略.........
开发者ID:Reve,项目名称:EVESharp,代码行数:101,代码来源:AuthenticationReq.cs

示例9: Decode

        public bool Decode(PyObject data)
        {
            isNode = false;

            if (data.Type != PyObjectType.Tuple)
            {
                Log.Error("LowLevelVersionExchange", "Wrong type");
                return false;
            }

            PyTuple tmp = data.As<PyTuple>();

            if (tmp.Items.Count != 6)
            {
                Log.Error("LowLevelVersionExchange", "Wrong item count");
                return false;
            }

            PyObject birth = tmp.Items[0];

            if ( (birth.Type != PyObjectType.IntegerVar) && (birth.Type != PyObjectType.LongLong) && (birth.Type != PyObjectType.Long))
            {
                Log.Error("LowLevelVersionExchange", "Wrong type for birthday. Type: " + (uint)birth.Type);
                return false;
            }

            birthday = birth.As<PyInt>().Value;

            PyObject macho = tmp.Items[1];

            if ((macho.Type != PyObjectType.IntegerVar) && (macho.Type != PyObjectType.LongLong) && (macho.Type != PyObjectType.Long))
            {
                Log.Error("LowLevelVersionExchange", "Wrong type for machoVersion");
                return false;
            }

            machoVersion = macho.As<PyInt>().Value;

            PyObject users = tmp.Items[2];

            if (users.Type == PyObjectType.None)
            {
                usercount = 0;
            }
            else if(users.Type == PyObjectType.Long)
            {
                usercount = users.As<PyInt>().Value;
            }
            else if (users.Type == PyObjectType.String)
            {
                isNode = true;
                nodeIdentifier = users.As<PyString>().Value;
            }
            else
            {
                Log.Error("LowLevelVersionExchange", "Wrong type for usercount/node identifier");
                return false;
            }

            PyObject ver = tmp.Items[3];

            if (ver.Type != PyObjectType.Float)
            {
                Log.Error("LowLevelVersionExchange", "Wrong type for version");
                return false;
            }

            version = ver.As<PyFloat>().Value;

            PyObject b = tmp.Items[4];

            if ((b.Type != PyObjectType.IntegerVar) && (b.Type != PyObjectType.LongLong) && (b.Type != PyObjectType.Long))
            {
                Log.Error("LowLevelVersionExchange", "Wrong type for build");
                return false;
            }

            build = b.As<PyInt>().Value;

            PyObject code = tmp.Items[5];

            if (code.Type != PyObjectType.String)
            {
                Log.Error("LowLevelVersionExchange", "Wrong type for codename");
                return false;
            }

            codename = code.As<PyString>().Value;

            return true;
        }
开发者ID:Reve,项目名称:EVESharp,代码行数:91,代码来源:LowLevelVersionExchange.cs


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