-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/leveldb-thread-ut' into leveldb-…
…thread-ut
- Loading branch information
Showing
24 changed files
with
1,704 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// Copyright (C) 2015-2024 The Neo Project. | ||
// | ||
// AndConditionBuilder.cs file belongs to the neo project and is free | ||
// software distributed under the MIT software license, see the | ||
// accompanying file LICENSE in the main directory of the | ||
// repository or http://www.opensource.org/licenses/mit-license.php | ||
// for more details. | ||
// | ||
// Redistribution and use in source and binary forms with or without | ||
// modifications are permitted. | ||
|
||
using Neo.Cryptography.ECC; | ||
using Neo.Network.P2P.Payloads.Conditions; | ||
using System; | ||
|
||
namespace Neo.Builders | ||
{ | ||
public sealed class AndConditionBuilder | ||
{ | ||
private readonly AndCondition _condition = new() { Expressions = [] }; | ||
|
||
private AndConditionBuilder() { } | ||
|
||
public static AndConditionBuilder CreateEmpty() | ||
{ | ||
return new AndConditionBuilder(); | ||
} | ||
|
||
public AndConditionBuilder And(Action<AndConditionBuilder> config) | ||
{ | ||
var acb = new AndConditionBuilder(); | ||
config(acb); | ||
|
||
_condition.Expressions = [.. _condition.Expressions, acb.Build()]; | ||
|
||
return this; | ||
} | ||
|
||
public AndConditionBuilder Or(Action<OrConditionBuilder> config) | ||
{ | ||
var ocb = OrConditionBuilder.CreateEmpty(); | ||
config(ocb); | ||
|
||
_condition.Expressions = [.. _condition.Expressions, ocb.Build()]; | ||
|
||
return this; | ||
} | ||
|
||
public AndConditionBuilder Boolean(bool expression) | ||
{ | ||
_condition.Expressions = [.. _condition.Expressions, new BooleanCondition { Expression = expression }]; | ||
return this; | ||
} | ||
|
||
public AndConditionBuilder CalledByContract(UInt160 hash) | ||
{ | ||
_condition.Expressions = [.. _condition.Expressions, new CalledByContractCondition { Hash = hash }]; | ||
return this; | ||
} | ||
|
||
public AndConditionBuilder CalledByEntry() | ||
{ | ||
_condition.Expressions = [.. _condition.Expressions, new CalledByEntryCondition()]; | ||
return this; | ||
} | ||
|
||
public AndConditionBuilder CalledByGroup(ECPoint publicKey) | ||
{ | ||
_condition.Expressions = [.. _condition.Expressions, new CalledByGroupCondition { Group = publicKey }]; | ||
return this; | ||
} | ||
|
||
public AndConditionBuilder Group(ECPoint publicKey) | ||
{ | ||
_condition.Expressions = [.. _condition.Expressions, new GroupCondition() { Group = publicKey }]; | ||
return this; | ||
} | ||
|
||
public AndConditionBuilder ScriptHash(UInt160 scriptHash) | ||
{ | ||
_condition.Expressions = [.. _condition.Expressions, new ScriptHashCondition() { Hash = scriptHash }]; | ||
return this; | ||
} | ||
|
||
public AndCondition Build() | ||
{ | ||
return _condition; | ||
} | ||
} | ||
} |
Oops, something went wrong.