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


C# ErlAtom类代码示例

本文整理汇总了C#中ErlAtom的典型用法代码示例。如果您正苦于以下问题:C# ErlAtom类的具体用法?C# ErlAtom怎么用?C# ErlAtom使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: ErlAbstractConnection

 private ErlAbstractConnection(ErlLocalNode home, ErlRemoteNode peer, TcpClient s, ErlAtom? cookie = null)
 {
   m_Peer = peer;
   m_Home = home;
   m_TcpClient = s;
   m_Cookie = !cookie.HasValue || cookie.Value == ErlAtom.Null
       ? (peer.Cookie == ErlAtom.Null ? home.Cookie : peer.Cookie) : cookie.Value;
   m_SentBytes = 0;
   m_ReceivedBytes = 0;
   m_MaxPayloadLength = DEFAULT_MAX_PAYLOAD_LENGTH;
 }
开发者ID:vlapchenko,项目名称:nfx,代码行数:11,代码来源:ErlAbstractConnection.cs

示例2: complexAnalyse

 public static ErlType complexAnalyse(ByteBuffer data)
 {
     int position = data.position;
     int num2 = data.readByte();
     data.position = position;
     if ((num2 == ErlArray.TAG[0]) || (num2 == ErlArray.TAG[1]))
     {
         ErlArray array = new ErlArray(null);
         array.bytesRead(data);
         return array;
     }
     switch (num2)
     {
     case 0x6a:
         {
             ErlNullList list = new ErlNullList();
             list.bytesRead(data);
             return list;
         }
     case 0x6c:
         {
             ErlList list2 = new ErlList(null);
             list2.bytesRead(data);
             return list2;
         }
     case 100:
         {
             ErlAtom atom = new ErlAtom(null);
             atom.bytesRead(data);
             return atom;
         }
     case 0x6b:
         {
             ErlString str = new ErlString(null);
             str.sampleBytesRead(data);
             return str;
         }
     case 110:
         {
             ErlLong @long = new ErlLong();
             @long.bytesRead(data);
             return @long;
         }
     case 0x6d:
         {
             ErlByteArray array2 = new ErlByteArray(null);
             array2.bytesRead(data);
             return array2;
         }
     }
     return null;
 }
开发者ID:hebbaixue99,项目名称:XJDemoServer,代码行数:52,代码来源:ByteKitClient.cs

示例3: ErlAbstractConnection

 private ErlAbstractConnection(ErlLocalNode home, ErlRemoteNode peer, IErlTransport s, ErlAtom? cookie = null)
 {
   m_Peer = peer;
   m_Home = home;
   m_Transport = s;
   m_Cookie = !cookie.HasValue || cookie.Value == ErlAtom.Null
       ? (peer.Cookie == ErlAtom.Null ? home.Cookie : peer.Cookie) : cookie.Value;
   m_SentBytes = 0;
   m_ReceivedBytes = 0;
   m_MaxPayloadLength = DEFAULT_MAX_PAYLOAD_LENGTH;
   if (m_Transport != null)
     m_Transport.Trace += (o, t, d, msg) => home.OnTrace(t, d, msg);
 }
开发者ID:PavelTorgashov,项目名称:nfx,代码行数:13,代码来源:ErlAbstractConnection.cs

示例4: AtomTableTest

        public void AtomTableTest()
        {
            Assert.AreEqual(0, AtomTable.Instance[string.Empty]);

              Assert.AreEqual(1, AtomTable.Instance["true"]);

              Assert.AreEqual(2, AtomTable.Instance["false"]);

              Assert.AreEqual(1, ErlAtom.True.Index);
              Assert.AreEqual(2, ErlAtom.False.Index);

              bool found = AtomTable.Instance.IndexOf("ok") != -1;
              int count = AtomTable.Instance.Count;

              var am_ok = new ErlAtom("ok");

              Assert.AreEqual(found ? am_ok.Index : AtomTable.Instance.Count - 1, am_ok.Index);
              Assert.AreEqual(found ? count : count + 1, AtomTable.Instance.Count);
        }
开发者ID:itadapter,项目名称:nfx,代码行数:19,代码来源:ErlTermTest.cs

