/// <summary> /// Get the state for the given file properties. /// </summary> /// <param name="fileProperties">The file properties to get the state for.</param> /// <returns>The state for the given file properties.</returns> internal static SourceFileState GetState(SalesForceAPI.Metadata.FileProperties fileProperties) { if (!fileProperties.manageableStateSpecified) { return(SourceFileState.None); } switch (fileProperties.manageableState) { case SalesForceAPI.Metadata.ManageableState.beta: return(SourceFileState.Beta); case SalesForceAPI.Metadata.ManageableState.deleted: return(SourceFileState.Deleted); case SalesForceAPI.Metadata.ManageableState.deprecated: return(SourceFileState.Deprecated); case SalesForceAPI.Metadata.ManageableState.installed: return(SourceFileState.Installed); case SalesForceAPI.Metadata.ManageableState.released: return(SourceFileState.Released); case SalesForceAPI.Metadata.ManageableState.unmanaged: return(SourceFileState.Unmanaged); default: throw new Exception("Unknown state: " + fileProperties.manageableState.ToString()); } }
/// <summary> /// Constructor. /// </summary> /// <param name="fileType">The type of file.</param> /// <param name="fileProperties">The file properties.</param> public SourceFile(SourceFileType fileType, SalesForceAPI.Metadata.FileProperties fileProperties) { if (fileType == null) { throw new ArgumentNullException("fileType"); } if (fileProperties == null) { throw new ArgumentNullException("fileProperties"); } Id = fileProperties.id; FileType = fileType; Name = fileProperties.fullName; FileName = fileProperties.fileName; Parent = null; ChangedBy = new User(fileProperties.lastModifiedById ?? String.Empty, fileProperties.lastModifiedByName); ChangedOn = fileProperties.lastModifiedDate.ToLocalTime(); CreatedBy = new User(fileProperties.createdById ?? String.Empty, fileProperties.createdByName); CreatedOn = fileProperties.createdDate.ToLocalTime(); Children = new SourceFile[0]; State = GetState(fileProperties); // salesforce defect workaround if (FileName != null && FileName.StartsWith("Workflow/")) { FileName = FileName.Replace("Workflow/", "workflows/"); } CheckedOutBy = null; }
/// <summary> /// Constructor. /// </summary> /// <param name="fileType">The type of file.</param> /// <param name="fileProperties">The file properties.</param> /// <param name="children">The child files for this file.</param> internal SourceFile(SourceFileType fileType, SalesForceAPI.Metadata.FileProperties fileProperties, IEnumerable <SourceFile> children) : this(fileType, fileProperties) { if (children == null) { Children = new SourceFile[0]; } else { Children = children.ToArray(); } foreach (SourceFile child in Children) { child.Parent = this; } Array.Sort(Children); }