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


C# IErlObject类代码示例

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


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

示例1: DecodeRPC

        internal static IErlObject DecodeRPC(IErlObject msg)
        {
            var term = msg as ErlTuple;
              if (term == null)
            return null;

              var binding = term.Match(RpcReplyPattern);
              return binding != null ? binding[T] : null;
        }
开发者ID:itadapter,项目名称:nfx,代码行数:9,代码来源:ErlRpcServer.cs

示例2: ErlOutputStream

    /// <summary>
    /// Create a stream containing the serialized Erlang term.
    /// Optionally include in the beginning Erlang protocol version byte
    /// </summary>
    public ErlOutputStream(IErlObject o = null, bool writeVersion = true, bool writePktSize = false,
        int capacity = DEFAULT_INITIAL_SIZE)
    {
      m_Buffer = new byte[capacity];
      m_Capacity = capacity;
      m_Position = 0;

      if (writePktSize)
        Write4BE(0); // make space for length data, but final value is not yet known

      if (o == null)
      {
        if (writeVersion)
          write(ErlExternalTag.Version);
        return;
      }

      encodeObject(o, writeVersion);

      if (writePktSize)
        Poke4BE(0, m_Position - 4);
    }
开发者ID:vlapchenko,项目名称:nfx,代码行数:26,代码来源:ErlOutputStream.cs

示例3: ErlTuple

		    /// <summary>
		    /// Create an Erlang tuple from the given list of items
		    /// </summary>
		    public ErlTuple(IErlObject[] items) : base(items) {}
开发者ID:sergey-msu,项目名称:nfx,代码行数:4,代码来源:ErlTuple.cs

示例4: Write

 /// <summary>
 /// Write an arbitrary Erlang term to the stream.
 /// </summary>
 public void Write(IErlObject o)
 {
   switch (o.TypeOrder)
   {
     case ErlTypeOrder.ErlAtom:      WriteAtom((ErlAtom)o); break;
     case ErlTypeOrder.ErlBinary:    WriteBinary((ErlBinary)o); break;
     case ErlTypeOrder.ErlBoolean:   WriteBoolean((ErlBoolean)o); break;
     case ErlTypeOrder.ErlByte:      WriteByte((ErlByte)o); break;
     case ErlTypeOrder.ErlDouble:    WriteDouble((ErlDouble)o); break;
     case ErlTypeOrder.ErlLong:      WriteLong((ErlLong)o); break;
     case ErlTypeOrder.ErlList:      WriteList((ErlList)o); break;
     case ErlTypeOrder.ErlPid:       WritePid((ErlPid)o); break;
     case ErlTypeOrder.ErlPort:      WritePort((ErlPort)o); break;
     case ErlTypeOrder.ErlRef:       WriteRef((ErlRef)o); break;
     case ErlTypeOrder.ErlString:    WriteString((ErlString)o); break;
     case ErlTypeOrder.ErlTuple:     WriteTuple((ErlTuple)o); break;
     default:
       throw new ErlException(
           StringConsts.ERL_UNSUPPORTED_ELEMENT_TYPE_ERROR,
               o.GetType().Name, o.TypeOrder.ToString());
   }
 }
开发者ID:vlapchenko,项目名称:nfx,代码行数:25,代码来源:ErlOutputStream.cs

示例5: 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

示例6: Send

 /// <summary>
 /// Send a message to a named mailbox created from another node
 /// </summary>
 public bool Send(ErlAtom node, ErlAtom name, IErlObject msg)
 {
   return m_Node.Deliver(node, ErlMsg.RegSend(m_Self, name, msg));
 }
开发者ID:PavelTorgashov,项目名称:nfx,代码行数:7,代码来源:ErlMbox.cs

示例7: Send

 /*
 * send to remote name
 * dest is recipient's registered name, the nodename is implied by
 * the choice of connection.
 */
 public void Send(ErlPid from, ErlAtom dest, IErlObject msg)
 {
   // encode and send the message
   base.Send(ErlMsg.RegSend(from, dest, msg, SendCookie));
 }
开发者ID:PavelTorgashov,项目名称:nfx,代码行数:10,代码来源:ErlConnection.cs

示例8: EncodeRPC

 internal static ErlTuple EncodeRPC(
     ErlPid from, ErlAtom mod, ErlAtom fun, ErlList args, IErlObject gleader)
 {
   /*{Self, {call, Mod, Fun, Args, GroupLeader}} */
   return new ErlTuple(from, new ErlTuple(ConstAtoms.Call, mod, fun, args, gleader));
 }
开发者ID:vlapchenko,项目名称:nfx,代码行数:6,代码来源:ErlRpcServer.cs

示例9: IoOutput

 internal void IoOutput(ErlAtom encoding, IErlObject output)
 {
     if (m_OnIoOutput != null)
         m_OnIoOutput(encoding, output);
 }
开发者ID:sergey-msu,项目名称:nfx,代码行数:5,代码来源:ErlLocalNode.cs

示例10: BreakLinks

 /// <summary>
 /// Break links of all pids linked to pids on the fromNode node
 /// </summary>
 internal void BreakLinks(ErlAtom fromNode, IErlObject reason)
 {
     foreach (var m in m_Mailboxes)
         m.Value.BreakLinks(fromNode, reason);
 }
开发者ID:sergey-msu,项目名称:nfx,代码行数:8,代码来源:ErlLocalNode.cs

示例11: Send

 /// <summary>
 /// Send a message to a named mailbox on local node
 /// </summary>
 public bool Send(ErlPid from, ErlAtom toName, IErlObject msg)
 {
     return Deliver(ErlMsg.RegSend(from, toName, msg));
 }
开发者ID:sergey-msu,项目名称:nfx,代码行数:7,代码来源:ErlLocalNode.cs

示例12: ErlList

 /// <summary>
 /// Create an Erlang string from the given string
 /// </summary>
 public ErlList(IErlObject[] items, bool clone = true)
     : base(items, clone)
 {
 }
开发者ID:itadapter,项目名称:nfx,代码行数:7,代码来源:ErlList.cs

示例13: Equals

 /// <summary>
 /// Determine if two Erlang objects are equal
 /// </summary>
 public override bool Equals(IErlObject o)
 {
     if (o is ErlList) return Equals((ErlList)o);
     if (o is ErlString)
     {
       var rhs = ((ErlString)o).Value;
       if (rhs.Length != m_Items.Count) return false;
       return !rhs.Where((t, i) => !m_Items[i].IsInt() || (int)t != m_Items[i].ValueAsInt).Any();
     }
     return false;
 }
开发者ID:itadapter,项目名称:nfx,代码行数:14,代码来源:ErlList.cs

示例14: Equals

 /// <summary>
 /// Determine if two Erlang objects are equal
 /// </summary>
 public override bool Equals(IErlObject o)
 {
     return o is ErlTuple ? Equals((ErlTuple)o) : false;
 }
开发者ID:sergey-msu,项目名称:nfx,代码行数:7,代码来源:ErlTuple.cs

示例15: 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


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