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


C# IErlObject.GetType方法代码示例

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


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

示例1: EncodeSize

 public static int EncodeSize(IErlObject o)
 {
   switch (o.TypeOrder)
   {
     case ErlTypeOrder.ErlAtom:
       return 1 + 2 + o.ValueAsString.Length;
     case ErlTypeOrder.ErlBinary:
       return 5 + o.ValueAsByteArray.Length;
     case ErlTypeOrder.ErlBoolean:
       return 1 + 2 + (o.ValueAsBool ? ErlConsts.TRUE.Length : ErlConsts.FALSE.Length);
     case ErlTypeOrder.ErlByte:
       return 1 + 1;
     case ErlTypeOrder.ErlDouble:
       return 9;
     case ErlTypeOrder.ErlLong:
       long l1 = o.ValueAsLong;
       if ((l1 & 0xff) == l1) return 2;
       else if ((ErlConsts.ERL_INT_MIN <= l1) && (l1 <= ErlConsts.ERL_INT_MAX)) return 5;
       return longArity(l1);
     case ErlTypeOrder.ErlList:
       var l2 = (ErlList)o;
       if (l2.Count == 0) return 1;
       return 5 + l2.Value.Sum(obj1 => EncodeSize(obj1));
     case ErlTypeOrder.ErlPid:
       var p1 = (ErlPid)o;
       return 1 + (1 + 2 + p1.Node.Length) + 4 + 4 + 1;
     case ErlTypeOrder.ErlPort:
       var p2 = (ErlPort)o;
       return 1 + (1 + 2 + p2.Node.Length) + 4 + 1;
     case ErlTypeOrder.ErlRef:
       var p3 = (ErlRef)o;
       return 1 + (1 + 2 + p3.Node.Length) + 1 + 4 * p3.Ids.Length;
     case ErlTypeOrder.ErlString:
       var l3 = o.ValueAsString;
       if (l3.Length == 0) return 1;
       if (l3.Length < 0xffff) return 2 + l3.Length;
       return 1 + 4 + 2 * l3.Length;
     case ErlTypeOrder.ErlTuple:
       var l4 = (ErlTuple)o;
       int sz = 1 + (l4.Count < 0xff ? 1 : 4);
       return sz + l4.Value.Sum(obj2 => EncodeSize(obj2));
     default:
       throw new ErlException(StringConsts.ERL_UNSUPPORTED_ELEMENT_TYPE_ERROR,
           o.GetType().Name, o.TypeOrder.ToString());
   }
 }
开发者ID:vlapchenko,项目名称:nfx,代码行数:46,代码来源:ErlOutputStream.cs

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

示例3: ErlIncompatibleTypesException

 public ErlIncompatibleTypesException(IErlObject lhs, Type rhs)
     : base(StringConsts.ERL_CANNOT_CONVERT_TYPES_ERROR, lhs.GetType().Name, rhs.Name)
 {}
开发者ID:sergey-msu,项目名称:nfx,代码行数:3,代码来源:ErlException.cs

示例4: ErlMsg

    /*
    internal ErlMsg(Tag tag, ErlMsg msg)
        : this(tag, msg.Sender, msg.Recipient, msg.Ref, msg.Reason, msg.Payload,
               msg.m_Paybuf, msg.TraceToken)
    {}
    */

    internal ErlMsg(Tag tag, IErlObject /* Pid or Atom */ from,
        IErlObject /* Pid or Atom */ to, ErlRef? eref = null, IErlObject reason = null,
        IErlObject payload = null, ErlInputStream paybuf = null,
        ErlAtom? cookie = null, ErlTrace trace = null)
    {
      if (!(from is ErlPid || from is ErlAtom))
        throw new ErlException(StringConsts.ERL_INVALID_VALUE_TYPE_ERROR.Args("sender", from.GetType().Name));
      if (!(to is ErlPid || to is ErlAtom))
        throw new ErlException(StringConsts.ERL_INVALID_VALUE_TYPE_ERROR.Args("recipient", from.GetType().Name));

      m_From      = from;
      m_To        = to;
      Type        = tag;
      Paybuf      = paybuf;
      m_Payload   = payload;
      Reason      = reason;
      Ref         = eref.HasValue ? eref.Value : ErlRef.Null;
      Cookie      = cookie.HasValue ? cookie.Value : ErlAtom.Null;
      TraceToken  = trace;
    }
开发者ID:vlapchenko,项目名称:nfx,代码行数:27,代码来源:ErlMsg.cs

示例5: Subst

 public bool Subst(ref IErlObject obj, ErlVarBind binding)
 {
     if (IsAny || binding == null || binding.Empty)
         throw new ErlException(StringConsts.ERL_UNBOUND_VARIABLE_ERROR);
     
     IErlObject term = binding[Name];
     if (term == null)
         //throw new ErlException(StringConsts.VARIABLE_NOT_FOUND_ERROR, Name);
         return false;
     if (!checkType(term))
         throw new ErlException(StringConsts.ERL_VARIABLE_INVALID_VALUE_TYPE_ERROR,
             Name, obj.GetType().Name, ValueType);
     obj = term;
     return true;
 }
开发者ID:sergey-msu,项目名称:nfx,代码行数:15,代码来源:ErlVar.cs

示例6: ErlToClrValue

    internal static object ErlToClrValue(IErlObject erlValue, Schema schema, Schema.FieldDef fdef, string targetName = null, IErlObject outerTerm = null)
    {
      if (erlValue.IsNull())
        return null;

      var atr = fdef[targetName];

      var dataType = atr.BackendType;
      if (dataType.IsNullOrWhiteSpace())
        throw new ErlDataAccessException(StringConsts.ERL_DS_INTERNAL_MAPPING_ERROR + 
                                         "fielddef '{0}.{1}' has no backend type".Args(schema.Name, fdef.Name));

      Tuple<Type, Func<IErlObject, object>> mapping;
      if (ERL_TO_CLR_TYPEMAP.TryGetValue(dataType, out mapping))
      {
        try
        {
          return mapping.Item2(erlValue);
        }
        catch (Exception error)
        {
          var err = "Schema '{0}' field '{1}' ({2}) cannot be converted from '{3}' to '{4}' format{5}"
            .Args(schema.Name, fdef.Name, erlValue.ToString(), erlValue.GetType(), dataType,
            outerTerm == null ? "" : " in record:\n  {0}".Args(outerTerm.ToString()));
          App.Log.Write(new Log.Message
          {
            Type      = Log.MessageType.TraceErl,
            Topic     = CoreConsts.ERLANG_TOPIC,
            From      = "SchemaMap.ErlTupleToRow({0})".Args(schema.Name),
            Text      = err + error.ToMessageWithType(),
            Exception = error
          });
          throw new ErlDataAccessException(err, inner: error);
        }
      }

      var er = StringConsts.ERL_DS_INTERNAL_MAPPING_ERROR +
               "erltype'{0}' not matched in the dict".Args(dataType);
      throw new ErlDataAccessException(er);
    }
开发者ID:yhhno,项目名称:nfx,代码行数:40,代码来源:SchemaMap.cs


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