dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System ApplicationException.


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System ApplicationException.cs,1.4,1.5 Exception.cs,1.13,1.14 SystemException.cs,1.6,1.7 Type.cs,1.16,1.17
Date: Fri, 04 Apr 2003 18:30:00 -0500

Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/System
In directory subversions:/tmp/cvs-serv2900/runtime/System

Modified Files:
        ApplicationException.cs Exception.cs SystemException.cs 
        Type.cs 
Log Message:


Implement type filters.


Index: ApplicationException.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/ApplicationException.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** ApplicationException.cs     28 Nov 2001 04:22:39 -0000      1.4
--- ApplicationException.cs     4 Apr 2003 23:29:58 -0000       1.5
***************
*** 23,26 ****
--- 23,29 ----
  {
  
+ using System.Runtime.Serialization;
+ 
+ [Serializable]
  public class ApplicationException : Exception
  {
***************
*** 33,36 ****
--- 36,44 ----
        public ApplicationException(String msg, Exception inner)
                : base(msg, inner) {}
+ #if !ECMA_COMPAT
+       protected ApplicationException(SerializationInfo info,
+                                                                  
StreamingContext context)
+               : base(info, context) {}
+ #endif
  
        // Get the default message to use for this exception type.

Index: Exception.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Exception.cs,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** Exception.cs        28 Dec 2002 09:57:33 -0000      1.13
--- Exception.cs        4 Apr 2003 23:29:58 -0000       1.14
***************
*** 77,80 ****
--- 77,86 ----
                        }
                }
+ #if !ECMA_COMPAT
+       protected Exception(SerializationInfo info, StreamingContext context)
+               {
+                       // TODO
+               }
+ #endif
  
        // Private constructor that is used for subclasses that

Index: SystemException.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/SystemException.cs,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** SystemException.cs  28 Dec 2002 09:57:33 -0000      1.6
--- SystemException.cs  4 Apr 2003 23:29:58 -0000       1.7
***************
*** 19,27 ****
   */
  