示例5: ErlAtomTest

        public void ErlAtomTest()
        {
            var am_test = new ErlAtom("test");
              Assert.IsTrue(am_test.Equals(new ErlAtom("test")));
              Assert.AreEqual(am_test, new ErlAtom("test"));
              Assert.AreEqual("test", am_test.Value);
              Assert.AreEqual("test", am_test.ToString());
              Assert.IsTrue(am_test.IsScalar);
              Assert.AreEqual(ErlTypeOrder.ErlAtom, am_test.TypeOrder);

              Assert.IsTrue(am_test.Matches(new ErlAtom("test")));
              Assert.AreEqual(new ErlVarBind(), am_test.Match(new ErlAtom("test")));

              var am_Test = new ErlAtom("Test");
              Assert.AreEqual("'Test'", am_Test.ToString());
              Assert.AreEqual(4, am_Test.Length);
              Assert.AreNotEqual(am_test, am_Test);

              IErlObject temp = null;
              Assert.IsFalse(am_test.Subst(ref temp, new ErlVarBind()));

              Assert.IsTrue(am_Test.Visit(true, (acc, o) => acc));

              Assert.DoesNotThrow(() => { var x = am_test.ValueAsObject; });
              Assert.Throws<ErlIncompatibleTypesException>(() => { var x = am_test.ValueAsInt; });
              Assert.Throws<ErlIncompatibleTypesException>(() => { var x = am_test.ValueAsLong; });
              Assert.Throws<ErlIncompatibleTypesException>(() => { var x = am_test.ValueAsDecimal; });
              Assert.Throws<ErlIncompatibleTypesException>(() => { var x = am_test.ValueAsDateTime; });
              Assert.Throws<ErlIncompatibleTypesException>(() => { var x = am_test.ValueAsTimeSpan; });
              Assert.Throws<ErlIncompatibleTypesException>(() => { var x = am_test.ValueAsDouble; });
              Assert.DoesNotThrow(() => { var x = am_test.ValueAsString; });
              Assert.DoesNotThrow(() => { var x = am_test.ValueAsBool; });
              Assert.AreEqual('a', new ErlAtom("a").ValueAsChar);
              Assert.Throws<ErlIncompatibleTypesException>(() => { var x = am_test.ValueAsByteArray; });

              string s = am_test;  // Implicit conversion
              Assert.AreEqual("test", s);

              ErlAtom a = "abc";   // Implicit conversion
              Assert.AreEqual("abc", a.Value);
        }
开发者ID:itadapter,项目名称:nfx,代码行数:41,代码来源:ErlTermTest.cs

示例6: genDigest

        private byte[] genDigest(int challenge, ErlAtom cookie)
        {
            long ch2 = challenge < 0
              ? 1L << 31 | (long)(challenge & 0x7FFFFFFFL)
              : (long)challenge;

              return new MD5CryptoServiceProvider().ComputeHash(
              Encoding.UTF8.GetBytes(cookie.Value + Convert.ToString(ch2)));
        }
开发者ID:itadapter,项目名称:nfx,代码行数:9,代码来源:ErlAbstractConnection.cs

示例7: ErlMbox

 internal ErlMbox(ErlLocalNode home, ErlPid self, ErlAtom name)
 {
   m_Self = self;
   m_Node = home;
   m_RegName = name;
   m_Queue = new ErlBlockingQueue<IQueable>();
   m_Links = new ErlLinks();
   m_Monitors = new ErlMonitors(this);
 }
开发者ID:PavelTorgashov,项目名称:nfx,代码行数:9,代码来源:ErlMbox.cs

示例8: BreakLinks

    /// <summary>
    /// Used to break all known links to this mbox
    /// </summary>
    internal void BreakLinks(ErlAtom fromNode, IErlObject reason)
    {
      var links = m_Links.Remove(fromNode);

      foreach (var link in links)
        if (link.HasPid)
          m_Node.Deliver(ErlMsg.Exit(m_Self, link.Pid, reason));
        else
          m_Node.Deliver(new ErlConnectionException(fromNode, reason));

      foreach (var m in m_Monitors.Where(o => o.Value.Node == fromNode)
                                  .Where(m => m_Monitors.Remove(m.Key)))
        Deliver(new ErlConnectionException(fromNode, reason));
    }
开发者ID:PavelTorgashov,项目名称:nfx,代码行数:17,代码来源:ErlMbox.cs

示例9: Down

 public void Down(ErlRef eref, ErlPid pid, ErlAtom reason)
 {
   // TODO
   throw new NotImplementedException();
 }
开发者ID:PavelTorgashov,项目名称:nfx,代码行数:5,代码来源:ErlMbox.cs

示例10: RPCcast

 public void RPCcast(ErlAtom node, ErlAtom mod, ErlAtom fun, ErlList args)
 {
   RPCcast(node, mod, fun, args, ConstAtoms.User);
 }
开发者ID:PavelTorgashov,项目名称:nfx,代码行数:4,代码来源:ErlMbox.cs

