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/Security MiniXml.cs, 1


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Security MiniXml.cs, 1.4, 1.5 SecurityElement.cs, 1.8, 1.9
Date: Sun, 31 Aug 2003 00:32:40 -0400

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

Modified Files:
        MiniXml.cs SecurityElement.cs 
Log Message:


Add some utility routines to "SecurityElement" and "MiniXml".


Index: MiniXml.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/MiniXml.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** MiniXml.cs  31 Aug 2003 03:41:06 -0000      1.4
--- MiniXml.cs  31 Aug 2003 04:32:38 -0000      1.5
***************
*** 22,26 ****
  {
  
! #if CONFIG_PERMISSIONS || CONFIG_POLICY_OBJECTS
  
  using System;
--- 22,26 ----
  {
  
! #if CONFIG_PERMISSIONS || CONFIG_POLICY_OBJECTS || CONFIG_REMOTING
  
  using System;
***************
*** 407,413 ****
                        }
  
  }; // class MiniXml
  
! #endif // CONFIG_PERMISSIONS || CONFIG_POLICY_OBJECTS
  
  }; // namespace System.Security
--- 407,429 ----
                        }
  
+       // Load the contents of an XML file.
+       public static SecurityElement Load(String filename)
+                       {
+                               try
+                               {
+                                       StreamReader reader = new 
StreamReader(filename);
+                                       SecurityElement e = (new 
MiniXml(reader)).Parse();
+                                       reader.Close();
+                                       return e;
+                               }
+                               catch(Exception)
+                               {
+                                       return null;
+                               }
+                       }
+ 
  }; // class MiniXml
  
! #endif // CONFIG_PERMISSIONS || CONFIG_POLICY_OBJECTS || CONFIG_REMOTING
  
  }; // namespace System.Security

Index: SecurityElement.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/SecurityElement.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** SecurityElement.cs  24 Jul 2003 05:02:44 -0000      1.8
--- SecurityElement.cs  31 Aug 2003 04:32:38 -0000      1.9
***************
*** 23,27 ****
  {
  
! #if CONFIG_PERMISSIONS || CONFIG_POLICY_OBJECTS
  
  using System;
--- 23,27 ----
  {
  
! #if CONFIG_PERMISSIONS || CONFIG_POLICY_OBJECTS || CONFIG_REMOTING
  
  using System;
***************
*** 695,701 ****
                        }
  
  }; // class SecurityElement
  
! #endif // CONFIG_PERMISSIONS || CONFIG_POLICY_OBJECTS
  
  }; // namespace System.Security
--- 695,742 ----
                        }
  
+       // Search for a child by tag path.
+       internal SecurityElement SearchForChildByPath(params String[] tags)
+                       {
+                               if(tags == null)
+                               {
+                                       throw new ArgumentNullException("tags");
+                               }
+                               SecurityElement current = this;
+                               foreach(String tag in tags)
+                               {
+                                       current = 
current.SearchForChildByTag(tag);
+                                       if(current == null)
+                                       {
+                                               break;
+                                       }
+                               }
+                               return current;
+                       }
+ 
+       // Get the value of an attribute by tag path.  The last string
+       // in the path is the attribute name.
+       internal String AttributeByPath(params String[] tags)
+                       {
+                               if(tags == null)
+                               {
+                                       throw new ArgumentNullException("tags");
+                               }
+                               SecurityElement current = this;
+                               int posn = 0;
+                               while(posn < (tags.Length - 1))
+                               {
+                                       current = 
current.SearchForChildByTag(tags[posn]);
+                                       if(current == null)
+                                       {
+                                               return null;
+                                       }
+                                       ++posn;
+                               }
+                               return current.Attribute(tags[posn]);
+                       }
+ 
  }; // class SecurityElement
  
! #endif // CONFIG_PERMISSIONS || CONFIG_POLICY_OBJECTS || CONFIG_REMOTING
  
  }; // namespace System.Security





reply via email to

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