using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using GitHub.Services.WebApi;
namespace GitHub.Build.WebApi
{
///
/// Represents a repository used by a build definition.
///
[DataContract]
public class BuildRepository : BaseSecuredObject
{
public BuildRepository()
{
}
internal BuildRepository(
ISecuredObject securedObject)
: base(securedObject)
{
}
private BuildRepository(
BuildRepository toClone)
: base(toClone)
{
this.Id = toClone.Id;
this.Type = toClone.Type;
this.Name = toClone.Name;
this.Url = toClone.Url;
this.DefaultBranch = toClone.DefaultBranch;
this.RootFolder = toClone.RootFolder;
this.Clean = toClone.Clean;
this.CheckoutSubmodules = toClone.CheckoutSubmodules;
if (toClone.m_properties != null)
{
foreach (var property in toClone.m_properties)
{
this.Properties.Add(property.Key, property.Value);
}
}
}
///
/// The ID of the repository.
///
[DataMember(EmitDefaultValue = false)]
public String Id
{
get;
set;
}
///
/// The type of the repository.
///
[DataMember]
public String Type
{
get;
set;
}
///
/// The friendly name of the repository.
///
[DataMember(EmitDefaultValue = false)]
public String Name
{
get;
set;
}
///
/// The URL of the repository.
///
[DataMember(EmitDefaultValue = false)]
public Uri Url
{
get;
set;
}
///
/// The name of the default branch.
///
[DataMember(EmitDefaultValue = false)]
public String DefaultBranch
{
get;
set;
}
///
/// The root folder.
///
[DataMember(EmitDefaultValue = false)]
public String RootFolder
{
get;
set;
}
///
/// Indicates whether to clean the target folder when getting code from the repository.
///
///
/// This is a String so that it can reference variables.
///
[DataMember(EmitDefaultValue = true)]
public String Clean
{
get;
set;
}
///
/// Indicates whether to checkout submodules.
///
[DataMember(EmitDefaultValue = true)]
public Boolean CheckoutSubmodules
{
get;
set;
}
///
/// A dictionary that holds additional information about the repository.
///
public IDictionary Properties
{
// Warning: This can contain secrets too. As part of #952656, we resolve secrets, it was done considering the fact that this is not a "DataMember"
// If it's ever made a "DataMember" please be cautious, we would be leaking secrets
get
{
if (m_properties == null)
{
m_properties = new Dictionary(StringComparer.OrdinalIgnoreCase);
}
return m_properties;
}
internal set
{
m_properties = new Dictionary(value, StringComparer.OrdinalIgnoreCase);
}
}
///
/// Clones this object.
///
///
public BuildRepository Clone()
{
return new BuildRepository(this);
}
[OnDeserialized]
private void OnDeserialized(StreamingContext context)
{
SerializationHelper.Copy(ref m_serializedProperties, ref m_properties, StringComparer.OrdinalIgnoreCase, true);
}
[OnSerializing]
private void OnSerializing(StreamingContext context)
{
SerializationHelper.Copy(ref m_properties, ref m_serializedProperties, StringComparer.OrdinalIgnoreCase);
}
[OnSerialized]
private void OnSerialized(StreamingContext context)
{
m_serializedProperties = null;
}
[DataMember(Name = "Properties", EmitDefaultValue = false)]
private IDictionary m_serializedProperties;
// Warning: This can contain secrets too. As part of #952656, we resolve secrets, it was done considering the fact that this is not a "DataMember"
// If it's ever made a "DataMember" please be cautious, we would be leaking secrets
private IDictionary m_properties;
}
}