本文整理汇总了C#中Signature类的典型用法代码示例。如果您正苦于以下问题:C# Signature类的具体用法?C# Signature怎么用?C# Signature使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Signature类属于命名空间,在下文中一共展示了Signature类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanStoreTest
public void CanStoreTest()
{
object[] obj = new object[5];
obj[0] = new object();
obj[1] = new int();
obj[2] = new float();
obj[3] = new Action(() => { });
obj[4] = new List<int>();
Type[] types1 = obj.GetTypes();
Type[] types2 = new Type[] { typeof(object), typeof(int), typeof(float), typeof(Delegate), typeof(IList<int>) };
Assert.IsTrue(types2.CanStore(types1));
Assert.IsFalse(types1.CanStore(types2));
Signature s1 = new Signature() { ParameterTypes = types1, ReturnType = typeof(Int16) };
Signature s2 = new Signature() { ParameterTypes = types2, ReturnType = typeof(object) };
Assert.IsTrue(s2.CanStore(s1));
Assert.IsFalse(s1.CanStore(s2));
types1 = new Type[0];
types2 = new Type[0];
Assert.IsTrue(types2.CanStore(types1));
Assert.IsTrue(types1.CanStore(types2));
s1 = new Signature() { ParameterTypes = types1, ReturnType = typeof(void) };
s2 = new Signature() { ParameterTypes = types2, ReturnType = typeof(void) };
Assert.IsTrue(s2.CanStore(s1));
Assert.IsTrue(s1.CanStore(s2));
}
示例2: SelectNodeByIdFromObjects
/// <summary>
/// Locate and return the node identified by idValue
/// </summary>
/// <param name="signature"></param>
/// <param name="idValue"></param>
/// <returns>node if found - else null</returns>
/// <remarks>Tries to match each object in the Object list.</remarks>
private static XmlElement SelectNodeByIdFromObjects(Signature signature, string idValue)
{
XmlElement node = null;
// enumerate the objects
foreach (DataObject dataObject in signature.ObjectList)
{
// direct reference to Object id - supported for all reference typs
if (String.CompareOrdinal(idValue, dataObject.Id) == 0)
{
// anticipate duplicate ID's and throw if any found
if (node != null)
throw new XmlException(SR.Get(SRID.DuplicateObjectId));
node = dataObject.GetXml();
}
}
// now search for XAdES specific references
if (node == null)
{
// For XAdES we implement special case where the reference may
// be to an internal tag with matching "Id" attribute.
node = SelectSubObjectNodeForXAdES(signature, idValue);
}
return node;
}
示例3: CommitToBranch
public Commit CommitToBranch(Repository repo, string branchName, string message, Signature author, Tree tree)
{
Branch branch = repo.Branches[branchName];
Commit commit = repo.ObjectDatabase.CreateCommit(author, author, message, tree, new List<Commit> { branch.Tip }, prettifyMessage: true);
repo.Refs.UpdateTarget(repo.Refs[branch.CanonicalName], commit.Id);
return commit;
}
示例4: ElementLabel
/// <summary>
/// Constructor for the <c>ElementLabel</c> object. This is
/// used to create a label that can convert a XML node into a
/// composite object or a primitive type from an XML element.
/// </summary>
/// <param name="contact">
/// this is the field that this label represents
/// </param>
/// <param name="label">
/// this is the annotation for the contact
/// </param>
public ElementLabel(Contact contact, Element label) {
this.detail = new Signature(contact, this);
this.decorator = new Qualifier(contact);
this.type = contact.Type;
this.name = label.name();
this.label = label;
}
示例5: RenameMyWishListPage
private static void RenameMyWishListPage(Repository repo, string myWishListPath, Signature sig)
{
repo.Index.Unstage(myWishListPath);
File.Move(myWishListPath, myWishListPath + "List");
repo.Index.Stage(myWishListPath + "List");
repo.Commit(sig, sig, "Fix MyWishList page name");
}
示例6: UpdateHomePageContent
private static void UpdateHomePageContent(Repository repo, string homePath, Signature sig)
{
File.AppendAllText(homePath, "\nThis will be a bare bone user experience.\n");
repo.Index.Stage(homePath);
repo.Commit(sig, sig,
"Add warning to the Home page\n\nA very informational explicit message preventing the user from expecting too much.");
}
示例7: SaveFile
public void SaveFile(string fileName, string content, string username, string email)
{
using (var repo = new Repository(_basePath))
{
File.WriteAllText(Path.Combine(repo.Info.WorkingDirectory, fileName), content);
// stage the file
repo.Stage(fileName);
// Create the committer's signature and commit
//var user = repo.Config.Get<string>("user", "name", null);
//var email = repo.Config.Get<string>("user", "email", null);
var author = new Signature(username, email, DateTime.Now);
var committer = author;
// Commit to the repo
var commitMessage = string.Format("Revision: {0}", GetRevisionCount(repo, fileName));
try
{
var commit = repo.Commit(commitMessage, author, committer);
foreach (var parent in commit.Parents)
{
Console.WriteLine("Id: {0}, Sha: {1}", parent.Id, parent.Sha);
}
}
catch (EmptyCommitException) { } // I don't care if the user didn't change anything at this time
}
}
示例8: BuildSampleWikiRepo
public static void BuildSampleWikiRepo()
{
var repoPath = Repository.Init(Constants.WorkingDirectory);
using (var repo = new Repository(repoPath))
{
string workDir = repo.Info.WorkingDirectory;
string homePath = Path.Combine(workDir, "Home");
var sig = new Signature("A. U. Thor", "[email protected]",
new DateTimeOffset(2011, 06, 16, 10, 58, 27, TimeSpan.FromHours(2)));
CreateHomePage(repo, homePath, sig);
Signature sig2 = Shift(sig, TimeSpan.FromMinutes(2));
UpdateHomePageContent(repo, homePath, sig2);
string myWishListPath = Path.Combine(workDir, "MyWish");
Signature sig3 = Shift(sig2, TimeSpan.FromMinutes(17));
CreateMyWishListPage(repo, myWishListPath, sig3);
Signature sig4 = Shift(sig3, TimeSpan.FromMinutes(31));
RenameMyWishListPage(repo, myWishListPath, sig4);
}
}
示例9: TextLabel
/// <summary>
/// Constructor for the <c>TextLabel</c> object. This is
/// used to create a label that can convert a XML node into a
/// primitive value from an XML element text value.
/// </summary>
/// <param name="contact">
/// this is the contact this label represents
/// </param>
/// <param name="label">
/// this is the annotation for the contact
/// </param>
public TextLabel(Contact contact, Text label) {
this.detail = new Signature(contact, this);
this.type = contact.Type;
this.empty = label.empty();
this.contact = contact;
this.label = label;
}
示例10: SignatureResponse
/// <summary>
/// Create an accepting response.
/// </summary>
/// <param name="signature">Signature of CA.</param>
public SignatureResponse(Guid subjectId, Signature signature)
{
SubjectId = subjectId;
Status = SignatureResponseStatus.Accepted;
Signature = signature;
Reason = string.Empty;
}
示例11: Matches
public bool Matches(Signature sig)
{
if (ComponentTypes.Intersect(sig.ComponentTypes).Count() == sig.ComponentTypes.Count())
return true;
else
return false;
}
示例12: DoubleSpendAttack_SouldHaveValidTransferChain
public static void DoubleSpendAttack_SouldHaveValidTransferChain()
{
//Arrange
var goofy = new Goofy();
var attacker = new Signature(256);
Global.GoofyPk = goofy.PublicKey;
var trans1 = goofy.CreateCoin(attacker.PublicKey);
//Action
var sgndTrans1 = attacker.SignMessage(trans1);
var destiny1 = new Person();
var transInfo1 = new TransferInfo(sgndTrans1, destiny1.PublicKey);
var trans2 = trans1.PayTo(transInfo1);
var destiny2 = new Person();
var transInfo2 = new TransferInfo(sgndTrans1, destiny2.PublicKey);
var trans3 = trans1.PayTo(transInfo2);
//Assert
try
{
//!previousTransSignedByMe.isValidSignedMsg(previous);
if ((trans2.isValidSignedMsg(trans2[trans1]))
&& (trans3.isValidSignedMsg(trans3[trans1])))
throw new Exception("Its not allowed to double spend the same coin.");
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
示例13: ChengeTransfer_SouldNotAffectTransferChain
/// <summary>
/// Attacker change a transfer in the middle of the chain and make the chain invalid
/// </summary>
public static void ChengeTransfer_SouldNotAffectTransferChain()
{
//Arrange
var goofy = new Goofy();
var changer = new Signature(256);
var person1 = new Person();
var person2 = new Person();
var trans1 = goofy.CreateCoin(changer.PublicKey);
var changerSgndTrans = changer.SignMessage(trans1);
var transInfo = new TransferInfo(changerSgndTrans, person1.PublicKey);
var changerTransfer = trans1.PayTo(transInfo);
person1.AddTransfer(changerTransfer);
var tran3 = person1.PayTo(person2.PublicKey);
//Act
changerTransfer.Hash = null;
changerTransfer.Info.DestinyPk = null;
//Assert
try
{
person2.CheckTransfers(tran3);
}
catch
{
Console.WriteLine("Transfer chain is broked because someone change a another transfer in the middle.");
}
}
示例14: Signature
/// <summary>
/// Loads the signature.
/// </summary>
/// <param name="signature">The signature.</param>
public Signature(Signature signature)
{
if (signature == null)
throw new ArgumentNullException(@"signature");
this.token = signature.token;
}
示例15: btnCommit_Click
private void btnCommit_Click(object sender, RibbonControlEventArgs e)
{
//Get Active Project
var pj = Globals.ThisAddIn.Application.ActiveProject;
//Get Project Filename.
var projectFile = pj.FullName;
//Get Directory from File Name
var directory = Path.GetDirectoryName(projectFile);
//Create a new Git Repository
Repository.Init(directory);
//Open the git repository in a using context so its automatically disposed of.
using (var repo = new Repository(directory))
{
// Stage the file
repo.Index.Stage(projectFile);
// Create the committer's signature and commit
var author = new Signature("Richard", "@ARM", DateTime.Now);
var committer = author;
// Commit to the repository
var commit = repo.Commit("Initial commit", author, committer);
}
}