AtlassianPS.Configuration.Types.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
using System;
using System.Collections; using System.Collections.Generic; using System.Management.Automation; using Microsoft.PowerShell.Commands; namespace AtlassianPS { public enum ServerType { BITBUCKET, CONFLUENCE, JIRA } public class MessageStyle { public MessageStyle() { Indent = 4; TimeStamp = true; BreadCrumbs = false; FunctionName = true; } public MessageStyle(UInt32 _Indent, Boolean _TimeStamp, Boolean _BreadCrumbs, Boolean _FunctionName) { Indent = _Indent; TimeStamp = _TimeStamp; BreadCrumbs = _BreadCrumbs; FunctionName = _FunctionName; } public UInt32 Indent { get; set; } public Boolean TimeStamp { get; set; } public Boolean BreadCrumbs { get; set; } public Boolean FunctionName { get; set; } } [Serializable] public class ServerData { public ServerData(UInt32 _Id, String _Name, String _Uri, ServerType _Type) { Uri tempUri; Uri.TryCreate(_Uri, UriKind.RelativeOrAbsolute, out tempUri); Id = _Id; Name = _Name; Uri = tempUri; Type = _Type; } public ServerData(IDictionary Table) { bool foundId = false; bool foundName = false; bool foundUri = false; bool foundType = false; foreach (object key in Table.Keys) { switch (key.ToString().ToLower()) { case "id": Id = Convert.ToUInt32(Table[key]); foundId = true; break; case "name": Name = (String)Table[key]; foundName = true; break; case "uri": Uri tempUri; Uri.TryCreate(Table[key].ToString(), UriKind.RelativeOrAbsolute, out tempUri); Uri = tempUri; foundUri = true; break; case "type": Type = (ServerType)Enum.Parse(typeof(ServerType), (Table[key].ToString()), true); foundType = true; break; case "session": Session = Table[key]; break; case "headers": Headers = (Hashtable)Table[key]; break; default: break; } } if (!(foundId && foundName && foundUri && foundType)) throw new ArgumentException("Must contain Id, Name, Uri and Type."); } public UInt32 Id { get; set; } public String Name { get; set; } public Uri Uri { get; set; } public ServerType Type { get; set; } // public Boolean IsCloudServer { get; set; } public Object Session { get; set; } public Hashtable Headers { get; set; } public override String ToString() { return String.Format("{0} ({1})", Name, Uri); } } } |