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


C# Erlang.atomValue方法代码示例

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


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

示例1: cookieError

 /*Send an auth error to peer because he sent a bad cookie.
 * The auth error uses his cookie (not revealing ours).
 * This is just like send_reg otherwise
 */
 private void  cookieError(OtpLocalNode local, Erlang.Atom cookie)
 {
     try
     {
         OtpOutputStream header = new OtpOutputStream(headerLen);
         
         // preamble: 4 byte length + "passthrough" tag + version
         header.write4BE(0); // reserve space for length
         header.write1(passThrough);
         header.write1(version);
         
         header.write_tuple_head(4);
         header.write_long((long)OtpMsg.Tag.regSendTag);
         header.write_any(local.createPid()); // disposable pid
         header.write_atom(cookie.atomValue()); // important: his cookie, not mine...
         header.write_atom("auth");
         
         // version for payload
         header.write1(version);
         
         // the payload
         
         // the no_auth message (copied from Erlang) Don't change this (Erlang will crash)
         // {$gen_cast, {print, "~n** Unauthorized cookie ~w **~n", [[email protected]]}}
         Erlang.Object[] msg = new Erlang.Object[2];
         Erlang.Object[] msgbody = new Erlang.Object[3];
         
         msgbody[0] = new Erlang.Atom("print");
         msgbody[1] = new Erlang.String("~n** Bad cookie sent to " + local + " **~n");
         // Erlang will crash and burn if there is no third argument here...
         msgbody[2] = new Erlang.List(); // empty list
         
         msg[0] = new Erlang.Atom("$gen_cast");
         msg[1] = new Erlang.Tuple(msgbody);
         
         OtpOutputStream payload = new OtpOutputStream(new Erlang.Tuple(msg));
         
         // fix up length in preamble
         header.poke4BE(0, header.count() + payload.count() - 4);
         
         try
         {
             do_send(header, payload);
         }
         catch (System.IO.IOException)
         {
         } // ignore
     }
     finally
     {
         close();
         throw new OtpAuthException("Remote cookie not authorized: " + cookie.atomValue());
     }
 }
开发者ID:saneman1,项目名称:otp.net,代码行数:58,代码来源:AbstractConnection.cs

示例2: encode_size

        public int encode_size(Erlang.Object o)
        {
            if (o is Erlang.Atom) return 1 + 2 + o.atomValue().Length;
            else if (o is Erlang.Boolean) return 1 + 2 + (o.boolValue()
                                                      ? Erlang.Boolean.s_true.atomValue().Length
                                                      : Erlang.Boolean.s_false.atomValue().Length);
            else if (o is Erlang.Binary) return 5 + o.binaryValue().Length;
            else if (o is Erlang.Long)
            {
                long l = o.longValue();
                if ((l & 0xff) == l) return 2;
                else if ((l <= OtpExternal.erlMax) && (l >= OtpExternal.erlMin)) return 5;
                return long_arity(l);
            }
            else if (o is Erlang.Byte) return 1 + 1;
            else if (o is Erlang.Double) return 9;
            else if (o is Erlang.String)
            {
                string l = o.stringValue();
                if (l.Length == 0) return 1;
                if (l.Length < 0xffff) return 2 + l.Length;
                return 1 + 4 + 2 * l.Length;

            }
            else if (o is Erlang.List)
            {
                Erlang.List l = o.listValue();
                if (l.arity() == 0)
                    return 1;
                int sz = 5;
                for (int i = 0; i < l.arity(); i++)
                    sz += encode_size(l[i]);
                return sz;
            }
            else if (o is Erlang.Tuple)
            {
                Erlang.Tuple l = o.tupleValue();
                int sz = 1 + (l.arity() < 0xff ? 1 : 4);
                for (int i = 0; i < l.arity(); i++)
                    sz += encode_size(l[i]);
                return sz;
            }
            else if (o is Erlang.Pid)
            {
                Erlang.Pid p = o.pidValue();
                return 1 + (1 + 2 + p.node().Length) + 4 + 4 + 1;
            }
            else if (o is Erlang.Ref)
            {
                Erlang.Ref p = o.refValue();
                int[] ids = p.ids();
                return 1 + (1 + 2 + p.node().Length) + 1 + 4 * ids.Length;
            }
            else if (o is Erlang.Port)
            {
                Erlang.Port p = o.portValue();
                return 1 + (1 + 2 + p.node().Length) + 4 + 1;
            }
            else
                throw new Erlang.Exception("Unknown encode size for object: " + o.ToString());
        }
开发者ID:saleyn,项目名称:otp.net,代码行数:61,代码来源:OtpOutputStream.cs


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