本文整理汇总了C#中System.Signature类的典型用法代码示例。如果您正苦于以下问题:C# Signature类的具体用法?C# Signature怎么用?C# Signature使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Signature类属于System命名空间,在下文中一共展示了Signature类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDynamicClass
public Type GetDynamicClass(IEnumerable<DynamicProperty> properties, Type resultType = null, Type baseType = null)
{
rwLock.AcquireReaderLock(Timeout.Infinite);
try
{
Signature signature = new Signature(properties);
Type type;
if (!classes.TryGetValue(signature, out type))
{
if (resultType == null)
type = CreateDynamicClass(signature.properties);
else
{
type = CreateDynamicClass(signature.properties, resultType, baseType);
}
classes.Add(signature, type);
}
return type;
}
finally
{
rwLock.ReleaseReaderLock();
}
}
示例2: AugmentSignatureHelpSession
public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList<ISignature> signatures)
{
if (!session.TextView.Properties.ContainsProperty(SessionKey))
{
return;
}
// Map the trigger point down to our buffer.
var subjectTriggerPoint = session.GetTriggerPoint(subjectBuffer.CurrentSnapshot);
if (!subjectTriggerPoint.HasValue)
{
return;
}
var currentSnapshot = subjectTriggerPoint.Value.Snapshot;
var querySpan = new SnapshotSpan(subjectTriggerPoint.Value, 0);
var applicableToSpan = currentSnapshot.CreateTrackingSpan(
querySpan.Start.Position,
0,
SpanTrackingMode.EdgeInclusive);
string encouragement = encouragements.GetRandomEncouragement();
var signature = new Signature(applicableToSpan, encouragement, "", "");
signatures.Add(signature);
}
示例3: CheckArguments
internal object[] CheckArguments(object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
{
int num = (parameters != null) ? parameters.Length : 0;
object[] objArray = new object[num];
ParameterInfo[] parametersNoCopy = null;
for (int i = 0; i < num; i++)
{
object defaultValue = parameters[i];
RuntimeType type = sig.Arguments[i];
if (defaultValue == Type.Missing)
{
if (parametersNoCopy == null)
{
parametersNoCopy = this.GetParametersNoCopy();
}
if (parametersNoCopy[i].DefaultValue == DBNull.Value)
{
throw new ArgumentException(Environment.GetResourceString("Arg_VarMissNull"), "parameters");
}
defaultValue = parametersNoCopy[i].DefaultValue;
}
objArray[i] = type.CheckValue(defaultValue, binder, culture, invokeAttr);
}
return objArray;
}
示例4: AuthorizationHeader
public AuthorizationHeader(ClientCredentials credentials, Nonce nonce, TimeStamp timestamp, Signature signature)
{
this.credentials = credentials;
this.timestamp = timestamp;
this.nonce = nonce;
this.signature = signature;
}
示例5: CanCommitALittleBit
public void CanCommitALittleBit()
{
SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
using (var repo = Repository.Init(scd.DirectoryPath))
{
string dir = repo.Info.Path;
Path.IsPathRooted(dir).ShouldBeTrue();
Directory.Exists(dir).ShouldBeTrue();
const string relativeFilepath = "new.txt";
string filePath = Path.Combine(repo.Info.WorkingDirectory, relativeFilepath);
File.WriteAllText(filePath, "null");
repo.Index.Stage(relativeFilepath);
File.AppendAllText(filePath, "token\n");
repo.Index.Stage(relativeFilepath);
repo.Head[relativeFilepath].ShouldBeNull();
var author = new Signature("Author N. Ame", "[email protected]", DateTimeOffset.Now.AddSeconds(-10));
Commit commit = repo.Commit("Initial egotistic commit", author, author);
AssertBlobContent(repo.Head[relativeFilepath], "nulltoken\n");
AssertBlobContent(commit[relativeFilepath], "nulltoken\n");
commit.Parents.Count().ShouldEqual(0);
repo.Info.IsEmpty.ShouldBeFalse();
File.WriteAllText(filePath, "nulltoken commits!\n");
repo.Index.Stage(relativeFilepath);
var author2 = new Signature(author.Name, author.Email, author.When.AddSeconds(5));
Commit commit2 = repo.Commit("Are you trying to fork me?", author2, author2);
AssertBlobContent(repo.Head[relativeFilepath], "nulltoken commits!\n");
AssertBlobContent(commit2[relativeFilepath], "nulltoken commits!\n");
commit2.Parents.Count().ShouldEqual(1);
commit2.Parents.First().Id.ShouldEqual(commit.Id);
Branch firstCommitBranch = repo.CreateBranch("davidfowl-rules", commit.Id.Sha); //TODO: This cries for a shortcut method :-/
repo.Branches.Checkout(firstCommitBranch.Name); //TODO: This cries for a shortcut method :-/
File.WriteAllText(filePath, "davidfowl commits!\n");
var author3 = new Signature("David Fowler", "[email protected]", author.When.AddSeconds(2));
repo.Index.Stage(relativeFilepath);
Commit commit3 = repo.Commit("I'm going to branch you backwards in time!", author3, author3);
AssertBlobContent(repo.Head[relativeFilepath], "davidfowl commits!\n");
AssertBlobContent(commit3[relativeFilepath], "davidfowl commits!\n");
commit3.Parents.Count().ShouldEqual(1);
commit3.Parents.First().Id.ShouldEqual(commit.Id);
AssertBlobContent(firstCommitBranch[relativeFilepath], "nulltoken\n");
}
}
示例6: AugmentSignatureHelpSession
public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList<ISignature> signatures)
{
if (!session.TextView.Properties.ContainsProperty(SessionKey))
{
return;
}
// At the moment there is a bug in the javascript provider which causes it to
// repeatedly insert the same Signature values into an ISignatureHelpSession
// instance. There is no way, other than reflection, for us to prevent this
// from happening. Instead we just ensure that our provider runs after
// Javascript and then remove the values they add here
signatures.Clear();
// Map the trigger point down to our buffer.
var subjectTriggerPoint = session.GetTriggerPoint(subjectBuffer.CurrentSnapshot);
if (!subjectTriggerPoint.HasValue)
{
return;
}
var currentSnapshot = subjectTriggerPoint.Value.Snapshot;
var querySpan = new SnapshotSpan(subjectTriggerPoint.Value, 0);
var applicableToSpan = currentSnapshot.CreateTrackingSpan(
querySpan.Start.Position,
0,
SpanTrackingMode.EdgeInclusive);
string encouragement = encouragements.GetRandomEncouragement();
if (encouragement != null)
{
var signature = new Signature(applicableToSpan, encouragement, "", "");
signatures.Add(signature);
}
}
示例7: SingMesssage
/// <summary>
/// Creates a signature for the given messsage and the given private key.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="privateKey">The array of 32 bytes of the private key.</param>
/// <param name="useCompressedPublicKey">true to specify that the public key should have the compressed format; otherwise, false.</param>
/// <exception cref="ArgumentException">The message is null or private key is null or invalid.</exception>
/// <returns>The signature for the given message and the given private key in base-64 encoding.</returns>
public static string SingMesssage(string message, byte[] privateKey, bool useCompressedPublicKey)
{
if (message == null)
{
throw new ArgumentException("The message is null.", nameof(message));
}
if (privateKey == null)
{
throw new ArgumentException("The private key is null.", nameof(privateKey));
}
if (!BitcoinPrivateKey.IsValid(privateKey))
{
throw new ArgumentException("The private key is invalid.", nameof(privateKey));
}
ECPrivateKeyParameters parameters = new ECPrivateKeyParameters(new BigInteger(1, privateKey), domainParameters);
ECDsaSigner signer = new ECDsaSigner(new HMacDsaKCalculator(new Sha256Digest()));
signer.Init(true, parameters);
var hash = GetMessageHash(message);
BigInteger[] signatureArray = signer.GenerateSignature(hash);
BigInteger r = signatureArray[0];
BigInteger s = signatureArray[1];
s = NormalizeS(s);
byte[] encodedPublicKey = BitcoinPrivateKey.ToEncodedPublicKey(privateKey, useCompressedPublicKey);
int pubKeyMaskOffset = useCompressedPublicKey ? 4 : 0;
Signature signature = null;
for (int i = 0; i < 4; i++)
{
Signature candidateSignature = new Signature();
candidateSignature.PublicKeyMask = i + pubKeyMaskOffset;
candidateSignature.R = r;
candidateSignature.S = s;
byte[] recoveredPublicKey = RecoverPublicKeyFromSignature(hash, candidateSignature);
if (recoveredPublicKey != null && recoveredPublicKey.SequenceEqual(encodedPublicKey))
{
signature = candidateSignature;
break;
}
}
if (signature == null)
{
// this should not happen
throw new Exception("The public key is not recoverable from signature.");
}
return EncodeSignature(signature);
}
示例8: UpdateFromMem
private void UpdateFromMem(IntPtr sigPtr)
{
_gpgme_op_verify_result ver = new _gpgme_op_verify_result();
Marshal.PtrToStructure(sigPtr, ver);
file_name = Gpgme.PtrToStringUTF8(ver.file_name);
if (ver.signature != IntPtr.Zero)
signature = new Signature(ver.signature);
}
示例9: UpdateInfo
public UpdateInfo(string updateVersion, Uri downloadURI, long downloadSize, Signature signature)
{
_updateVersion = updateVersion;
_downloadURI = downloadURI;
_downloadSize = downloadSize;
_signature = signature;
if (_signature.SigningCertificate.Capability != CertificateCapability.SignFile)
throw new Exception("Signing certificate is not capable to sign files.");
}
示例10: TypeDecoderMethodAttribute
public TypeDecoderMethodAttribute(Type[] dependency)
{
try
{
m_dependency = new Signature(dependency[0], dependency[1]);
}
catch (Exception)
{
// TODO: wrongly constructed dependency
}
}
示例11: GetDynamicClass
public Type GetDynamicClass(IEnumerable<DynamicProperty> properties)
{
Type type;
Signature key = new Signature(properties);
if (!this.classes.TryGetValue(key, out type))
{
type = this.CreateDynamicClass(key.properties);
this.classes.Add(key, type);
}
return type;
}
示例12: GetDynamicClass
public Type GetDynamicClass( IEnumerable< DynamicProperty > properties ) {
rwLock.AcquireReaderLock( Timeout.Infinite );
try {
var signature = new Signature( properties );
Type type;
if ( !classes.TryGetValue( signature , out type ) ) {
type = CreateDynamicClass( signature.properties );
classes.Add( signature , type );
}
return type;
}
finally {
rwLock.ReleaseReaderLock();
}
}
示例13: CanCreateAndRetrieveCommit
public async Task CanCreateAndRetrieveCommit()
{
string owner = this._repository.Owner.Login;
var author = new Signature { Name = "author", Email = "[email protected]", Date = DateTime.UtcNow };
var commiter = new Signature { Name = "commiter", Email = "[email protected]", Date = DateTime.Today };
var newCommit = new NewCommit("test-commit", "[Change this to tree sha]", Enumerable.Empty<string>())
{
Author = author,
Committer = commiter
};
var commit = await this._commitsClient.Create(owner, this._repository.Name, newCommit);
Assert.NotNull(commit);
var retrieved = await this._commitsClient.Get(owner, this._repository.Name, commit.Sha);
Assert.NotNull(retrieved);
}
示例14: AddCommitToRepo
private static Commit AddCommitToRepo(IRepository repo)
{
string relativeFilepath = "test.txt";
Touch(repo.Info.WorkingDirectory, relativeFilepath, content);
repo.Index.Stage(relativeFilepath);
var ie = repo.Index[relativeFilepath];
Assert.NotNull(ie);
Assert.Equal("9daeafb9864cf43055ae93beb0afd6c7d144bfa4", ie.Id.Sha);
var author = new Signature("nulltoken", "[email protected]", DateTimeOffset.Parse("Wed, Dec 14 2011 08:29:03 +0100"));
var commit = repo.Commit("Initial commit", author, author);
relativeFilepath = "big.txt";
var zeros = new string('0', 32*1024 + 3);
Touch(repo.Info.WorkingDirectory, relativeFilepath, zeros);
repo.Index.Stage(relativeFilepath);
ie = repo.Index[relativeFilepath];
Assert.NotNull(ie);
Assert.Equal("6518215c4274845a759cb498998fe696c42e3e0f", ie.Id.Sha);
return commit;
}
示例15: DiffSigs
internal static bool DiffSigs(Signature sig1, RuntimeTypeHandle typeHandle1, Signature sig2, RuntimeTypeHandle typeHandle2)
{
SignatureStruct left = (SignatureStruct) sig1;
SignatureStruct right = (SignatureStruct) sig2;
return CompareSig(ref left, typeHandle1, ref right, typeHandle2);
}