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


C# DateTime.ToBinary方法代码示例

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


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

示例1: ToBinary

        public void ToBinary()
        {
            DateTime d1 = new DateTime(2009, 1, 4);
            var a = d1.ToBinary();
            var b = DateTimeExtensions.ToBinary(d1);
            Assert.AreEqual(a, b);

            d1 = new DateTime(2008, 6, 19);
            a = d1.ToBinary();
            b = DateTimeExtensions.ToBinary(d1);
            Assert.AreEqual(a, b);

            d1 = new DateTime(2008, 6, 19, 0, 0, 0, DateTimeKind.Utc);
            a = d1.ToBinary();
            b = DateTimeExtensions.ToBinary(d1);
            Assert.AreEqual(a, b);

            d1 = DateTime.Now;
            a = d1.ToBinary();
            b = DateTimeExtensions.ToBinary(d1);
            Assert.AreEqual(a, b);

            d1 = DateTime.UtcNow;
            a = d1.ToBinary();
            b = DateTimeExtensions.ToBinary(d1);
            Assert.AreEqual(a, b);

            d1 = DateTime.Today;
            a = d1.ToBinary();
            b = DateTimeExtensions.ToBinary(d1);
            Assert.AreEqual(a, b);
        }
开发者ID:modulexcite,项目名称:LoreSoft.Shared,代码行数:32,代码来源:DateTimeTests.cs

示例2: GetFullSessionID

 /// <summary>
 /// Generates a shared session ID
 /// </summary>
 /// <param name="serverId">The server ID</param>
 /// <param name="sessionId">The session ID</param>
 /// <param name="sessionTimestamp">The session data timestamp</param>
 /// <returns>A well-formated shared session ID</returns>
 public static string GetFullSessionID(string serverId, string sessionId, DateTime sessionTimestamp)
 {
     return String.Format("{0}/{1}/{2}",
         sessionId,
         serverId,
         sessionTimestamp.ToBinary());
 }
开发者ID:rrdiaz,项目名称:MongoDBSharedSession,代码行数:14,代码来源:SharedSessionIDManager.cs

示例3: CreateDefaultPref

    public void CreateDefaultPref()
    {
        PlayerPrefs.SetInt("GamePlayCount", GamePlayCount);
        PlayerPrefs.SetInt("TotalCoins", GameGlobalVariablesManager.InitCoins);
        PlayerPrefs.SetInt("TotalCrystals", TotalCrystals);
        PlayerPrefs.SetInt("EnergyAvailable", GameGlobalVariablesManager.InitEnergyAvailable);
        PlayerPrefs.SetInt("PlayerLevel", GameGlobalVariablesManager.PlayerLevel);
        PlayerPrefs.SetInt("SwordLevel", GameGlobalVariablesManager.SwordLevel);
        PlayerPrefs.SetInt("ArmorLevel", GameGlobalVariablesManager.ArmorLevel);
        PlayerPrefs.SetInt("KnifeCount", GameGlobalVariablesManager.InitKnifeCount);
        PlayerPrefs.SetInt("BombsCount", GameGlobalVariablesManager.InitBombsCount);
        PlayerPrefs.SetInt("CycloneCount", GameGlobalVariablesManager.InitCycloneCount);
        PlayerPrefs.SetInt("LevelsCleared", GameGlobalVariablesManager.InitLevelsCleared);

        currentDate = System.DateTime.Now;
        LastSavedTime = currentDate.ToBinary().ToString();
        LastDailyBonusTime = LastSavedTime;
        LastEnergyBonusTime = LastSavedTime;
        PlayerPrefs.SetString("LastSavedTime", LastSavedTime);
        PlayerPrefs.SetString("FirstDailyBonusTime", LastSavedTime);
        PlayerPrefs.SetString("LastDailyBonusTime", LastDailyBonusTime);
        PlayerPrefs.SetString("LastEnergyBonusTime", LastEnergyBonusTime);
        PlayerPrefs.SetInt("DayCount", DayCount);

        PlayerPrefs.Save();
    }
开发者ID:Skytou,项目名称:Project-P,代码行数:26,代码来源:SavedData.cs

