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


C# DateTime.ToFileTime方法代码示例

本文整理汇总了C#中DateTime.ToFileTime方法的典型用法代码示例。如果您正苦于以下问题:C# DateTime.ToFileTime方法的具体用法?C# DateTime.ToFileTime怎么用?C# DateTime.ToFileTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DateTime的用法示例。


在下文中一共展示了DateTime.ToFileTime方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildChain

        //
        // Builds a certificate chain.
        //

        internal static unsafe int BuildChain (IntPtr hChainEngine,
                                               SafeCertContextHandle pCertContext,
                                               X509Certificate2Collection extraStore, 
                                               OidCollection applicationPolicy,
                                               OidCollection certificatePolicy,
                                               X509RevocationMode revocationMode,
                                               X509RevocationFlag revocationFlag,
                                               DateTime verificationTime,
                                               TimeSpan timeout,
                                               ref SafeCertChainHandle ppChainContext) {
            if (pCertContext == null || pCertContext.IsInvalid)
                throw new ArgumentException(SR.GetString(SR.Cryptography_InvalidContextHandle), "pCertContext");

            SafeCertStoreHandle hCertStore = SafeCertStoreHandle.InvalidHandle;
            if (extraStore != null && extraStore.Count > 0)
                hCertStore = X509Utils.ExportToMemoryStore(extraStore);

            CAPI.CERT_CHAIN_PARA ChainPara = new CAPI.CERT_CHAIN_PARA();

            // Initialize the structure size.
            ChainPara.cbSize = (uint) Marshal.SizeOf(ChainPara);

            SafeLocalAllocHandle applicationPolicyHandle = SafeLocalAllocHandle.InvalidHandle;
            SafeLocalAllocHandle certificatePolicyHandle = SafeLocalAllocHandle.InvalidHandle;
            try {
                // Application policy
                if (applicationPolicy != null && applicationPolicy.Count > 0) {
                    ChainPara.RequestedUsage.dwType = CAPI.USAGE_MATCH_TYPE_AND;
                    ChainPara.RequestedUsage.Usage.cUsageIdentifier = (uint) applicationPolicy.Count;
                    applicationPolicyHandle = X509Utils.CopyOidsToUnmanagedMemory(applicationPolicy);
                    ChainPara.RequestedUsage.Usage.rgpszUsageIdentifier = applicationPolicyHandle.DangerousGetHandle();
                }

                // Certificate policy
                if (certificatePolicy != null && certificatePolicy.Count > 0) {
                    ChainPara.RequestedIssuancePolicy.dwType = CAPI.USAGE_MATCH_TYPE_AND;
                    ChainPara.RequestedIssuancePolicy.Usage.cUsageIdentifier = (uint) certificatePolicy.Count;
                    certificatePolicyHandle = X509Utils.CopyOidsToUnmanagedMemory(certificatePolicy);
                    ChainPara.RequestedIssuancePolicy.Usage.rgpszUsageIdentifier = certificatePolicyHandle.DangerousGetHandle();
                }

                ChainPara.dwUrlRetrievalTimeout = (uint) Math.Floor(timeout.TotalMilliseconds);

                _FILETIME ft = new _FILETIME();
                *((long*) &ft) = verificationTime.ToFileTime();

                uint flags = X509Utils.MapRevocationFlags(revocationMode, revocationFlag);

                // Build the chain.
                if (!CAPI.CertGetCertificateChain(hChainEngine,
                                                  pCertContext,
                                                  ref ft,
                                                  hCertStore,
                                                  ref ChainPara,
                                                  flags,
                                                  IntPtr.Zero,
                                                  ref ppChainContext))
                    return Marshal.GetHRForLastWin32Error();
            }
            finally {
                applicationPolicyHandle.Dispose();
                certificatePolicyHandle.Dispose();
            }

            return CAPI.S_OK;
        }
开发者ID:stormleoxia,项目名称:referencesource,代码行数:70,代码来源:x509chain.cs

示例2: UpdateIdleServicePoint

        //
        // UpdateIdleServicePoint -
        //
        // Perform an update if the servicePoint changed its timeout
        //  value, most likly by an external call.  But we need to
        //  do this, otherwise the servicePoint may sit a while,
        //  before we recognize the change
        //

        internal static void UpdateIdleServicePoint(DateTime oldExpiresAt, ServicePoint servicePoint) {
            GlobalLog.Enter("ServicePointManager::UpdateIdleServicePoint() servicePoint#" + ValidationHelper.HashString(servicePoint) + " ExpiresAt:" + (servicePoint.ExpiresAt.ToFileTime()).ToString() + " oldExpiresAt:" + (oldExpiresAt.ToFileTime()).ToString());
            lock (s_StrongReferenceServicePointList) {

                try {
                    // may have already been deleted by scavenge

                    // if we for some reason changed ourselves,
                    // so that we don't expire early as planed,
                    // readd ourselves, so that we expire later
                    //

                    s_StrongReferenceServicePointList.Remove(oldExpiresAt);
                    s_StrongReferenceServicePointList.Add(servicePoint.ExpiresAt, servicePoint);
                }
                catch (Exception exception) {
                    GlobalLog.Print("ServicePointManager::UpdateIdleServicePoint() caught exception accessing s_StrongReferenceServicePointList:" + exception.ToString());
                }
            }
            GlobalLog.Leave("ServicePointManager::UpdateIdleServicePoint");
        }
