当前位置: 首页>>代码示例>>C#>>正文


C# Reference类代码示例

本文整理汇总了C#中Reference的典型用法代码示例。如果您正苦于以下问题:C# Reference类的具体用法?C# Reference怎么用?C# Reference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Reference类属于命名空间,在下文中一共展示了Reference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的Reference类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。