Equals() public méthode

public Equals ( left, right ) : bool
Résultat bool
Exemple #1
0
        private bool EndpointEquals(Edge x, Edge y)
        {
            if (IgnoreDirection)
            {
                if (NameComparer.Equals(x.Source.Name, y.Source.Name))
                {
                    return(NameComparer.Equals(x.Target.Name, y.Target.Name));
                }
                else
                {
                    return(NameComparer.Equals(x.Source.Name, y.Target.Name) &&
                           NameComparer.Equals(x.Target.Name, y.Source.Name));
                }
            }

            if (!NameComparer.Equals(x.Source.Name, y.Source.Name))
            {
                return(false);
            }

            if (!NameComparer.Equals(x.Target.Name, y.Target.Name))
            {
                return(false);
            }

            return(true);
        }
Exemple #2
0
 private bool AreParametersEqual(ParameterSymbol parameter, ParameterSymbol other)
 {
     Debug.Assert(parameter.Ordinal == other.Ordinal);
     return(NameComparer.Equals(parameter.Name, other.Name) &&
            (parameter.RefKind == other.RefKind) &&
            this.comparer.Equals(parameter.Type, other.Type));
 }
Exemple #3
0
        public bool Equals(Node x, Node y)
        {
            if (ReferenceEquals(x, y))
            {
                return(true);
            }
            if (ReferenceEquals(x, null) || ReferenceEquals(y, null))
            {
                return(false);
            }

            if (IncludeName && !NameComparer.Equals(x.Name, y.Name))
            {
                return(false);
            }

            if (IncludeUserData && !UserDataComparer.Equals(x.UserData, y.UserData))
            {
                return(false);
            }

            if (IncludeInDegree && x.InDegree != y.InDegree)
            {
                return(false);
            }

            if (IncludeOutDegree && x.OutDegree != y.OutDegree)
            {
                return(false);
            }

            return(true);
        }
Exemple #4
0
        private bool IsMatch(IXmlIdentity xmlIdentity)
        {
            var name = xmlIdentity.Name;

            return(NameComparer.Equals(rootLocalName, name.LocalName) &&
                   (rootNamespaceUri == null || NameComparer.Equals(rootNamespaceUri, name.NamespaceUri)));
        }
        private IEnumerable <KeyValuePair <string, ICfgNode> > scanInclude(IConfigNodeProvider source, Context context)
        {
            foreach (var pair in source.Items)
            {
                var configName = pair.Key;

                if (NameComparer.Equals(configName, AppSettingExtensions.IdentitySectionName))
                {
                    continue;
                }

                var configNode = _cfgNodeConverter(configName, pair.Value);
                if (configNode == null)
                {
                    continue;
                }

                List <Include> hadlers;
                if (!_includeHandlers.TryGetValue(configName, out hadlers))
                {
                    yield return(new KeyValuePair <string, ICfgNode>(configName, configNode));

                    continue;
                }

                var includeSettings = hadlers
                                      .Select(_ => _(source, context.Deserializer, configNode, context.SearchPath))
                                      .FirstOrDefault(_ => _ != null);

                if (includeSettings == null)
                {
                    throw new NotSupportedException("any registered handlers returned null");
                }

                var includeSettingsArray = includeSettings.ToArray();
                var includeRequired      = context.Deserializer.Deserialize <RequiredContainConfig>(configNode).Required;

                if (includeRequired && includeSettingsArray.Length == 0)
                {
                    throw new ApplicationException(string.Format("include setting from section '{0}' not found", configName));
                }

                foreach (var cnProvider in includeSettingsArray)
                {
                    if (context.CheckLoaded(cnProvider))
                    {
                        continue;
                    }

                    onLoaded(cnProvider);
                    context.Sources.Add(cnProvider);

                    foreach (var includePair in scanInclude(cnProvider, context))
                    {
                        yield return(includePair);
                    }
                }
            }
        }
        public void Equal_When_All_Fields_Are_Equal()
        {
            var x = CreateName();
            var y = CreateName();

            var comparer = new NameComparer();
            bool result = comparer.Equals(x, y);

            Assert.IsTrue(result);
        }
        public void Not_Equal_When_MutKod_Is_Different()
        {
            var x = CreateName();
            var y = CreateName();
            y.MutKod = MutKod.RecordUpdated;

            var comparer = new NameComparer();
            bool result = comparer.Equals(x, y);

            Assert.IsFalse(result);
        }
        public void Not_Equal_When_NmNaam_Is_Different()
        {
            var x = CreateName();
            var y = CreateName();
            y.NmNaam = "D";

            var comparer = new NameComparer();
            bool result = comparer.Equals(x, y);

            Assert.IsFalse(result);
        }
