本文整理汇总了C#中Reference类的典型用法代码示例。如果您正苦于以下问题:C# Reference类的具体用法?C# Reference怎么用?C# Reference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Reference类属于命名空间,在下文中一共展示了Reference类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: EncodeCMS
public override object EncodeCMS(X509Certificate2 certificate, string xmlFilePath)
{
XmlDocument Document = new XmlDocument();
Document.PreserveWhitespace = true;
XmlTextReader XmlFile = new XmlTextReader(xmlFilePath);
Document.Load(XmlFile);
XmlFile.Close();
XmlNodeList SignaturesList = Document.GetElementsByTagName("Signature");
// Remove existing signatures, this is not a countersigning.
for (int i = 0; i < SignaturesList.Count; i++)
{
SignaturesList[i].ParentNode.RemoveChild(SignaturesList[i]);
i--;
}
SignedXml SignedXml = new SignedXml(Document);
SignedXml.SigningKey = certificate.PrivateKey;
Reference Reference = new Reference();
Reference.Uri = "";
XmlDsigEnvelopedSignatureTransform EnvelopedSignatureTransform = new XmlDsigEnvelopedSignatureTransform();
Reference.AddTransform(EnvelopedSignatureTransform);
SignedXml.AddReference(Reference);
KeyInfo Key = new KeyInfo();
Key.AddClause(new KeyInfoX509Data(certificate));
SignedXml.KeyInfo = Key;
SignedXml.ComputeSignature();
// Get the XML representation of the signature and save
// it to an XmlElement object.
XmlElement XmlDigitalSignature = SignedXml.GetXml();
return XmlDigitalSignature;
}
开发者ID:usnistgov,项目名称:DT4SM,代码行数:32,代码来源:XML4PLOT.cs
示例2: SignXml
// Sign an XML file.
// This document cannot be verified unless the verifying
// code has the key with which it was signed.
public static void SignXml(XmlDocument xmlDoc, RSA Key)
{
// Check arguments.
if (xmlDoc == null)
throw new ArgumentException("xmlDoc");
if (Key == null)
throw new ArgumentException("Key");
// Create a SignedXml object.
SignedXml signedXml = new SignedXml(xmlDoc);
// Add the key to the SignedXml document.
signedXml.SigningKey = Key;
// Create a reference to be signed.
Reference reference = new Reference();
reference.Uri = "";
// Add an enveloped transformation to the reference.
XmlDsigEnvelopedSignatureTransform env = new XmlDsigEnvelopedSignatureTransform();
reference.AddTransform(env);
// Add the reference to the SignedXml object.
signedXml.AddReference(reference);
// Compute the signature.
signedXml.ComputeSignature();
// Get the XML representation of the signature and save
// it to an XmlElement object.
XmlElement xmlDigitalSignature = signedXml.GetXml();
// Append the element to the XML document.
xmlDoc.DocumentElement.AppendChild(xmlDoc.ImportNode(xmlDigitalSignature, true));
}
开发者ID:duyisu,项目名称:MissionPlanner,代码行数:38,代码来源:SignXML.cs
示例3: SignXml
private static string SignXml(XmlDocument unsignedXml,
AsymmetricAlgorithm key)
{
if (unsignedXml.DocumentElement == null)
{
throw new ArgumentNullException("unsignedXml");
}
// Create a reference to be signed. Blank == Everything
var emptyReference = new Reference { Uri = "" };
// Add an enveloped transformation to the reference.
var envelope = new XmlDsigEnvelopedSignatureTransform();
emptyReference.AddTransform(envelope);
var signedXml = new SignedXml(unsignedXml) { SigningKey = key };
signedXml.AddReference(emptyReference);
signedXml.ComputeSignature();
var digitalSignature = signedXml.GetXml();
unsignedXml.DocumentElement.AppendChild(
unsignedXml.ImportNode(digitalSignature, true));
var signedXmlOut = new StringBuilder();
using (var swOut = new StringWriter(signedXmlOut))
{
unsignedXml.Save(swOut);
}
return signedXmlOut.ToString();
}
开发者ID:huoxudong125,项目名称:HQF.Tutorial.Encryption,代码行数:32,代码来源:SignAndVerify.cs
示例4: Sign
public static string Sign(string xml, X509Certificate2 certificate)
{
if (xml == null) throw new ArgumentNullException("xml");
if (certificate == null) throw new ArgumentNullException("certificate");
if (!certificate.HasPrivateKey) throw new ArgumentException("certificate", "Certificate should have a private key");
XmlDocument doc = new XmlDocument();
doc.PreserveWhitespace = true;
doc.LoadXml(xml);
SignedXml signedXml = new SignedXml(doc);
signedXml.SigningKey = certificate.PrivateKey;
// Attach certificate KeyInfo
KeyInfoX509Data keyInfoData = new KeyInfoX509Data(certificate);
KeyInfo keyInfo = new KeyInfo();
keyInfo.AddClause(keyInfoData);
signedXml.KeyInfo = keyInfo;
// Attach transforms
var reference = new Reference("");
reference.AddTransform(new XmlDsigEnvelopedSignatureTransform(includeComments: false));
reference.AddTransform(new XmlDsigExcC14NTransform(includeComments: false));
signedXml.AddReference(reference);
// Compute signature
signedXml.ComputeSignature();
var signatureElement = signedXml.GetXml();
// Add signature to bundle
doc.DocumentElement.AppendChild(doc.ImportNode(signatureElement, true));
return doc.OuterXml;
}
开发者ID:raysearchlabs,项目名称:spark,代码行数:35,代码来源:XmlSignatureHelper.cs
示例5: Channel
internal Channel(DiscordClient client, string id, string serverId, string recipientId)
: base(client, id)
{
_server = new Reference<Server>(serverId,
x => _client.Servers[x],
x => x.AddChannel(this),
x => x.RemoveChannel(this));
_recipient = new Reference<User>(recipientId,
x => _client.Users.GetOrAdd(x, _server.Id),
x =>
{
Name = "@" + x.Name;
if (_server.Id == null)
x.GlobalUser.PrivateChannel = this;
},
x =>
{
if (_server.Id == null)
x.GlobalUser.PrivateChannel = null;
});
_permissionOverwrites = _initialPermissionsOverwrites;
_areMembersStale = true;
//Local Cache
_messages = new ConcurrentDictionary<string, Message>();
}
开发者ID:hermanocabral,项目名称:Discord.Net,代码行数:26,代码来源:Channel.cs
示例6: GetCallbackMethodInvocation
public MethodInvocationExpression GetCallbackMethodInvocation(AbstractTypeEmitter invocation, Expression[] args,
Reference targetField,
MethodEmitter invokeMethodOnTarget)
{
var @delegate = GetDelegate(invocation, invokeMethodOnTarget);
return new MethodInvocationExpression(@delegate, GetCallbackMethod(), args);
}
开发者ID:jeremymeng,项目名称:Core,代码行数:7,代码来源:InvocationWithGenericDelegateContributor.cs
示例7: ConnectionRequestHandler
public ConnectionRequestHandler(Reference @ref, Ice.ConnectionI connection, bool compress)
{
_reference = @ref;
_response = _reference.getMode() == Reference.Mode.ModeTwoway;
_connection = connection;
_compress = compress;
}
开发者ID:Crysty-Yui,项目名称:ice,代码行数:7,代码来源:ConnectionRequestHandler.cs
示例8: Immediate
/// <summary>
/// Initializes a new instance of the <see cref="Immediate"/> class.
/// </summary>
/// <param name="reference">A reference.</param>
public Immediate(Reference reference)
: this(reference, DataSize.None)
{
#region Contract
Contract.Requires<ArgumentNullException>(reference != null);
#endregion
}
开发者ID:Konctantin,项目名称:CSharpAssembler,代码行数:11,代码来源:Immediate.cs
示例9: ListsStorageActions
public ListsStorageActions(TableStorage tableStorage, IUuidGenerator generator, Reference<SnapshotReader> snapshot, Reference<WriteBatch> writeBatch, IBufferPool bufferPool)
: base(snapshot, bufferPool)
{
this.tableStorage = tableStorage;
this.generator = generator;
this.writeBatch = writeBatch;
}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:7,代码来源:ListsStorageActions.cs
示例10: AppendSignatureToXMLDocument
/// <summary>
/// Use an X509 certificate to append a computed signature to an XML serialized Response
/// </summary>
/// <param name="XMLSerializedSAMLResponse"></param>
/// <param name="ReferenceURI">Assertion ID from SAML Response</param>
/// <param name="SigningCert">X509 Certificate for signing</param>
/// <remarks>Referenced this article:
/// http://www.west-wind.com/weblog/posts/2008/Feb/23/Digitally-Signing-an-XML-Document-and-Verifying-the-Signature
/// </remarks>
public static void AppendSignatureToXMLDocument(ref XmlDocument XMLSerializedSAMLResponse, String ReferenceURI, X509Certificate2 SigningCert)
{
XmlNamespaceManager ns = new XmlNamespaceManager(XMLSerializedSAMLResponse.NameTable);
ns.AddNamespace("saml", "urn:oasis:names:tc:SAML:2.0:assertion");
XmlElement xeAssertion = XMLSerializedSAMLResponse.DocumentElement.SelectSingleNode("saml:Assertion", ns) as XmlElement;
//SignedXml signedXML = new SignedXml(XMLSerializedSAMLResponse);
SignedXml signedXML = new SignedXml(xeAssertion);
signedXML.SigningKey = SigningCert.PrivateKey;
signedXML.SignedInfo.CanonicalizationMethod = SignedXml.XmlDsigExcC14NTransformUrl;
Reference reference = new Reference();
reference.Uri = ReferenceURI;
reference.AddTransform(new XmlDsigEnvelopedSignatureTransform());
reference.AddTransform(new XmlDsigExcC14NTransform());
signedXML.AddReference(reference);
signedXML.ComputeSignature();
XmlElement signature = signedXML.GetXml();
XmlElement xeResponse = XMLSerializedSAMLResponse.DocumentElement;
xeResponse.AppendChild(signature);
}
开发者ID:DodgeDerek,项目名称:saml-http-post-reference,代码行数:34,代码来源:CertificateUtility.cs
示例11: Post
public Post(string id, Reference from, DateTime createdTime, DateTime updatedTime)
{
this.ID = id;
this.From = from;
this.CreatedTime = createdTime;
this.UpdatedTime = updatedTime;
}
开发者ID:kisspa,项目名称:spring-net-social-facebook,代码行数:7,代码来源:Post.cs
示例12: LowLevelRemoteStreamAsync
public void LowLevelRemoteStreamAsync()
{
using (var store = NewRemoteDocumentStore())
{
using (var session = store.OpenSession())
{
for (int i = 0; i < 1500; i++)
{
session.Store(new User());
}
session.SaveChanges();
}
WaitForIndexing(store);
var queryHeaderInfo = new Reference<QueryHeaderInformation>();
var enumerator =
store.AsyncDatabaseCommands.StreamQueryAsync(new RavenDocumentsByEntityName().IndexName, new IndexQuery
{
Query = "",
SortedFields = new[] {new SortedField(Constants.DocumentIdFieldName),}
}, queryHeaderInfo).Result;
Assert.Equal(1500, queryHeaderInfo.Value.TotalResults);
int count = 0;
while (enumerator.MoveNextAsync().Result)
{
count++;
}
Assert.Equal(1500, count);
}
}
开发者ID:j2jensen,项目名称:ravendb,代码行数:34,代码来源:RavenDB937.cs
示例13: StartPage
public StartPage()
{
try
{
InitializeComponent();
_dbConnectionString = ConfigurationSettings.AppSettings["DBConStr"];
DataAccess.conStr = _dbConnectionString;
MainMenu _mainMenu = new MainMenu(_dbConnectionString);
_mainFrame.Navigate(_mainMenu);
dataAccess = new DataAccess();
lines = dataAccess.getLines();
lineQ = new Queue<int>();
foreach (line l in lines)
lineQ.Enqueue(l.ID);
reference = new Reference();
andonManager = new AndonManager(AndonManager.MODE.SLAVE);
andonManager.andonAlertEvent += new EventHandler<AndonAlertEventArgs>(andonManager_andonAlertEvent);
andonManager.start();
}
catch( Exception e)
{
tbMsg.Text+= e.Message;
}
}
开发者ID:subhra209,项目名称:SEPFC_OUTPUT_TRACKING,代码行数:33,代码来源:StartPage.xaml.cs
示例14: AddDependency
internal void AddDependency(Reference dependency)
{
if (!this.dependencies.Contains(dependency))
{
this.dependencies.Add(dependency);
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:Reference.cs
示例15: btnSaveRef_Click
protected void btnSaveRef_Click(object sender, EventArgs e)
{
Reference NewRef = new Reference();
if (getCurrentReference > 0)
{
NewRef.LoadByPrimaryKey(getCurrentReference);
}
else
{
NewRef.AddNew();
}
if (CollImgFileUpload.HasFile)
{
Bitmap UpImg = (Bitmap)Bitmap.FromStream(CollImgFileUpload.PostedFile.InputStream);
string path = "UploadedFiles/References/" + DateTime.Now.ToString("ddMMyyyyhhmmss") + CollImgFileUpload.FileName;
UpImg.Save(MapPath(path), System.Drawing.Imaging.ImageFormat.Png);
NewRef.MainImagePath = path;
}
NewRef.IsActive = chkActive.Checked;
NewRef.NameAr = txtRefernceName.Text;
NewRef.DescriptionAr = txtDescription.Text;
NewRef.DescriptionEn = txtDescription.Text;
NewRef.Save();
Response.Redirect("ManageReference.aspx?refid=" + NewRef.ReferenceID.ToString());
}
开发者ID:menasbeshay,项目名称:ivalley-svn,代码行数:28,代码来源:ManageReference.aspx.cs
示例16: Whitespace
/// <summary>
/// Initializes a new instance of the Whitespace class.
/// </summary>
/// <param name="text">The whitespace text.</param>
/// <param name="location">The location of the whitespace in the code.</param>
/// <param name="parent">The parent code unit.</param>
/// <param name="generated">True if the token is inside of a block of generated code.</param>
internal Whitespace(
string text,
CodeLocation location,
Reference<ICodePart> parent,
bool generated)
: base(text,
CsTokenType.WhiteSpace,
CsTokenClass.Whitespace,
location,
parent,
generated)
{
Param.AssertValidString(text, "text");
Param.AssertNotNull(location, "location");
Param.AssertNotNull(parent, "parent");
Param.Ignore(generated);
for (int i = 0; i < text.Length; ++i)
{
if (text[i] == ' ')
{
++this.spaceCount;
}
else if (text[i] == '\t')
{
++this.tabCount;
}
}
}
开发者ID:katerina-marchenkova,项目名称:my,代码行数:36,代码来源:Whitespace.cs
示例17: add_reference
public static void add_reference(Dictionary<string, Reference> refmap, Reference refer)
{
if (refmap.ContainsKey(refer.Label))
return;
refmap.Add(refer.Label, refer);
}
开发者ID:boombuler,项目名称:CommonMark.NET,代码行数:7,代码来源:InlineMethods.cs
示例18: Main
static void Main(string[] args) {
if (args.Length != 4) {
Console.WriteLine("Usage: cra.exe cert-file cert-password input-path output-path");
return;
}
String certFile = args[0];
String password = args[1];
String input = args[2];
String output = args[3];
X509Certificate2 cert = new X509Certificate2(certFile, password, X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet);
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(input);
var XmlToSign = new XmlDocument();
XmlToSign.LoadXml(xmlDoc.DocumentElement["Body"].OuterXml);
SignedXml signedXml = new SignedXml(XmlToSign);
signedXml.SigningKey = cert.PrivateKey;
Reference reference = new Reference();
reference.Uri = "";
XmlDsigEnvelopedSignatureTransform env = new XmlDsigEnvelopedSignatureTransform();
reference.AddTransform(env);
signedXml.AddReference(reference);
signedXml.ComputeSignature();
XmlElement xmlDigitalSignature = signedXml.GetXml();
xmlDoc.DocumentElement["Body"].AppendChild(xmlDoc.ImportNode(xmlDigitalSignature, true));
xmlDoc.Save(output);
}
开发者ID:dimakura,项目名称:cra.ge,代码行数:34,代码来源:cra.cs
示例19: AuthenticodeSignLicenseDom
private static void AuthenticodeSignLicenseDom(XmlDocument licenseDom, System.Deployment.Internal.CodeSigning.CmiManifestSigner signer, string timeStampUrl)
{
if (signer.Certificate.PublicKey.Key.GetType() != typeof(RSACryptoServiceProvider))
{
throw new NotSupportedException();
}
System.Deployment.Internal.CodeSigning.ManifestSignedXml xml = new System.Deployment.Internal.CodeSigning.ManifestSignedXml(licenseDom) {
SigningKey = signer.Certificate.PrivateKey
};
xml.SignedInfo.CanonicalizationMethod = "http://www.w3.org/2001/10/xml-exc-c14n#";
xml.KeyInfo.AddClause(new RSAKeyValue(signer.Certificate.PublicKey.Key as RSA));
xml.KeyInfo.AddClause(new KeyInfoX509Data(signer.Certificate, signer.IncludeOption));
Reference reference = new Reference {
Uri = ""
};
reference.AddTransform(new XmlDsigEnvelopedSignatureTransform());
reference.AddTransform(new XmlDsigExcC14NTransform());
xml.AddReference(reference);
xml.ComputeSignature();
XmlElement node = xml.GetXml();
node.SetAttribute("Id", "AuthenticodeSignature");
XmlNamespaceManager nsmgr = new XmlNamespaceManager(licenseDom.NameTable);
nsmgr.AddNamespace("r", "urn:mpeg:mpeg21:2003:01-REL-R-NS");
(licenseDom.SelectSingleNode("r:license/r:issuer", nsmgr) as XmlElement).AppendChild(licenseDom.ImportNode(node, true));
if ((timeStampUrl != null) && (timeStampUrl.Length != 0))
{
TimestampSignedLicenseDom(licenseDom, timeStampUrl);
}
licenseDom.DocumentElement.ParentNode.InnerXml = "<msrel:RelData xmlns:msrel=\"http://schemas.microsoft.com/windows/rel/2005/reldata\">" + licenseDom.OuterXml + "</msrel:RelData>";
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:SignedCmiManifest.cs
示例20: ImplementInvokeMethodOnTarget
protected override void ImplementInvokeMethodOnTarget(AbstractTypeEmitter invocation, ParameterInfo[] parameters, MethodEmitter invokeMethodOnTarget, Reference targetField)
{
invokeMethodOnTarget.CodeBuilder.AddStatement(
new ExpressionStatement(
new MethodInvocationExpression(SelfReference.Self, InvocationMethods.EnsureValidTarget)));
base.ImplementInvokeMethodOnTarget(invocation, parameters, invokeMethodOnTarget, targetField);
}
开发者ID:vbedegi,项目名称:Castle.Core,代码行数:7,代码来源:CompositionInvocationTypeGenerator.cs
注:本文中的Reference类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论