XrmTools.Meta.Attributes
1.0.2
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package XrmTools.Meta.Attributes --version 1.0.2
NuGet\Install-Package XrmTools.Meta.Attributes -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="XrmTools.Meta.Attributes" Version="1.0.2"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="XrmTools.Meta.Attributes" Version="1.0.2" />
<PackageReference Include="XrmTools.Meta.Attributes"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add XrmTools.Meta.Attributes --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: XrmTools.Meta.Attributes, 1.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package XrmTools.Meta.Attributes@1.0.2
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=XrmTools.Meta.Attributes&version=1.0.2
#tool nuget:?package=XrmTools.Meta.Attributes&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Power Platform Tools - Attributes
By installing this nuget packge, you will be able to use attributes to decorate your Dataverse plugins with metadata to enable code generation and automatic registration. Supported attributes are:
PluginRegistrationAttribute
: Used to decorate a class that implementsIPlugin
to specify the plugin registration details. This attribute should be the first registration attribute on the class.PluginStepAttribute
: Used to decorate a class that implementsIPlugin
to specify the step registration details. This attribute comes after thePluginRegistrationAttribute
and can be used multiple times to register multiple steps for the same plugin.PluginImageAttribute
: Used to decorate a class that implementsIPlugin
to specify the image registration details. This attribute comes after thePluginStepAttribute
and can be used multiple times to register multiple images for the same step.CustomApiAttribute
: Used to decorate a clas that implementsIPlugin
to specify the custom API registration details. This attribute comes after thePluginRegistrattionAttribute
and can be used only once to register a custom API for the same plugin.CustomApiRequestAttribute
: Used to decorate a class, INSIDE the calss that implementsIPlugin
to specify the custom API request parameters. By applying this attribute, all properties of the class will become request parameters for your custom API. This attribute can only be applied to a single class within the plugin class.CustomApiResponseAttribute
: Used to decorate a class, INSIDE the calss that implementsIPlugin
to specify the custom API response properties. By applying this attribute, all properties of the class will become response properties for your custom API. This attribute can only be applied to a single class within the plugin class.
Let's look at some examples:
Example 1: Plugin Registration
using Microsoft.Xrm.Sdk;
using System;
using XrmTools.Meta.Attributes;
using XrmTools.Meta.Model;
namespace XrmGenTest;
[Plugin]
[Step("Create", "contact", "firstname,lastname", Stages.PostOperation, ExecutionMode.Synchronous)]
[Image(ImageTypes.PostImage, "firstname,lastname")]
public partial class ContactCreatePlugin : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
if (serviceProvider == null)
{
throw new InvalidPluginExecutionException(nameof(serviceProvider));
}
Initialize(serviceProvider);
}
}
Example 2: Plugin Registration with a PluginBase class
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Extensions;
using System;
using XrmTools.Meta.Attributes;
using XrmTools.Meta.Model;
namespace XrmGenTest;
public abstract class PluginBase : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
if (serviceProvider == null)
{
throw new InvalidPluginExecutionException(nameof(serviceProvider));
}
var executionContext = serviceProvider.Get<IPluginExecutionContext7>();
var organizationService = serviceProvider.GetOrganizationService(executionContext.UserId);
var tracing = serviceProvider.Get<ITracingService>();
Initialize(serviceProvider);
}
internal virtual void Initialize(IServiceProvider serviceProvider) { }
}
[Plugin]
[Step("Create", "account", "accountnumber,accountcategorycode,accountclassificationcode", Stages.PostOperation, ExecutionMode.Synchronous)]
[Image(ImageTypes.PostImage, "accountnumber")]
public partial class AccountCreatePlugin : PluginBase, IPlugin
{
public void ExecuteLocal(IServiceProvider serviceProvider)
{
// It's just business logic!
}
}
Example 3: Custom API Registration
using Microsoft.Xrm.Sdk;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XrmTools.Meta.Attributes;
namespace XrmGenTest;
[Plugin]
[CustomApi("test_MyCustomApi", "My Custom API", "MyCustomApi")]
public partial class MyCustomApiPlugin : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
throw new InvalidPluginExecutionException("Test", PluginHttpStatusCode.ExpectationFailed);
}
[CustomApiRequest]
public class Request
{
public bool BooleanParameter { get; set; }
public DateTime DateTimeParameter { get; set; }
public decimal DecimalParameter { get; set; }
public Entity EntityParameter { get; set; }
public EntityCollection EntityCollectionParameter { get; set; }
public EntityReference EntityReferenceParameter { get; set; }
public float FloatParameter { get; set; }
public int IntegerParameter { get; set; }
public Money MoneyParameter { get; set; }
public OptionSetValue PicklistParameter { get; set; }
public XrmTools.Meta.Model.BindingTypes EnumParameter { get; set; }
public string StringParameter { get; set; }
public string[] StringArrayParameter { get; set; }
public Guid GuidParameter { get; set; }
}
[CustomApiResponse]
public class Response
{
public bool BooleanParameter { get; set; }
public DateTime DateTimeParameter { get; set; }
public decimal DecimalParameter { get; set; }
public Entity EntityParameter { get; set; }
public EntityCollection EntityCollectionParameter { get; set; }
public EntityReference EntityReferenceParameter { get; set; }
public float FloatParameter { get; set; }
public int IntegerParameter { get; set; }
public Money MoneyParameter { get; set; }
public OptionSetValue PicklistParameter { get; set; }
public XrmTools.Meta.Model.BindingTypes EnumParameter { get; set; }
public string StringParameter { get; set; }
public string[] StringArrayParameter { get; set; }
public Guid GuidParameter { get; set; }
}
}
To learn more about Xrm Tools extension for Visual Studio, please refer to:
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETFramework 4.6.2
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.