SharedPropertyGroup Class
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents a collection of shared properties. This class cannot be inherited.
public ref class SharedPropertyGroup sealed
[System.Runtime.InteropServices.ComVisible(false)]
public sealed class SharedPropertyGroup
[<System.Runtime.InteropServices.ComVisible(false)>]
type SharedPropertyGroup = class
Public NotInheritable Class SharedPropertyGroup
- Inheritance
-
SharedPropertyGroup
- Attributes
The following code example shows how to use the SharedPropertyGroupManager class to create a SharedPropertyGroup.
#using <System.EnterpriseServices.dll>
using namespace System;
using namespace System::EnterpriseServices;
using namespace System::Reflection;
[assembly:AssemblyKeyFile("..\\common\\key.snk")];
[assembly:ApplicationName("ReceiptNumberGenerator")];
[assembly:ApplicationActivation(ActivationOption::Library)];
public ref class ReceiptNumberGeneratorClass
{
public:
// Generates a new receipt number based on the receipt number
// stored by the Shared Property Manager (SPM)
int GetNextReceiptNumber()
{
bool groupExists;
bool propertyExists;
int nextReceiptNumber = 0;
PropertyLockMode lockMode = PropertyLockMode::SetGet;
PropertyReleaseMode releaseMode = PropertyReleaseMode::Standard;
// Create a shared property group manager.
SharedPropertyGroupManager^ groupManager = gcnew SharedPropertyGroupManager;
// Create a shared property group.
SharedPropertyGroup^ group =
groupManager->CreatePropertyGroup( "Receipts", lockMode, releaseMode, groupExists );
// Create a shared property.
SharedProperty^ ReceiptNumber;
ReceiptNumber = group->CreateProperty( "ReceiptNumber", propertyExists );
// Retrieve the value from shared property, and increment the shared
// property value.
nextReceiptNumber = safe_cast<int>(ReceiptNumber->Value);
ReceiptNumber->Value = nextReceiptNumber + 1;
// Return nextReceiptNumber
return nextReceiptNumber;
}
};
using System;
using System.EnterpriseServices;
using System.Reflection;
[assembly: ApplicationName("ReceiptNumberGenerator")]
[assembly: ApplicationActivation(ActivationOption.Library)]
public class ReceiptNumberGeneratorClass
{
// Generates a new receipt number based on the receipt number
// stored by the Shared Property Manager (SPM)
public int GetNextReceiptNumber()
{
bool groupExists,propertyExists;
int nextReceiptNumber = 0;
PropertyLockMode lockMode = PropertyLockMode.SetGet;
PropertyReleaseMode releaseMode = PropertyReleaseMode.Standard;
// Create a shared property group manager.
SharedPropertyGroupManager groupManager = new SharedPropertyGroupManager();
// Create a shared property group.
SharedPropertyGroup group = groupManager.CreatePropertyGroup("Receipts",
ref lockMode, ref releaseMode, out groupExists);
// Create a shared property.
SharedProperty ReceiptNumber;
ReceiptNumber = group.CreateProperty("ReceiptNumber",out propertyExists);
// Retrieve the value from shared property, and increment the shared
// property value.
nextReceiptNumber = (int) ReceiptNumber.Value;
ReceiptNumber.Value = nextReceiptNumber + 1;
// Return nextReceiptNumber
return nextReceiptNumber;
}
}
Imports System.EnterpriseServices
Imports System.Reflection
<Assembly: ApplicationName("ReceiptNumberGenerator")>
<Assembly: ApplicationActivation(ActivationOption.Library)>
Public Class ReceiptNumberGeneratorClass
' Generates a new receipt number based on the receipt number
' stored by the Shared Property Manager (SPM)
Public Function GetNextReceiptNumber() As Integer
Dim groupExists, propertyExists As Boolean
Dim nextReceiptNumber As Integer = 0
Dim lockMode As PropertyLockMode = PropertyLockMode.SetGet
Dim releaseMode As PropertyReleaseMode = PropertyReleaseMode.Standard
' Create a shared property group manager.
Dim groupManager As New SharedPropertyGroupManager()
' Create a shared property group.
Dim group As SharedPropertyGroup = groupManager.CreatePropertyGroup("Receipts", lockMode, releaseMode, groupExists)
' Create a shared property.
Dim ReceiptNumber As SharedProperty
ReceiptNumber = group.CreateProperty("ReceiptNumber", propertyExists)
' Retrieve the value from shared property, and increment the shared
' property value.
nextReceiptNumber = Fix(ReceiptNumber.Value)
ReceiptNumber.Value = nextReceiptNumber + 1
' Return nextReceiptNumber
Return nextReceiptNumber
End Function 'GetNextReceiptNumber
End Class
The shared property group is synchronized by the containing manager.
Create |
Creates a property with the given name. |
Create |
Creates a property at the given position. |
Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
Get |
Serves as the default hash function. (Inherited from Object) |
Get |
Gets the Type of the current instance. (Inherited from Object) |
Memberwise |
Creates a shallow copy of the current Object. (Inherited from Object) |
Property(String) |
Returns the property with the given name. |
Property |
Returns the property at the given position. |
To |
Returns a string that represents the current object. (Inherited from Object) |
Produkt | Versions |
---|---|
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET feedback
.NET er et åben kildekode projekt. Vælg et link for at give feedback: