本文整理汇总了C#中Datum类的典型用法代码示例。如果您正苦于以下问题:C# Datum类的具体用法?C# Datum怎么用?C# Datum使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Datum类属于命名空间,在下文中一共展示了Datum类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Evaluate
public override Continuation Evaluate(Continuation oldContinuation, Datum args)
{
// Replace the old continuation with the new continuation - but pass in the
// supplied argument as the 'return value' of the new continuation.
var returnValue = args.ToArray()[0];
return c.PushResult(returnValue);
}
示例2: GetSingle
public static Datum GetSingle(Datum args)
{
var argArray = args.ToArray();
if (argArray.Length != 1)
throw DatumHelpers.error("Expected a single argument. Got {0}", argArray.Length);
return argArray[0];
}
示例3: eval
protected override Datum eval(Datum arg1, Datum arg2)
{
if ((arg1 as Pair) != null ||
(arg2 as Pair) != null)
return DatumHelpers.atom(ReferenceEquals(arg1, arg2));
return DatumHelpers.atom(arg1.Equals(arg2));
}
示例4: car
public static Datum car(Datum d)
{
var pair = d as Pair;
if (pair == null)
throw error("'{0}' is not a pair", d);
return pair.First;
}
示例5: Evaluate
public override Continuation Evaluate(Continuation c, LexicalEnvironment env, Datum args)
{
var argArray = DatumHelpers.enumerate(args).ToArray();
Array.Reverse(argArray);
c = c.PushTask(new InvokeFunction(function, argArray.Length));
return argArray.Aggregate(c, (current, arg) => current.Evaluate(env, arg));
}
示例6: asContinuation
private static Continuation asContinuation(Datum arg)
{
var cfunction = arg as CallCC.ContinuationFunction;
if (cfunction == null)
throw DatumHelpers.error("'{0}' is not a continuation", arg);
return cfunction.Continuation;
}
示例7: Evaluate
public override Continuation Evaluate(Continuation s, Datum args)
{
var argArray = args.ToArray();
var expression = argArray[0];
var environment = (Environment) argArray[1].CastObject();
return s.Evaluate(environment, expression);
}
示例8: evaluate
private static Datum evaluate(Continuation c, Datum args)
{
var argList = args.ToArray();
if (argList.Length != 1)
throw c.error("invalid syntax '{0}'", args);
return argList[0];
}
示例9: Evaluate
public Datum Evaluate(Datum args)
{
var argArray = args.ToArray();
var names = argArray.Select(x => x.CastString()).ToArray();
var fullname = string.Join(".", names);
return GetTypeEx(fullname).ToAtom();
}
示例10: castObject
public static object castObject(Datum d)
{
var a = d as Atom;
if (a == null)
throw error("Expected '{0}' to be an atom, but got '{1}' instead", d, d.GetType().Name);
return a.Value;
}
示例11: Write
public override void Write(Datum aggregatedDatum)
{
if (!App.Available) return;
if (UseLog)
base.Write(aggregatedDatum);
var node = ReceiverNode;
if (node.IsNullOrWhiteSpace()) return;
string site;
if (SiteName.IsNotNullOrWhiteSpace())
site = SiteName;
else
site = "{0}::{1}@{2}".Args(App.Name, App.InstanceID, System.Environment.MachineName);
try
{
if (m_Client==null)
m_Client = new TelemetryReceiverClient(ReceiverNode);
m_Client.Send(site, aggregatedDatum);
}
catch(Exception error)
{
cleanupClient();
WriteLog(MessageType.Error, error.ToMessageWithType(), from: "{0}.{1}".Args(GetType().Name, "Write(datum)") );
}
}
示例12: Evaluate
public Datum Evaluate(Datum args)
{
var argArray = args.ToArray();
if (argArray.Length != 1)
throw DatumHelpers.error("Expected a single argument. Got {0}", argArray.Length);
return eval(argArray[0]);
}
示例13: Evaluate
public Datum Evaluate(Datum args)
{
var function = UnaryFunction.GetSingle(args) as StackFunction;
if (function == null)
throw error("Expected function argument");
return ToMacro(function);
}
示例14: Evaluate
public Datum Evaluate(Datum args)
{
var argDatums = args.ToArray();
if (argDatums.Length != 2)
throw DatumHelpers.error("Exactly 2 arguments expected");
return eval(argDatums[0], argDatums[1]);
}
示例15: buildSymbolForm
// Create a "special form" for a symbol that has either "." or "/" inside it.
private static Datum buildSymbolForm(Datum name, IEnumerable<string> contents)
{
// "prefix" with a 'dot' so that higher level macros can interpret it.
// This means you can't have normal symbols containing dots, which is a
// small price to pay IMO.
var args = compound(contents.Select(c => c == "" ? nil : parseSymbol(c)).ToArray());
return cons(name, args);
}