本文整理汇总了C#中Message.AssignFrom方法的典型用法代码示例。如果您正苦于以下问题:C# Message.AssignFrom方法的具体用法?C# Message.AssignFrom怎么用?C# Message.AssignFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message
的用法示例。
在下文中一共展示了Message.AssignFrom方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AssignInvalidData
public void AssignInvalidData()
{
var name = "field";
var m = new Message("topic");
try
{
m.AssignFrom(name, new object[] { 1, 2, "invalid" });
Assert.Fail("Invalid elements should throw Exception");
}
catch (BinTypeMismatchException)
{
// ok!
}
}
示例2: AssignContainingNullTyped
public void AssignContainingNullTyped()
{
var name = "field";
var m = new Message("topic");
try
{
m.AssignFrom(name, new object[] { 1, 2, null }, typeof(int));
Assert.Fail("Invalid elements should throw Exception");
}
catch (ArgumentNullException)
{
// ok!
}
}
示例3: AssignFromTest
public void AssignFromTest()
{
var name = "field";
var m = new Message("topic");
m.Commit(this);
Assert.IsFalse(m.IsChanged);
var data = Enumerable.Repeat(4, 4);
m.AssignFrom(name, data);
Assert.IsTrue(m.IsChanged);
Assert.AreEqual(m[name], BinFactory.New(4, 4, 4, 4));
Assert.AreEqual(m[name].Count, 4);
}
示例4: Evaluate
public override void Evaluate(int SpreadMax)
{
InitDX11Graph();
bool warnPinSafety = false;
if (RemovePinsFirst) warnPinSafety = !RetryConfig();
if (!FNew.Any()) // if none true
{
FOutput.FlushNil();
return;
}
SpreadMax = FNew.CombineWith(FTopic);
foreach (string name in FPins.Keys)
{
var pin = FPins[name].ToISpread();
pin.Sync();
SpreadMax = Math.Max(pin.SliceCount, SpreadMax);
}
FOutput.SliceCount = 0;
for (int i = 0; i < SpreadMax; i++)
{
if (FNew[i])
{
var message = new Message();
message.Topic = FTopic[i];
foreach (string name in FPins.Keys)
{
var pin = FPins[name].ToISpread();
if (pin.SliceCount > 0)
message.AssignFrom(name, pin[i] as ISpread);
else message[name] = BinFactory.New(Formular[name].Type); // will do empty spreads as well, but ignore faults
}
FOutput.Add(message);
}
}
FOutput.Flush();
if (warnPinSafety)
throw new PinConnectionException("Manually remove unneeded links first! [Create]. ID = [" + PluginHost.GetNodePath(false) + "]");
}
示例5: AssignStartingWithNull
public void AssignStartingWithNull()
{
var name = "field";
var m = new Message("topic");
try
{
m.AssignFrom(name, new object[] { null, 2, 3 });
Assert.Fail("Invalid elements should throw Exception");
}
catch (ArgumentNullException)
{
// ok!
}
}
示例6: AssignNull
public void AssignNull()
{
var name = "field";
var m = new Message("topic");
try
{
m.AssignFrom(name, null);
Assert.Fail("Assigning null should throw Exception");
}
catch (ArgumentNullException)
{
// ok!
}
}
示例7: AssignInvalidType
public void AssignInvalidType()
{
var name = "field";
var m = new Message("topic");
try
{
m.AssignFrom(name, new object[] { new object(), 2, 3 });
Assert.Fail("Invalid elements should throw Exception");
}
catch (TypeNotSupportedException)
{
// ok!
}
}
示例8: AssignInvalidName
public void AssignInvalidName()
{
var name = "this fails";
var m = new Message("topic");
try
{
m.AssignFrom(name, Enumerable.Repeat(4, 4), typeof(int));
Assert.Fail("Invalid Names should throw Exception");
}
catch (ParseFormularException)
{
// ok!
}
}