- using System.Runtime.Serialization;
- 
  namespace System
  {
  
  public class SystemException : Exception
  {
--- 19,28 ----
   */
  
  namespace System
  {
  
+ using System.Runtime.Serialization;
+ 
+ [Serializable]
  public class SystemException : Exception
  {
***************
*** 34,44 ****
        public SystemException(String msg, Exception inner)
                : base(msg, inner) {}
-       
  #if !ECMA_COMPAT
!       [TODO]
!       public SystemException (SerializationInfo info, 
!                                                       StreamingContext ctxt)
!               {
!               }
  #endif
  
--- 35,41 ----
        public SystemException(String msg, Exception inner)
                : base(msg, inner) {}
  #if !ECMA_COMPAT
!       protected SystemException(SerializationInfo info, StreamingContext ctxt)
!               : base(info, ctxt) {}
  #endif
  

Index: Type.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Type.cs,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -r1.16 -r1.17
*** Type.cs     9 Mar 2003 07:37:08 -0000       1.16
--- Type.cs     4 Apr 2003 23:29:58 -0000       1.17
***************
*** 41,51 ****
  
  #if !ECMA_COMPAT
        public static readonly MemberFilter FilterName = 
                                new MemberFilter(FilterNameImpl);
-       
-       [TODO]
        public static readonly MemberFilter FilterAttribute = 
                                new MemberFilter(FilterAttributeImpl);
-       
        public static readonly MemberFilter FilterNameIgnoreCase = 
                                new MemberFilter(FilterNameIgnoreCaseImpl);
--- 41,49 ----
  
  #if !ECMA_COMPAT
+       // Pre-defined member filters.
        public static readonly MemberFilter FilterName = 
                                new MemberFilter(FilterNameImpl);
        public static readonly MemberFilter FilterAttribute = 
                                new MemberFilter(FilterAttributeImpl);
        public static readonly MemberFilter FilterNameIgnoreCase = 
                                new MemberFilter(FilterNameIgnoreCaseImpl);
***************
*** 247,287 ****
                        }
        
!       private static bool FilterNameImpl(     MemberInfo m, 
!                                                                               
Object filterCriteria)
!       {
!               String name= (String)filterCriteria;
!               if(name==null || name.IndexOf('*')==-1)
!               {
!                       return String.Equals(name,m.Name);
!               }
!               else
!               {
!                       // TODO : bit of regexp magic ?
!               }
!               return false;
!       }
  
        private static bool FilterNameIgnoreCaseImpl(MemberInfo m, 
                                                                                
                 Object filterCriteria)
!       {
!               String name= (String)filterCriteria;
!               if(name==null || name.IndexOf('*')==-1)
!               {
!                       return (String.Compare(name,m.Name,true)==0);
!               }
!               else
!               {
!                       // TODO : bit of regexp magic ?
!               }
!               return false;
!       }
  
        private static bool FilterAttributeImpl(MemberInfo m, 
                                                                                
        Object filterCriteria)
!       {
!               throw new NotImplementedException("FilterAttributeImpl");
!       }
  
! #endif
  
        // Get the element type for this type.
--- 245,415 ----
                        }
        
!       // Filter a member based on its name.
!       private static bool FilterNameImpl(MemberInfo m, Object filterCriteria)
!                       {
!                               // Validate the filter critiera.
!                               String filter = (filterCriteria as String);
!                               if(filter == null)
!                               {
!                                       throw new InvalidFilterCriteriaException
!                                               (_("Exception_FilterName"));
!                               }
!                               filter = filter.Trim();
! 
!                               // Get the member name.
!                               String name = m.Name;
!                               if(m is Type)
!                               {
!                                       // Trim nested type names down to their 
last component.
!                                       int index = name.LastIndexOf('+');
!                                       if(index != -1)
!                                       {
!                                               name = name.Substring(index + 
1);
!                                       }
!                               }
  
+                               // Check for prefix matches.
+                               if(filter.EndsWith("*"))
+                               {
+                                       return name.StartsWith
+                                               (filter.Substring(0, 
filter.Length - 1));
+                               }
+ 
+                               // Perform an ordinary match.
+                               return (name == filter);
+                       }
+ 
+       // Filter a member based on its name and ignore case.
        private static bool FilterNameIgnoreCaseImpl(MemberInfo m, 
                                                                                
                 Object filterCriteria)
!                       {
!                               // Validate the filter critiera.
!                               String filter = (filterCriteria as String);
!                               if(filter == null)
!                               {
!                                       throw new InvalidFilterCriteriaException
!                                               (_("Exception_FilterName"));
!                               }
!                               filter = filter.Trim();
! 
!                               // Get the member name.
!                               String name = m.Name;
!                               if(m is Type)
!                               {
!                                       // Trim nested type names down to their 
last component.
!                                       int index = name.LastIndexOf('+');
!                                       if(index != -1)
!                                       {
!                                               name = name.Substring(index + 
1);
!                                       }
!                               }
  
+                               // Check for prefix matches.
+                               if(filter.EndsWith("*"))
+                               {
+                                       filter = filter.Substring(0, 
filter.Length - 1);
+                                       if(name.Length < filter.Length)
+                                       {
+                                               return false;
+                                       }
+                                       return (String.Compare(name, 0, filter, 
0,
+                                                                               
   filter.Length, true) == 0);
+                               }
+ 
+                               // Perform an ordinary match.
+                               return (String.Compare(name, filter, true) == 
0);
+                       }
+ 
+       // Filter a member based on its attributes.
        private static bool FilterAttributeImpl(MemberInfo m, 
                                                                                
        Object filterCriteria)
!                       {
!                               if(filterCriteria == null)
!                               {
!                                       throw new InvalidFilterCriteriaException
!                                               
(_("Exception_FilterAttribute"));
!                               }
!                               if(m is FieldInfo)
!                               {
!                                       // Validate the field criteria.
!                                       FieldAttributes fattrs;
!                                       if(filterCriteria is int)
!                                       {
!                                               fattrs = 
(FieldAttributes)(int)filterCriteria;
!                                       }
!                                       else if(filterCriteria is 
FieldAttributes)
!                                       {
!                                               fattrs = 
(FieldAttributes)filterCriteria;
!                                       }
!                                       else
!                                       {
!                                               throw new 
InvalidFilterCriteriaException
!                                                       
(_("Exception_FilterAttribute"));
!                                       }
  
!                                       // Check the specified conditions.
!                                       FieldAttributes fmattrs = 
((FieldInfo)m).Attributes;
!                                       if((fattrs & 
FieldAttributes.FieldAccessMask) != 0)
!                                       {
!                                               if((fattrs & 
FieldAttributes.FieldAccessMask) !=
!                                                               (fmattrs & 
FieldAttributes.FieldAccessMask))
!                                               {
!                                                       return false;
!                                               }
!                                       }
!                                       fattrs &= (FieldAttributes.Static |
!                                                          
FieldAttributes.InitOnly |
!                                                          
FieldAttributes.Literal |
!                                                          
FieldAttributes.NotSerialized |
!                                                          
FieldAttributes.PinvokeImpl);
!                                       if((fattrs & fmattrs) != fattrs)
!                                       {
!                                               return false;
!                                       }
!                                       return true;
!                               }
!                               else if(m is MethodInfo || m is ConstructorInfo)
!                               {
!                                       // Validate the method criteria.
!                                       MethodAttributes mattrs;
!                                       if(filterCriteria is int)
!                                       {
!                                               mattrs = 
(MethodAttributes)(int)filterCriteria;
!                                       }
!                                       else if(filterCriteria is 
MethodAttributes)
!                                       {
!                                               mattrs = 
(MethodAttributes)filterCriteria;
!                                       }
!                                       else
!                                       {
!                                               throw new 
InvalidFilterCriteriaException
!                                                       
(_("Exception_FilterAttribute"));
!                                       }
! 
!                                       // Check the specified conditions.
!                                       MethodAttributes mmattrs = 
((MethodBase)m).Attributes;
!                                       if((mattrs & 
MethodAttributes.MemberAccessMask) != 0)
!                                       {
!                                               if((mattrs & 
MethodAttributes.MemberAccessMask) !=
!                                                               (mmattrs & 
MethodAttributes.MemberAccessMask))
!                                               {
!                                                       return false;
!                                               }
!                                       }
!                                       mattrs &= (MethodAttributes.Static |
!                                                          
MethodAttributes.Final |
!                                                          
MethodAttributes.Virtual |
!                                                          
MethodAttributes.Abstract |
!                                                          
MethodAttributes.SpecialName);
!                                       if((mattrs & mmattrs) != mattrs)
!                                       {
!                                               return false;
!                                       }
!                                       return true;
!                               }
!                               return false;
!                       }
! 
! #endif // !ECMA_COMPAT
  
        // Get the element type for this type.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]