本文整理汇总了C#中Block.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Block.Clone方法的具体用法?C# Block.Clone怎么用?C# Block.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Block
的用法示例。
在下文中一共展示了Block.Clone方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Clone
public void Clone()
{
var block = new Block { BlockType = new BlockType() };
var result = block.Clone() as Block;
Assert.NotNull( result );
Assert.NotNull( result.BlockType );
}
示例2: VisitBlock
public virtual Differences VisitBlock(Block block1, Block block2){
Differences differences = new Differences(block1, block2);
if (block1 == null || block2 == null){
if (block1 != block2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++;
return differences;
}
Block changes = (Block)block2.Clone();
Block deletions = (Block)block2.Clone();
Block insertions = (Block)block2.Clone();
if (block1.Checked == block2.Checked) differences.NumberOfSimilarities++; else differences.NumberOfDifferences++;
StatementList statChanges, statDeletions, statInsertions;
Differences diff = this.VisitStatementList(block1.Statements, block2.Statements, out statChanges, out statDeletions, out statInsertions);
if (diff == null){Debug.Assert(false); return differences;}
changes.Statements = statChanges;
deletions.Statements = statDeletions;
insertions.Statements = statInsertions;
differences.NumberOfDifferences += diff.NumberOfDifferences;
differences.NumberOfSimilarities += diff.NumberOfSimilarities;
if (block1.SuppressCheck == block2.SuppressCheck) differences.NumberOfSimilarities++; else differences.NumberOfDifferences++;
if (differences.NumberOfDifferences == 0){
differences.Changes = null;
differences.Deletions = null;
differences.Insertions = null;
}else{
differences.Changes = changes;
differences.Deletions = deletions;
differences.Insertions = insertions;
}
return differences;
}
示例3: LookupBlock
public Block LookupBlock (Block from)
{
Block result;
if (!block_map.TryGetValue (from, out result)) {
result = (Block) from.Clone (this);
}
return result;
}
示例4: ShouldCopyProperties
public void ShouldCopyProperties()
{
var block = new Block { Name = "Foo" };
var result = block.Clone( false );
Assert.AreEqual( result.Name, block.Name );
}
示例5: VisitBlock
public override Block VisitBlock(Block block)
{
if (block == null) return null;
Block dup = (Block)this.DuplicateFor[block.UniqueKey];
if (dup != null) return dup;
this.DuplicateFor[block.UniqueKey] = dup = (Block)block.Clone();
return base.VisitBlock(dup);
}
示例6: ShallowClone
public void ShallowClone()
{
var block = new Block { Name = "Foo" };
var result = block.Clone( false );
Assert.Equal( result.Name, block.Name );
}
示例7: BlockAndValidity
public BlockAndValidity(Dictionary<uint256, int> blockToHeightMap, Dictionary<uint256, Block> hashHeaderMap, Block block,
bool connects, bool throwsException, uint256 hashChainTipAfterBlock, int heightAfterBlock, String blockName)
: base(blockName)
{
if(connects && throwsException)
throw new InvalidOperationException("A block cannot connect if an exception was thrown while adding it.");
this.block = block;
this.blockHash = block.GetHash();
this.connects = connects;
this.throwsException = throwsException;
this.hashChainTipAfterBlock = hashChainTipAfterBlock;
this.heightAfterBlock = heightAfterBlock;
// Keep track of the set of blocks indexed by hash
hashHeaderMap.AddOrReplace(block.GetHash(), block.Clone());
// Double-check that we are always marking any given block at the same height
int height = 0;
;
if(blockToHeightMap.TryGetValue(hashChainTipAfterBlock, out height))
Assert.True(height == heightAfterBlock);
else
blockToHeightMap.Add(hashChainTipAfterBlock, heightAfterBlock);
}