-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce CommunityToolkit.Diagnostics for guards (#289)
- Loading branch information
1 parent
f47cebd
commit aea7341
Showing
14 changed files
with
129 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,205 +1,216 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012 IBM Corporation. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Eclipse Distribution License v. 1.0 which accompanies this distribution. | ||
* | ||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html | ||
* and the Eclipse Distribution License is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* Contributors: | ||
* Steve Pitschke - initial API and implementation | ||
*******************************************************************************/ | ||
|
||
using OSLC4Net.Core.Attribute; | ||
|
||
namespace OSLC4Net.Core.Model; | ||
|
||
/// <summary> | ||
/// OSLC ServiceProvider resource | ||
/// </summary> | ||
[OslcNamespace(OslcConstants.OSLC_CORE_NAMESPACE)] | ||
[OslcResourceShape(title = "OSLC Service Provider Resource Shape", describes = new string[] { OslcConstants.TYPE_SERVICE_PROVIDER })] | ||
public class ServiceProvider : AbstractResource | ||
{ | ||
private readonly SortedSet<Uri> details = new SortedUriSet(); | ||
private readonly IList<PrefixDefinition> prefixDefinitions = new List<PrefixDefinition>(); | ||
private readonly IList<Service> services = new List<Service>(); | ||
|
||
private DateTime? created; // TODO - ServiceProvider.created nice to have, but not required. | ||
private string description; | ||
private string identifier; // TODO - ServiceProvider.identifier nice to have, but not required. | ||
private OAuthConfiguration oauthConfiguration; | ||
private Publisher publisher; | ||
private string title; | ||
|
||
public ServiceProvider() : base() | ||
{ | ||
} | ||
|
||
public void AddService(Service srvc) | ||
{ | ||
this.services.Add(srvc); | ||
} | ||
|
||
[OslcDescription("The date and time that this resource was created")] | ||
[OslcPropertyDefinition(OslcConstants.DCTERMS_NAMESPACE + "created")] | ||
[OslcReadOnly] | ||
[OslcTitle("Created")] | ||
/******************************************************************************* | ||
* Copyright (c) 2012 IBM Corporation. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Eclipse Distribution License v. 1.0 which accompanies this distribution. | ||
* | ||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html | ||
* and the Eclipse Distribution License is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* Contributors: | ||
* Steve Pitschke - initial API and implementation | ||
*******************************************************************************/ | ||
|
||
using CommunityToolkit.Diagnostics; | ||
using OSLC4Net.Core.Attribute; | ||
|
||
namespace OSLC4Net.Core.Model; | ||
|
||
/// <summary> | ||
/// OSLC ServiceProvider resource | ||
/// </summary> | ||
[OslcNamespace(OslcConstants.OSLC_CORE_NAMESPACE)] | ||
[OslcResourceShape(title = "OSLC Service Provider Resource Shape", describes = | ||
[ | ||
OslcConstants.TYPE_SERVICE_PROVIDER | ||
])] | ||
public class ServiceProvider : AbstractResource | ||
{ | ||
private readonly SortedSet<Uri> _details = new SortedUriSet(); | ||
private readonly IList<PrefixDefinition> _prefixDefinitions = new List<PrefixDefinition>(); | ||
private readonly IList<Service> _services = new List<Service>(); | ||
|
||
private DateTime? _created; // TODO - ServiceProvider.created nice to have, but not required. | ||
private string _description; | ||
private string _identifier; // TODO - ServiceProvider.identifier nice to have, but not required. | ||
private OAuthConfiguration _oauthConfiguration; | ||
private Publisher _publisher; | ||
private string _title; | ||
|
||
public ServiceProvider() : base() | ||
{ | ||
} | ||
|
||
public void AddService(Service service) | ||
{ | ||
Guard.IsNotNull(service, nameof(service)); | ||
this._services.Add(service); | ||
} | ||
|
||
[OslcDescription("The date and time that this resource was created")] | ||
[OslcPropertyDefinition(OslcConstants.DCTERMS_NAMESPACE + "created")] | ||
[OslcReadOnly] | ||
[OslcTitle("Created")] | ||
public DateTime? GetCreated() | ||
{ | ||
return created; | ||
{ | ||
return _created; | ||
} | ||
|
||
[OslcDescription("Description of the service provider")] | ||
[OslcPropertyDefinition(OslcConstants.DCTERMS_NAMESPACE + "description")] | ||
[OslcReadOnly] | ||
[OslcReadOnly] | ||
[OslcTitle("Description")] | ||
[OslcValueType(ValueType.XMLLiteral)] | ||
[OslcValueType(ValueType.XMLLiteral)] | ||
public string GetDescription() | ||
{ | ||
return description; | ||
return _description; | ||
} | ||
|
||
[OslcDescription("URLs that may be used to retrieve web pages to determine additional details about the service provider")] | ||
[OslcPropertyDefinition(OslcConstants.OSLC_CORE_NAMESPACE + "details")] | ||
[OslcReadOnly] | ||
[OslcTitle("Details")] | ||
[OslcReadOnly] | ||
[OslcTitle("Details")] | ||
public Uri[] GetDetails() | ||
{ | ||
return details.ToArray(); | ||
return _details.ToArray(); | ||
} | ||
|
||
[OslcDescription("A unique identifier for this resource")] | ||
[OslcPropertyDefinition(OslcConstants.DCTERMS_NAMESPACE + "identifier")] | ||
[OslcReadOnly] | ||
[OslcTitle("Identifier")] | ||
[OslcDescription("A unique identifier for this resource")] | ||
[OslcPropertyDefinition(OslcConstants.DCTERMS_NAMESPACE + "identifier")] | ||
[OslcReadOnly] | ||
[OslcTitle("Identifier")] | ||
public string GetIdentifier() | ||
{ | ||
return identifier; | ||
{ | ||
return _identifier; | ||
} | ||
|
||
[OslcDescription("Defines the three OAuth URIs required for a client to act as an OAuth consumer")] | ||
[OslcPropertyDefinition(OslcConstants.OSLC_CORE_NAMESPACE + "oauthConfiguration")] | ||
[OslcRange(OslcConstants.TYPE_O_AUTH_CONFIGURATION)] | ||
[OslcReadOnly] | ||
[OslcReadOnly] | ||
[OslcRepresentation(Representation.Inline)] | ||
[OslcTitle("OAuth Configuration")] | ||
[OslcValueShape(OslcConstants.PATH_RESOURCE_SHAPES + "/" + OslcConstants.PATH_OAUTH_CONFIGURATION)] | ||
[OslcValueType(ValueType.LocalResource)] | ||
[OslcValueShape(OslcConstants.PATH_RESOURCE_SHAPES + "/" + OslcConstants.PATH_OAUTH_CONFIGURATION)] | ||
[OslcValueType(ValueType.LocalResource)] | ||
public OAuthConfiguration GetOauthConfiguration() | ||
{ | ||
return oauthConfiguration; | ||
return _oauthConfiguration; | ||
} | ||
|
||
[OslcDescription("Defines namespace prefixes for use in JSON representations and in forming OSLC Query Syntax strings")] | ||
[OslcName("prefixDefinition")] | ||
[OslcPropertyDefinition(OslcConstants.OSLC_CORE_NAMESPACE + "prefixDefinition")] | ||
[OslcRange(OslcConstants.TYPE_PREFIX_DEFINITION)] | ||
[OslcReadOnly] | ||
[OslcReadOnly] | ||
[OslcRepresentation(Representation.Inline)] | ||
[OslcTitle("Prefix Definitions")] | ||
[OslcValueShape(OslcConstants.PATH_RESOURCE_SHAPES + "/" + OslcConstants.PATH_PREFIX_DEFINITION)] | ||
[OslcValueType(ValueType.LocalResource)] | ||
[OslcValueShape(OslcConstants.PATH_RESOURCE_SHAPES + "/" + OslcConstants.PATH_PREFIX_DEFINITION)] | ||
[OslcValueType(ValueType.LocalResource)] | ||
public PrefixDefinition[] GetPrefixDefinitions() | ||
{ | ||
return prefixDefinitions.ToArray(); | ||
return _prefixDefinitions.ToArray(); | ||
} | ||
|
||
[OslcDescription("Describes the software product that provides the implementation")] | ||
[OslcPropertyDefinition(OslcConstants.DCTERMS_NAMESPACE + "publisher")] | ||
[OslcRange(OslcConstants.TYPE_PUBLISHER)] | ||
[OslcReadOnly] | ||
[OslcReadOnly] | ||
[OslcRepresentation(Representation.Inline)] | ||
[OslcTitle("Publisher")] | ||
[OslcValueShape(OslcConstants.PATH_RESOURCE_SHAPES + "/" + OslcConstants.PATH_PUBLISHER)] | ||
[OslcValueType(ValueType.LocalResource)] | ||
[OslcValueShape(OslcConstants.PATH_RESOURCE_SHAPES + "/" + OslcConstants.PATH_PUBLISHER)] | ||
[OslcValueType(ValueType.LocalResource)] | ||
public Publisher GetPublisher() | ||
{ | ||
return publisher; | ||
return _publisher; | ||
} | ||
|
||
[OslcDescription("Describes services offered by the service provider")] | ||
[OslcName("service")] | ||
[OslcOccurs(Occurs.OneOrMany)] | ||
[OslcPropertyDefinition(OslcConstants.OSLC_CORE_NAMESPACE + "service")] | ||
[OslcRange(OslcConstants.TYPE_SERVICE)] | ||
[OslcReadOnly] | ||
[OslcReadOnly] | ||
[OslcRepresentation(Representation.Inline)] | ||
[OslcTitle("Services")] | ||
[OslcValueShape(OslcConstants.PATH_RESOURCE_SHAPES + "/" + OslcConstants.PATH_SERVICE)] | ||
[OslcValueShape(OslcConstants.PATH_RESOURCE_SHAPES + "/" + OslcConstants.PATH_SERVICE)] | ||
[OslcValueType(ValueType.LocalResource)] | ||
public Service[] GetServices() | ||
{ | ||
return services.ToArray(); | ||
return _services.ToArray(); | ||
} | ||
|
||
[OslcDescription("Title of the service provider")] | ||
[OslcPropertyDefinition(OslcConstants.DCTERMS_NAMESPACE + "title")] | ||
[OslcReadOnly] | ||
[OslcReadOnly] | ||
[OslcTitle("Title")] | ||
[OslcValueType(ValueType.XMLLiteral)] | ||
[OslcValueType(ValueType.XMLLiteral)] | ||
public string GetTitle() | ||
{ | ||
return title; | ||
return _title; | ||
} | ||
|
||
public void SetCreated(DateTime? created) | ||
{ | ||
this.created = created; | ||
} | ||
|
||
{ | ||
this._created = created; | ||
} | ||
|
||
public void SetDescription(string description) | ||
{ | ||
this.description = description; | ||
this._description = description; | ||
} | ||
|
||
public void SetDetails(Uri[] details) | ||
{ | ||
this.details.Clear(); | ||
this._details.Clear(); | ||
if (details != null) | ||
{ | ||
this.details.AddAll(details); | ||
{ | ||
this._details.AddAll(details); | ||
} | ||
} | ||
|
||
public void SetIdentifier(string identifier) | ||
{ | ||
this.identifier = identifier; | ||
{ | ||
this._identifier = identifier; | ||
} | ||
|
||
public void SetOauthConfiguration(OAuthConfiguration oauthConfiguration) | ||
{ | ||
this.oauthConfiguration = oauthConfiguration; | ||
this._oauthConfiguration = oauthConfiguration; | ||
} | ||
|
||
public void SetPrefixDefinitions(PrefixDefinition[] prefixDefinitions) | ||
{ | ||
this.prefixDefinitions.Clear(); | ||
this._prefixDefinitions.Clear(); | ||
if (prefixDefinitions != null) | ||
{ | ||
this.prefixDefinitions.AddAll(prefixDefinitions); | ||
{ | ||
this._prefixDefinitions.AddAll(prefixDefinitions); | ||
} | ||
} | ||
|
||
public void SetPublisher(Publisher publisher) | ||
{ | ||
this.publisher = publisher; | ||
this._publisher = publisher; | ||
} | ||
|
||
public void SetServices(Service[] services) | ||
public void SetServices(Service[]? services) | ||
{ | ||
this.services.Clear(); | ||
this._services.Clear(); | ||
if (services != null) | ||
{ | ||
this.services.AddAll(services); | ||
{ | ||
this._services.AddAll(services); | ||
} | ||
} | ||
|
||
public void SetServices(IEnumerable<Service> services) | ||
{ | ||
this._services.Clear(); | ||
this._services.AddAll(services); | ||
} | ||
|
||
public void SetTitle(string title) | ||
{ | ||
this.title = title; | ||
} | ||
} | ||
this._title = title; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.