This documentation is archived and is not being maintained.

StrongNameIdentityPermission.Name Property

Gets or sets the simple name portion of the strong name identity.

[Visual Basic]
Public Property Name As String
[C#]
public string Name {get; set;}
[C++]
public: __property String* get_Name();
public: __property void set_Name(String*);
[JScript]
public function get Name() : String;
public function set Name(String);

Property Value

The simple name of the identity.

Remarks

The value of Name can be an exact name or can be modified by a wildcard character in the final position; for example, both MyCompany.MyDepartment.MyFile and MyCompany.MyDepartment.* are valid names.

Example

[Visual Basic] 
' Intersect creates and returns a new permission that is the intersection of the current 
' permission and the permission specified.
Private Function IntersectDemo() As Boolean

    Dim returnValue As Boolean = True

    Dim Sn1, Sn2 As String
    Dim SnIdPerm1, SnIdPerm2, SnIdPerm3 As StrongNameIdentityPermission

    Dim SnGen1 As New SnGenerator()
    Dim SnGen2 As New SnGenerator()

    SnGen1.ResetIndex()
    While SnGen1.CreateSn(SnIdPerm1, Sn1)
        If SnIdPerm1 Is Nothing Then
            GoTo ContinueWhile1
        End If
        Console.WriteLine("**********************************************************" + ControlChars.Lf)
        SnGen2.ResetIndex()

        While SnGen2.CreateSn(SnIdPerm2, Sn2)
            If SnIdPerm2 Is Nothing Then
                GoTo ContinueWhile2
            End If
            Dim firstPermission As String = IIf(Sn1 = "" Or Sn1 Is Nothing, "null", Sn1)
            Dim secondPermission As String = IIf(Sn2 = "" Or Sn2 Is Nothing, "null", Sn2)
            Try

                SnIdPerm3 = CType(SnIdPerm1.Intersect(SnIdPerm2), StrongNameIdentityPermission)
                If Not (SnIdPerm3 Is Nothing) AndAlso Not (SnIdPerm3.Name Is Nothing) Then

                    Console.WriteLine(("The intersection of " + firstPermission + ControlChars.Lf + ControlChars.Tab + "and  " + secondPermission + " = " + ControlChars.Lf + ControlChars.Tab + CType(SnIdPerm3, StrongNameIdentityPermission).Name.ToString()))
                Else
                    Console.WriteLine(("The intersection of " + firstPermission + ControlChars.Lf + ControlChars.Tab + "and  " + secondPermission + " is null."))
                End If
            Catch e As Exception
                Console.WriteLine(("An exception was thrown for intersection " + e.ToString()))
                returnValue = False
            End Try
ContinueWhile2:
        End While
ContinueWhile1:
    End While

    Return returnValue
End Function 'IntersectDemo


[C#] 
// Intersect creates and returns a new permission that is the intersection of the current 
// permission and the permission specified.
        private bool IntersectDemo()
        {

            bool returnValue = true;

            string sn1,sn2;
            StrongNameIdentityPermission snIdPerm1,snIdPerm2,snIdPerm3;

            SnGenerator snGen1 = new SnGenerator();
            SnGenerator snGen2 = new SnGenerator();

            snGen1.ResetIndex();
            while(snGen1.CreateSn(out snIdPerm1, out sn1)) 
            {
                if(snIdPerm1 == null) continue;
                Console.WriteLine("**********************************************************\n");
                snGen2.ResetIndex();

                while(snGen2.CreateSn(out snIdPerm2, out sn2)) 
                {
                    if(snIdPerm2 == null) continue;
                    string firstPermission = sn1 == "" | sn1 == null ? "null" : sn1 ;
                    string secondPermission = sn2 == "" | sn2 == null ? "null" : sn2;
                    try
                    {
            
                        snIdPerm3 = (StrongNameIdentityPermission)snIdPerm1.Intersect(snIdPerm2);
                        if (snIdPerm3 != null && snIdPerm3.Name != null)
                        {

                            Console.WriteLine("The intersection of " + firstPermission + "\n\tand  "  
                                + secondPermission + " = \n\t" 
                                + ((StrongNameIdentityPermission)snIdPerm3).Name.ToString());
                        }
                        else
                        {
                            Console.WriteLine("The intersection of " + firstPermission + "\n\tand  "  
                                + secondPermission + " is null.");
                        }
                    }
                    catch(Exception e) 
                    {
                        Console.WriteLine("An exception was thrown for intersection "  + e);
                        returnValue=false;
                    }
                }
            }

            return returnValue;

        }

[C++] 
// Intersect creates and returns a new permission that is the intersection of the current
// permission and the permission specified.
bool IntersectDemo() {

   bool returnValue = true;

   String* sn1, *sn2;
   StrongNameIdentityPermission *snIdPerm1, *snIdPerm2, *snIdPerm3;

   SnGenerator* snGen1 = new SnGenerator();
   SnGenerator* snGen2 = new SnGenerator();

   snGen1->ResetIndex();
   while(snGen1->CreateSn(&snIdPerm1, &sn1)) {
      if (snIdPerm1 == 0) continue;
      Console::WriteLine(S"**********************************************************\n");
      snGen2->ResetIndex();

      while(snGen2->CreateSn(&snIdPerm2, &sn2)) {
         if (snIdPerm2 == 0) continue;
         String* firstPermission = sn1->Equals(S"") || sn1 == 0 ? S"null" : sn1 ;
         String* secondPermission = sn2->Equals(S"") || sn2 == 0 ? S"null" : sn2;
         try {
            snIdPerm3 = dynamic_cast<StrongNameIdentityPermission*>(snIdPerm1->Intersect(snIdPerm2));
            if (snIdPerm3 != 0 && snIdPerm3->Name != 0) {
               Console::WriteLine(S"The intersection of {0}\n\tand  {1} = \n\t{2}",
                  firstPermission,
                  secondPermission,
                  (dynamic_cast<StrongNameIdentityPermission*>(snIdPerm3))->Name);
            } else {
               Console::WriteLine(S"The intersection of {0}\n\tand  {1} is null.",
                  firstPermission, secondPermission);
            }
         } catch (Exception* e) {
            Console::WriteLine(S"An exception was thrown for intersection {0}", e);
            returnValue=false;
         }
      }
   }

   return returnValue;

}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

StrongNameIdentityPermission Class | StrongNameIdentityPermission Members | System.Security.Permissions Namespace

Show: