mirror of
https://github.com/actions/runner.git
synced 2025-12-11 04:46:58 +00:00
c
This commit is contained in:
@@ -1,80 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.Serialization;
|
||||
using GitHub.Services.Common;
|
||||
using GitHub.Services.Common.Internal;
|
||||
using GitHub.Services.WebApi;
|
||||
using GitHub.Services.WebApi.Patch;
|
||||
using GitHub.Services.WebApi.Patch.Json;
|
||||
|
||||
namespace GitHub.Core.WebApi
|
||||
{
|
||||
[GenerateAllConstants]
|
||||
public enum ProjectState
|
||||
{
|
||||
/// <summary>
|
||||
/// Project is in the process of being deleted.
|
||||
/// </summary>
|
||||
[EnumMember]
|
||||
Deleting = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Project is in the process of being created.
|
||||
/// </summary>
|
||||
[EnumMember]
|
||||
New = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Project is completely created and ready to use.
|
||||
/// </summary>
|
||||
[EnumMember]
|
||||
WellFormed = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Project has been queued for creation, but the process has not yet started.
|
||||
/// </summary>
|
||||
[EnumMember]
|
||||
CreatePending = 3,
|
||||
|
||||
/// <summary>
|
||||
/// All projects regardless of state.
|
||||
/// </summary>
|
||||
[EnumMember]
|
||||
All = -1, // Used for filtering.
|
||||
|
||||
/// <summary>
|
||||
/// Project has not been changed.
|
||||
/// </summary>
|
||||
[EnumMember]
|
||||
Unchanged = -2, // Used for updating projects.
|
||||
|
||||
/// <summary>
|
||||
/// Project has been deleted.
|
||||
/// </summary>
|
||||
[EnumMember]
|
||||
Deleted = 4, // Used for the project history.
|
||||
}
|
||||
|
||||
public enum ProjectVisibility // Stored as a TINYINT
|
||||
{
|
||||
[ClientInternalUseOnly]
|
||||
Unchanged = -1, // Used for updating projects.
|
||||
/// <summary>
|
||||
/// The project is only visible to users with explicit access.
|
||||
/// </summary>
|
||||
Private = 0,
|
||||
/// <summary>
|
||||
/// Enterprise level project visibility
|
||||
/// </summary>
|
||||
[ClientInternalUseOnly(omitFromTypeScriptDeclareFile: false)]
|
||||
Organization = 1,
|
||||
/// <summary>
|
||||
/// The project is visible to all.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
Public = 2,
|
||||
[ClientInternalUseOnly]
|
||||
SystemPrivate = 3 // Soft-deleted projects
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using GitHub.Services.Common;
|
||||
using GitHub.Services.WebApi;
|
||||
|
||||
namespace GitHub.Core.WebApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a shallow reference to a TeamProject.
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
public class TeamProjectReference : ISecuredObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor to ensure we set up the project state correctly for serialization.
|
||||
/// </summary>
|
||||
public TeamProjectReference()
|
||||
{
|
||||
State = ProjectState.Unchanged;
|
||||
Visibility = ProjectVisibility.Unchanged;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Project identifier.
|
||||
/// </summary>
|
||||
[DataMember(Order = 0, EmitDefaultValue = false)]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Project abbreviation.
|
||||
/// </summary>
|
||||
[DataMember(Order = 1, EmitDefaultValue = false)]
|
||||
public string Abbreviation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Project name.
|
||||
/// </summary>
|
||||
[DataMember(Order = 2, EmitDefaultValue = false)]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The project's description (if any).
|
||||
/// </summary>
|
||||
[DataMember(Order = 3, EmitDefaultValue = false)]
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Url to the full version of the object.
|
||||
/// </summary>
|
||||
[DataMember(Order = 4, EmitDefaultValue = false)]
|
||||
public string Url { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Project state.
|
||||
/// </summary>
|
||||
[DataMember(Order = 5)]
|
||||
public ProjectState State { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Project revision.
|
||||
/// </summary>
|
||||
[DataMember(Order = 6, EmitDefaultValue = false)]
|
||||
public Int64 Revision { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Project visibility.
|
||||
/// </summary>
|
||||
[DataMember(Order = 7)]
|
||||
public ProjectVisibility Visibility { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Url to default team identity image.
|
||||
/// </summary>
|
||||
[DataMember(Order = 8, EmitDefaultValue = false)]
|
||||
public String DefaultTeamImageUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Project last update time.
|
||||
/// </summary>
|
||||
[DataMember(Order = 9)]
|
||||
public DateTime LastUpdateTime { get; set; }
|
||||
|
||||
#region ISecuredObject
|
||||
Guid ISecuredObject.NamespaceId => NamespaceId;
|
||||
|
||||
int ISecuredObject.RequiredPermissions => RequiredPermissions;
|
||||
|
||||
string ISecuredObject.GetToken()
|
||||
{
|
||||
return GetToken();
|
||||
}
|
||||
|
||||
protected virtual Guid NamespaceId => TeamProjectSecurityConstants.NamespaceId;
|
||||
|
||||
protected virtual int RequiredPermissions => TeamProjectSecurityConstants.GenericRead;
|
||||
|
||||
protected virtual string GetToken()
|
||||
{
|
||||
// WE DON'T CARE THIS FOR NOW
|
||||
return TeamProjectSecurityConstants.GetToken(Id.ToString("D"));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using GitHub.Services.WebApi;
|
||||
|
||||
namespace GitHub.DistributedTask.Common.Contracts
|
||||
{
|
||||
[DataContract]
|
||||
public class AuthorizationHeader : BaseSecuredObject
|
||||
{
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public String Name { get; set; }
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public String Value { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,149 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using GitHub.Services.Common;
|
||||
using GitHub.Services.WebApi;
|
||||
|
||||
namespace GitHub.DistributedTask.Common.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents binding of data source for the service endpoint request.
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
public class DataSourceBindingBase : BaseSecuredObject
|
||||
{
|
||||
public DataSourceBindingBase()
|
||||
{
|
||||
}
|
||||
|
||||
protected DataSourceBindingBase(DataSourceBindingBase inputDefinitionToClone)
|
||||
: this(inputDefinitionToClone, null)
|
||||
{
|
||||
}
|
||||
|
||||
protected DataSourceBindingBase(DataSourceBindingBase inputDefinitionToClone, ISecuredObject securedObject)
|
||||
: base(securedObject)
|
||||
{
|
||||
this.DataSourceName = inputDefinitionToClone.DataSourceName;
|
||||
this.EndpointId = inputDefinitionToClone.EndpointId;
|
||||
this.Target = inputDefinitionToClone.Target;
|
||||
this.ResultTemplate = inputDefinitionToClone.ResultTemplate;
|
||||
this.EndpointUrl = inputDefinitionToClone.EndpointUrl;
|
||||
this.ResultSelector = inputDefinitionToClone.ResultSelector;
|
||||
this.RequestVerb = inputDefinitionToClone.RequestVerb;
|
||||
this.RequestContent = inputDefinitionToClone.RequestContent;
|
||||
this.CallbackContextTemplate = inputDefinitionToClone.CallbackContextTemplate;
|
||||
this.CallbackRequiredTemplate = inputDefinitionToClone.CallbackRequiredTemplate;
|
||||
this.InitialContextTemplate = inputDefinitionToClone.InitialContextTemplate;
|
||||
inputDefinitionToClone.Parameters.Copy(this.Parameters);
|
||||
this.CloneHeaders(inputDefinitionToClone.Headers);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the data source.
|
||||
/// </summary>
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public string DataSourceName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the parameters for the data source.
|
||||
/// </summary>
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public Dictionary<string, string> Parameters
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_parameters == null)
|
||||
{
|
||||
m_parameters = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
return m_parameters;
|
||||
}
|
||||
}
|
||||
|
||||
public DataSourceBindingBase Clone(ISecuredObject securedObject)
|
||||
{
|
||||
return new DataSourceBindingBase(this, securedObject);
|
||||
}
|
||||
|
||||
private void CloneHeaders(List<AuthorizationHeader> headers)
|
||||
{
|
||||
if (headers == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.Headers = headers.Select(header => new AuthorizationHeader { Name = header.Name, Value = header.Value }).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the endpoint Id.
|
||||
/// </summary>
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public String EndpointId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the target of the data source.
|
||||
/// </summary>
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public String Target { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the result template.
|
||||
/// </summary>
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public String ResultTemplate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets http request verb
|
||||
/// </summary>
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public String RequestVerb { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets http request body
|
||||
/// </summary>
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public String RequestContent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the url of the service endpoint.
|
||||
/// </summary>
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public String EndpointUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the result selector.
|
||||
/// </summary>
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public String ResultSelector { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Pagination format supported by this data source(ContinuationToken/SkipTop).
|
||||
/// </summary>
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public String CallbackContextTemplate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Subsequent calls needed?
|
||||
/// </summary>
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public String CallbackRequiredTemplate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Defines the initial value of the query params
|
||||
/// </summary>
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public String InitialContextTemplate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the authorization headers.
|
||||
/// </summary>
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public List<AuthorizationHeader> Headers { get; set; }
|
||||
|
||||
private Dictionary<String, String> m_parameters;
|
||||
}
|
||||
}
|
||||
@@ -1,163 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using GitHub.DistributedTask.WebApi;
|
||||
using GitHub.Services.Common;
|
||||
using GitHub.Services.WebApi;
|
||||
|
||||
namespace GitHub.DistributedTask.Common.Contracts
|
||||
{
|
||||
[DataContract]
|
||||
public class ProcessParameters : BaseSecuredObject
|
||||
{
|
||||
public ProcessParameters()
|
||||
: this(null)
|
||||
{
|
||||
}
|
||||
|
||||
public ProcessParameters(ISecuredObject securedObject)
|
||||
: this(null, securedObject)
|
||||
{
|
||||
}
|
||||
|
||||
private ProcessParameters(ProcessParameters toClone, ISecuredObject securedObject)
|
||||
: base(securedObject)
|
||||
{
|
||||
if (toClone != null)
|
||||
{
|
||||
if (toClone.Inputs.Count > 0)
|
||||
{
|
||||
Inputs.AddRange(toClone.Inputs.Select(i => i.Clone(securedObject)));
|
||||
}
|
||||
|
||||
if (toClone.SourceDefinitions.Count > 0)
|
||||
{
|
||||
SourceDefinitions.AddRange(toClone.SourceDefinitions.Select(sd => sd.Clone(securedObject)));
|
||||
}
|
||||
|
||||
if (toClone.DataSourceBindings.Count > 0)
|
||||
{
|
||||
DataSourceBindings.AddRange(toClone.DataSourceBindings.Select(dsb => dsb.Clone(securedObject)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IList<TaskInputDefinitionBase> Inputs
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_inputs == null)
|
||||
{
|
||||
m_inputs = new List<TaskInputDefinitionBase>();
|
||||
}
|
||||
return m_inputs;
|
||||
}
|
||||
}
|
||||
|
||||
public IList<TaskSourceDefinitionBase> SourceDefinitions
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_sourceDefinitions == null)
|
||||
{
|
||||
m_sourceDefinitions = new List<TaskSourceDefinitionBase>();
|
||||
}
|
||||
return m_sourceDefinitions;
|
||||
}
|
||||
}
|
||||
|
||||
public IList<DataSourceBindingBase> DataSourceBindings
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_dataSourceBindings == null)
|
||||
{
|
||||
m_dataSourceBindings = new List<DataSourceBindingBase>();
|
||||
}
|
||||
return m_dataSourceBindings;
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var processParameters2 = obj as ProcessParameters;
|
||||
if (processParameters2 == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.Inputs == null && processParameters2.Inputs == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((this.Inputs != null && processParameters2.Inputs == null)
|
||||
|| (this.Inputs == null && processParameters2.Inputs != null))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.Inputs.Count != processParameters2.Inputs.Count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var orderedProcessParameters1 = this.Inputs.Where(i => i != null).OrderBy(i => i.Name);
|
||||
var orderedProcessParameters2 = processParameters2.Inputs.Where(i => i != null).OrderBy(i => i.Name);
|
||||
|
||||
if (!orderedProcessParameters1.OrderBy(i => i.Name).SequenceEqual(orderedProcessParameters2))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public ProcessParameters Clone(ISecuredObject securedObject = null)
|
||||
{
|
||||
return new ProcessParameters(this, securedObject);
|
||||
}
|
||||
|
||||
[OnDeserialized]
|
||||
private void OnDeserialized(StreamingContext context)
|
||||
{
|
||||
SerializationHelper.Copy(ref m_serializedInputs, ref m_inputs, true);
|
||||
SerializationHelper.Copy(ref m_serializedSourceDefinitions, ref m_sourceDefinitions, true);
|
||||
SerializationHelper.Copy(ref m_serializedDataSourceBindings, ref m_dataSourceBindings, true);
|
||||
}
|
||||
|
||||
[OnSerializing]
|
||||
private void OnSerializing(StreamingContext context)
|
||||
{
|
||||
SerializationHelper.Copy(ref m_inputs, ref m_serializedInputs);
|
||||
SerializationHelper.Copy(ref m_sourceDefinitions, ref m_serializedSourceDefinitions);
|
||||
SerializationHelper.Copy(ref m_dataSourceBindings, ref m_serializedDataSourceBindings);
|
||||
}
|
||||
|
||||
[OnSerialized]
|
||||
private void OnSerialized(StreamingContext context)
|
||||
{
|
||||
m_serializedInputs = null;
|
||||
m_serializedSourceDefinitions = null;
|
||||
m_serializedDataSourceBindings = null;
|
||||
}
|
||||
|
||||
[DataMember(Name = "Inputs", EmitDefaultValue = false)]
|
||||
private List<TaskInputDefinitionBase> m_serializedInputs;
|
||||
|
||||
[DataMember(Name = "SourceDefinitions", EmitDefaultValue = false)]
|
||||
private List<TaskSourceDefinitionBase> m_serializedSourceDefinitions;
|
||||
|
||||
[DataMember(Name = "DataSourceBindings", EmitDefaultValue = false)]
|
||||
private List<DataSourceBindingBase> m_serializedDataSourceBindings;
|
||||
|
||||
private List<TaskInputDefinitionBase> m_inputs;
|
||||
private List<TaskSourceDefinitionBase> m_sourceDefinitions;
|
||||
private List<DataSourceBindingBase> m_dataSourceBindings;
|
||||
}
|
||||
}
|
||||
@@ -1,254 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using GitHub.Services.WebApi;
|
||||
|
||||
namespace GitHub.DistributedTask.Common.Contracts
|
||||
{
|
||||
[DataContract]
|
||||
public class TaskInputDefinitionBase : BaseSecuredObject
|
||||
{
|
||||
public TaskInputDefinitionBase()
|
||||
{
|
||||
InputType = TaskInputType.String;
|
||||
DefaultValue = String.Empty;
|
||||
Required = false;
|
||||
HelpMarkDown = String.Empty;
|
||||
}
|
||||
|
||||
protected TaskInputDefinitionBase(TaskInputDefinitionBase inputDefinitionToClone)
|
||||
: this(inputDefinitionToClone, null)
|
||||
{
|
||||
}
|
||||
|
||||
protected TaskInputDefinitionBase(TaskInputDefinitionBase inputDefinitionToClone, ISecuredObject securedObject)
|
||||
: base(securedObject)
|
||||
{
|
||||
this.DefaultValue = inputDefinitionToClone.DefaultValue;
|
||||
this.InputType = inputDefinitionToClone.InputType;
|
||||
this.Label = inputDefinitionToClone.Label;
|
||||
this.Name = inputDefinitionToClone.Name;
|
||||
this.Required = inputDefinitionToClone.Required;
|
||||
this.HelpMarkDown = inputDefinitionToClone.HelpMarkDown;
|
||||
this.VisibleRule = inputDefinitionToClone.VisibleRule;
|
||||
this.GroupName = inputDefinitionToClone.GroupName;
|
||||
|
||||
if (inputDefinitionToClone.Validation != null)
|
||||
{
|
||||
this.Validation = inputDefinitionToClone.Validation.Clone(securedObject);
|
||||
}
|
||||
|
||||
if (inputDefinitionToClone.m_aliases != null)
|
||||
{
|
||||
this.m_aliases = new List<String>(inputDefinitionToClone.m_aliases);
|
||||
}
|
||||
|
||||
if (inputDefinitionToClone.m_options != null)
|
||||
{
|
||||
this.m_options = new Dictionary<String, String>(inputDefinitionToClone.m_options);
|
||||
}
|
||||
if (inputDefinitionToClone.m_properties != null)
|
||||
{
|
||||
this.m_properties = new Dictionary<String, String>(inputDefinitionToClone.m_properties);
|
||||
}
|
||||
}
|
||||
|
||||
public IList<String> Aliases
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_aliases == null)
|
||||
{
|
||||
m_aliases = new List<String>();
|
||||
}
|
||||
return m_aliases;
|
||||
}
|
||||
}
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public String Name
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public String Label
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public String DefaultValue
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public Boolean Required
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[DataMember(Name = "Type")]
|
||||
public String InputType
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public String HelpMarkDown
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
// VisibleRule should specify the condition at which this input is to be shown/displayed
|
||||
// Typical format is "NAME OF THE DEPENDENT INPUT = VALUE TOBE BOUND"
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public string VisibleRule
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public string GroupName
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public TaskInputValidation Validation
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Dictionary<String, String> Options
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_options == null)
|
||||
{
|
||||
m_options = new Dictionary<String, String>();
|
||||
}
|
||||
return m_options;
|
||||
}
|
||||
}
|
||||
|
||||
public Dictionary<String, String> Properties
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_properties == null)
|
||||
{
|
||||
m_properties = new Dictionary<String, String>();
|
||||
}
|
||||
return m_properties;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual TaskInputDefinitionBase Clone(
|
||||
ISecuredObject securedObject)
|
||||
{
|
||||
return new TaskInputDefinitionBase(this, securedObject);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return this.Name.GetHashCode() ^ this.DefaultValue.GetHashCode() ^ this.Label.GetHashCode();
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var taskInput2 = obj as TaskInputDefinitionBase;
|
||||
if (taskInput2 == null
|
||||
|| !string.Equals(InputType, taskInput2.InputType, StringComparison.OrdinalIgnoreCase)
|
||||
|| !string.Equals(Label, taskInput2.Label, StringComparison.OrdinalIgnoreCase)
|
||||
|| !string.Equals(Name, taskInput2.Name, StringComparison.OrdinalIgnoreCase)
|
||||
|| !string.Equals(GroupName, taskInput2.GroupName, StringComparison.OrdinalIgnoreCase)
|
||||
|| !string.Equals(DefaultValue, taskInput2.DefaultValue, StringComparison.OrdinalIgnoreCase)
|
||||
|| !string.Equals(HelpMarkDown, taskInput2.HelpMarkDown, StringComparison.OrdinalIgnoreCase)
|
||||
|| !string.Equals(VisibleRule, taskInput2.VisibleRule, StringComparison.OrdinalIgnoreCase)
|
||||
|| !this.Required.Equals(taskInput2.Required))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!AreListsEqual(Aliases, taskInput2.Aliases)
|
||||
|| !AreDictionariesEqual(Properties, taskInput2.Properties)
|
||||
|| !AreDictionariesEqual(Options, taskInput2.Options))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((Validation != null && taskInput2.Validation == null)
|
||||
|| (Validation == null && taskInput2.Validation != null)
|
||||
|| ((Validation != null && taskInput2.Validation != null)
|
||||
&& !Validation.Equals(taskInput2.Validation)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool AreDictionariesEqual(Dictionary<String, String> input1, Dictionary<String, String> input2)
|
||||
{
|
||||
if (input1 == null && input2 == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((input1 == null && input2 != null)
|
||||
|| (input1 != null && input2 == null)
|
||||
|| (input1.Count != input2.Count))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (var key in input1.Keys)
|
||||
{
|
||||
if (!(input2.ContainsKey(key) && String.Equals(input1[key], input2[key], StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private Boolean AreListsEqual(IList<String> list1, IList<String> list2)
|
||||
{
|
||||
if (list1.Count != list2.Count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Int32 i = 0; i < list1.Count; i++)
|
||||
{
|
||||
if (!String.Equals(list1[i], list2[i], StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
[DataMember(Name = "Aliases", EmitDefaultValue = false)]
|
||||
private List<String> m_aliases;
|
||||
|
||||
[DataMember(Name = "Options", EmitDefaultValue = false)]
|
||||
private Dictionary<String, String> m_options;
|
||||
|
||||
[DataMember(Name = "Properties", EmitDefaultValue = false)]
|
||||
private Dictionary<String, String> m_properties;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using System.Runtime.Serialization;
|
||||
using System;
|
||||
|
||||
namespace GitHub.DistributedTask.Common.Contracts
|
||||
{
|
||||
public static class TaskInputType
|
||||
{
|
||||
public const String String = "string";
|
||||
public const String Repository = "repository";
|
||||
public const String Boolean = "boolean";
|
||||
public const String KeyValue = "keyvalue";
|
||||
public const String FilePath = "filepath";
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using GitHub.Services.WebApi;
|
||||
|
||||
namespace GitHub.DistributedTask.Common.Contracts
|
||||
{
|
||||
[DataContract]
|
||||
public class TaskInputValidation : BaseSecuredObject
|
||||
{
|
||||
public TaskInputValidation()
|
||||
{
|
||||
}
|
||||
|
||||
private TaskInputValidation(TaskInputValidation toClone, ISecuredObject securedObject)
|
||||
: base(securedObject)
|
||||
{
|
||||
if (toClone != null)
|
||||
{
|
||||
this.Expression = toClone.Expression;
|
||||
this.Message = toClone.Message;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Conditional expression
|
||||
/// </summary>
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public String Expression
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Message explaining how user can correct if validation fails
|
||||
/// </summary>
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public String Message
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Expression.GetHashCode() ^ Message.GetHashCode();
|
||||
}
|
||||
|
||||
public TaskInputValidation Clone()
|
||||
{
|
||||
return this.Clone(null);
|
||||
}
|
||||
|
||||
public TaskInputValidation Clone(ISecuredObject securedObject)
|
||||
{
|
||||
return new TaskInputValidation(this, securedObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using GitHub.Services.WebApi;
|
||||
|
||||
namespace GitHub.DistributedTask.Common.Contracts
|
||||
{
|
||||
[DataContract]
|
||||
public class TaskSourceDefinitionBase : BaseSecuredObject
|
||||
{
|
||||
public TaskSourceDefinitionBase()
|
||||
{
|
||||
AuthKey = String.Empty;
|
||||
Endpoint = String.Empty;
|
||||
Selector = String.Empty;
|
||||
Target = String.Empty;
|
||||
KeySelector = String.Empty;
|
||||
}
|
||||
|
||||
protected TaskSourceDefinitionBase(TaskSourceDefinitionBase inputDefinitionToClone)
|
||||
: this(inputDefinitionToClone, null)
|
||||
{
|
||||
}
|
||||
|
||||
protected TaskSourceDefinitionBase(TaskSourceDefinitionBase inputDefinitionToClone, ISecuredObject securedObject)
|
||||
: base(securedObject)
|
||||
{
|
||||
this.Endpoint = inputDefinitionToClone.Endpoint;
|
||||
this.Target = inputDefinitionToClone.Target;
|
||||
this.AuthKey = inputDefinitionToClone.AuthKey;
|
||||
this.Selector = inputDefinitionToClone.Selector;
|
||||
this.KeySelector = inputDefinitionToClone.KeySelector;
|
||||
}
|
||||
|
||||
public virtual TaskSourceDefinitionBase Clone(ISecuredObject securedObject)
|
||||
{
|
||||
return new TaskSourceDefinitionBase(this, securedObject);
|
||||
}
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public String Endpoint
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public String Target
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public String AuthKey
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public String Selector
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public String KeySelector
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user