示例#1
0
 void AddPropertiesFromBaseType(List <IProperty> l, IReturnType baseType)
 {
     if (baseType != null)
     {
         foreach (IProperty p in baseType.GetProperties())
         {
             bool ok = true;
             if (p.IsOverridable)
             {
                 StringComparer comparer = p.DeclaringType.ProjectContent.Language.NameComparer;
                 foreach (IProperty oldProperty in c.Properties)
                 {
                     if (comparer.Equals(oldProperty.Name, p.Name))
                     {
                         if (p.IsStatic == oldProperty.IsStatic && object.Equals(p.ReturnType, oldProperty.ReturnType))
                         {
                             if (DiffUtility.Compare(oldProperty.Parameters, p.Parameters) == 0)
                             {
                                 ok = false;
                                 break;
                             }
                         }
                     }
                 }
             }
             if (ok)
             {
                 l.Add(p);
             }
         }
     }
 }
示例#2
0
        public virtual int CompareTo(IMethod value)
        {
            int cmp;

            cmp = base.CompareTo((IDecoration)value);

            if (cmp != 0)
            {
                return(cmp);
            }

            if (FullyQualifiedName != null)
            {
                cmp = FullyQualifiedName.CompareTo(value.FullyQualifiedName);
                if (cmp != 0)
                {
                    return(cmp);
                }
            }

            cmp = this.TypeParameters.Count - value.TypeParameters.Count;
            if (cmp != 0)
            {
                return(cmp);
            }

            return(DiffUtility.Compare(Parameters, value.Parameters));
        }
        public virtual int CompareTo(IProperty value)
        {
            int cmp = string.CompareOrdinal(this.FullyQualifiedName, value.FullyQualifiedName);

            if (cmp != 0)
            {
                return(cmp);
            }

            return(DiffUtility.Compare(Parameters, value.Parameters));
        }
示例#4
0
        public virtual int CompareTo(IMethod value)
        {
            int cmp = string.CompareOrdinal(this.FullyQualifiedName, value.FullyQualifiedName);

            if (cmp != 0)
            {
                return(cmp);
            }

            cmp = this.TypeParameters.Count - value.TypeParameters.Count;
            if (cmp != 0)
            {
                return(cmp);
            }

            return(DiffUtility.Compare(Parameters, value.Parameters));
        }
        public static IMember FindSimilarMember(IClass type, IMember member)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            StringComparer nameComparer = member.DeclaringType.ProjectContent.Language.NameComparer;

            member = GetGenericMember(member);
            if (member is IMethod)
            {
                IMethod parentMethod = (IMethod)member;
                foreach (IMethod m in type.Methods)
                {
                    if (nameComparer.Equals(parentMethod.Name, m.Name))
                    {
                        if (m.IsStatic == parentMethod.IsStatic)
                        {
                            if (DiffUtility.Compare(parentMethod.Parameters, m.Parameters) == 0)
                            {
                                return(m);
                            }
                        }
                    }
                }
            }
            else if (member is IProperty)
            {
                IProperty parentMethod = (IProperty)member;
                foreach (IProperty m in type.Properties)
                {
                    if (nameComparer.Equals(parentMethod.Name, m.Name))
                    {
                        if (m.IsStatic == parentMethod.IsStatic)
                        {
                            if (DiffUtility.Compare(parentMethod.Parameters, m.Parameters) == 0)
                            {
                                return(m);
                            }
                        }
                    }
                }
            }
            return(null);
        }
        static bool IsSimilarMemberInternal(IMember member1, IMember member2)
        {
            if (member1 == member2)
            {
                return(true);
            }
            if (member1 == null || member2 == null)
            {
                return(false);
            }
            if (member1.FullyQualifiedName != member2.FullyQualifiedName)
            {
                return(false);
            }
            if (member1.IsStatic != member2.IsStatic)
            {
                return(false);
            }
            IMethodOrProperty m1 = member1 as IMethodOrProperty;
            IMethodOrProperty m2 = member2 as IMethodOrProperty;

            if (m1 != null || m2 != null)
            {
                if (m1 != null && m2 != null)
                {
                    if (DiffUtility.Compare(m1.Parameters, m2.Parameters) != 0)
                    {
                        return(false);
                    }
                    if (m1 is IMethod && m2 is IMethod)
                    {
                        if ((m1 as IMethod).TypeParameters.Count != (m2 as IMethod).TypeParameters.Count)
                        {
                            return(false);
                        }
                    }
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }
示例#7
0
        public virtual int CompareTo(IProperty value)
        {
            int cmp;

            if (0 != (cmp = base.CompareTo((IDecoration)value)))
            {
                return(cmp);
            }

            if (FullyQualifiedName != null)
            {
                cmp = FullyQualifiedName.CompareTo(value.FullyQualifiedName);
                if (cmp != 0)
                {
                    return(cmp);
                }
            }

            return(DiffUtility.Compare(Parameters, value.Parameters));
        }
 public static IMember FindSimilarMember(IClass type, IMember member)
 {
     member = GetGenericMember(member);
     if (member is IMethod)
     {
         IMethod parentMethod = (IMethod)member;
         foreach (IMethod m in type.Methods)
         {
             if (string.Equals(parentMethod.Name, m.Name, StringComparison.InvariantCultureIgnoreCase))
             {
                 if (m.IsStatic == parentMethod.IsStatic)
                 {
                     if (DiffUtility.Compare(parentMethod.Parameters, m.Parameters) == 0)
                     {
                         return(m);
                     }
                 }
             }
         }
     }
     else if (member is IProperty)
     {
         IProperty parentMethod = (IProperty)member;
         foreach (IProperty m in type.Properties)
         {
             if (string.Equals(parentMethod.Name, m.Name, StringComparison.InvariantCultureIgnoreCase))
             {
                 if (m.IsStatic == parentMethod.IsStatic)
                 {
                     if (DiffUtility.Compare(parentMethod.Parameters, m.Parameters) == 0)
                     {
                         return(m);
                     }
                 }
             }
         }
     }
     return(null);
 }
示例#9
0
        void AddMethodsFromBaseType(List <IMethod> l, IReturnType baseType)
        {
            if (baseType != null)
            {
                foreach (IMethod m in baseType.GetMethods())
                {
                    if (m.IsConstructor)
                    {
                        continue;
                    }

                    bool ok = true;
                    if (m.IsOverridable)
                    {
                        StringComparer comparer = m.DeclaringType.ProjectContent.Language.NameComparer;
                        foreach (IMethod oldMethod in c.Methods)
                        {
                            if (comparer.Equals(oldMethod.Name, m.Name))
                            {
                                if (m.IsStatic == oldMethod.IsStatic && object.Equals(m.ReturnType, oldMethod.ReturnType))
                                {
                                    if (DiffUtility.Compare(oldMethod.Parameters, m.Parameters) == 0)
                                    {
                                        ok = false;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    if (ok)
                    {
                        l.Add(m);
                    }
                }
            }
        }