Exemple #9
0
        private bool IsMatchOnNamespaceUri(IXmlIdentity xmlIdentity)
        {
            var otherNamespaceUri = xmlIdentity.Name.NamespaceUri;

            if (Context.IsReservedNamespaceUri(otherNamespaceUri))
            {
                return(NameComparer.Equals(namespaceUri, otherNamespaceUri));
            }
            return(namespaceUri == null ||
                   ShouldIgnoreAttributeNamespaceUri(xmlIdentity) ||
                   NameComparer.Equals(namespaceUri, otherNamespaceUri));
        }
        public ICfgNode CfgNodeConverter(string name, ICfgNode candidate)
        {
            if (!NameComparer.Equals(name, "variable"))
            {
                return(new CfgNodeWrapper(candidate, this));
            }

            var varConfig = DefaultDeserializer.Instance.Deserialize <VariableConfig>(candidate);

            this[varConfig.Name] = varConfig.Value;
            return(null);
        }
Exemple #11
0
 private bool AreTypeParametersEqual(TypeParameterSymbol type, TypeParameterSymbol other)
 {
     Debug.Assert(type.Ordinal == other.Ordinal);
     Debug.Assert(NameComparer.Equals(type.Name, other.Name));
     // Comparing constraints is unnecessary: two methods cannot differ by
     // constraints alone and changing the signature of a method is a rude
     // edit. Furthermore, comparing constraint types might lead to a cycle.
     Debug.Assert(type.HasConstructorConstraint == other.HasConstructorConstraint);
     Debug.Assert(type.HasValueTypeConstraint == other.HasValueTypeConstraint);
     Debug.Assert(type.HasReferenceTypeConstraint == other.HasReferenceTypeConstraint);
     Debug.Assert(type.ConstraintTypesNoUseSiteDiagnostics.Length == other.ConstraintTypesNoUseSiteDiagnostics.Length);
     return(true);
 }
Exemple #12
0
            private bool AreMethodsEqual(MethodSymbol method, MethodSymbol other)
            {
                Debug.Assert(NameComparer.Equals(method.Name, other.Name));

                Debug.Assert(method.IsDefinition);
                Debug.Assert(other.IsDefinition);

                method = SubstituteTypeParameters(method);
                other  = SubstituteTypeParameters(other);

                return(this.comparer.Equals(method.ReturnType, other.ReturnType) &&
                       method.Parameters.SequenceEqual(other.Parameters, AreParametersEqual) &&
                       method.TypeArguments.SequenceEqual(other.TypeArguments, AreTypesEqual));
            }
            public bool Equals(BytesKey other)
            {
                if (other == null)
                {
                    return(false);
                }

                if (this == other)
                {
                    return(true);
                }

                return(NameComparer.Equals(this.UniqueName, other.UniqueName));
            }
Exemple #14
0
        public bool Equals(Node x, Node y)
        {
            if (ReferenceEquals(x, y))
            {
                return(true);
            }
            if (ReferenceEquals(x, null) || ReferenceEquals(y, null))
            {
                return(false);
            }

            if (IncludeName && !NameComparer.Equals(x.Name, y.Name))
            {
                return(false);
            }

            if (IncludeUserData)
            {
                if (x.UserData.Count != y.UserData.Count)
                {
                    return(false);
                }

                foreach (var entry in x.UserData)
                {
                    if (!y.UserData.TryGetValue(entry.Key, out var value) || !Equals(entry.Value, value))
                    {
                        return(false);
                    }
                }
            }

            if (IncludeInDegree && x.InDegree != y.InDegree)
            {
                return(false);
            }

            if (IncludeOutDegree && x.OutDegree != y.OutDegree)
            {
                return(false);
            }

            return(true);
        }
Exemple #15
0
            public bool Equals(IXmlIdentity x, IXmlIdentity y)
            {
                var nameX = x.Name;
                var nameY = y.Name;

                if (!NameComparer.Equals(nameX.LocalName, nameY.LocalName))
                {
                    return(false);
                }

                if (!XsiTypeComparer.Equals(x.XsiType, y.XsiType))
                {
                    return(false);
                }

                return(nameX.NamespaceUri == null ||
                       nameY.NamespaceUri == null ||
                       NameComparer.Equals(nameX.NamespaceUri, nameY.NamespaceUri));
            }
        /// <summary>
        ///     Try resolving <paramref name="name" /> as a property of the value returned by the <paramref name="valueExpr" />.
        /// </summary>
        private bool TryResolveAsPropertyAccess(DbExpression valueExpr, string name, out DbExpression propertyExpr)
        {
            DebugCheck.NotNull(valueExpr);

            propertyExpr = null;

            if (Helper.IsStructuralType(valueExpr.ResultType.EdmType))
            {
                EdmMember member;
                if (TypeResolver.Perspective.TryGetMember(
                        (StructuralType)valueExpr.ResultType.EdmType, name, _parserOptions.NameComparisonCaseInsensitive /*ignoreCase*/,
                        out member))
                {
                    Debug.Assert(member != null, "member != null");
                    Debug.Assert(NameComparer.Equals(name, member.Name), "this.NameComparer.Equals(name, member.Name)");
                    propertyExpr = DbExpressionBuilder.CreatePropertyExpressionFromMember(valueExpr, member);
                    return(true);
                }
            }

            return(false);
        }
 public override bool ShowInNamespaceCompletion(IClass c)
 {
     foreach (IAttribute attr in c.Attributes)
     {
         if (NameComparer.Equals(attr.Name, "Microsoft.VisualBasic.HideModuleNameAttribute"))
         {
             return(false);
         }
         if (NameComparer.Equals(attr.Name, "HideModuleNameAttribute"))
         {
             return(false);
         }
         if (NameComparer.Equals(attr.Name, "Microsoft.VisualBasic.HideModuleName"))
         {
             return(false);
         }
         if (NameComparer.Equals(attr.Name, "HideModuleName"))
         {
             return(false);
         }
     }
     return(base.ShowInNamespaceCompletion(c));
 }