示例11: AsyncRPC

 public void AsyncRPC(ErlAtom node, ErlAtom mod, ErlAtom fun, ErlList args, ErlAtom? remoteCookie = null)
 {
   AsyncRPC(node, mod, fun, args, (IErlObject)m_Node.GroupLeader.Self, remoteCookie);
 }
开发者ID:PavelTorgashov,项目名称:nfx,代码行数:4,代码来源:ErlMbox.cs

示例12: rpcCall

    private IErlObject rpcCall(ErlPid from, ErlRef eref,
        ErlAtom mod, ErlAtom fun, ErlList args, IErlObject groupLeader)
    {
      // We spawn a new task, so that RPC calls wouldn't block the RPC server thread
      Task.Factory.StartNew(() =>
      {
        var type = Type.GetType(mod);

        if (type == null)
        {
          sendRpcReply(from, eref,
              ErlTuple.Create(ConstAtoms.Error, "unknown type: {0}".Args(mod)));
          return;
        }

        // TODO: add LRU caching
        //var method = type.GetMethod(fun.Value, BindingFlags.Static | BindingFlags.Public);

        string methodName = fun.Value;

        if (args.Count == 0)
        {
          var pi = type.GetProperty(fun, BindingFlags.Static | BindingFlags.Public);
          if (pi != null)
          {
            try
            {
              var result = pi.GetValue(null, null);
              sendRpcReply(from, eref,
                  ErlTuple.Create(ConstAtoms.Ok, result.ToErlObject()));
            }
            catch (Exception e)
            {
              sendRpcReply(from, eref,
                  ErlTuple.Create(ConstAtoms.Error, new ErlString(e.Message)));
            };
            return;
          }
        }

        var mi = type.GetMethods(BindingFlags.Static | BindingFlags.Public)
                     .Where(m => m.Name == methodName && m.GetParameters().Count() == args.Count)
                     .FirstOrDefault();

        if (mi == null)
        {
          sendRpcReply(from, eref,
              ErlTuple.Create(ConstAtoms.Error, "unknown method: {0}".Args(fun)));
          return;
        }

        var pars = mi.GetParameters();

        var margs = new object[pars.Length];

        for (int i = 0; i < pars.Length; i++)
        {
          var par = pars[i];
          var val = args[i];
          margs[i] = val.AsType(par.ParameterType);
        }

        try
        {
          var result = mi.Invoke(type, margs);
          sendRpcReply(from, eref, ErlTuple.Create(ConstAtoms.Ok, result.ToErlObject()));
        }
        catch (Exception e)
        {
          sendRpcReply(from, eref, ErlTuple.Create(ConstAtoms.Error, new ErlString(e.Message)));
        }
      });
      return (IErlObject)null;
    }
开发者ID:vlapchenko,项目名称:nfx,代码行数:74,代码来源:ErlRpcServer.cs

示例13: EncodeRPCcast

 internal static ErlTuple EncodeRPCcast(
     ErlPid from, ErlAtom mod, ErlAtom fun, ErlList args, IErlObject gleader)
 {
   /*{'$gen_cast', { cast, Mod, Fun, Args, GroupLeader}} */
   return new ErlTuple(
           ConstAtoms.GenCast,
           new ErlTuple(ConstAtoms.Cast, mod, fun, args, gleader));
 }
开发者ID:vlapchenko,项目名称:nfx,代码行数:8,代码来源:ErlRpcServer.cs

示例14: ErlRemoteNode

 /// <summary>
 /// Create a peer node
 /// </summary>
 public ErlRemoteNode(ErlLocalNode home, ErlAtom toNode, ErlAtom? cookie = null)
     : base(toNode, cookie ?? home.Cookie, home.UseShortName)
 {
   ctor(home);
 }
开发者ID:kinpro,项目名称:nfx,代码行数:8,代码来源:ErlRemoteNode.cs

示例15: ioProcessPutChars

 private IErlObject ioProcessPutChars(ErlAtom encoding,
     ErlAtom mod, ErlAtom fun, ErlList args, IErlObject replyAs)
 {
   string term;
   if (mod == ConstAtoms.Io_Lib && fun == ConstAtoms.Format && args.Count == 2)
     try { term = ErlObject.Format(args); }
     catch { term = "{0}:{1}({2})".Args(mod, fun, args.ToString(true)); }
   else
     term = "{0}:{1}({2})".Args(mod, fun, args.ToString(true));
   Node.OnIoOutput(encoding, new ErlString(term));
   return s_ReplyPattern.Subst(
       new ErlVarBind { { RA, replyAs }, { R, ConstAtoms.Ok } });
 }
开发者ID:PavelTorgashov,项目名称:nfx,代码行数:13,代码来源:ErlIoServer.cs


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