示例4: DeleteInactiveProfiles

        public override int DeleteInactiveProfiles(ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
        {
            var connection = GetConnection();
            var min = (double)userInactiveSinceDate.ToBinary();
            const double max = double.MaxValue;
            var key = string.Empty;
            switch (authenticationOption)
            {
                case ProfileAuthenticationOption.All:
                    key = GetProfilesKey();
                    break;
                case ProfileAuthenticationOption.Anonymous:
                    key = GetProfilesKeyAnonymous();
                    break;
                case ProfileAuthenticationOption.Authenticated:
                    key = GetProfilesKeyAuthenticated();
                    break;
            }

            var inactiveUsersTask = connection.SortedSets.Range(_redisDb, key, min, max);
            var inactiveUsers = connection.Wait(inactiveUsersTask);
            var count = 0;

            Parallel.ForEach(inactiveUsers, result =>
            {
                var profileResult = new string(Encoding.Unicode.GetChars(result.Key));
                var parts = profileResult.Split(':');
                var username = parts[0];
                var isAuthenticated = Convert.ToBoolean(parts[1]);
                if (DeleteProfile(username, isAuthenticated))
                    Interlocked.Increment(ref count);
            });

            return count;
        }
开发者ID:kylesonaty,项目名称:AspNetRedisProviders,代码行数:35,代码来源:RedisProfileProvider.cs

示例5: Generate

 public static VerificationToken Generate(DateTime timestamp)
 {
     var data = new byte[DataLength];
     new RNGCryptoServiceProvider().GetBytes(data);
     Array.Copy(BitConverter.GetBytes(timestamp.ToBinary()), data, sizeof(long));
     return new VerificationToken(data);
 }
开发者ID:Sinbadsoft,项目名称:Sinbadsoft.Lib.UserManagement,代码行数:7,代码来源:VerificationToken.cs

示例6: TimeSpanDefinition

        /// <summary>
        /// Creates a new timespan definition
        /// </summary>
        /// <param name="myFrom">The point in time where the timespan begins</param>
        /// <param name="myTo">The point in time where the timespan ends</param>
        public TimeSpanDefinition(DateTime myFrom, DateTime myTo)
        {
            From = myFrom;
            _fromConverted = From.ToBinary();

            To = myTo;
            _toConverted = To.ToBinary();
        }
开发者ID:anukat2015,项目名称:sones,代码行数:13,代码来源:TimeSpanDefinition.cs

示例7: LogPath

        static string LogPath(string appPath, DateTime now)
        {
            if (string.IsNullOrEmpty(appPath)) throw new ArgumentNullException("appPath");

            var logPath = Path.GetFullPath(Path.Combine(appPath, @"..\Private\Logs\Exceptions\", now.ToString("yy-MM-dd")));
            Directory.CreateDirectory(logPath);
            return Path.Combine(logPath, now.ToBinary() + ".xml");
        }
开发者ID:maxime-paquatte,项目名称:MultiRando,代码行数:8,代码来源:ExceptionLoggerService.cs

示例8:

 void IArchByteBoxWriter.wDateTime(DateTime DT, bool isBinary)
 {
     byte[] @Byte = null;
     if (isBinary)
         @Byte = BitConverter.GetBytes(DT.ToBinary());
     else
         @Byte = BitConverter.GetBytes(DT.Ticks);
     nMStream.Write(@Byte, 0, @Byte.Length);
 }
开发者ID:AnotherAltr,项目名称:Rc.Core,代码行数:9,代码来源:ArchMBWriter.cs

示例9: CheckThrowDatePriorToLast

		protected void CheckThrowDatePriorToLast(DateTime appending) {
			if (this.DateTimes.Count == 0) return;
			DateTime lastDateTime = this.LastStaticDate;
			if (lastDateTime.ToBinary() < appending.ToBinary()) return;

			string msg = "#3 Can not append time[" + appending + "] should be > this.Date["
				+ (this.DateTimes.Count - 1) + "]=[" + lastDateTime + "]";
			throw new Exception(msg);
		}
开发者ID:sanyaade-fintechnology,项目名称:SquareOne,代码行数:9,代码来源:DataSeriesTimeBased.cs

示例10: MakeETag

        public static string MakeETag(string UID, DateTime pLastModified)
        {
            byte[] hash = md5.ComputeHash(Encoding.ASCII.GetBytes(UID + "/" + pLastModified.ToBinary()));

            StringBuilder pendingETag = new StringBuilder();
            for (int i = 0; i < hash.Length; ++i)
                pendingETag.Append(hash[i].ToString("X2"));

            return "\"" + pendingETag.ToString() + "\"";
        }
开发者ID:danm36,项目名称:Bismuth,代码行数:10,代码来源:HTTPResponse.cs

示例11: Write

 public static int Write(BinaryWriter writer, DateTime dateTime, int tick, string component, string thread, string message)
 {
     writer.Write(dateTime.ToBinary());
     writer.Write(tick);
     writer.Write(component);
     writer.Write(thread);
     writer.Write(message);
     writer.Flush();
     return (int)writer.BaseStream.Position;
 }
开发者ID:Fulborg,项目名称:dwarrowdelf,代码行数:10,代码来源:MMLog.cs

示例12: Write

        public static int Write(BinaryWriter writer, DateTime dateTime, TraceEventType eventType, int tick,
			LogComponent component, string thread, string header, string message)
        {
            writer.Write(dateTime.ToBinary());
            writer.Write((int)eventType);
            writer.Write(tick);
            writer.Write((byte)component);
            writer.Write(thread);
            writer.Write(header);
            writer.Write(message);
            writer.Flush();
            return (int)writer.BaseStream.Position;
        }
开发者ID:tomba,项目名称:dwarrowdelf,代码行数:13,代码来源:MMLog.cs

示例13: GetHistoricalPathRoots

        public DataAddress[] GetHistoricalPathRoots(IServiceAddress root, string pathName, DateTime time, int maxCount)
        {
            InspectNetwork();

            // Check machine is in the schema,
            MachineProfile machine = CheckMachineInNetwork(root);
            // Check it's root,
            if (!machine.IsRoot)
                throw new NetworkAdminException("Machine '" + root + "' is not a root");

            // Perform the command,
            RequestMessage request = new RequestMessage("getPathHistorical");
            request.Arguments.Add(pathName);
            request.Arguments.Add(time.ToBinary());
            request.Arguments.Add(time.ToBinary());

            ResponseMessage m = (ResponseMessage) Command(root, ServiceType.Root, request);
            if (m.HasError)
                throw new NetworkAdminException(m.ErrorMessage);

            // Return the data address array,
            return (DataAddress[])m.ReturnValue;
        }
开发者ID:yuexiaoyun,项目名称:cloudb,代码行数:23,代码来源:NetworkProfile_Root.cs

示例14: Send

 public bool Send(int udpPort, string strType, string strSend, DateTime timeStamp)
 {
   if (socket == null)
     socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
   try
   {
     byte[] sendbuf = Encoding.UTF8.GetBytes(string.Format("{0}|{1}|{2}~", strType, strSend, timeStamp.ToBinary()));
     IPEndPoint endPoint = new IPEndPoint(hostIP, udpPort);
     socket.SendTo(sendbuf, endPoint);
     return true;
   }
   catch (SocketException se)
   {
     Log.Info("UDPHelper: Send port {0}: {1} - {2}", udpPort, se.ErrorCode, se.Message);
     return false;
   }
 }
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:17,代码来源:UdpHelper.cs

示例15: Log

 /// <summary>
 /// Write message to a file
 /// </summary>
 /// <param name="text"></param>
 /// <param name="InputStyle"></param>
 /// <param name="owner"></param>
 /// <param name="directory"></param>
 /// <param name="time"></param>
 public static void Log(string text, Client.ContentLine.MessageStyle InputStyle, Graphics.Window owner, string directory, DateTime time)
 {
     try
     {
         if (!Directory.Exists(Configuration.Logs.logs_dir))
         {
             Directory.CreateDirectory(Configuration.Logs.logs_dir);
         }
         if (!Directory.Exists(Configuration.Logs.logs_dir + Path.DirectorySeparatorChar + owner._Network.ServerName))
         {
             System.IO.Directory.CreateDirectory(Configuration.Logs.logs_dir + Path.DirectorySeparatorChar + owner._Network.ServerName);
         }
         if (!Directory.Exists(Configuration.Logs.logs_dir + Path.DirectorySeparatorChar + owner._Network.ServerName + Path.DirectorySeparatorChar + validpath(owner, directory)))
         {
             Directory.CreateDirectory(Configuration.Logs.logs_dir + Path.DirectorySeparatorChar + owner._Network.ServerName + Path.DirectorySeparatorChar + validpath(owner, directory));
         }
         if (Configuration.Logs.logs_txt)
         {
             string stamp = "";
             if (Configuration.Scrollback.chat_timestamp)
             {
                 stamp = Configuration.Scrollback.format_date.Replace("$1", time.ToString(Configuration.Scrollback.timestamp_mask));
             }
             Core.IO.InsertText(stamp + Protocol.DecodeText(Core.RemoveSpecial(text)) + "\n", _getFileName(owner, directory, time) + ".txt");
         }
         if (Configuration.Logs.logs_html)
         {
             string stamp = "";
             if (Configuration.Scrollback.chat_timestamp)
             {
                 stamp = Configuration.Scrollback.format_date.Replace("$1", time.ToString(Configuration.Scrollback.timestamp_mask));
             }
             Core.IO.InsertText("<font size=\"" + Configuration.CurrentSkin.FontSize.ToString() + "px\" face=" + Configuration.CurrentSkin.LocalFont + ">" + System.Web.HttpUtility.HtmlEncode(stamp + Protocol.DecodeText(Core.RemoveSpecial(text))) + "</font><br>\n", _getFileName(owner, directory, time) + ".html");
         }
         if (Configuration.Logs.logs_xml)
         {
             Core.IO.InsertText("<line time=\"" + time.ToBinary().ToString() + "\" style=\"" + InputStyle.ToString() + "\">" + System.Web.HttpUtility.HtmlEncode(Protocol.DecodeText(Core.RemoveSpecial(text))) + "</line>\n", _getFileName(owner, directory, time) + ".xml");
         }
     }
     catch (Exception fail)
     {
         Core.handleException(fail);
     }
 }
开发者ID:JGunning,项目名称:OpenAIM,代码行数:52,代码来源:LineLogs.cs


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