Exemple #18
0
 protected override bool AreValuesEqual(string x, string y)
 {
     return((null == x) ? null == y : null != y && NameComparer.Equals(x, y));
 }
 /// <summary>
 /// Returns the collection of child nodes with the specified name or empty if no match is found.
 /// </summary>
 /// <param name="name">node name is not case-sensitive.</param>
 /// <returns>Returns the collection of child nodes with the specified name or empty if no match is found.</returns>
 public static IEnumerable <ICfgNode> NestedByName(this ICfgNode parent, string name)
 {
     return(parent.Nested
            .Where(p => NameComparer.Equals(p.Key, name))
            .Select(p => p.Value));
 }
Exemple #20
0
 protected virtual bool IsMatch(IXmlIdentity xmlIdentity)
 {
     return(NameComparer.Equals(localName, xmlIdentity.Name.LocalName) &&
            IsMatchOnNamespaceUri(xmlIdentity) &&
            IsMatchOnXsiType(xmlIdentity));
 }
Exemple #21
0
 private bool AreEventsEqual(EventSymbol @event, EventSymbol other)
 {
     Debug.Assert(NameComparer.Equals(@event.Name, other.Name));
     return(this.comparer.Equals(@event.Type, other.Type));
 }
Exemple #22
0
 private bool AreFieldsEqual(FieldSymbol field, FieldSymbol other)
 {
     Debug.Assert(NameComparer.Equals(field.Name, other.Name));
     return(this.comparer.Equals(field.Type, other.Type));
 }
Exemple #23
0
 private bool AreNamedTypesEqual(NamedTypeSymbol type, NamedTypeSymbol other)
 {
     Debug.Assert(NameComparer.Equals(type.Name, other.Name));
     return(type.TypeArgumentsNoUseSiteDiagnostics.SequenceEqual(other.TypeArgumentsNoUseSiteDiagnostics, AreTypesEqual));
 }
Exemple #24
0
 private bool ArePropertiesEqual(PropertySymbol property, PropertySymbol other)
 {
     Debug.Assert(NameComparer.Equals(property.Name, other.Name));
     return(this.comparer.Equals(property.Type, other.Type) &&
            property.Parameters.SequenceEqual(other.Parameters, AreParametersEqual));
 }
Exemple #25
0
            private IDefinition VisitDefInternal(IDefinition def)
            {
                var type = def as ITypeDefinition;

                if (type != null)
                {
                    var namespaceType = type.AsNamespaceTypeDefinition(this.sourceContext);
                    if (namespaceType != null)
                    {
                        return(VisitNamespaceType(namespaceType));
                    }

                    var nestedType = type.AsNestedTypeDefinition(this.sourceContext);
                    Debug.Assert(nestedType != null);

                    var otherContainer = (ITypeDefinition)this.VisitDef(nestedType.ContainingTypeDefinition);
                    if (otherContainer == null)
                    {
                        return(null);
                    }

                    return(this.VisitTypeMembers(otherContainer, nestedType, GetNestedTypes, (a, b) => NameComparer.Equals(a.Name, b.Name)));
                }

                var member = def as ITypeDefinitionMember;

                if (member != null)
                {
                    var otherContainer = (ITypeDefinition)this.VisitDef(member.ContainingTypeDefinition);
                    if (otherContainer == null)
                    {
                        return(null);
                    }

                    var field = def as IFieldDefinition;
                    if (field != null)
                    {
                        return(this.VisitTypeMembers(otherContainer, field, GetFields, (a, b) => NameComparer.Equals(a.Name, b.Name)));
                    }
                }

                // We are only expecting types and fields currently.
                throw ExceptionUtilities.UnexpectedValue(def);
            }