本文整理汇总了C#中IErlObject.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# IErlObject.ToString方法的具体用法?C# IErlObject.ToString怎么用?C# IErlObject.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IErlObject
的用法示例。
在下文中一共展示了IErlObject.ToString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: checkForError
private void checkForError(IErlObject pattern, IErlObject response, ErlVarBind bind, int reqID)
{
if (bind != null)
return;
bind = response.Match(pattern);
if (bind == null)
throw new ErlDataAccessException(StringConsts.ERL_DS_INVALID_RESP_PROTOCOL_ERROR + "invalid error response pattern", new Exception(response.ToString()));
var gotReqID = bind[ATOM_ReqID].ValueAsLong;
if (gotReqID != reqID)
throw new ErlDataAccessException(StringConsts.ERL_DS_INVALID_RESP_PROTOCOL_ERROR + "unexpected transaction ID (expected={0}, got={1})".Args(reqID, gotReqID));
var ecode = bind[ATOM_Code].ValueAsInt;
var rmsg = bind[ATOM_Msg];
var emsg = rmsg.TypeOrder == ErlTypeOrder.ErlString || rmsg.TypeOrder == ErlTypeOrder.ErlAtom
? rmsg.ValueAsString
: rmsg.ToString();
Exception error;
switch (ecode)
{
case INVALID_SUBSCRIPTION_REQUEST_EXCEPTION:
error = new NFX.DataAccess.CRUD.Subscriptions.InvalidSubscriptionRequestException(emsg, null);
break;
case -1:
error = new ErlDataAccessException("Remote error message: {0}".Args(emsg));
break;
default:
error = new ErlDataAccessException("Remote error code {0}. Message: {1}".Args(ecode, emsg));
break;
}
throw error;
}
示例2: erlIP2String
private static string erlIP2String(IErlObject erl)
{
try
{
return string.Join(".", ((ErlTuple) erl).Value.Select(i => i.ValueAsInt.ToString()).Take(4));
}
catch (Exception e)
{
throw new ErlException(StringConsts.ERL_INVALID_VALUE_ERROR.Args(erl.ToString()), e);
}
}
示例3: erlDate2DateTime
private static DateTime erlDate2DateTime(IErlObject erl)
{
try
{
var date = (ErlTuple)erl;
var y = date[0].ValueAsInt;
var m = date[1].ValueAsInt;
var d = date[2].ValueAsInt;
return new DateTime(y, m, d, 0, 0, 0, DateTimeKind.Utc);
}
catch (Exception e)
{
throw new ErlException(StringConsts.ERL_INVALID_VALUE_ERROR.Args(erl.ToString()), e);
}
}
示例4: 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);
}