protected virtual void OnPropertyChanged <T>(string name, ref Nullable <T> oldValue, Nullable <T> newValue) where T : struct, IComparable <T>
        {
            if (oldValue == null && newValue == null)
            {
                return;
            }

            if (oldValue != null && (oldValue.Equals(newValue) || Comparer <Nullable <T> > .Default.Compare(oldValue, newValue) == 0))
            {
                return;
            }

            if (oldValue.HasValue != newValue.HasValue || (newValue.HasValue && oldValue.Value.CompareTo(newValue.Value) != 0))
            {
                if (oldValue != null)
                {
                    this.AddChangs(name, oldValue, newValue);
                }

                oldValue = newValue;

                this.HasModelChanged = true;

                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
            }
        }
示例#2
0
    public bool PosTest3()
    {
        bool         retVal      = true;
        const string c_TEST_DESC = "PosTest3: Verify the Nullable's hasValue is false";
        const string c_TEST_ID   = "P003";

        int value   = TestLibrary.Generator.GetInt32(-55);
        int?nullObj = new Nullable <int>();

        TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);

        try
        {
            if (nullObj.Equals((object)value))
            {
                string errorDesc = "result is false as expected: Actual(true)";
                errorDesc += "\n parameter value is " + value;
                errorDesc += "\n Nullable object's HasValue is false";
                TestLibrary.TestFramework.LogError("005 " + "TestID_" + c_TEST_ID, errorDesc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("006 " + "TestID_" + c_TEST_ID, "Unexpected exception: " + e + "\n parameter value is " + value + "\n Nullable object's  HasValue is false");
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return(retVal);
    }
            public bool Equals(EventDetailModel x, EventDetailModel y)
            {
                var bandComparer  = new ObjectsComparer.Comparer <BandListModel>();
                var stageComparer = new ObjectsComparer.Comparer <StageListModel>();

                if (ReferenceEquals(x, y))
                {
                    return(true);
                }
                if (ReferenceEquals(x, null))
                {
                    return(false);
                }
                if (ReferenceEquals(y, null))
                {
                    return(false);
                }
                if (x.GetType() != y.GetType())
                {
                    return(false);
                }
                return(Nullable.Equals(x.Start, y.Start) && Nullable.Equals(x.End, y.End) &&
                       x.BandId.Equals(y.BandId) && bandComparer.Compare(x.Band, y.Band) && x.StageId.Equals(y.StageId) &&
                       stageComparer.Compare(x.Stage, y.Stage));
            }
示例#4
0
    public bool PosTest2()
    {
        bool         retVal      = true;
        const string c_TEST_DESC = "PosTest2: Verify the Nullable object's value doesn't equal the parameter";
        const string c_TEST_ID   = "P002";

        Random rand    = new Random(-55);
        int    value   = rand.Next(Int32.MinValue, Int32.MaxValue);
        int?   nullObj = new Nullable <int>(value + 1);

        TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);

        try
        {
            if (nullObj.Equals((object)value))
            {
                string errorDesc = "result is false as expected: Actual(true)";
                errorDesc += "\n parameter value is " + value;
                errorDesc += "\n Nullable object's value is " + nullObj.Value;
                TestLibrary.TestFramework.LogError("003 " + "TestID_" + c_TEST_ID, errorDesc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004 " + "TestID_" + c_TEST_ID, "Unexpected exception: " + e + "\n parameter value is " + value + "\n Nullable object's value is " + nullObj.Value);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return(retVal);
    }
示例#5
0
    public bool PosTest2()
    {
        bool retVal = true;
        const string c_TEST_DESC = "PosTest2: Verify the Nullable object's value doesn't equal the parameter";
        const string c_TEST_ID = "P002";

        Random rand = new Random(-55);
        int value = rand.Next(Int32.MinValue,Int32.MaxValue);
        int? nullObj = new Nullable<int>(value+1);

        TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);

        try
        {
            if (nullObj.Equals((object)value))
            {
                string errorDesc = "result is false as expected: Actual(true)";
                errorDesc += "\n parameter value is " + value;
                errorDesc += "\n Nullable object's value is " + nullObj.Value;
                TestLibrary.TestFramework.LogError("003 " + "TestID_" + c_TEST_ID, errorDesc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004 " + "TestID_" + c_TEST_ID, "Unexpected exception: " + e + "\n parameter value is " + value+"\n Nullable object's value is "+nullObj.Value);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
示例#6
0
    public bool PosTest1()
    {
        bool retVal = true;
        const string c_TEST_DESC = "PosTest1: Verify the Nullable object's value equals the parameter";
        const string c_TEST_ID = "P001";

        int value = TestLibrary.Generator.GetInt32(-55);
        int? nullObj = new Nullable<int>(value);

        TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);

        try
        {
            if (!nullObj.Equals((object)value))
            {
                string errorDesc = "result is true as expected: Actual(false)";
                errorDesc += "\n parameter value is " + value;
                TestLibrary.TestFramework.LogError("001 " + "TestID_" + c_TEST_ID, errorDesc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002 " + "TestID_" + c_TEST_ID, "Unexpected exception: " + e+"parameter value is "+ value);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
示例#7
0
 public bool Equals(ResourceBindings other)
 {
     return(Nullable.Equals(ResourceSet0, other.ResourceSet0) &&
            Nullable.Equals(ResourceSet1, other.ResourceSet1) &&
            Nullable.Equals(ResourceSet2, other.ResourceSet2) &&
            Nullable.Equals(ResourceSet3, other.ResourceSet3));
 }
示例#8
0
文件: Guild.cs 项目: Daktyl/Daktyl
 public bool Equals(Guild other)
 {
     return(Id.Equals(other.Id) && Name == other.Name && Icon == other.Icon && Splash == other.Splash &&
            DiscoverySplash == other.DiscoverySplash && Owner == other.Owner && OwnerId.Equals(other.OwnerId) &&
            Permissions == other.Permissions && Region == other.Region &&
            Nullable.Equals(AfkChannelId, other.AfkChannelId) && AfkTimeout == other.AfkTimeout &&
            EmbedEnabled == other.EmbedEnabled && Nullable.Equals(EmbedChannelId, other.EmbedChannelId) &&
            VerificationLevel == other.VerificationLevel &&
            DefaultMessageNotifictations == other.DefaultMessageNotifictations &&
            ExplicitContentFilter == other.ExplicitContentFilter && Equals(Roles, other.Roles) &&
            Equals(Emojis, other.Emojis) && Equals(Features, other.Features) && MFALevel == other.MFALevel &&
            Nullable.Equals(ApplicationId, other.ApplicationId) && WidgedEnabled == other.WidgedEnabled &&
            Nullable.Equals(WidgedChnanelId, other.WidgedChnanelId) &&
            Nullable.Equals(SystemChannelId, other.SystemChannelId) &&
            SystemChannelFlags == other.SystemChannelFlags &&
            Nullable.Equals(RulesChannelId, other.RulesChannelId) &&
            Nullable.Equals(JoinedAt, other.JoinedAt) && Large == other.Large &&
            Unavailable == other.Unavailable && MemberCount == other.MemberCount &&
            Equals(VoiceStates, other.VoiceStates) && Equals(Members, other.Members) &&
            Equals(Channels, other.Channels) && Equals(Presences, other.Presences) &&
            MaxPresences == other.MaxPresences && MaxMembers == other.MaxMembers &&
            VanityUrlCode == other.VanityUrlCode && Description == other.Description &&
            Banner == other.Banner && PremiumTier == other.PremiumTier &&
            PremiumSubscriptionCount == other.PremiumSubscriptionCount &&
            PrefferedLocale == other.PrefferedLocale &&
            Nullable.Equals(PublicUpdatesChannelId, other.PublicUpdatesChannelId));
 }
示例#9
0
 private bool Equals(ICustomer other)
 {
     return(CustomerID == other.CustomerID && CustomerName == other.CustomerName && BusinessNumber == other.BusinessNumber && Domain == other.Domain && Address == other.Address &&
            City == other.City && State == other.State && Country == other.Country && ZipCode == other.ZipCode && Phone == other.Phone && Fax == other.Fax && Notes == other.Notes &&
            Logo == other.Logo && Website == other.Website && Nullable.Equals(Longitude, other.Longitude) && Nullable.Equals(Latitude, other.Latitude) && CreatedOn.Equals(other.CreatedOn) &&
            LastModified.Equals(other.LastModified));
 }
示例#10
0
        /// <summary>
        /// compare la valeur courante de l'objet passe a la valeur definie pour un type de comparaison
        /// </summary>
        /// <param name="obj">l'objet re�u</param>
        /// <returns>vrai ou faux</returns>
        public bool Predicate(object obj)
        {
            bool result = false;
            Nullable <DateTime> CurrentPropertyValue = (Nullable <DateTime>)PredicateUtils.GetValue(obj, Property);

            switch (Comparaison)
            {
            case DateTimeComparaison.Equals:
                result = CurrentPropertyValue.Equals(Value);
                break;

            case DateTimeComparaison.inf:
                if (CurrentPropertyValue < Value)
                {
                    result = true;
                }
                break;

            case DateTimeComparaison.Sup:
                if (CurrentPropertyValue > Value)
                {
                    result = true;
                }
                break;
            }

            return(result);
        }
示例#11
0
        /// <summary>
        /// Returns true if this = other
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public bool Equals(ExcelCellStyleInfo other)
        {
            if (other == null && !this.HasCellInfo)
            {
                return(true);
            }
            if (other == null)
            {
                return(false);
            }

            if (!Nullable <Color> .Equals(this.FillColour, other.FillColour))
            {
                return(false);
            }
            if (!string.Equals(this.NumberFormat, other.NumberFormat))
            {
                return(false);
            }
            if (!ExcelCellFontInfo.Equals(this.FontInfo, other.FontInfo))
            {
                return(false);
            }
            if (!ExcelCellBorderInfo.Equals(this.BorderInfo, other.BorderInfo))
            {
                return(false);
            }
            if (!ExcelCellAlignmentInfo.Equals(this.AlignmentInfo, other.AlignmentInfo))
            {
                return(false);
            }

            return(true);
        }
示例#12
0
        /// <inheritdoc cref="IEquatable{T}.Equals(T)" />
        public bool Equals(RabbitConnectionConfig?other)
        {
            if (other is null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(Equals(AmqpUriSslProtocols, other.AmqpUriSslProtocols) &&
                   Equals(AutomaticRecoveryEnabled, other.AutomaticRecoveryEnabled) &&
                   string.Equals(HostName, other.HostName, StringComparison.Ordinal) &&
                   Nullable.Equals(NetworkRecoveryInterval, other.NetworkRecoveryInterval) &&
                   Nullable.Equals(HandshakeContinuationTimeout, other.HandshakeContinuationTimeout) &&
                   Nullable.Equals(ContinuationTimeout, other.ContinuationTimeout) &&
                   Equals(Port, other.Port) &&
                   Equals(RequestedConnectionTimeout, other.RequestedConnectionTimeout) &&
                   Equals(SocketReadTimeout, other.SocketReadTimeout) &&
                   Equals(SocketWriteTimeout, other.SocketWriteTimeout) &&
                   Equals(Ssl, other.Ssl) &&
                   Equals(TopologyRecoveryEnabled, other.TopologyRecoveryEnabled) &&
                   ClientPropertiesComparer.Equals(ClientProperties, other.ClientProperties) &&
                   string.Equals(Password, other.Password, StringComparison.Ordinal) &&
                   Equals(RequestedChannelMax, other.RequestedChannelMax) &&
                   Equals(RequestedFrameMax, other.RequestedFrameMax) &&
                   Equals(RequestedHeartbeat, other.RequestedHeartbeat) &&
                   Equals(UseBackgroundThreadsForIO, other.UseBackgroundThreadsForIO) &&
                   string.Equals(UserName, other.UserName, StringComparison.Ordinal) &&
                   string.Equals(VirtualHost, other.VirtualHost, StringComparison.Ordinal) &&
                   string.Equals(ClientProvidedName, other.ClientProvidedName, StringComparison.Ordinal));
        }
示例#13
0
 static void Compare(Nullable <int> first, Nullable <long> second)
 {
     Console.WriteLine($"first == second: {first == second}");
     Console.WriteLine($"first.Equals(second): {first.Equals(second)}");
     Console.WriteLine($"object.Equals(first, second): {object.Equals(first, second)}");
     Console.WriteLine($"object.ReferenceEquals(first, second): {object.ReferenceEquals(first, second)}");
 }
示例#14
0
 public bool Equals(StreamMetadata other) => Nullable.Equals(MaxAge, other.MaxAge) &&
 Nullable.Equals(TruncateBefore, other.TruncateBefore) &&
 Nullable.Equals(CacheControl, other.CacheControl) &&
 Equals(Acl, other.Acl) && MaxCount == other.MaxCount &&
 string.Equals(
     CustomMetadata?.RootElement.GetRawText(),
     other.CustomMetadata?.RootElement.GetRawText());
示例#15
0
 public static void ShouldBe <T>(this T?actual, T?expected, string userMessage = null) where T : struct
 {
     if (!Nullable.Equals(actual, expected))
     {
         throw new AssertException(expected, actual, userMessage);
     }
 }
示例#16
0
        public Object ObterAlteracoesAuditoria(object objetoOriginal, object objetoAtualizado, Object objetoAuditoria, out bool valorAlterado)
        {
            valorAlterado = false;
            if (objetoOriginal.GetType() == objetoAtualizado.GetType())
            {
                foreach (PropertyInfo propriedadeObjeto in objetoOriginal.GetType().GetProperties())
                {
                    object valorOriginal = propriedadeObjeto.GetValue(objetoOriginal, null);
                    object valorAtualizado = propriedadeObjeto.GetValue(objetoAtualizado, null);

                    if (!Nullable.Equals(valorOriginal,valorAtualizado))
                    {
                        valorAlterado = true;
                        foreach (PropertyInfo propriedadeAuditoria in objetoAuditoria.GetType().GetProperties())
                        {
                            if (propriedadeObjeto.Name == propriedadeAuditoria.Name)
                            {
                                propriedadeObjeto.SetValue(objetoAuditoria, Convert.ChangeType(valorAtualizado, propriedadeObjeto.PropertyType), null);
                                break;
                            }
                        }
                    }
                }
            }

            return objetoAuditoria;
        }
示例#17
0
        public static bool NullableTest6()
        {
            bool?v1 = null;
            bool?v2 = true;

            return(!Nullable.Equals(v1, v2));
        }
示例#18
0
    public bool PosTest2()
    {
        bool retVal = true;

        const string c_TEST_DESC = "PosTest2: Verify n1 is null and n2 is not null";
        const string c_TEST_ID   = "P002";
        char?        n1          = null;
        char?        n2          = TestLibrary.Generator.GetChar(-55);

        TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);

        try
        {
            if (Nullable.Equals <char>(n1, n2))
            {
                string errorDesc = "Return value is false as expected: Actual(true)";
                errorDesc += " when  n1 is null and n2 is " + n2;
                TestLibrary.TestFramework.LogError("003 " + "TestID_" + c_TEST_ID, errorDesc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e + "\n n1 is  null and n2 is " + n2);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return(retVal);
    }
示例#19
0
    public bool PosTest3()
    {
        bool retVal = true;

        const string c_TEST_DESC = "PosTest3: Verify n1 and n2 are eaual";
        const string c_TEST_ID   = "P003";
        int?         n1          = TestLibrary.Generator.GetInt32(-55);
        int?         n2          = n1;

        TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);

        try
        {
            if (!Nullable.Equals <int>(n1, n2))
            {
                string errorDesc = "Return value is true as expected: Actual(false)";
                errorDesc += " when  n1 is " + n1 + " and n2 is " + n2;
                TestLibrary.TestFramework.LogError("005 " + "TestID_" + c_TEST_ID, errorDesc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e + "\n n1 is  " + n1 + " and n2 is " + n2);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return(retVal);
    }
示例#20
0
    public bool PosTest1()
    {
        bool retVal = true;

        const string c_TEST_DESC = "PosTest1: Verify two Nullable<T> objects are null";
        const string c_TEST_ID   = "P001";
        char?        n1          = null;
        char?        n2          = null;

        TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);

        try
        {
            if (!Nullable.Equals <char>(n1, n2))
            {
                string errorDesc = "Return value is true as expected: Actual(false)";
                errorDesc += " when  n1 and n2 are null ";
                TestLibrary.TestFramework.LogError("001 " + "TestID_" + c_TEST_ID, errorDesc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e + "\n n1 and n2 are null");
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return(retVal);
    }
示例#21
0
        public void UpdateData(IRepositoryInfoCacheData data)
        {
            var now       = DateTimeOffset.Now;
            var isUpdated = false;

            if (!Nullable.Equals(currentGitRemote, data.CurrentGitRemote))
            {
                currentGitRemote = data.CurrentGitRemote ?? GitRemote.Default;
                isUpdated        = true;
            }

            if (!Nullable.Equals(currentGitBranch, data.CurrentGitBranch))
            {
                currentGitBranch = data.CurrentGitBranch ?? GitBranch.Default;
                isUpdated        = true;
            }

            if (!Nullable.Equals(currentConfigRemote, data.CurrentConfigRemote))
            {
                currentConfigRemote = data.CurrentConfigRemote ?? ConfigRemote.Default;
                isUpdated           = true;
            }

            if (!Nullable.Equals(currentConfigBranch, data.CurrentConfigBranch))
            {
                currentConfigBranch = data.CurrentConfigBranch ?? ConfigBranch.Default;
                isUpdated           = true;
            }

            SaveData(now, isUpdated);
        }
示例#22
0
        public static int UpdateAccountClassification(SqlConnection Connection, SqlTransaction Transaction, Guid?AccountID, Guid ActionBy, string ActionByName)
        {
            int affectedRows = 0;

            Nullable <Guid> currentClassificationCID = GetClassificationCID(AccountID);
            Nullable <Guid> ClassificationCID        = CalculateClassification(AccountID);

            if (!currentClassificationCID.Equals(ClassificationCID) && !ClassificationCID.Equals(Guid.Empty))
            {
                using (SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["CRM"].ToString()))
                {
                    conn.Open();
                    using (SqlCommand cmd = new SqlCommand("", conn))
                    {
                        StringBuilder sql = new StringBuilder();
                        sql.AppendLine("UPDATE Account");
                        sql.AppendLine("SET ClassificationCID = @ClassificationCID, ModifiedDate = getdate(), ModifiedBy = @ActionBy, ModifiedByName = @ActionByName");
                        sql.AppendLine("WHERE AccountID = @AccountID");
                        cmd.CommandText = sql.ToString();
                        cmd.Parameters.AddWithValue("@AccountID", AccountID);
                        cmd.Parameters.AddWithValue("@ClassificationCID", ConvertDbNull(ClassificationCID));
                        cmd.Parameters.AddWithValue("@ActionBy", ActionBy);
                        cmd.Parameters.AddWithValue("@ActionByName", ActionByName);
                        affectedRows += cmd.ExecuteNonQuery();
                    }
                }
            }

            return(affectedRows);
        }
 public bool Equals(PartialSelectedRange x, PartialSelectedRange y)
 {
     return(Nullable.Equals(x.StartLine, y.StartLine) &&
            Nullable.Equals(x.StartColumn, y.StartColumn) &&
            Nullable.Equals(x.EndLine, y.EndLine) &&
            Nullable.Equals(x.EndColumn, y.EndColumn));
 }
示例#24
0
        public static int UpdateAccountJVCategory(SqlConnection Connection, SqlTransaction Transaction, Guid?AccountID, Guid ActionBy, string ActionByName)
        {
            int affectedRows = 0;

            Nullable <Guid> currentJVCategoryCID = GetJVCategoryCID(AccountID);
            Nullable <Guid> JVCategoryCID        = CalculateJVCategory(AccountID);

            if (!currentJVCategoryCID.Equals(JVCategoryCID))
            {
                using (SqlCommand cmd = new SqlCommand("", Connection))
                {
                    StringBuilder sql = new StringBuilder();
                    sql.AppendLine("UPDATE Account");
                    sql.AppendLine("SET JVCategoryCID = @JVCategoryCID, ModifiedDate = getdate(), ModifiedBy = @ActionBy, ModifiedByName = @ActionByName");
                    sql.AppendLine("WHERE AccountID = @AccountID");
                    cmd.CommandText = sql.ToString();
                    cmd.Parameters.AddWithValue("@AccountID", AccountID);
                    cmd.Parameters.AddWithValue("@JVCategoryCID", ConvertDbNull(JVCategoryCID));
                    cmd.Parameters.AddWithValue("@ActionBy", ActionBy);
                    cmd.Parameters.AddWithValue("@ActionByName", ActionByName);
                    affectedRows += cmd.ExecuteNonQuery();
                }
            }

            return(affectedRows);
        }
示例#25
0
        private bool Equals(IAgent other)
        {
            if (!(AgentID == other.AgentID && MachineID == other.MachineID && DeviceGuid == other.DeviceGuid && CustomerID == other.CustomerID && CustomerName == other.CustomerName &&
                  FolderID == other.FolderID && AgentName == other.AgentName && SystemName == other.SystemName && MachineName == other.MachineName && DomainName == other.DomainName &&
                  CurrentLoggedUsers == other.CurrentLoggedUsers && ComputerDescription == other.ComputerDescription && Monitored == other.Monitored &&
                  Nullable.Equals(LastPatchManagementReceived, other.LastPatchManagementReceived) && AgentVersion == other.AgentVersion && Favorite == other.Favorite &&
                  ThresholdID == other.ThresholdID && MonitoredAgentID == other.MonitoredAgentID && Created.Equals(other.Created) && Modified.Equals(other.Modified) && Online == other.Online &&
                  ReportedFromIP == other.ReportedFromIP && AppViewUrl == other.AppViewUrl && Motherboard == other.Motherboard && Processor == other.Processor && Memory == other.Memory &&
                  Display == other.Display && Sound == other.Sound && ProcessorCoresCount == other.ProcessorCoresCount && SystemDrive == other.SystemDrive && ProcessorClock == other.ProcessorClock &&
                  Vendor == other.Vendor && VendorSerialNumber == other.VendorSerialNumber && VendorBrandModel == other.VendorBrandModel && ProductName == other.ProductName &&
                  OS == other.OS && OSType == other.OSType && OSVersion == other.OSVersion && OSBuild == other.OSBuild &&
                  WindowsSerialNumber == other.WindowsSerialNumber && Office == other.Office && OfficeSP == other.OfficeSP && OfficeOEM == other.OfficeOEM &&
                  OfficeSerialNumber == other.OfficeSerialNumber && OfficeFullVersion == other.OfficeFullVersion && LastLoginUser == other.LastLoginUser))
            {
                return(false);
            }

            if (!(HardwareDisks ?? new IHardwareDisk[0]).OrderBy(x => x.Drive).SequenceEqual((other.HardwareDisks ?? new IHardwareDisk[0]).OrderBy(x => x.Drive)))
            {
                return(false);
            }
            if (!(MacAddresses ?? new string[0]).OrderBy(x => x).SequenceEqual((other.MacAddresses ?? new string[0]).OrderBy(x => x)))
            {
                return(false);
            }
            if (!(IpAddresses ?? new string[0]).OrderBy(x => x).SequenceEqual((other.IpAddresses ?? new string[0]).OrderBy(x => x)))
            {
                return(false);
            }

            return(true);
        }
示例#26
0
        public static void OptionalTypeTest()
        {
            var intOptional = new int?(10).ToOptional();

            True(intOptional.HasValue);
            False(intOptional.IsUndefined);
            False(intOptional.IsNull);
            Equal(10, (int)intOptional);
            Equal(10, intOptional.Or(20));
            Equal(10, intOptional.Value);
            Equal(10, intOptional.OrThrow(() => new ArithmeticException()));
            True(Nullable.Equals(10, intOptional.OrNull()));
            Equal(typeof(int), Optional.GetUnderlyingType(intOptional.GetType()));

            intOptional = default(int?).ToOptional();
            False(intOptional.HasValue);
            Equal(20, intOptional.Or(20));
            True(Nullable.Equals(null, intOptional.OrNull()));
            Equal(30, intOptional.Coalesce(new int?(30).ToOptional()).Value);
            Equal(40, (intOptional | new int?(40).ToOptional()).Value);
            Throws <InvalidOperationException>(() => intOptional.Value);

            Optional <string> strOptional = null;

            False(strOptional.HasValue);
            Equal("Hello, world", strOptional.Or("Hello, world"));
            Throws <InvalidOperationException>(() => strOptional.Value);
            Throws <ArithmeticException>(() => strOptional.OrThrow(() => new ArithmeticException()));
            Equal(typeof(string), Optional.GetUnderlyingType(strOptional.GetType()));
        }
示例#27
0
 protected bool Equals(Ticket other)
 {
     return(base.Equals(other) && SeatNumber == other.SeatNumber &&
            Price.Equals(other.Price) && EventId.Equals(other.EventId) &&
            Nullable.Equals(UserId, other.UserId) && UserName == other.UserName &&
            Nullable.Equals(PurchaseDate, other.PurchaseDate));
 }
示例#28
0
 protected bool Equals(NConsoleOption other)
 {
     return(Name == other.Name && Function.Equals(other.Function) && Equals(AltFunction, other.AltFunction) &&
            Equals(CtrlFunction, other.CtrlFunction) && Equals(ShiftFunction, other.ShiftFunction) &&
            Equals(ComboFunction, other.ComboFunction) && Equals(Data, other.Data) &&
            Nullable.Equals(Color, other.Color));
 }
示例#29
0
    public bool PosTest4()
    {
        bool retVal = true;

        const string c_TEST_DESC = "PosTest4: Verify n1 and n2 are not eaual";
        const string c_TEST_ID   = "P004";
        Random       rand        = new Random(-55);
        int?         n1          = rand.Next(Int32.MinValue, Int32.MaxValue);
        int?         n2          = n1 + 1;

        TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);

        try
        {
            if (Nullable.Equals <int>(n1, n2))
            {
                string errorDesc = "Return value is false as expected: Actual(true)";
                errorDesc += " when  n1 is " + n1 + " and n2 is " + n2;
                TestLibrary.TestFramework.LogError("007 " + "TestID_" + c_TEST_ID, errorDesc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("008", "Unexpected exception: " + e + "\n n1 is  " + n1 + " and n2 is " + n2);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return(retVal);
    }
示例#30
0
            static public bool CompareLists <T>(List <T> l1, List <T> l2)
            {
                if ((l1 == null || l1.Count == 0) && (l2 == null || l2.Count == 0))
                {
                    return(true);
                }

                for (int i = 0; i < l1.Count; i++)
                {
                    if (typeof(T).Name == "String")
                    {
                        string str1 = l1[i] == null? "" : l1[i].ToString();
                        string str2 = l2[i] == null ? "" : l2[i].ToString();
                        return(string.Equals(str1, str2));
                    }
                    if (typeof(T).Name == "Font")
                    {
                        return(Font.Equals(l1[i], l2[i]));
                    }
                    if (Nullable.GetUnderlyingType(typeof(T)) != null)
                    {
                        return(Nullable.Equals(l1[i], l2[i]));
                    }

                    if ((l1[i] == null && l2[i] != null) ||
                        (l1[i] != null && l2[i] == null) ||
                        (!object.Equals(l1[i], l2[i])))
                    {
                        return(false);
                    }
                }

                return(true);
            }
        public override bool FullEquals(RequestListFilterEntity other)
        {
            if (other == null)
            {
                return(false);
            }

            if (object.ReferenceEquals(this, other))
            {
                return(true);
            }

            return(other != null &&
                   StartDateTime == other.StartDateTime &&
                   Nullable.Equals(StopDateTime, other.StopDateTime) &&
                   UserEntity.Equals(ResponseUser, other.ResponseUser) &&
                   UserEntity.Equals(CreatorUser, other.CreatorUser) &&
                   AppEntity.Equals(Application, other.Application) &&
                   OrgEntity.Equals(Organization, other.Organization) &&
                   string.Equals(StatusIdList, other.StatusIdList) &&
                   string.Equals(TagIdList, other.TagIdList) &&
                   string.Equals(Subject, other.Subject) &&
                   string.Equals(Comments, other.Comments) &&
                   string.Equals(Contact, other.Contact) &&
                   string.Equals(RequestId, other.RequestId));
        }
示例#32
0
        static internal LocalFile[] ListByParentId(Nullable <int> parent_id)
        {
            return(Core.FileSystem.UseConnection <LocalFile[]>(delegate(IDbConnection connection) {
                IDbCommand command = connection.CreateCommand();
                string query = null;
                if (parent_id.Equals(null))
                {
                    query = "SELECT * FROM directoryitems WHERE parent_id ISNULL AND type = 'F'";
                }
                else
                {
                    query = "SELECT * FROM directoryitems WHERE parent_id = @parent_id AND type = 'F'";
                    Core.FileSystem.AddParameter(command, "@parent_id", parent_id);
                }
                command.CommandText = query;
                DataSet ds = Core.FileSystem.ExecuteDataSet(command);

                LocalFile[] results = new LocalFile[ds.Tables[0].Rows.Count];
                for (int x = 0; x < ds.Tables[0].Rows.Count; x++)
                {
                    results[x] = new LocalFile(ds.Tables[0].Rows[x]);
                }
                return results;
            }));
        }
示例#33
0
 public static bool proofLoggedIn(Nullable<Int64> currentUser)
 {
     if (currentUser.Equals(null))
     {
         return false;
     }
     else
     {
         return true;
     }
 }
示例#34
0
        public void TestCase()
        {
            Nullable<Int32> foo = new Nullable<Int32>();
            Assert.IsNull(foo, "#1");
            Assert.IsFalse(foo.HasValue, "#2");

            foo = 3;
            Assert.IsTrue(foo.HasValue, "#3");
            Assert.AreEqual(3, foo, "#4");
            Assert.IsTrue(foo.Equals(3), "#5");
            Assert.IsTrue(3.Equals(foo), "#6");

            foo = null;
            Assert.IsNull(foo, "#7");
            Assert.IsFalse(foo.HasValue, "#8");
        }
示例#35
0
 /// <summary>
 /// 页面上,get时,单精度型转为" "
 /// </summary>
 /// <param name="arg"></param>
 /// <returns></returns>
 public static string ConvertSingleToNullable(Nullable<Single> arg)
 {
     return arg.Equals(null) ? "" : arg.Value.ToString();
 }
示例#36
0
    public bool PosTest6()
    {
        bool retVal = true;
        const string c_TEST_DESC = "PosTest6: Verify the Nullable's type is int and parameter is string";
        const string c_TEST_ID = "P006";

        object value = TestLibrary.Generator.GetString(-55, false,1,10);
        int i = TestLibrary.Generator.GetInt32(-55);
        int? nullObj = new Nullable<int>(i);

        TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);

        try
        {
            if (nullObj.Equals(value))
            {
                string errorDesc = "result is true as expected: Actual(fasle)";
                errorDesc += "\n parameter value is "+value.ToString();
                errorDesc += "\n Nullable object's value is "+ i;
                TestLibrary.TestFramework.LogError("009 " + "TestID_" + c_TEST_ID, errorDesc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("010 " + "TestID_" + c_TEST_ID, "Unexpected exception: " + e + "\n parameter value is "+value.ToString()+" \n Nullable object's  value is "+i);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
示例#37
0
 /// <summary>
 /// 页面上,get时,转为{0:yyyy-MM}或""
 /// </summary>
 /// <param name="arg"></param>
 /// <returns></returns>
 public static string ConvertDateTimeToShotMonth(Nullable<DateTime> arg)
 {
     return arg.Equals(DBNull.Value) ? "" : String.Format("{0:yyyy-MM-1}", arg);
 }
示例#38
0
 /// <summary>
 /// 页面上,get时,转为{0:HH:mm:ss}或""
 /// </summary>
 /// <param name="arg"></param>
 /// <returns></returns>
 public static string ConvertDateTimeToTime(Nullable<DateTime> arg)
 {
     return arg.Equals(DBNull.Value) ? "" : String.Format("{0:HH:mm:ss}", arg);
 }
	/**
	 * Convert a Nullable<DateTime> into a String.
	 * 
	 * @param d
	 *            The Date to convert.
	 * @return The formated date or null.
	 * @see java.util.SimpleDateFormat
	 */
	private String GetDateValue(Nullable<DateTime> d) {
		if (d == null || d.Equals(""))
			return "";
		else {
			SimpleDateFormat df = new SimpleDateFormat(
					"yyyy-MM-dd'T'HH:mm:ss'Z'");
            return df.Format(d.Value, CultureInfo.CurrentCulture);
		}
	}
示例#40
0
 /// <summary>
 /// 页面上,get时,转为{0:yyyy-MM-dd HH:mm:ss}或""
 /// </summary>
 /// <param name="arg"></param>
 /// <returns></returns>
 public static string ConvertDateTimeToNullable(Nullable<DateTime> arg)
 {
     return arg.Equals(null) ? "" : arg.Value.ToString();
 }
示例#41
0
        internal static LocalDirectory[] ListByParentId(Nullable<int> parent_id)
        {
            return Core.FileSystem.UseConnection<LocalDirectory[]>(delegate (IDbConnection connection) {
                IDbCommand command = connection.CreateCommand();
                string query = null;
                if (parent_id.Equals(null)) {
                    query = "SELECT * FROM directoryitems WHERE parent_id ISNULL AND type = 'D'";
                } else {
                    query = "SELECT * FROM directoryitems WHERE parent_id = @parent_id AND type = 'D'";
                    Core.FileSystem.AddParameter(command, "@parent_id", (int)parent_id);
                }
                command.CommandText = query;
                DataSet ds = Core.FileSystem.ExecuteDataSet(command);

                LocalDirectory[] results = new LocalDirectory[ds.Tables[0].Rows.Count];
                for (int x = 0; x < ds.Tables[0].Rows.Count; x++) {
                    results[x] = LocalDirectory.FromDataRow(ds.Tables[0].Rows[x]);
                }
                return results;
            });
        }
示例#42
0
 /// <summary>
 /// 将时间范型转为数据库类型,处理空值
 /// </summary>
 /// <param name="arg">可为空时间范型</param>
 /// <returns>数据库类型</returns>
 public static string ConvertNullableToDBType(Nullable<DateTime> arg)
 {
     return arg.Equals(null) ? "null" : arg.Value.ToString();
 }
示例#43
0
 internal static long CountByParentId(Nullable<int> parent_id)
 {
     return Core.FileSystem.UseConnection<long>(delegate (IDbConnection connection) {
         IDbCommand command = connection.CreateCommand();
         string query = null;
         if (parent_id.Equals(null)) {
             query = "SELECT count(id) FROM directoryitems WHERE parent_id ISNULL AND type = 'D'";
         } else {
             query = "SELECT count(id) FROM directoryitems WHERE parent_id = @parent_id AND type = 'D'";
             Core.FileSystem.AddParameter(command, "@parent_id", (int)parent_id);
         }
         command.CommandText = query;
         return (long) Core.FileSystem.ExecuteScalar(command);
     });
 }
示例#44
0
 /// <summary>
 /// 将单精度范型转为数据库类型,处理空值
 /// </summary>
 /// <param name="arg">可为空单精度范型</param>
 /// <returns>数据库类型</returns>
 public static string ConvertSingleNullToDBType(Nullable<Single> arg)
 {
     return arg.Equals(null) ? "null" : arg.Value.ToString();
 }
示例#45
0
 /// <summary>
 /// 页面上,get时,int空值转为“”
 /// </summary>
 /// <param name="arg"></param>
 /// <returns></returns>
 public static string ConvertIntToNullable(Nullable<int> arg)
 {
     return arg.Equals(null) ? "" : arg.Value.ToString();
 }
示例#46
0
 /// <summary>
 /// 将整型转为数据库类型,处理空值
 /// </summary>
 /// <param name="arg"></param>
 /// <returns></returns>
 public static string ConvertNullableToDBString(Nullable<int> arg)
 {
     return arg.Equals(null) ? "null" : arg.Value.ToString();
 }
示例#47
0
    public bool PosTest5()
    {
        bool retVal = true;
        const string c_TEST_DESC = "PosTest5: Verify the Nullable's hasValue is false and parameter is null";
        const string c_TEST_ID = "P005";

        object value = null;
        int? nullObj = new Nullable<int>();

        TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);

        try
        {
            if (!nullObj.Equals(value))
            {
                string errorDesc = "result is true as expected: Actual(fasle)";
                errorDesc += "\n parameter value is null";
                errorDesc += "\n Nullable object's HasValue is false";
                TestLibrary.TestFramework.LogError("009 " + "TestID_" + c_TEST_ID, errorDesc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("010 " + "TestID_" + c_TEST_ID, "Unexpected exception: " + e + "\n parameter value is null  \n Nullable object's  HasValue is false");
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
示例#48
0
 /// <summary>
 /// 页面上,get时,转为{0:yyyy}或""
 /// </summary>
 /// <param name="arg"></param>
 /// <returns></returns>
 public static string ConvertDateTimeToYear(Nullable<DateTime> arg)
 {
     return arg.Equals(DBNull.Value) ? "" : String.Format("{0:yyyy}", arg);
 }