开发者ID:ArildF,项目名称:masters,代码行数:30,代码来源:servicepointmanager.cs

示例3: BuildChain

        static unsafe void BuildChain(IntPtr hChainEngine,
                                     IntPtr pCertContext,
                                     X509Certificate2Collection extraStore,
                                     OidCollection applicationPolicy,
                                     OidCollection certificatePolicy,
                                     X509RevocationMode revocationMode,
                                     X509RevocationFlag revocationFlag,
                                     DateTime verificationTime,
                                     TimeSpan timeout,
                                     out SafeCertChainHandle ppChainContext)
        {
            SafeCertStoreHandle hCertStore = ExportToMemoryStore(extraStore, pCertContext);

            CAPI.CERT_CHAIN_PARA ChainPara = new CAPI.CERT_CHAIN_PARA();
            ChainPara.cbSize = (uint)Marshal.SizeOf(typeof(CAPI.CERT_CHAIN_PARA));

            // Application policy
            SafeHGlobalHandle applicationPolicyHandle = SafeHGlobalHandle.InvalidHandle;
            SafeHGlobalHandle certificatePolicyHandle = SafeHGlobalHandle.InvalidHandle;
            try
            {
                if (applicationPolicy != null && applicationPolicy.Count > 0)
                {
                    ChainPara.RequestedUsage.dwType = CAPI.USAGE_MATCH_TYPE_AND;
                    ChainPara.RequestedUsage.Usage.cUsageIdentifier = (uint)applicationPolicy.Count;
                    applicationPolicyHandle = CopyOidsToUnmanagedMemory(applicationPolicy);
                    ChainPara.RequestedUsage.Usage.rgpszUsageIdentifier = applicationPolicyHandle.DangerousGetHandle();
                }

                // Certificate policy
                if (certificatePolicy != null && certificatePolicy.Count > 0)
                {
                    ChainPara.RequestedIssuancePolicy.dwType = CAPI.USAGE_MATCH_TYPE_AND;
                    ChainPara.RequestedIssuancePolicy.Usage.cUsageIdentifier = (uint)certificatePolicy.Count;
                    certificatePolicyHandle = CopyOidsToUnmanagedMemory(certificatePolicy);
                    ChainPara.RequestedIssuancePolicy.Usage.rgpszUsageIdentifier = certificatePolicyHandle.DangerousGetHandle();
                }

                ChainPara.dwUrlRetrievalTimeout = (uint)timeout.Milliseconds;

                FILETIME ft = new FILETIME();
                *((long*)&ft) = verificationTime.ToFileTime();

                uint flags = MapRevocationFlags(revocationMode, revocationFlag);

                // Build the chain.
                if (!CAPI.CertGetCertificateChain(hChainEngine,
                                                  pCertContext,
                                                  ref ft,
                                                  hCertStore,
                                                  ref ChainPara,
                                                  flags,
                                                  IntPtr.Zero,
                                                  out ppChainContext))
                {
                    int error = Marshal.GetLastWin32Error();
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CryptographicException(error));
                }
            }
            finally
            {
                if (applicationPolicyHandle != null)
                    applicationPolicyHandle.Dispose();
                if (certificatePolicyHandle != null)
                    certificatePolicyHandle.Dispose();
                hCertStore.Close();
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:68,代码来源:X509CertificateChain.cs

示例4: WriteFileTime

 /// <summary>
 /// Writes a File Time TimeStamp
 /// </summary>
 /// <param name="xIn"></param>
 public void WriteFileTime(DateTime xIn)
 {
     try { Write(xIn.ToFileTime()); }
     catch (Exception x) { throw x; }
 }
开发者ID:VictorOverX,项目名称:X360,代码行数:9,代码来源:DJsIO.cs

示例5: WriteFileTime

 /// <summary>
 /// Writes a File Time TimeStamp
 /// </summary>
 /// <param name="xIn"></param>
 public void WriteFileTime(DateTime xIn)
 {
     Write(xIn.ToFileTime());
 }
开发者ID:BGCX261,项目名称:ziggy-pro-editor-svn-to-git,代码行数:8,代码来源:oldDJsIO.cs


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