public void CompareTo_Object_ShouldMimicSystem()
        {
            var lowerTicks = 1;
            var sameTicks = 2;
            var higherTicks = 3;

            var sameSystemDate = new System.DateTime(sameTicks);
            var expectedHigher = sameSystemDate.CompareTo(new System.DateTime(lowerTicks) as object);
            var expectedSame = sameSystemDate.CompareTo(new System.DateTime(sameTicks) as object);
            var expectedLower = sameSystemDate.CompareTo(new System.DateTime(higherTicks) as object);
            var expectedForNull = sameSystemDate.CompareTo(null as object);
            expectedLower.Should().Be(-1, "Sanity check we know the result");
            expectedSame.Should().Be(0, "Sanity check we know the result");
            expectedHigher.Should().Be(1, "Sanity check we know the result");
            expectedForNull.Should().Be(1, "Sanity check we know the result");

            var sut = new Abstractions.DateTime(sameTicks);

            //  Act.
            var actualHigher = sut.CompareTo(new Abstractions.DateTime(lowerTicks) as object);
            var actualSame = sut.CompareTo(new Abstractions.DateTime(sameTicks) as object);
            var actualLower = sut.CompareTo(new Abstractions.DateTime(higherTicks) as object);
            var actualForNull = sut.CompareTo(null as object);

            //  Assert.
            actualHigher.Should().Be(expectedHigher);
            actualSame.Should().Be(expectedSame);
            actualLower.Should().Be(expectedLower);
            actualForNull.Should().Be(expectedForNull);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Determined whether an aar file should be exploded (extracted).
        ///
        /// This is required for some aars so that the Unity Jar Resolver can perform variable
        /// expansion on manifests in the package before they're merged by aapt.
        /// </summary>
        /// <returns><c>true</c>, if the aar should be exploded, <c>false</c> otherwise.</returns>
        /// <param name="aarFile">The aar file.</param>
        internal virtual bool ShouldExplode(string aarFile)
        {
            AarExplodeData aarData = null;

            if (!aarExplodeData.TryGetValue(aarFile, out aarData))
            {
                aarData = new AarExplodeData();
            }
            bool explode = !SupportsAarFiles;

            if (!explode)
            {
                System.DateTime modificationTime = File.GetLastWriteTime(aarFile);
                if (modificationTime.CompareTo(aarData.modificationTime) <= 0)
                {
                    explode = aarData.explode;
                }
            }
            if (!explode)
            {
                string temporaryDirectory = CreateTemporaryDirectory();
                if (temporaryDirectory == null)
                {
                    return(false);
                }
                string manifestFilename = "AndroidManifest.xml";
                try
                {
                    if (ExtractAar(aarFile, new string[] { manifestFilename },
                                   temporaryDirectory))
                    {
                        string manifestPath = Path.Combine(temporaryDirectory,
                                                           manifestFilename);
                        if (File.Exists(manifestPath))
                        {
                            string manifest = File.ReadAllText(manifestPath);
                            explode = manifest.IndexOf("${applicationId}") >= 0;
                        }
                        aarData.modificationTime = File.GetLastWriteTime(aarFile);
                    }
                }
                catch (System.Exception e)
                {
                    Debug.Log("Unable to examine AAR file " + aarFile + ", err: " + e);
                    throw e;
                }
                finally
                {
                    PlayServicesSupport.DeleteExistingFileOrDirectory(temporaryDirectory);
                }
            }
            aarData.explode         = explode;
            aarExplodeData[aarFile] = aarData;
            return(explode);
        }
Ejemplo n.º 3
0
 public int CompareTo(DateTime other)
 {
     if (ReferenceEquals(null, other))
     {
         return(1);
     }
     else
     {
         return(backingDateTime.CompareTo(other.backingDateTime));
     }
 }
Ejemplo n.º 4
0
        static void Changed(object sender, System.IO.FileSystemEventArgs e)
        {
            if (!e.FullPath.Equals(CfgPath, System.StringComparison.CurrentCultureIgnoreCase))
            {
                return;
            }

            var lastTime = System.IO.File.GetLastWriteTime(e.FullPath);

            if (0 <= cfgLastTime.CompareTo(lastTime))
            {
                return;
            }

            cfgLastTime = lastTime;

            //------------------//

            var dels = Bind.businessList.Where(c => c.Value.Configuration.EnableWatcher).Select(c => c.Value.Configuration).ToList();

            if (0 == dels.Count)
            {
                return;
            }

            var config = GetConfig();

            if (default(ConfigJson).Equals(config) || 0 == config.Attributes.Count)
            {
                return;
            }

            foreach (var item in config.Group)
            {
                var dels2 = dels.Where(c => c.info.BusinessName.Equals(item.Key));

                foreach (var del in dels2)
                {
                    SetBusinessAttribute(del.attributes, del.metaData, item.Value);
                }
            }
        }
        //---------------------------------------------------------------------

        /// <summary>
        /// Makes the set of biomass cohorts at a site based on the age cohorts
        /// at the site, using a specified method for computing a cohort's
        /// initial biomass.
        /// </summary>
        /// <param name="ageCohorts">
        /// A sorted list of age cohorts, from oldest to youngest.
        /// </param>
        /// <param name="site">
        /// Site where cohorts are located.
        /// </param>
        /// <param name="initialBiomassMethod">
        /// The method for computing the initial biomass for a new cohort.
        /// </param>

        public static ISiteCohorts MakeBiomassCohorts(List <Landis.Library.AgeOnlyCohorts.ICohort> ageCohorts, ActiveSite site)

        {
            PlugIn.Cohorts[site] = new Library.BiomassCohortsPnET.SiteCohorts();

            Hydrology.Initialize(site);

            Hydrology.AnnualTranspiration[site] = 0;
            CanopyBiomass.CanopyLAI[site]       = 0;

            if (ageCohorts.Count == 0)
            {
                return(PlugIn.Cohorts[site]);
            }

            System.DateTime SpinUpDate = PlugIn.StartDate.AddYears(-(ageCohorts[0].Age) + ((successionTimestep == 1) ? -1 : 0));

            while (SpinUpDate.CompareTo(PlugIn.StartDate) < 0)
            {
                CanopyBiomass.SubCanopyPAR[site] = Static.PAR0[SpinUpDate];

                //  Add those cohorts that were born at the current year
                foreach (Library.AgeOnlyCohorts.ICohort ageonlycohort in ageCohorts)
                {
                    if (PlugIn.StartDate.Year - SpinUpDate.Year == ageonlycohort.Age)
                    {
                        Cohort cohort = new Cohort(ageonlycohort.Species, 1, ConstantParameters.InitialFol, 0, 0, 0, 0, SpinUpDate.Year, true);
                        PlugIn.Cohorts[site].AddNewCohort(cohort);
                        CohortOutput.WriteHeader(site, cohort);
                        SiteOutput.WriteHeader(site);
                    }
                }

                PlugIn.GrowCohorts(site, SpinUpDate, SpinUpDate.AddYears(1), false);

                SpinUpDate = SpinUpDate.AddYears(1);
            }


            return(PlugIn.Cohorts[site]);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 解析xml数据
        /// </summary>
        /// <param name="Config">xml文件字符串</param>
        public void ParseXML(string Config)
        {
            JSONObject arrStr = new JSONObject(Config);

            if (arrStr == null || arrStr.Count == 0)
            {
                Utils.LogSys.LogError("-------------localNotification Config is null : -------------");
                return;
            }
            List <JSONObject> myList = arrStr[0].list;

            if (myList == null || myList.Count == 0)
            {
                return;
                //Utils.LogSys.Log("--------------AppStorePay callback 1-------------");
            }
            System.DateTime nowDay   = System.DateTime.Now;
            System.DateTime tempWeek = System.DateTime.Now;

            for (int i = 0; i < myList.Count; i++)
            {
                JSONObject item_temp             = myList[i];
                Dictionary <string, string> item = item_temp.ToDictionary();
                string loopType = "day";
                if (item.ContainsKey("open"))
                {
                    if (item["open"].ToLower() != "true")
                    {
                        continue;
                    }
                }
                int key = 0;
                if (item.ContainsKey("id"))
                {
                    int.TryParse(item["id"], out key);
                }
                string sTitle = "";
                if (item.ContainsKey("title"))
                {
                    sTitle = item["title"];
                }
                string sMessage = "";
                if (item.ContainsKey("text"))
                {
                    sMessage = item["text"];
                }

                string sWeek   = "-1";
                int    weekDay = 1;
                if (item.ContainsKey("week"))
                {
                    sWeek = item["week"].ToLower();
                    if (sWeek != "-1")
                    {
                        loopType = "week";
                        int.TryParse(item["week"], out weekDay);
                        weekDay = Mathf.Clamp(weekDay, 1, 7);
                    }
                }

                int yy = 0;
                if (item.ContainsKey("yy"))
                {
                    int.TryParse(item["yy"], out yy);
                }
                int mm = 0;
                if (item.ContainsKey("mm"))
                {
                    int.TryParse(item["mm"], out mm);
                }
                int dd = 0;
                if (item.ContainsKey("dd"))
                {
                    int.TryParse(item["dd"], out dd);
                }
                int hour = 0;
                if (item.ContainsKey("hour"))
                {
                    int.TryParse(item["hour"], out hour);
                }
                int min = 0;
                if (item.ContainsKey("minute"))
                {
                    int.TryParse(item["minute"], out min);
                }
                int second = 0;

                yy   = (yy == -1) ? nowDay.Year : yy;
                mm   = (mm == -1) ? nowDay.Month : mm;
                dd   = (dd == -1) ? nowDay.Day : dd;
                hour = (hour == -1) ? nowDay.Hour : hour;
                min  = (min == -1) ? nowDay.Minute : min;
                System.DateTime newDate = new System.DateTime(yy, mm, dd, hour, min, second);
                if (loopType == "week")
                {
                    int nowWeek = (int)nowDay.DayOfWeek - 1;//周天是0,周一是1......
                    if (nowWeek == -1)
                    {
                        nowWeek = 6;
                    }
                    nowWeek += 1;//要转成周天是7, 周一是1, 周二是2
                    int offset = weekDay - nowWeek;
                    offset = offset < 0 ? offset + 7 : offset;
                    if (offset > 0)
                    {
                        newDate = newDate.AddDays(offset);
                    }
                }
                else
                {
                    if (nowDay.CompareTo(newDate) >= 0) //nowDay >= newDate
                    {
                        newDate = newDate.AddDays(1);   //如果现在时间比闹钟时大,则取第二天时间
                        //newDate = new System.DateTime(nowDay.Year, nowDay.Month, nowDay.Day, hour, min, second);
                        Utils.LogSys.Log("--------------add notification next:" + newDate.ToString() + "-------------");
                    }
                    else
                    {
                        Utils.LogSys.Log("--------------add notification :" + newDate.ToString() + "-------------");
                    }
                }
                localNotification.AddNotificationMessage(sTitle, sMessage, newDate, loopType, key);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Determined whether an aar file should be exploded (extracted).
        ///
        /// This is required for some aars so that the Unity Jar Resolver can perform variable
        /// expansion on manifests in the package before they're merged by aapt.
        /// </summary>
        /// <returns><c>true</c>, if the aar should be exploded, <c>false</c> otherwise.</returns>
        /// <param name="aarFile">The aar file.</param>
        internal virtual bool ShouldExplode(string aarFile)
        {
            AarExplodeData aarData = null;

            if (!aarExplodeData.TryGetValue(aarFile, out aarData))
            {
                aarData = new AarExplodeData();
            }
            bool explosionEnabled = true;

            // Unfortunately, as of Unity 5.5.0f3, Unity does not set the applicationId variable
            // in the build.gradle it generates.  This results in non-functional libraries that
            // require the ${applicationId} variable to be expanded in their AndroidManifest.xml.
            // To work around this when Gradle builds are enabled, explosion is enabled for all
            // AARs that require variable expansion unless this behavior is explicitly disabled
            // in the settings dialog.
            if (PlayServicesResolver.GradleBuildEnabled &&
                PlayServicesResolver.ProjectExportEnabled &&
                !SettingsDialog.ExplodeAars)
            {
                explosionEnabled = false;
            }
            bool explode = false;

            if (explosionEnabled)
            {
                explode = !SupportsAarFiles;
                if (!explode)
                {
                    System.DateTime modificationTime = File.GetLastWriteTime(aarFile);
                    if (modificationTime.CompareTo(aarData.modificationTime) <= 0)
                    {
                        explode = aarData.explode;
                    }
                }
                if (!explode)
                {
                    string temporaryDirectory = CreateTemporaryDirectory();
                    if (temporaryDirectory == null)
                    {
                        return(false);
                    }
                    string manifestFilename = "AndroidManifest.xml";
                    try
                    {
                        if (ExtractAar(aarFile, new string[] { manifestFilename },
                                       temporaryDirectory))
                        {
                            string manifestPath = Path.Combine(temporaryDirectory,
                                                               manifestFilename);
                            if (File.Exists(manifestPath))
                            {
                                string manifest = File.ReadAllText(manifestPath);
                                explode = manifest.IndexOf("${applicationId}") >= 0;
                            }
                            aarData.modificationTime = File.GetLastWriteTime(aarFile);
                        }
                    }
                    catch (System.Exception e)
                    {
                        Debug.Log("Unable to examine AAR file " + aarFile + ", err: " + e);
                        throw e;
                    }
                    finally
                    {
                        PlayServicesSupport.DeleteExistingFileOrDirectory(temporaryDirectory);
                    }
                }
            }
            aarData.explode         = explode;
            aarExplodeData[aarFile] = aarData;
            return(explode);
        }
Ejemplo n.º 8
0
 private int CompareTo(System.DateTime o1, System.DateTime o2)
 {
     return(o1.CompareTo(o2));
 }
 /// <summary>
 ///     A T extension method that check if the value is between inclusively the minValue and maxValue.
 /// </summary>
 /// <param name="this">The @this to act on.</param>
 /// <param name="minValue">The minimum value.</param>
 /// <param name="maxValue">The maximum value.</param>
 /// <returns>true if the value is between inclusively the minValue and maxValue, otherwise false.</returns>
 /// ###
 /// <typeparam name="T">Generic type parameter.</typeparam>
 public static bool InRange(this System.DateTime @this, System.DateTime minValue,
                            System.DateTime maxValue)
 {
     return(@this.CompareTo(minValue) >= 0 && @this.CompareTo(maxValue) <= 0);
 }
 /// <summary>
 ///     A T extension method that check if the value is between (exclusif) the minValue and maxValue.
 /// </summary>
 /// <param name="this">The @this to act on.</param>
 /// <param name="minValue">The minimum value.</param>
 /// <param name="maxValue">The maximum value.</param>
 /// <returns>true if the value is between the minValue and maxValue, otherwise false.</returns>
 /// ###
 public static bool Between(this System.DateTime @this, System.DateTime minValue,
                            System.DateTime maxValue)
 {
     return(minValue.CompareTo(@this) == -1 && @this.CompareTo(maxValue) == -1);
 }
Ejemplo n.º 11
0
 public virtual int CompareToDateTime(BaseSensorReading anotherSensorReading)
 {
     return(dateTime.CompareTo(anotherSensorReading.dateTime));
 }