├── Aria2c ├── Aria2c.cs ├── Aria2c.csproj ├── Aria2cBittorrent.cs ├── Aria2cEvent.cs ├── Aria2cFiles.cs ├── Aria2cGlobalStat.cs ├── Aria2cGlobalStatEvent.cs ├── Aria2cLink.cs ├── Aria2cOption.cs ├── Aria2cPeers.cs ├── Aria2cProxy.cs ├── Aria2cRuntime.cs ├── Aria2cSettings.cs ├── Aria2cTask.cs ├── Aria2cTaskEvent.cs ├── Aria2cTools.cs ├── Aria2cUri.cs ├── Aria2cWarpper.cs └── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── Readme └── XmlRpcNet ├── AssemblyDesc.cs ├── AssemblyDescFX1_0.cs ├── AssemblyInfo.cs ├── CookComputing.XmlRpc.Targets ├── DateTime8601.cs ├── GuidEx.cs ├── IXmlRpcProxy.cs ├── MappingActions.cs ├── MappingStack.cs ├── RequestResponseLogger.cs ├── Tracer.cs ├── WebSettings.cs ├── XmlRpcAsyncResult.cs ├── XmlRpcBeginAttribute.cs ├── XmlRpcClientFormatterSink.cs ├── XmlRpcClientFormatterSinkProvider.cs ├── XmlRpcClientProtocol.cs ├── XmlRpcClientProtocol.resx ├── XmlRpcDebugLogger.cs ├── XmlRpcDeserializer.cs ├── XmlRpcEndAttribute.cs ├── XmlRpcEnumMapping.cs ├── XmlRpcException.cs ├── XmlRpcFaultException.cs ├── XmlRpcFormatSettings.cs ├── XmlRpcLogger.cs ├── XmlRpcMemberAttribute.cs ├── XmlRpcMethodAttribute.cs ├── XmlRpcMethodInfo.cs ├── XmlRpcMissingMappingAttribute.cs ├── XmlRpcNet.csproj ├── XmlRpcNonStandard.cs ├── XmlRpcNullMappingAttribute.cs ├── XmlRpcParameterAttribute.cs ├── XmlRpcParameterInfo.cs ├── XmlRpcParser.cs ├── XmlRpcProxyCodeGen.cs ├── XmlRpcProxyGen.cs ├── XmlRpcRequest.cs ├── XmlRpcRequestEventArgs.cs ├── XmlRpcRequestSerializer.cs ├── XmlRpcResponse.cs ├── XmlRpcResponseDeserializer.cs ├── XmlRpcResponseEventArgs.cs ├── XmlRpcReturnValueAttribute.cs ├── XmlRpcSerializer.cs ├── XmlRpcStruct.cs ├── XmlRpcTypeInfo.cs ├── XmlRpcUrlAttribute.cs ├── XmlRpcXmlReader.cs ├── XmlRpcXmlWriter.cs └── util.cs /Aria2c/Aria2c.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {E352E426-A614-4E27-A8EE-CD80FA184FF2} 8 | Library 9 | Properties 10 | FlyVR.Aria2 11 | Aria2c 12 | v4.5.2 13 | 512 14 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 15 | 4 16 | true 17 | 18 | 19 | AnyCPU 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | 28 | 29 | AnyCPU 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | 37 | 38 | 39 | 40 | 41 | true 42 | bin\x64\Debug\ 43 | DEBUG;TRACE 44 | full 45 | x64 46 | prompt 47 | MinimumRecommendedRules.ruleset 48 | 49 | 50 | bin\x64\Release\ 51 | TRACE 52 | true 53 | pdbonly 54 | x64 55 | prompt 56 | MinimumRecommendedRules.ruleset 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 4.0 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 | Code 96 | 97 | 98 | True 99 | True 100 | Resources.resx 101 | 102 | 103 | True 104 | Settings.settings 105 | True 106 | 107 | 108 | ResXFileCodeGenerator 109 | Resources.Designer.cs 110 | 111 | 112 | SettingsSingleFileGenerator 113 | Settings.Designer.cs 114 | 115 | 116 | 117 | 118 | 119 | {1F8D0987-7BE8-47DC-BFAD-9CA61F2F3D9D} 120 | DebugLog 121 | 122 | 123 | {1B4B0A58-0AFB-4090-91DD-18912CC7DE65} 124 | XmlRpcNet 125 | 126 | 127 | 128 | 135 | -------------------------------------------------------------------------------- /Aria2c/Aria2cBittorrent.cs: -------------------------------------------------------------------------------- 1 | #region 类信息 2 | /*---------------------------------------------------------------- 3 | * 模块名:Aria2cBittorrent 4 | * 创建者:isRight 5 | * 修改者列表: 6 | * 创建日期:2016.12.29 7 | * 模块描述:aria2c种子任务信息 8 | *----------------------------------------------------------------*/ 9 | #endregion 10 | 11 | namespace FlyVR.Aria2 12 | { 13 | using CookComputing.XmlRpc; 14 | using System; 15 | using System.Collections.Generic; 16 | using System.Linq; 17 | using System.Text; 18 | using System.Threading.Tasks; 19 | 20 | /// 21 | /// 种子文件模式 22 | /// 23 | public enum Aria2cBittorrentMode 24 | { 25 | Single, 26 | Multi, 27 | } 28 | 29 | public sealed class Aria2cBittorrent 30 | { 31 | 32 | public Aria2cBittorrent() 33 | { 34 | 35 | } 36 | 37 | /// 38 | /// 将rpc信息转换为种子信息 39 | /// 40 | /// 41 | public Aria2cBittorrent(XmlRpcStruct rpcStruct) 42 | { 43 | List keyList = rpcStruct.Keys as List; 44 | List valueList = rpcStruct.Values as List; 45 | 46 | for (int i = 0; i < rpcStruct.Count; i++) 47 | { 48 | string key = keyList[i]; 49 | object value = valueList[i]; 50 | 51 | if (key == "announceList") 52 | { 53 | this.AnnounceList = value as string[]; 54 | } 55 | else if (key == "comment") 56 | { 57 | this.Comment = value as string; 58 | } 59 | else if (key == "creationDate") 60 | { 61 | this.CreationDate = Convert.ToInt64(value as string); 62 | } 63 | else if (key == "mode") 64 | { 65 | this.Mode = ConvertToAria2cBittorrentMode(value as string); 66 | } 67 | else if (key == "name") 68 | { 69 | this.Name = ConvertToBittorrentInfoName(value as XmlRpcStruct); 70 | } 71 | else 72 | { 73 | throw new Exception("Aria2cBittorrent不包含该属性"); 74 | } 75 | 76 | } 77 | } 78 | 79 | /// 80 | /// 将字符串转换为Aria2cBittorrentMode 81 | /// 82 | /// 83 | /// 84 | public static Aria2cBittorrentMode ConvertToAria2cBittorrentMode(string str) 85 | { 86 | if (str == "single") 87 | { 88 | return Aria2cBittorrentMode.Single; 89 | } 90 | else if (str == "multi") 91 | { 92 | return Aria2cBittorrentMode.Multi; 93 | } 94 | else 95 | { 96 | throw new Exception("Aria2cBittorrentMode不包含该属性"); 97 | } 98 | } 99 | 100 | /// 101 | /// 将rpc信息转换为种子信息名称 102 | /// 103 | /// 104 | /// 105 | public static string ConvertToBittorrentInfoName(XmlRpcStruct rpcStruct) 106 | { 107 | List keyList = rpcStruct.Keys as List; 108 | List valueList = rpcStruct.Values as List; 109 | 110 | if (rpcStruct.ContainsKey("name")) 111 | { 112 | string value = valueList[0] as string; 113 | return value; 114 | } 115 | 116 | return string.Empty; 117 | } 118 | 119 | /// 120 | /// 匿名下载地址 121 | /// 122 | public string[] AnnounceList { get; set;} 123 | 124 | /// 125 | /// 种子文件描述 126 | /// 127 | public string Comment { get; set; } 128 | 129 | /// 130 | /// 种子文件创建时间, 从1970-01-01 00:00:00 UTC开始记秒 131 | /// 132 | public long CreationDate { get; set; } 133 | 134 | /// 135 | /// 种子包含文件的模式 136 | /// 137 | public Aria2cBittorrentMode Mode { get; set; } 138 | 139 | /// 140 | /// 暂定 141 | /// 142 | public string Name { get; set; } 143 | 144 | 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /Aria2c/Aria2cEvent.cs: -------------------------------------------------------------------------------- 1 | #region 类信息 2 | /*---------------------------------------------------------------- 3 | * 模块名:Aria2cGlobalStatEvent 4 | * 创建者:isRight 5 | * 修改者列表: 6 | * 创建日期:2016.12.29 7 | * 模块描述:aria2c事件 8 | *----------------------------------------------------------------*/ 9 | #endregion 10 | 11 | namespace FlyVR.Aria2 12 | { 13 | using System; 14 | 15 | public sealed class Aria2cEvent : EventArgs 16 | { 17 | public Aria2cEvent() 18 | { 19 | 20 | } 21 | 22 | public Aria2cEvent(string gid) 23 | { 24 | } 25 | 26 | /// 27 | /// 任务标识符 28 | /// 29 | public string Gid { get; internal set; } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Aria2c/Aria2cFiles.cs: -------------------------------------------------------------------------------- 1 | #region 类信息 2 | /*---------------------------------------------------------------- 3 | * 模块名:Aria2cFiles 4 | * 创建者:isRight 5 | * 修改者列表: 6 | * 创建日期:2016.12.29 7 | * 模块描述:aria2c下载任务文件信息 8 | *----------------------------------------------------------------*/ 9 | #endregion 10 | 11 | 12 | namespace FlyVR.Aria2 13 | { 14 | using CookComputing.XmlRpc; 15 | using System; 16 | using System.Collections.Generic; 17 | 18 | public sealed class Aria2cFile 19 | { 20 | public Aria2cFile() 21 | { 22 | 23 | } 24 | 25 | /// 26 | /// 将rpc信息转换为下载任务文件信息 27 | /// 28 | /// 29 | public Aria2cFile(XmlRpcStruct rpcStruct) 30 | { 31 | List keyList = rpcStruct.Keys as List; 32 | List valueList = rpcStruct.Values as List; 33 | 34 | for (int i = 0; i < rpcStruct.Count; i++) 35 | { 36 | string key = keyList[i]; 37 | object value = valueList[i]; 38 | 39 | if (key == "index") 40 | { 41 | this.Index = Convert.ToInt64(value as string); 42 | } 43 | else if (key == "path") 44 | { 45 | this.Path = value as string; 46 | } 47 | else if (key == "length") 48 | { 49 | this.Length = Convert.ToInt64(value as string); 50 | } 51 | else if (key == "completedLength") 52 | { 53 | this.CompletedLength = Convert.ToInt64(value as string); 54 | } 55 | else if (key == "selected") 56 | { 57 | this.Selected = (value as string) == "true" ? true : false; 58 | } 59 | else if (key == "uris") 60 | { 61 | this.Uris = ConvertToAria2cUris(value as XmlRpcStruct[]); 62 | } 63 | else 64 | { 65 | throw new Exception("Aria2cFile不包含该属性"); 66 | } 67 | } 68 | } 69 | 70 | /// 71 | /// 将rpc信息转换为下载任务文件链接信息 72 | /// 73 | /// 74 | /// 75 | public List ConvertToAria2cUris(params XmlRpcStruct[] rpcStruct) 76 | { 77 | List uriList = new List(); 78 | 79 | if (rpcStruct != null) 80 | { 81 | foreach (XmlRpcStruct rpc in rpcStruct) 82 | { 83 | Aria2cUri uri = new Aria2cUri(rpc); 84 | uriList.Add(uri); 85 | } 86 | } 87 | 88 | return uriList; 89 | } 90 | 91 | /// 92 | /// 文件在下载任务文件列表中的索引 93 | /// 94 | public long Index { get; set; } 95 | 96 | 97 | /// 98 | /// 文件路径,包含文件名 99 | /// 100 | public string Path { get; set; } 101 | 102 | /// 103 | /// 文件长度 单位 byte 104 | /// 105 | public long Length { get; set; } 106 | 107 | /// 108 | /// 已下载的文件长度 单位byte 109 | /// 110 | public long CompletedLength { get; set; } 111 | 112 | /// 113 | /// 文件是否被选中 114 | /// 115 | public bool Selected { get; set; } 116 | 117 | 118 | List _uriList = new List(); 119 | 120 | /// 121 | /// 文件下载地址 122 | /// 123 | public List Uris 124 | { 125 | get 126 | { 127 | return _uriList; 128 | } 129 | set 130 | { 131 | _uriList = value; 132 | } 133 | } 134 | 135 | /// 136 | /// 添加uri 137 | /// 138 | /// 139 | /// 140 | public void AddUri(Aria2cUri uri) 141 | { 142 | _uriList.Add(uri); 143 | } 144 | 145 | /// 146 | /// 移除uri 147 | /// 148 | /// 149 | /// 150 | public bool Remove(Aria2cUri uri) 151 | { 152 | return _uriList.Remove(uri); 153 | } 154 | 155 | } 156 | 157 | 158 | } 159 | -------------------------------------------------------------------------------- /Aria2c/Aria2cGlobalStat.cs: -------------------------------------------------------------------------------- 1 | #region 类信息 2 | /*---------------------------------------------------------------- 3 | * 模块名:Aria2cGlobalStat 4 | * 创建者:isRight 5 | * 修改者列表: 6 | * 创建日期:2016.12.29 7 | * 模块描述:全局状态信息 8 | *----------------------------------------------------------------*/ 9 | #endregion 10 | 11 | namespace FlyVR.Aria2 12 | { 13 | using System; 14 | using CookComputing.XmlRpc; 15 | using System.Collections.Generic; 16 | 17 | public sealed class Aria2cGlobalStat 18 | { 19 | public Aria2cGlobalStat() 20 | { 21 | 22 | } 23 | 24 | public Aria2cGlobalStat(XmlRpcStruct rpcStruct) 25 | { 26 | List keyList = rpcStruct.Keys as List; 27 | List valueList = rpcStruct.Values as List; 28 | 29 | for (int i = 0; i < rpcStruct.Count; i++) 30 | { 31 | string key = keyList[i]; 32 | object value = valueList[i]; 33 | 34 | if (key == "downloadSpeed") 35 | { 36 | this.DownloadSpeed = Convert.ToInt64(value as string); 37 | } 38 | else if (key == "uploadSpeed") 39 | { 40 | this.UploadSpeed = Convert.ToInt64(value as string); 41 | } 42 | else if (key == "numActive") 43 | { 44 | this.NumActive = Convert.ToInt64(value as string); 45 | } 46 | else if (key == "numWaiting") 47 | { 48 | this.NumWaiting = Convert.ToInt64(value as string); 49 | } 50 | else if (key == "numStopped") 51 | { 52 | this.NumStopped = Convert.ToInt64(value as string); 53 | } 54 | else if (key == "numStoppedTotal") 55 | { 56 | this.NumStoppedTotal = Convert.ToInt64(value as string); 57 | } 58 | else 59 | { 60 | throw new Exception("无法将属性转换到Aria2cGlobalStat中"); 61 | } 62 | } 63 | } 64 | 65 | /// 66 | /// 全局下载速度 byte/s 67 | /// 68 | public long DownloadSpeed { get; set; } 69 | 70 | /// 71 | /// 全局上传速度 byte/s 72 | /// 73 | public long UploadSpeed { get; set; } 74 | 75 | /// 76 | /// 当前激活的任务数量 77 | /// 78 | public long NumActive { get; set; } 79 | 80 | /// 81 | /// 正在等待的任务数量 82 | /// 83 | public long NumWaiting { get; set; } 84 | 85 | /// 86 | /// 已经停止的任务数量 87 | /// 88 | public long NumStopped { get; set; } 89 | 90 | /// 91 | /// 当前会话总共停止的任务数量 92 | /// 93 | public long NumStoppedTotal { get; set; } 94 | 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /Aria2c/Aria2cGlobalStatEvent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | #region 类信息 4 | /*---------------------------------------------------------------- 5 | * 模块名:Aria2cGlobalStatEvent 6 | * 创建者:isRight 7 | * 修改者列表: 8 | * 创建日期:2016.12.29 9 | * 模块描述:aria2c全局状态事件 10 | *----------------------------------------------------------------*/ 11 | #endregion 12 | 13 | 14 | namespace FlyVR.Aria2 15 | { 16 | public sealed class Aria2cGlobalStatEvent : EventArgs 17 | { 18 | public Aria2cGlobalStatEvent() 19 | { 20 | 21 | } 22 | 23 | public Aria2cGlobalStatEvent(Aria2cGlobalStat stat) 24 | { 25 | Stat = stat; 26 | } 27 | 28 | /// 29 | /// 全局状态 30 | /// 31 | public Aria2cGlobalStat Stat { get; internal set; } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Aria2c/Aria2cLink.cs: -------------------------------------------------------------------------------- 1 | #region 类信息 2 | /*---------------------------------------------------------------- 3 | * 模块名:Aria2cLink 4 | * 创建者:isRight 5 | * 修改者列表: 6 | * 创建日期:2016.12.29 7 | * 模块描述:下载任务链接信息 8 | *----------------------------------------------------------------*/ 9 | #endregion 10 | 11 | namespace FlyVR.Aria2 12 | { 13 | using CookComputing.XmlRpc; 14 | using System; 15 | using System.Collections.Generic; 16 | using System.Linq; 17 | using System.Text; 18 | using System.Threading.Tasks; 19 | 20 | public sealed class Aria2cServerLink 21 | { 22 | public Aria2cServerLink() 23 | { 24 | 25 | } 26 | 27 | public Aria2cServerLink(XmlRpcStruct rpcStruct) 28 | { 29 | List keyList = rpcStruct.Keys as List; 30 | List valueList = rpcStruct.Values as List; 31 | 32 | for (int i = 0; i < rpcStruct.Count; i++) 33 | { 34 | string key = keyList[i]; 35 | object value = valueList[i]; 36 | 37 | if (key == "uri") 38 | { 39 | this.Uri = value as string; 40 | } 41 | else if (key == "currentUri") 42 | { 43 | this.CurrentUri = value as string; 44 | } 45 | else if (key == "downloadSpeed") 46 | { 47 | this.DownloadSpeed = Convert.ToInt64(value as string); 48 | } 49 | else 50 | { 51 | throw new Exception("无法将属性转换到Aria2cServerLink中"); 52 | } 53 | } 54 | } 55 | 56 | /// 57 | /// 原始地址 58 | /// 59 | public string Uri { get; set; } 60 | 61 | /// 62 | /// 当前下载地址 63 | /// 64 | public string CurrentUri { get; set; } 65 | 66 | /// 67 | /// 下载速度 byte/s 68 | /// 69 | public long DownloadSpeed { get; set; } 70 | } 71 | 72 | 73 | public class Aria2cLink 74 | { 75 | 76 | public Aria2cLink() 77 | { 78 | 79 | } 80 | 81 | /// 82 | /// 将rpc信息转换到服务器信息中 83 | /// 84 | /// 85 | public Aria2cLink(XmlRpcStruct rpcStruct) 86 | { 87 | List keyList = rpcStruct.Keys as List; 88 | List valueList = rpcStruct.Values as List; 89 | 90 | for (int i = 0; i < rpcStruct.Count; i++) 91 | { 92 | string key = keyList[i]; 93 | object value = valueList[i]; 94 | 95 | if (key == "index") 96 | { 97 | this.Index = Convert.ToInt64(value as string); 98 | } 99 | else if (key == "servers") 100 | { 101 | this.Servers = Aria2cTools.ConvertToAria2cServerLink(value as XmlRpcStruct[]); 102 | } 103 | else 104 | { 105 | throw new Exception("无法将属性转换到Aria2cServer中"); 106 | } 107 | } 108 | } 109 | 110 | /// 111 | /// 文件索引 112 | /// 113 | public long Index; 114 | 115 | private List _serverList = new List(); 116 | 117 | /// 118 | /// 服务器地址 119 | /// 120 | public List Servers 121 | { 122 | get 123 | { 124 | return _serverList; 125 | } 126 | 127 | set 128 | { 129 | _serverList = value; 130 | } 131 | } 132 | 133 | public void AddServer(Aria2cServerLink server) 134 | { 135 | _serverList.Add(server); 136 | } 137 | 138 | public bool RemoveServer(Aria2cServerLink server) 139 | { 140 | return _serverList.Remove(server); 141 | } 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /Aria2c/Aria2cOption.cs: -------------------------------------------------------------------------------- 1 | #region 类信息 2 | /*---------------------------------------------------------------- 3 | * 模块名:Aria2cOption 4 | * 创建者:isRight 5 | * 修改者列表: 6 | * 创建日期:2016.12.29 7 | * 模块描述:下载任务设置 8 | *----------------------------------------------------------------*/ 9 | #endregion 10 | 11 | namespace FlyVR.Aria2 12 | { 13 | using CookComputing.XmlRpc; 14 | using System.Collections.Generic; 15 | 16 | public sealed class Aria2cOption 17 | { 18 | Dictionary optionDictionary = new Dictionary(); 19 | 20 | public Aria2cOption() 21 | { 22 | 23 | } 24 | 25 | /// 26 | /// 将rpc信息转换为设置信息 27 | /// 28 | /// 29 | /// 30 | public Aria2cOption(XmlRpcStruct rpcStruct) 31 | { 32 | List keyList = rpcStruct.Keys as List; 33 | List valueList = rpcStruct.Values as List; 34 | 35 | for (int i = 0; i < rpcStruct.Count; i++) 36 | { 37 | string key = keyList[i]; 38 | string value = valueList[i] as string; 39 | 40 | this.SetOption(key, value); 41 | } 42 | } 43 | 44 | public XmlRpcStruct ToXmlRpcStruct() 45 | { 46 | XmlRpcStruct rpcStruct = new XmlRpcStruct(); 47 | 48 | foreach (KeyValuePair kvp in optionDictionary) 49 | { 50 | rpcStruct.Add(kvp.Key, kvp.Value); 51 | } 52 | 53 | return rpcStruct; 54 | } 55 | 56 | public Dictionary Option 57 | { 58 | get 59 | { 60 | return optionDictionary; 61 | } 62 | set 63 | { 64 | optionDictionary = value; 65 | } 66 | } 67 | 68 | public void SetOption(string key, string value) 69 | { 70 | optionDictionary[key] = value; 71 | } 72 | 73 | public bool RemoveOption(string key) 74 | { 75 | return optionDictionary.Remove(key); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Aria2c/Aria2cPeers.cs: -------------------------------------------------------------------------------- 1 | #region 类信息 2 | /*---------------------------------------------------------------- 3 | * 模块名:Aria2cPeers 4 | * 创建者:isRight 5 | * 修改者列表: 6 | * 创建日期:2016.12.29 7 | * 模块描述:aria2c下载任务链接信息 8 | *----------------------------------------------------------------*/ 9 | #endregion 10 | 11 | 12 | namespace FlyVR.Aria2 13 | { 14 | using CookComputing.XmlRpc; 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Linq; 18 | using System.Text; 19 | using System.Threading.Tasks; 20 | 21 | public sealed class Aria2cPeers 22 | { 23 | public Aria2cPeers() 24 | { 25 | 26 | } 27 | 28 | /// 29 | /// 将rpc信息转换为种子链接信息 30 | /// 31 | /// rpc信息 32 | public Aria2cPeers(XmlRpcStruct rpcStruct) 33 | { 34 | List keyList = rpcStruct.Keys as List; 35 | List valueList = rpcStruct.Values as List; 36 | 37 | for (int i = 0; i < rpcStruct.Count; i++) 38 | { 39 | string key = keyList[i]; 40 | object value = valueList[i]; 41 | 42 | if (key == "peerId") 43 | { 44 | this.PeerId = Convert.ToInt64(value as string); 45 | } 46 | else if (key == "ip") 47 | { 48 | this.IP = value as string; 49 | } 50 | else if (key == "port") 51 | { 52 | this.Port = Convert.ToInt64(value as string); 53 | } 54 | else if (key == "bitfield") 55 | { 56 | this.Bitfield = value as string; 57 | } 58 | else if (key == "amChoking") 59 | { 60 | this.AmChoking = (value as string) == "true" ? true : false; 61 | } 62 | else if (key == "peerChoking") 63 | { 64 | this.PeerChoking = (value as string) == "true" ? true : false; 65 | } 66 | else if (key == "downloadSpeed") 67 | { 68 | this.downloadSpeed = Convert.ToInt64(value as string); 69 | } 70 | else if (key == "uploadSpeed") 71 | { 72 | this.uploadSpeed = Convert.ToInt64(value as string); 73 | } 74 | else if (key == "seeder") 75 | { 76 | this.seeder = (value as string) == "true" ? true : false; 77 | } 78 | else 79 | { 80 | throw new Exception("无法将属性转换到Aria2cPeers中"); 81 | } 82 | } 83 | } 84 | 85 | /// 86 | /// 链接ID 87 | /// 88 | public long PeerId { get; set; } 89 | 90 | /// 91 | /// IP地址 92 | /// 93 | public string IP { get; set; } 94 | 95 | /// 96 | /// 端口号 97 | /// 98 | public long Port { get; set; } 99 | 100 | /// 101 | /// 未知 102 | /// 103 | public string Bitfield { get; set; } 104 | 105 | /// 106 | /// 下载链接阻塞标识 107 | /// 108 | public bool AmChoking { get; set; } 109 | 110 | /// 111 | /// 并行阻塞标识 112 | /// 113 | public bool PeerChoking { get; set; } 114 | 115 | /// 116 | /// 下载速度 byte/s 117 | /// 118 | public long downloadSpeed { get; set; } 119 | 120 | /// 121 | /// 上传速度 byte/s 122 | /// 123 | public long uploadSpeed { get; set; } 124 | 125 | /// 126 | /// 做种标识 127 | /// 128 | public bool seeder { get; set; } 129 | 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /Aria2c/Aria2cRuntime.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace FlyVR.Aria2 3 | { 4 | using Log; 5 | using System; 6 | using System.Diagnostics; 7 | using System.IO; 8 | using System.Text; 9 | 10 | public sealed class Aria2cRuntime 11 | { 12 | #region 私有变量 13 | private static int aria2cPort = 6800; 14 | private static string aria2cHost = "localhost"; 15 | private static string downLoadDirectory; 16 | private static Process aria2cProcess; 17 | #endregion 18 | 19 | #region 属性 20 | /// 21 | /// Aria2c IP地址 22 | /// 23 | public static string Aria2cHost 24 | { 25 | get 26 | { 27 | return aria2cHost; 28 | } 29 | set 30 | { 31 | aria2cHost = value; 32 | SetAria2cHost(Aria2cHost, Aria2cPort); 33 | } 34 | } 35 | 36 | /// 37 | /// Aria2c端口 38 | /// 39 | public static int Aria2cPort 40 | { 41 | get 42 | { 43 | return aria2cPort; 44 | } 45 | set 46 | { 47 | aria2cPort = value; 48 | SetAria2cHost(Aria2cHost, aria2cPort); 49 | } 50 | } 51 | 52 | /// 53 | /// 是否正在运行 54 | /// 55 | public static bool IsLoaded 56 | { 57 | get 58 | { 59 | try 60 | { 61 | string version = Aria2cWarpper.GetVersion(); 62 | return true; 63 | } 64 | catch (Exception ex) 65 | { 66 | Console.WriteLine(ex); 67 | return false; 68 | } 69 | } 70 | } 71 | 72 | 73 | /// 74 | /// 全局下载目录 75 | /// 76 | public static string DownLoadDirectory 77 | { 78 | get 79 | { 80 | try 81 | { 82 | downLoadDirectory = Aria2cWarpper.DownLoadDirectory; 83 | } 84 | catch (Exception ex) 85 | { 86 | Console.WriteLine(ex); 87 | } 88 | return downLoadDirectory; 89 | } 90 | set 91 | { 92 | downLoadDirectory = value; 93 | try 94 | { 95 | Aria2cWarpper.DownLoadDirectory = downLoadDirectory; 96 | } 97 | catch (Exception ex) 98 | { 99 | Console.WriteLine(ex); 100 | } 101 | } 102 | } 103 | 104 | #endregion 105 | 106 | #region 公共方法 107 | /// 108 | /// 启动服务进程 109 | /// 110 | /// 111 | public static void Load(Aria2cSettings settings) 112 | { 113 | SetAria2cHost(settings.Aria2Host, settings.Aria2Port); 114 | 115 | if (!IsLoaded && File.Exists(settings.Aria2Path)) 116 | { 117 | StartProcess(settings.Aria2Path, settings.Aria2Args); 118 | } 119 | } 120 | 121 | /// 122 | /// 关闭服务进程 123 | /// 124 | public static void ShutDown() 125 | { 126 | aria2cProcess?.Kill(); 127 | aria2cProcess?.Dispose(); 128 | aria2cProcess = null; 129 | } 130 | #endregion 131 | 132 | #region 实现 133 | /// 134 | /// 设置host地址 135 | /// 136 | /// 137 | /// 138 | private static void SetAria2cHost(string host, int port) 139 | { 140 | StringBuilder builder = new StringBuilder(); 141 | builder.Append("http://"); 142 | builder.Append(host); 143 | builder.Append(":"); 144 | builder.Append(port); 145 | builder.Append("/rpc"); 146 | 147 | Aria2cWarpper.Aria2cHost = builder.ToString(); 148 | } 149 | 150 | 151 | private static void StartProcess(string path, string args = "") 152 | { 153 | try 154 | { 155 | var aria2Dir = Aria2cTools.GetDirectoryName(path); 156 | var aria2cName = Aria2cTools.GetFileNameWithoutExtension(path); 157 | string config = aria2cName + ".conf"; 158 | 159 | if (string.IsNullOrWhiteSpace(args)) 160 | { 161 | if (File.Exists(config)) 162 | { 163 | args = " --conf-path=" + config; 164 | } 165 | else 166 | { 167 | args = " --enable-rpc --rpc-listen-all=true --rpc-allow-origin-all --rpc-listen-port=6800 -c -D"; 168 | } 169 | } 170 | 171 | var psi = new ProcessStartInfo(path, args); 172 | psi.WorkingDirectory = aria2Dir; 173 | psi.WindowStyle = ProcessWindowStyle.Hidden; 174 | psi.CreateNoWindow = true; 175 | psi.UseShellExecute = false; 176 | psi.RedirectStandardOutput = false; 177 | psi.RedirectStandardError = false; 178 | aria2cProcess = Process.Start(psi); 179 | } 180 | catch (Exception ex) 181 | { 182 | Logger.Debug(ex); 183 | } 184 | } 185 | 186 | #endregion 187 | 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /Aria2c/Aria2cSettings.cs: -------------------------------------------------------------------------------- 1 | namespace FlyVR.Aria2 2 | { 3 | public sealed class Aria2cSettings 4 | { 5 | /// 6 | /// exe路径 7 | /// 8 | public string Aria2Path 9 | { 10 | get; 11 | set; 12 | } 13 | 14 | 15 | /// 16 | /// exe启动参数 17 | /// 18 | public string Aria2Args 19 | { 20 | get; 21 | set; 22 | } 23 | 24 | /// 25 | /// RPC连接地址 26 | /// 27 | public string Aria2Host 28 | { 29 | get; 30 | set; 31 | } 32 | 33 | /// 34 | /// RPC连接端口 35 | /// 36 | public int Aria2Port 37 | { 38 | get; 39 | set; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Aria2c/Aria2cTask.cs: -------------------------------------------------------------------------------- 1 | #region 类信息 2 | /*---------------------------------------------------------------- 3 | * 模块名:Aria2cTask 4 | * 创建者:isRight 5 | * 修改者列表: 6 | * 创建日期:2016.12.29 7 | * 模块描述:下载任务信息 8 | *----------------------------------------------------------------*/ 9 | #endregion 10 | 11 | namespace FlyVR.Aria2 12 | { 13 | using CookComputing.XmlRpc; 14 | using System; 15 | using System.Collections.Generic; 16 | 17 | public enum Aria2cTaskStatus 18 | { 19 | //正在下载 20 | Active, 21 | 22 | //任务队列等待 23 | Waiting, 24 | 25 | //暂停 26 | Paused, 27 | 28 | //错误,停止 29 | Error, 30 | 31 | //下载完成 32 | Complete, 33 | 34 | //被用户移除 35 | Removed, 36 | } 37 | 38 | public sealed class Aria2cTask 39 | { 40 | public Aria2cTask() 41 | { 42 | 43 | } 44 | 45 | /// 46 | /// 将RPC信息转换为下载任务 47 | /// 48 | /// RPC信息 49 | public Aria2cTask(XmlRpcStruct rpcStruct) 50 | { 51 | List keyList = rpcStruct.Keys as List; 52 | List valueList = rpcStruct.Values as List; 53 | 54 | for (int i = 0; i < rpcStruct.Count; i++) 55 | { 56 | string key = keyList[i]; 57 | object value = valueList[i]; 58 | 59 | if (key == "gid") 60 | { 61 | this.Gid = value as string; 62 | } 63 | else if (key == "status") 64 | { 65 | this.Status = ConvertToAria2cTaskStatus(value as string); 66 | } 67 | else if (key == "totalLength") 68 | { 69 | this.TotalLength = Convert.ToInt64(value as string); 70 | } 71 | else if (key == "completedLength") 72 | { 73 | this.CompletedLength = Convert.ToInt64(value as string); 74 | } 75 | else if (key == "uploadLength") 76 | { 77 | this.UploadLength = Convert.ToInt64(value as string); 78 | } 79 | else if (key == "bitfield") 80 | { 81 | this.Bitfield = value as string; 82 | } 83 | else if (key == "downloadSpeed") 84 | { 85 | this.DownloadSpeed = Convert.ToInt64(value as string); 86 | } 87 | else if (key == "uploadSpeed") 88 | { 89 | this.UploadSpeed = Convert.ToInt64(value as string); 90 | } 91 | else if (key == "infoHash") 92 | { 93 | this.InfoHash = value as string; 94 | } 95 | else if (key == "numSeeders") 96 | { 97 | this.NumSeeders = Convert.ToInt64(value as string); 98 | } 99 | else if (key == "numPieces") 100 | { 101 | this.NumPieces = Convert.ToInt64(value as string); 102 | } 103 | else if (key == "seeder") 104 | { 105 | this.Seeder = (value as string) == "true" ? true : false; 106 | } 107 | else if (key == "pieceLength") 108 | { 109 | this.PieceLength = Convert.ToInt64(value as string); 110 | } 111 | else if (key == "connections") 112 | { 113 | this.Connections = Convert.ToInt64(value as string); 114 | } 115 | else if (key == "errorCode") 116 | { 117 | this.ErrorCode = Convert.ToInt64(value as string); 118 | } 119 | else if (key == "errorMessage") 120 | { 121 | this.ErrorMessage = value as string; 122 | } 123 | else if (key == "followedBy") 124 | { 125 | this.FollowedBy = value; 126 | } 127 | else if (key == "following") 128 | { 129 | this.Following = value; 130 | } 131 | else if (key == "belongsTo") 132 | { 133 | this.BelongsTo = value as string; 134 | } 135 | else if (key == "dir") 136 | { 137 | this.Dir = value as string; 138 | } 139 | else if (key == "files") 140 | { 141 | this.Files = Aria2cTools.ConvertToAria2cFiles(value as XmlRpcStruct[]); 142 | } 143 | else if (key == "bittorrent") 144 | { 145 | this.Bittorrent = new Aria2cBittorrent(value as XmlRpcStruct); 146 | } 147 | else if (key == "verifiedLength") 148 | { 149 | this.VerifiedLength = Convert.ToInt64(value as string); 150 | } 151 | else if (key == "verifyIntegrityPending") 152 | { 153 | this.VerifyIntegrityPending = (value as string) == "true" ? true : false; 154 | } 155 | else 156 | { 157 | throw new Exception("Aria2cTask不包含该属性"); 158 | } 159 | } 160 | } 161 | 162 | /// 163 | /// 将字符串转化为任务状态 164 | /// 165 | /// 166 | /// 167 | public static Aria2cTaskStatus ConvertToAria2cTaskStatus(string str) 168 | { 169 | if (str == "active") 170 | { 171 | return Aria2cTaskStatus.Active; 172 | } 173 | else if (str == "waiting") 174 | { 175 | return Aria2cTaskStatus.Waiting; 176 | } 177 | else if (str == "paused") 178 | { 179 | return Aria2cTaskStatus.Paused; 180 | } 181 | else if (str == "error") 182 | { 183 | return Aria2cTaskStatus.Error; 184 | } 185 | else if (str == "complete") 186 | { 187 | return Aria2cTaskStatus.Complete; 188 | } 189 | else if (str == "removed") 190 | { 191 | return Aria2cTaskStatus.Removed; 192 | } 193 | else 194 | { 195 | throw new Exception("Aria2cTaskStatus不包含该属性"); 196 | } 197 | } 198 | 199 | /// 200 | /// 任务标识符 201 | /// 202 | public string Gid { get; set; } 203 | 204 | /// 205 | /// 任务状态 206 | /// 207 | public Aria2cTaskStatus Status { get; set; } 208 | 209 | /// 210 | /// 任务总长度 单位byte 211 | /// 212 | public long TotalLength { get; set; } 213 | 214 | /// 215 | /// 下载完成长度 单位byte 216 | /// 217 | public long CompletedLength { get; set; } 218 | 219 | /// 220 | /// 上传总长度 221 | /// 222 | public long UploadLength { get; set; } 223 | 224 | 225 | /// 226 | /// 位标识符 227 | /// 228 | public string Bitfield { get; set; } 229 | 230 | /// 231 | /// 下载速度 单位byte/s 232 | /// 233 | public long DownloadSpeed { get; set; } 234 | 235 | /// 236 | /// 上传速度 单位byte/s 237 | /// 238 | public long UploadSpeed { get; set; } 239 | 240 | /// 241 | /// 哈希值, 只对种子下载有效 242 | /// 243 | public string InfoHash { get; set; } 244 | 245 | /// 246 | /// 资源链接数,只对种子下载有效 247 | /// 248 | public long NumSeeders { get; set; } 249 | 250 | /// 251 | /// 本地做种标识, 只对种子下载有效 252 | /// 253 | public bool Seeder { get; set; } 254 | 255 | /// 256 | /// 文件块长度 257 | /// 258 | public long PieceLength { get; set; } 259 | 260 | /// 261 | /// 文件快数量 262 | /// 263 | public long NumPieces { get; set; } 264 | 265 | /// 266 | /// 服务器链接数 267 | /// 268 | public long Connections { get; set; } 269 | 270 | /// 271 | /// 最后一个错误代码 272 | /// 273 | public long ErrorCode { get; set; } 274 | 275 | /// 276 | /// 错误信息描述 277 | /// 278 | public string ErrorMessage { get; set; } 279 | 280 | 281 | 282 | private List _followedByList = new List(); 283 | 284 | /// 285 | /// 所有子任务标识符 286 | /// 待定 287 | /// 288 | public object FollowedBy { get; set; } 289 | 290 | //public void AddFollowedGid(string gid) 291 | //{ 292 | // _followedByList.Add(gid); 293 | //} 294 | 295 | //public bool RemoveFollowedGid(string gid) 296 | //{ 297 | // return _followedByList.Remove(gid); 298 | //} 299 | 300 | 301 | /// 302 | /// 所有子任务标识符, 同FollowedBy 303 | /// 待定 304 | /// 305 | public object Following { get; set; } 306 | 307 | 308 | /// 309 | /// 父级任务标识符 310 | /// 311 | public string BelongsTo { get; set; } 312 | 313 | 314 | /// 315 | /// 任务下载目录 316 | /// 317 | public string Dir { get; set; } 318 | 319 | private List _fileList = new List(); 320 | /// 321 | /// 父级任务标识符 322 | /// 323 | public List Files 324 | { 325 | get 326 | { 327 | return _fileList; 328 | } 329 | set 330 | { 331 | _fileList = value; 332 | } 333 | } 334 | 335 | public void AddAria2cFile(Aria2cFile file) 336 | { 337 | _fileList.Add(file); 338 | } 339 | 340 | public bool RemoveAria2cFile(Aria2cFile file) 341 | { 342 | return _fileList.Remove(file); 343 | } 344 | 345 | /// 346 | /// 种子文件信息 347 | /// 348 | public Aria2cBittorrent Bittorrent { get; set; } 349 | 350 | /// 351 | /// 已确定的文件长度 352 | /// 353 | public long VerifiedLength { get; set; } 354 | 355 | /// 356 | /// 是否在判定任务文件长度 357 | /// 358 | public bool VerifyIntegrityPending { get; set; } 359 | } 360 | } 361 | -------------------------------------------------------------------------------- /Aria2c/Aria2cTaskEvent.cs: -------------------------------------------------------------------------------- 1 | #region 类信息 2 | /*---------------------------------------------------------------- 3 | * 模块名:Aria2cTaskEvent 4 | * 创建者:isRight 5 | * 修改者列表: 6 | * 创建日期:2016.12.29 7 | * 模块描述:aria2c任务信息事件 8 | *----------------------------------------------------------------*/ 9 | #endregion 10 | 11 | namespace FlyVR.Aria2 12 | { 13 | using System; 14 | 15 | public sealed class Aria2cTaskEvent : EventArgs 16 | { 17 | public Aria2cTaskEvent() 18 | { 19 | 20 | } 21 | 22 | public Aria2cTaskEvent(Aria2cTask task) 23 | { 24 | Gid = task.Gid; 25 | Task = task; 26 | } 27 | 28 | /// 29 | /// 任务标识符 30 | /// 31 | public string Gid { get; set; } 32 | 33 | /// 34 | /// 任务信息 35 | /// 36 | public Aria2cTask Task { get; set; } 37 | 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Aria2c/Aria2cTools.cs: -------------------------------------------------------------------------------- 1 | #region 类信息 2 | /*---------------------------------------------------------------- 3 | * 模块名:Aria2cTools 4 | * 创建者:isRight 5 | * 修改者列表: 6 | * 创建日期:2016.12.29 7 | * 模块描述:工具方法 8 | *----------------------------------------------------------------*/ 9 | #endregion 10 | 11 | namespace FlyVR.Aria2 12 | { 13 | using CookComputing.XmlRpc; 14 | using System; 15 | using System.Collections.Generic; 16 | using System.ComponentModel; 17 | using System.Linq; 18 | using System.Text; 19 | using System.Threading.Tasks; 20 | 21 | public enum PosType 22 | { 23 | //头部 24 | [Description("POS_SET")] 25 | POS_SET, 26 | 27 | //当前位置 28 | [Description("POS_CUR")] 29 | POS_CUR, 30 | 31 | //尾部 32 | [Description("POS_END")] 33 | POS_END, 34 | } 35 | 36 | public sealed class Aria2cTools 37 | { 38 | private Aria2cTools() 39 | { 40 | 41 | } 42 | 43 | /// 44 | /// 将RPC信息转化为任务状态 45 | /// 46 | /// 47 | /// 48 | public static List ConvertToAria2cTasks(XmlRpcStruct[] rpcStruct) 49 | { 50 | List taskList = new List(); 51 | 52 | foreach (XmlRpcStruct rpc in rpcStruct) 53 | { 54 | Aria2cTask task = new Aria2cTask(rpc); 55 | taskList.Add(task); 56 | } 57 | 58 | return taskList; 59 | } 60 | 61 | 62 | /// 63 | /// 将rpc信息转换为下载任务文件信息 64 | /// 65 | /// 66 | /// 67 | public static List ConvertToAria2cFiles(params XmlRpcStruct[] rpcStruct) 68 | { 69 | List fileList = new List(); 70 | 71 | foreach (XmlRpcStruct rpc in rpcStruct) 72 | { 73 | Aria2cFile file = new Aria2cFile(rpc); 74 | fileList.Add(file); 75 | } 76 | 77 | return fileList; 78 | } 79 | 80 | /// 81 | /// 将rpc信息转换为下载任务文件链接信息 82 | /// 83 | /// 84 | /// 85 | public static List ConvertToAria2cUris(params XmlRpcStruct[] rpcStruct) 86 | { 87 | List uriList = new List(); 88 | 89 | foreach (XmlRpcStruct rpc in rpcStruct) 90 | { 91 | Aria2cUri uri = new Aria2cUri(rpc); 92 | uriList.Add(uri); 93 | } 94 | 95 | return uriList; 96 | } 97 | 98 | 99 | /// 100 | /// 将rpc信息转换为种子链接信息 101 | /// 102 | /// rpc信息 103 | /// 种子链接信息列表 104 | public static List ConvertToAria2cPeers(params XmlRpcStruct[] rpcStruct) 105 | { 106 | List peerList = new List(); 107 | 108 | foreach (XmlRpcStruct rpc in rpcStruct) 109 | { 110 | Aria2cPeers peer = new Aria2cPeers(rpc); 111 | peerList.Add(peer); 112 | } 113 | 114 | return peerList; 115 | } 116 | 117 | 118 | /// 119 | /// 将rpc信息转换到服务器信息中 120 | /// 121 | /// 122 | /// 服务器信息列表 123 | public static List ConvertToAria2cServers(params XmlRpcStruct[] rpcStruct) 124 | { 125 | List serverList = new List(); 126 | 127 | foreach (XmlRpcStruct rpc in rpcStruct) 128 | { 129 | Aria2cLink server = new Aria2cLink(rpc); 130 | serverList.Add(server); 131 | } 132 | 133 | return serverList; 134 | } 135 | 136 | /// 137 | /// 将rpc信息转换到服务器地址信息中 138 | /// 139 | /// 140 | /// 服务器信息地址列表 141 | public static List ConvertToAria2cServerLink(params XmlRpcStruct[] rpcStruct) 142 | { 143 | List linkList = new List(); 144 | 145 | foreach (XmlRpcStruct rpc in rpcStruct) 146 | { 147 | Aria2cServerLink serverLink = new Aria2cServerLink(rpc); 148 | linkList.Add(serverLink); 149 | } 150 | 151 | return linkList; 152 | } 153 | 154 | /// 155 | /// 获取XmlRpcStruct中的值 156 | /// 157 | /// 158 | /// 主键名 159 | /// 160 | public static object GetRpcStructValue(XmlRpcStruct rpcStruct, string key) 161 | { 162 | List keyList = rpcStruct.Keys as List; 163 | List valueList = rpcStruct.Values as List; 164 | 165 | for (int i = 0; i < rpcStruct.Count; i++) 166 | { 167 | if (key == keyList[i]) 168 | { 169 | object value = valueList[i]; 170 | return value; 171 | } 172 | } 173 | 174 | throw new Exception("XmlRpcStruct中不包含该主键"); 175 | } 176 | 177 | /// 178 | /// 获取枚举类型描述 179 | /// 180 | /// 181 | /// 返回描述,没有描述将直接返回枚举名称 182 | public static string GetEnumDescription(Enum value) 183 | { 184 | string str = value.ToString(); 185 | System.Reflection.FieldInfo field = value.GetType().GetField(str); 186 | object[] objs = field.GetCustomAttributes(typeof(System.ComponentModel.DescriptionAttribute), false); 187 | if (objs == null || objs.Length == 0) 188 | { 189 | return str; 190 | } 191 | 192 | System.ComponentModel.DescriptionAttribute da = (System.ComponentModel.DescriptionAttribute)objs[0]; 193 | return da.Description; 194 | } 195 | 196 | 197 | /// 198 | /// 根据路径获取文件目录 199 | /// 200 | /// 文件路径 201 | /// 文件目录 202 | public static string GetDirectoryName(string path) 203 | { 204 | return System.IO.Path.GetDirectoryName(path); 205 | } 206 | 207 | /// 208 | /// 根据路径获取文件名 209 | /// 210 | /// 文件路径 211 | /// 212 | public static string GetFileName(string path) 213 | { 214 | return System.IO.Path.GetFileName(path); 215 | } 216 | 217 | /// 218 | /// 根据路径获取文件名,不带后缀名 219 | /// 220 | /// 文件路径 221 | /// 222 | public static string GetFileNameWithoutExtension(string path) 223 | { 224 | return System.IO.Path.GetFileNameWithoutExtension(path); 225 | } 226 | 227 | /// 228 | /// 将纪元时间转换为标准时间 229 | /// 230 | /// 从1970.1.1开始,到现在经过的秒数 231 | /// UTC时间 232 | public static DateTime EpochToUtcTime(long second) 233 | { 234 | DateTime dateTime = new DateTime(1970, 1, 1); 235 | dateTime.AddSeconds(second); 236 | return dateTime; 237 | } 238 | 239 | /// 240 | /// 纪元时间转换为字符串 241 | /// 242 | /// 从1970.1.1开始,到现在经过的秒数 243 | /// UTC时间字符串 244 | public static string EpochToString(long second) 245 | { 246 | DateTime dateTime = new DateTime(1970, 1, 1); 247 | dateTime.AddSeconds(second); 248 | string dateString = dateTime.ToString("yyyy-MM-dd hh:mm:ss"); 249 | return dateString; 250 | } 251 | 252 | /// 253 | /// 将UTC时间转换为字符串 254 | /// 255 | /// UTC时间 256 | /// UTC时间字符串 257 | public static string DateTimeToString(DateTime dateTime) 258 | { 259 | string dateString = dateTime.ToString("yyyy-MM-dd hh:mm:ss"); 260 | return dateString; 261 | } 262 | } 263 | } 264 | -------------------------------------------------------------------------------- /Aria2c/Aria2cUri.cs: -------------------------------------------------------------------------------- 1 | #region 类信息 2 | /*---------------------------------------------------------------- 3 | * 模块名:Aria2cUri 4 | * 创建者:isRight 5 | * 修改者列表: 6 | * 创建日期:2016.12.29 7 | * 模块描述:aria2c下载任务uri 8 | *----------------------------------------------------------------*/ 9 | #endregion 10 | 11 | using CookComputing.XmlRpc; 12 | using System; 13 | using System.Collections.Generic; 14 | 15 | namespace FlyVR.Aria2 16 | { 17 | /// 18 | /// Uri状态 19 | /// 20 | public enum Aria2cUriStatus 21 | { 22 | //正在使用 23 | Used, 24 | 25 | //下载任务队列中等待 26 | Waiting, 27 | } 28 | 29 | /// 30 | /// 下载文件Uri 31 | /// 32 | public sealed class Aria2cUri 33 | { 34 | public Aria2cUri() 35 | { 36 | 37 | } 38 | 39 | /// 40 | /// 将rpc信息转换为下载任务文件链接信息 41 | /// 42 | /// 43 | public Aria2cUri(XmlRpcStruct rpcStruct) 44 | { 45 | List keyList = rpcStruct.Keys as List; 46 | List valueList = rpcStruct.Values as List; 47 | 48 | for (int i = 0; i < rpcStruct.Count; i++) 49 | { 50 | string key = keyList[i]; 51 | object value = valueList[i]; 52 | 53 | if (key == "status") 54 | { 55 | this.Status = ConvertToAria2cUriStatus(value as string); 56 | } 57 | else if (key == "uri") 58 | { 59 | this.Uri = value as string; 60 | } 61 | else 62 | { 63 | throw new Exception("无法将属性转换到Aria2cUri中"); 64 | } 65 | 66 | } 67 | } 68 | 69 | /// 70 | /// 将字符串转换为链接状态信息 71 | /// 72 | /// 73 | /// 74 | public static Aria2cUriStatus ConvertToAria2cUriStatus(string str) 75 | { 76 | if (str == "used") 77 | { 78 | return Aria2cUriStatus.Used; 79 | } 80 | else if (str == "waiting") 81 | { 82 | return Aria2cUriStatus.Waiting; 83 | } 84 | else 85 | { 86 | throw new Exception("Aria2cUriStatusAria2cFile不包含该属性"); 87 | } 88 | } 89 | 90 | /// 91 | /// 文件Uri 92 | /// 93 | public string Uri { get; set; } 94 | 95 | 96 | /// 97 | /// Uri状态 98 | /// 99 | public Aria2cUriStatus Status { get; set; } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /Aria2c/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // 有关程序集的一般信息由以下 8 | // 控制。更改这些特性值可修改 9 | // 与程序集关联的信息。 10 | [assembly: AssemblyTitle("aria2c")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("aria2c")] 15 | [assembly: AssemblyCopyright("Copyright © 2016")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | //将 ComVisible 设置为 false 将使此程序集中的类型 20 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 21 | //请将此类型的 ComVisible 特性设置为 true。 22 | [assembly: ComVisible(false)] 23 | 24 | //若要开始生成可本地化的课程程序,请 25 | // 中的 .csproj 文件中 26 | //例如,如果您在源文件中使用的是美国英语, 27 | //使用的是美国英语,请将 设置为 en-US。 然后取消 28 | //对以下 NeutralResourceLanguage 特性的注释。 更新 29 | //以下行中的“en-US”以匹配项目文件中的 UICulture 设置。 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //主题特定资源词典所处位置 36 | //(当资源未在页面 37 | //或课程程序资源字典中找到时使用) 38 | ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置 39 | //(当资源未在页面 40 | //、课程程序或任何主题专用资源字典中找到时使用) 41 | )] 42 | 43 | 44 | // 程序集的版本信息由下列四个值组成: 45 | // 46 | // 主版本 47 | // 次版本 48 | // 生成号 49 | // 修订号 50 | // 51 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 52 | // 方法是按如下所示使用“*”: : 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /Aria2c/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace FlyVR.Aria2.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// 一个强类型的资源类,用于查找本地化的字符串等。 17 | /// 18 | // 此类是由 StronglyTypedResourceBuilder 19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen 21 | // (以 /str 作为命令选项),或重新生成 VS 项目。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// 返回此类使用的缓存的 ResourceManager 实例。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FlyVR.Aria2.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 使用此强类型资源类,为所有资源查找 51 | /// 重写当前线程的 CurrentUICulture 属性。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Aria2c/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 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 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /Aria2c/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace FlyVR.Aria2.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Aria2c/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Readme: -------------------------------------------------------------------------------- 1 | C#封装的Ari2c接口,详细的接口使用说明在代码中注释 2 | -------------------------------------------------------------------------------- /XmlRpcNet/AssemblyDesc.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2011, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | using System.Reflection; 27 | using System.Runtime.CompilerServices; 28 | using System.Security; 29 | 30 | [assembly: AssemblyDescription("Requires .NET 2.0 or later")] 31 | 32 | -------------------------------------------------------------------------------- /XmlRpcNet/AssemblyDescFX1_0.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2006, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | using System.Reflection; 27 | using System.Runtime.CompilerServices; 28 | using System.Security; 29 | 30 | [assembly: AssemblyDescription("Supports all versions of .NET")] 31 | 32 | -------------------------------------------------------------------------------- /XmlRpcNet/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2011, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | using System.Reflection; 27 | using System.Security; 28 | 29 | [assembly: AssemblyTitle("XML-RPC.NET")] 30 | [assembly: AssemblyConfiguration("")] 31 | [assembly: AssemblyCompany("Cook Computing")] 32 | [assembly: AssemblyProduct("XML-RPC.Net")] 33 | [assembly: AssemblyCopyright("Charles Cook (c) 2001-2011")] 34 | [assembly: AssemblyTrademark("")] 35 | [assembly: AssemblyCulture("")] 36 | 37 | #if (!COMPACT_FRAMEWORK) 38 | [assembly: AllowPartiallyTrustedCallers] 39 | #endif 40 | [assembly: System.CLSCompliant(true)] 41 | -------------------------------------------------------------------------------- /XmlRpcNet/CookComputing.XmlRpc.Targets: -------------------------------------------------------------------------------- 1 |  3 | 4 | 5 | <_DisabledWarnings>$(NoWarn) 6 | $(DefineConstants);FX1_0 7 | 8 | 9 | 27 | 28 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /XmlRpcNet/DateTime8601.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Text.RegularExpressions; 4 | 5 | namespace CookComputing.XmlRpc 6 | { 7 | public static class DateTime8601 8 | { 9 | static Regex _dateTime8601Regex = new Regex( 10 | @"(((?\d{4})-(?\d{2})-(?\d{2}))|((?\d{4})(?\d{2})(?\d{2})))" 11 | + @"T" 12 | + @"(((?\d{2}):(?\d{2}):(?\d{2}))|((?\d{2})(?\d{2})(?\d{2})))" 13 | + @"(?$|Z|([+-]\d{2}:?(\d{2})?))"); 14 | 15 | 16 | static public bool TryParseDateTime8601(string date, out DateTime result) 17 | { 18 | result = DateTime.MinValue; 19 | var m = _dateTime8601Regex.Match(date); 20 | if (m == null) 21 | return false; 22 | string normalized = m.Groups["year"].Value + m.Groups["month"].Value + m.Groups["day"].Value 23 | + "T" 24 | + m.Groups["hour"].Value + m.Groups["minute"].Value + m.Groups["second"].Value 25 | + m.Groups["tz"].Value; 26 | var formats = new string[] 27 | { 28 | "yyyyMMdd'T'HHmmss", 29 | "yyyyMMdd'T'HHmmss'Z'", 30 | "yyyyMMdd'T'HHmmsszzz", 31 | "yyyyMMdd'T'HHmmsszz", 32 | }; 33 | // Compact Framework doesn't support TryParseExact() 34 | try 35 | { 36 | result = DateTime.ParseExact(normalized, formats, CultureInfo.InvariantCulture, 37 | System.Globalization.DateTimeStyles.AdjustToUniversal); 38 | return true; 39 | } 40 | catch (Exception) 41 | { 42 | return false; 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /XmlRpcNet/GuidEx.cs: -------------------------------------------------------------------------------- 1 | ////========================================================================================== 2 | //// 3 | //// OpenNETCF.GuidEx 4 | //// Copyright (C) 2003-2005, OpenNETCF.org 5 | //// 6 | //// This library is free software; you can redistribute it and/or modify it under 7 | //// the terms of the OpenNETCF.org Shared Source License. 8 | //// 9 | //// This library is distributed in the hope that it will be useful, but 10 | //// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | //// FITNESS FOR A PARTICULAR PURPOSE. See the OpenNETCF.org Shared Source License 12 | //// for more details. 13 | //// 14 | //// You should have received a copy of the OpenNETCF.org Shared Source License 15 | //// along with this library; if not, email licensing@opennetcf.org to request a copy. 16 | //// 17 | //// If you wish to contact the OpenNETCF Advisory Board to discuss licensing, please 18 | //// email licensing@opennetcf.org. 19 | //// 20 | //// For general enquiries, email enquiries@opennetcf.org or visit our website at: 21 | //// http://www.opennetcf.org 22 | //// 23 | //// !!! A HUGE thank-you goes out to Casey Chesnut for supplying parts of this code !!! 24 | //// !!! You can contact Casey at http://www.brains-n-brawn.com 25 | //// 26 | ////========================================================================================== 27 | 28 | //#if(COMPACT_FRAMEWORK) 29 | 30 | //using System; 31 | //using System.Runtime.InteropServices; 32 | ////using OpenNETCF.Security.Cryptography; 33 | 34 | //// New for v1.3 - "The Guid to end all Guids" - Peter Foot 35 | //namespace OpenNETCF 36 | //{ 37 | // /// 38 | // /// Helper class for generating a globally unique identifier (GUID). 39 | // /// Revised in v1.3 40 | // /// 41 | // /// 42 | // public sealed class GuidEx 43 | // { 44 | // private GuidEx(){} 45 | 46 | // #region New Guid 47 | // /// 48 | // /// Initializes a new instance of the class. 49 | // /// 50 | // /// A new object. 51 | // /// On CE.NET 4.1 and higher this method uses the CoCreateGuid API call. 52 | // /// On CE 3.0 based Pocket PCs it uses the OpenNETCF.Security.Cryptography classes to generate a random Guid. 53 | // public static System.Guid NewGuid() 54 | // { 55 | // //cocreateguid supported on CE.NET 4.1 and above (4.0 not supported by .NETCF) 56 | // if(System.Environment.OSVersion.Version.Major > 3) 57 | // { 58 | // return NewOleGuid(); 59 | // } 60 | // else 61 | // { 62 | // //check if target has crypto API support 63 | //// if(OpenNETCF.Security.Cryptography.NativeMethods.Context.IsCryptoApi) 64 | //// { 65 | //// return NewCryptoGuid(); 66 | //// } 67 | //// else 68 | // { 69 | // //if not use random generator 70 | // return NewRandomGuid(); 71 | // } 72 | // } 73 | // } 74 | // #endregion 75 | 76 | 77 | // #region Constants 78 | // // constants that are used in the class 79 | // private class Const 80 | // { 81 | // // guid variant types 82 | // public enum GuidVariant 83 | // { 84 | // ReservedNCS = 0x00, 85 | // Standard = 0x02, 86 | // ReservedMicrosoft = 0x06, 87 | // ReservedFuture = 0x07 88 | // } 89 | 90 | // // guid version types 91 | // public enum GuidVersion 92 | // { 93 | // TimeBased = 0x01, 94 | // Reserved = 0x02, 95 | // NameBased = 0x03, 96 | // Random = 0x04 97 | // } 98 | 99 | // // multiplex variant info 100 | // public const int VariantByte = 8; 101 | // public const int VariantByteMask = 0x3f; 102 | // public const int VariantByteShift = 6; 103 | 104 | // // multiplex version info 105 | // public const int VersionByte = 7; 106 | // public const int VersionByteMask = 0x0f; 107 | // public const int VersionByteShift = 4; 108 | // } 109 | // #endregion 110 | 111 | // #region Crypto 112 | //// /// 113 | //// /// Create a new Random Guid using Crypto APIs 114 | //// /// 115 | //// /// 116 | //// public static System.Guid NewCryptoGuid() 117 | //// { 118 | //// //create guid manually 119 | //// byte[] guidbytes = new byte[16]; 120 | //// 121 | //// //use crypto apis to generate random bytes 122 | //// OpenNETCF.Security.Cryptography.RNGCryptoServiceProvider rng = new OpenNETCF.Security.Cryptography.RNGCryptoServiceProvider(); 123 | //// rng.GetBytes(guidbytes); 124 | //// 125 | //// //set version etc 126 | //// MakeValidRandomGuid(guidbytes); 127 | //// 128 | //// // create the new System.Guid object 129 | //// return new System.Guid(guidbytes); 130 | //// } 131 | // #endregion 132 | 133 | // #region Random 134 | // /// 135 | // /// Create a new Random Guid (For platforms without Crypto support). 136 | // /// 137 | // /// 138 | // public static System.Guid NewRandomGuid() 139 | // { 140 | // byte[] guidbytes = new byte[16]; 141 | // (new Random()).NextBytes(guidbytes); 142 | 143 | // //set version etc 144 | // MakeValidRandomGuid(guidbytes); 145 | 146 | 147 | // // create the new System.Guid object 148 | // return new System.Guid(guidbytes); 149 | // } 150 | // #endregion 151 | 152 | // #region Helper Methods 153 | // private static void MakeValidRandomGuid(byte[] guidbytes) 154 | // { 155 | // // set the variant 156 | // guidbytes[Const.VariantByte] &= Const.VariantByteMask; 157 | // guidbytes[Const.VariantByte] |= 158 | // ((int)Const.GuidVariant.Standard << Const.VariantByteShift); 159 | 160 | // // set the version 161 | // guidbytes[Const.VersionByte] &= Const.VersionByteMask; 162 | // guidbytes[Const.VersionByte] |= 163 | // ((int)Const.GuidVersion.Random << Const.VersionByteShift); 164 | // } 165 | // #endregion 166 | 167 | // #region Ticks 168 | // /// 169 | // /// Create a new only using TickCount and bit shifting. 170 | // /// 171 | // public static System.Guid NewGuidTicks() 172 | // { 173 | // // Create a unique GUID 174 | // long fileTime = DateTime.Now.ToUniversalTime().ToFileTime(); 175 | // UInt32 high32 = (UInt32)(fileTime >> 32)+0x146BF4; 176 | // int tick = System.Environment.TickCount; 177 | // byte[] guidBytes = new byte[8]; 178 | 179 | // // load the byte array with random bits 180 | // Random rand = new Random((int)fileTime); 181 | // rand.NextBytes(guidBytes); 182 | 183 | // // use tick info in the middle of the array 184 | // guidBytes[2] = (byte)(tick >> 24); 185 | // guidBytes[3] = (byte)(tick >> 16); 186 | // guidBytes[4] = (byte)(tick >> 8); 187 | // guidBytes[5] = (byte)tick; 188 | 189 | // // Construct a Guid with our data 190 | // System.Guid guid = new System.Guid((int)fileTime, (short)high32, (short)((high32 | 0x10000000) >> 16), guidBytes); 191 | // return guid; 192 | // } 193 | // #endregion 194 | 195 | // #region Ole 196 | // /// 197 | // /// Create a new using COM APIs 198 | // /// 199 | // /// 200 | // /// Requires Windows CE.NET 4.1 or higher. 201 | // public static System.Guid NewOleGuid() 202 | // { 203 | // System.Guid val = System.Guid.Empty; 204 | 205 | // int hresult = 0; 206 | // hresult = CoCreateGuid(ref val); 207 | 208 | // if(hresult != 0) 209 | // { 210 | // throw new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error(), "Error creating new Guid"); 211 | // } 212 | 213 | // return val; 214 | // } 215 | // [DllImport("ole32.dll", SetLastError=true)] 216 | // private static extern int CoCreateGuid(ref System.Guid pguid); 217 | // #endregion 218 | // } 219 | 220 | //} 221 | 222 | //#endif -------------------------------------------------------------------------------- /XmlRpcNet/IXmlRpcProxy.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2006, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | using System; 27 | using System.ComponentModel; 28 | using System.Collections; 29 | using System.Net; 30 | using System.Security.Cryptography.X509Certificates; 31 | using System.Text; 32 | 33 | namespace CookComputing.XmlRpc 34 | { 35 | public interface IXmlRpcProxy 36 | { 37 | bool AllowAutoRedirect { get; set; } 38 | 39 | void AttachLogger(XmlRpcLogger logger); 40 | 41 | #if (!COMPACT_FRAMEWORK && !SILVERLIGHT && !SILVERLIGHT) 42 | X509CertificateCollection ClientCertificates { get; } 43 | #endif 44 | 45 | #if (!COMPACT_FRAMEWORK && !SILVERLIGHT) 46 | string ConnectionGroupName { get; set; } 47 | #endif 48 | 49 | CookieContainer CookieContainer { get; } 50 | 51 | [Browsable(false)] 52 | ICredentials Credentials { get; set; } 53 | 54 | #if (!COMPACT_FRAMEWORK && !FX1_0 && !SILVERLIGHT) 55 | bool EnableCompression { get; set;} 56 | 57 | bool Expect100Continue { get; set; } 58 | 59 | bool UseNagleAlgorithm { get; set; } 60 | #endif 61 | 62 | [Browsable(false)] 63 | WebHeaderCollection Headers { get; } 64 | 65 | Guid Id { get; } 66 | 67 | int Indentation { get; set; } 68 | 69 | bool KeepAlive { get; set; } 70 | 71 | XmlRpcNonStandard NonStandard { get; set; } 72 | 73 | bool PreAuthenticate { get; set; } 74 | 75 | #if (!SILVERLIGHT) 76 | [Browsable(false)] 77 | System.Version ProtocolVersion { get; set; } 78 | #endif 79 | 80 | #if (!SILVERLIGHT) 81 | [Browsable(false)] 82 | IWebProxy Proxy { get; set; } 83 | #endif 84 | 85 | [Browsable(false)] 86 | CookieCollection ResponseCookies { get; } 87 | 88 | [Browsable(false)] 89 | WebHeaderCollection ResponseHeaders { get; } 90 | 91 | int Timeout { get; set; } 92 | 93 | string Url { get; set; } 94 | 95 | bool UseEmptyElementTags { get; set; } 96 | 97 | bool UseEmptyParamsTag { get; set; } 98 | 99 | bool UseIndentation { get; set; } 100 | 101 | bool UseIntTag { get; set; } 102 | 103 | bool UseStringTag { get; set; } 104 | 105 | string UserAgent { get; set; } 106 | 107 | [Browsable(false)] 108 | Encoding XmlEncoding { get; set; } 109 | 110 | string XmlRpcMethod { get; set; } 111 | 112 | // introspecton methods 113 | string[] SystemListMethods(); 114 | object[] SystemMethodSignature(string MethodName); 115 | string SystemMethodHelp(string MethodName); 116 | 117 | // events 118 | event XmlRpcRequestEventHandler RequestEvent; 119 | event XmlRpcResponseEventHandler ResponseEvent; 120 | 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /XmlRpcNet/MappingActions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CookComputing.XmlRpc 6 | { 7 | public class MappingActions 8 | { 9 | public NullMappingAction NullMappingAction { get; set; } 10 | public EnumMapping EnumMapping { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /XmlRpcNet/MappingStack.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CookComputing.XmlRpc 6 | { 7 | public class MappingStack : Stack 8 | { 9 | public MappingStack(string parseType) 10 | { 11 | m_parseType = parseType; 12 | } 13 | 14 | public string MappingType 15 | { 16 | get { return m_parseType; } 17 | } 18 | 19 | public string m_parseType = ""; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /XmlRpcNet/RequestResponseLogger.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2006, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | using System; 27 | using System.IO; 28 | 29 | namespace CookComputing.XmlRpc 30 | { 31 | public class RequestResponseLogger : XmlRpcLogger 32 | { 33 | string _directory = "."; 34 | 35 | public string Directory 36 | { 37 | get { return _directory; } 38 | set { _directory = Path.GetDirectoryName(value + "/"); } 39 | } 40 | 41 | protected override void OnRequest(object sender, XmlRpcRequestEventArgs e) 42 | { 43 | string fname = string.Format("{0}/{1}-{2:0000}-request-{3}.xml", 44 | _directory, DateTime.Now.Ticks, e.RequestNum, e.ProxyID); 45 | FileStream fstm = new FileStream(fname, FileMode.Create); 46 | Util.CopyStream(e.RequestStream, fstm); 47 | fstm.Close(); 48 | } 49 | 50 | protected override void OnResponse(object sender, XmlRpcResponseEventArgs e) 51 | { 52 | string fname = string.Format("{0}/{1}-{2:0000}-response-{3}.xml", 53 | _directory, DateTime.Now.Ticks, e.RequestNum, e.ProxyID); 54 | FileStream fstm = new FileStream(fname, FileMode.Create); 55 | Util.CopyStream(e.ResponseStream, fstm); 56 | fstm.Close(); 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /XmlRpcNet/Tracer.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2006, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | #if (!SILVERLIGHT) 27 | 28 | using System; 29 | using System.Diagnostics; 30 | using System.IO; 31 | using CookComputing.XmlRpc; 32 | 33 | namespace CookComputing.XmlRpc 34 | { 35 | public class Tracer : XmlRpcLogger 36 | { 37 | protected override void OnRequest(object sender, XmlRpcRequestEventArgs e) 38 | { 39 | DumpStream(e.RequestStream); 40 | } 41 | 42 | protected override void OnResponse(object sender, XmlRpcResponseEventArgs e) 43 | { 44 | DumpStream(e.ResponseStream); 45 | } 46 | 47 | private void DumpStream(Stream stm) 48 | { 49 | TextReader trdr = new StreamReader(stm); 50 | String s = trdr.ReadToEnd(); 51 | Trace.WriteLine(s); 52 | stm.Position = 0; 53 | } 54 | } 55 | } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /XmlRpcNet/WebSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.ComponentModel; 5 | using System.Security.Cryptography.X509Certificates; 6 | using System.Net; 7 | 8 | namespace CookComputing.XmlRpc 9 | { 10 | public class WebSettings 11 | { 12 | public bool AllowAutoRedirect 13 | { 14 | get { return _allowAutoRedirect; } 15 | set { _allowAutoRedirect = value; } 16 | } 17 | private bool _allowAutoRedirect = true; 18 | 19 | #if (!COMPACT_FRAMEWORK && !SILVERLIGHT) 20 | [Browsable(false)] 21 | public X509CertificateCollection ClientCertificates 22 | { 23 | get { return _clientCertificates; } 24 | } 25 | private X509CertificateCollection _clientCertificates 26 | = new X509CertificateCollection(); 27 | #endif 28 | 29 | #if (!COMPACT_FRAMEWORK) 30 | public string ConnectionGroupName 31 | { 32 | get { return _connectionGroupName; } 33 | set { _connectionGroupName = value; } 34 | } 35 | private string _connectionGroupName = null; 36 | #endif 37 | 38 | [Browsable(false)] 39 | public ICredentials Credentials 40 | { 41 | get { return _credentials; } 42 | set { _credentials = value; } 43 | } 44 | private ICredentials _credentials = null; 45 | 46 | #if (!COMPACT_FRAMEWORK && !FX1_0) 47 | public bool EnableCompression 48 | { 49 | get { return _enableCompression; } 50 | set { _enableCompression = value; } 51 | } 52 | private bool _enableCompression = false; 53 | #endif 54 | 55 | [Browsable(false)] 56 | public WebHeaderCollection Headers 57 | { 58 | get { return _headers; } 59 | } 60 | private WebHeaderCollection _headers = new WebHeaderCollection(); 61 | 62 | #if (!COMPACT_FRAMEWORK && !FX1_0) 63 | public bool Expect100Continue 64 | { 65 | get { return _expect100Continue; } 66 | set { _expect100Continue = value; } 67 | } 68 | private bool _expect100Continue = false; 69 | #endif 70 | 71 | public CookieContainer CookieContainer 72 | { 73 | get { return _cookies; } 74 | } 75 | private CookieContainer _cookies = new CookieContainer(); 76 | 77 | public bool KeepAlive 78 | { 79 | get { return _keepAlive; } 80 | set { _keepAlive = value; } 81 | } 82 | private bool _keepAlive = true; 83 | 84 | public bool PreAuthenticate 85 | { 86 | get { return _preAuthenticate; } 87 | set { _preAuthenticate = value; } 88 | } 89 | private bool _preAuthenticate = false; 90 | 91 | #if (!SILVERLIGHT) 92 | [Browsable(false)] 93 | public System.Version ProtocolVersion 94 | { 95 | get { return _protocolVersion; } 96 | set { _protocolVersion = value; } 97 | } 98 | private Version _protocolVersion = HttpVersion.Version11; 99 | #endif 100 | 101 | #if (!SILVERLIGHT) 102 | [Browsable(false)] 103 | public IWebProxy Proxy 104 | { 105 | get { return _proxy; } 106 | set { _proxy = value; } 107 | } 108 | private IWebProxy _proxy = null; 109 | #endif 110 | 111 | public int Timeout 112 | { 113 | get { return _timeout; } 114 | set { _timeout = value; } 115 | } 116 | private int _timeout = 100000; 117 | 118 | public string Url 119 | { 120 | get { return _url; } 121 | set { _url = value; } 122 | } 123 | private string _url = null; 124 | 125 | #if (!COMPACT_FRAMEWORK && !FX1_0 && !SILVERLIGHT) 126 | public bool UseNagleAlgorithm 127 | { 128 | get { return _useNagleAlgorithm; } 129 | set { _useNagleAlgorithm = value; } 130 | } 131 | private bool _useNagleAlgorithm = false; 132 | #endif 133 | 134 | public string UserAgent 135 | { 136 | get { return _userAgent; } 137 | set { _userAgent = value; } 138 | } 139 | private string _userAgent = "XML-RPC.NET"; 140 | 141 | 142 | 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcAsyncResult.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2011, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | namespace CookComputing.XmlRpc 27 | { 28 | using System; 29 | using System.IO; 30 | using System.Net; 31 | using System.Reflection; 32 | using System.Text; 33 | using System.Threading; 34 | 35 | public class XmlRpcAsyncResult : IAsyncResult 36 | { 37 | public XmlRpcFormatSettings XmlRpcFormatSettings { get; private set; } 38 | 39 | // IAsyncResult members 40 | public object AsyncState 41 | { 42 | get { return userAsyncState; } 43 | } 44 | 45 | public WaitHandle AsyncWaitHandle 46 | { 47 | get 48 | { 49 | bool completed = isCompleted; 50 | if (manualResetEvent == null) 51 | { 52 | lock(this) 53 | { 54 | if (manualResetEvent == null) 55 | manualResetEvent = new ManualResetEvent(completed); 56 | } 57 | } 58 | if (!completed && isCompleted) 59 | manualResetEvent.Set(); 60 | return manualResetEvent; 61 | } 62 | } 63 | 64 | public bool CompletedSynchronously 65 | { 66 | get { return completedSynchronously; } 67 | set 68 | { 69 | if (completedSynchronously) 70 | completedSynchronously = value; 71 | } 72 | } 73 | 74 | public bool IsCompleted 75 | { 76 | get { return isCompleted; } 77 | } 78 | 79 | public CookieCollection ResponseCookies 80 | { 81 | get { return _responseCookies; } 82 | } 83 | 84 | public WebHeaderCollection ResponseHeaders 85 | { 86 | get { return _responseHeaders; } 87 | } 88 | 89 | // public members 90 | public void Abort() 91 | { 92 | if (request != null) 93 | request.Abort(); 94 | } 95 | 96 | public Exception Exception 97 | { 98 | get { return exception; } 99 | } 100 | 101 | public XmlRpcClientProtocol ClientProtocol 102 | { 103 | get { return clientProtocol; } 104 | } 105 | 106 | //internal members 107 | internal XmlRpcAsyncResult( 108 | XmlRpcClientProtocol ClientProtocol, 109 | XmlRpcRequest XmlRpcReq, 110 | XmlRpcFormatSettings xmlRpcFormatSettings, 111 | WebRequest Request, 112 | AsyncCallback UserCallback, 113 | object UserAsyncState, 114 | int retryNumber) 115 | { 116 | xmlRpcRequest = XmlRpcReq; 117 | clientProtocol = ClientProtocol; 118 | request = Request; 119 | userAsyncState = UserAsyncState; 120 | userCallback = UserCallback; 121 | completedSynchronously = true; 122 | XmlRpcFormatSettings = xmlRpcFormatSettings; 123 | } 124 | 125 | internal void Complete( 126 | Exception ex) 127 | { 128 | exception = ex; 129 | Complete(); 130 | } 131 | 132 | internal void Complete() 133 | { 134 | try 135 | { 136 | if (responseStream != null) 137 | { 138 | responseStream.Close(); 139 | responseStream = null; 140 | } 141 | if (responseBufferedStream != null) 142 | responseBufferedStream.Position = 0; 143 | } 144 | catch(Exception ex) 145 | { 146 | if (exception == null) 147 | exception = ex; 148 | } 149 | isCompleted = true; 150 | try 151 | { 152 | if (manualResetEvent != null) 153 | manualResetEvent.Set(); 154 | } 155 | catch(Exception ex) 156 | { 157 | if (exception == null) 158 | exception = ex; 159 | } 160 | if (userCallback != null) 161 | userCallback(this); 162 | } 163 | 164 | internal WebResponse WaitForResponse() 165 | { 166 | if (!isCompleted) 167 | AsyncWaitHandle.WaitOne(); 168 | if (exception != null) 169 | throw exception; 170 | return response; 171 | } 172 | 173 | internal bool EndSendCalled 174 | { 175 | get { return endSendCalled; } 176 | set { endSendCalled = value; } 177 | } 178 | 179 | internal byte[] Buffer 180 | { 181 | get { return buffer; } 182 | set { buffer = value; } 183 | } 184 | 185 | internal WebRequest Request { get { return request; } 186 | } 187 | 188 | internal WebResponse Response 189 | { 190 | get { return response; } 191 | set { response = value; } 192 | } 193 | 194 | internal Stream ResponseStream 195 | { 196 | get { return responseStream; } 197 | set { responseStream = value; } 198 | } 199 | 200 | internal XmlRpcRequest XmlRpcRequest 201 | { 202 | get { return xmlRpcRequest; } 203 | set { xmlRpcRequest = value; } 204 | } 205 | 206 | internal Stream ResponseBufferedStream 207 | { 208 | get { return responseBufferedStream; } 209 | set { responseBufferedStream = value; } 210 | } 211 | 212 | XmlRpcClientProtocol clientProtocol; 213 | WebRequest request; 214 | AsyncCallback userCallback; 215 | object userAsyncState; 216 | bool completedSynchronously; 217 | bool isCompleted; 218 | bool endSendCalled = false; 219 | ManualResetEvent manualResetEvent; 220 | Exception exception; 221 | WebResponse response; 222 | Stream responseStream; 223 | Stream responseBufferedStream; 224 | byte[] buffer; 225 | XmlRpcRequest xmlRpcRequest; 226 | internal CookieCollection _responseCookies; 227 | internal WebHeaderCollection _responseHeaders; 228 | } 229 | } -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcBeginAttribute.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2006, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | namespace CookComputing.XmlRpc 27 | { 28 | using System; 29 | 30 | [AttributeUsage(AttributeTargets.Method)] 31 | public class XmlRpcBeginAttribute : Attribute 32 | { 33 | public XmlRpcBeginAttribute() 34 | { 35 | } 36 | 37 | public XmlRpcBeginAttribute(string method) 38 | { 39 | this.method = method; 40 | } 41 | 42 | public string Method 43 | { 44 | get 45 | { return method; } 46 | } 47 | 48 | public Type ReturnType 49 | { 50 | get { return returnType; } 51 | set { returnType = value; } 52 | } 53 | 54 | public bool IntrospectionMethod 55 | { 56 | get { return introspectionMethod; } 57 | set { introspectionMethod = value; } 58 | } 59 | 60 | public override string ToString() 61 | { 62 | string value = "Method : " + method; 63 | return value; 64 | } 65 | 66 | public string Description = ""; 67 | public bool Hidden = false; 68 | private string method = ""; 69 | private bool introspectionMethod = false; 70 | private Type returnType = null; 71 | } 72 | } 73 | 74 | -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcClientFormatterSink.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2006, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | using System; 27 | using System.Collections; 28 | using System.IO; 29 | using System.Reflection; 30 | using System.Runtime.Remoting.Channels; 31 | using System.Runtime.Remoting.Messaging; 32 | 33 | using CookComputing.XmlRpc; 34 | 35 | namespace CookComputing.XmlRpc 36 | { 37 | public class XmlRpcClientFormatterSink : IClientChannelSink, IMessageSink 38 | { 39 | // constructors 40 | // 41 | public XmlRpcClientFormatterSink( 42 | IClientChannelSink NextSink) 43 | { 44 | m_next = NextSink; 45 | } 46 | 47 | // properties 48 | // 49 | public IClientChannelSink NextChannelSink 50 | { 51 | get { return m_next; } 52 | } 53 | 54 | public IMessageSink NextSink 55 | { 56 | get { throw new NotSupportedException(); } 57 | } 58 | 59 | public IDictionary Properties 60 | { 61 | get { return null; } 62 | } 63 | 64 | // public methods 65 | // 66 | public IMessageCtrl AsyncProcessMessage( 67 | IMessage msg, 68 | IMessageSink replySink) 69 | { 70 | throw new NotSupportedException(); 71 | } 72 | 73 | public void AsyncProcessRequest( 74 | IClientChannelSinkStack sinkStack, 75 | IMessage msg, 76 | ITransportHeaders headers, 77 | Stream stream) 78 | { 79 | throw new Exception("not implemented"); 80 | } 81 | 82 | public void AsyncProcessResponse( 83 | IClientResponseChannelSinkStack sinkStack, 84 | object state, 85 | ITransportHeaders headers, 86 | Stream stream) 87 | { 88 | throw new Exception("not implemented"); 89 | } 90 | 91 | public Stream GetRequestStream( 92 | IMessage msg, 93 | ITransportHeaders headers) 94 | { 95 | return null; // TODO: ??? 96 | } 97 | 98 | public void ProcessMessage( 99 | IMessage msg, 100 | ITransportHeaders requestHeaders, 101 | Stream requestStream, 102 | out ITransportHeaders responseHeaders, 103 | out Stream responseStream) 104 | { 105 | responseHeaders = null; 106 | responseStream = null; 107 | } 108 | 109 | public IMessage SyncProcessMessage( 110 | IMessage msg 111 | ) 112 | { 113 | IMethodCallMessage mcm = msg as IMethodCallMessage; 114 | try 115 | { 116 | Stream reqStm = null; 117 | ITransportHeaders reqHeaders = null; 118 | SerializeMessage(mcm, ref reqHeaders, ref reqStm); 119 | 120 | Stream respStm = null; 121 | ITransportHeaders respHeaders = null; 122 | m_next.ProcessMessage(msg, reqHeaders, reqStm, 123 | out respHeaders, out respStm); 124 | 125 | IMessage imsg = DeserializeMessage(mcm, respHeaders, respStm); 126 | return imsg; 127 | } 128 | catch(Exception ex) 129 | { 130 | return new ReturnMessage(ex, mcm); 131 | } 132 | } 133 | 134 | // private methods 135 | // 136 | void SerializeMessage( 137 | IMethodCallMessage mcm, 138 | ref ITransportHeaders headers, 139 | ref Stream stream) 140 | { 141 | ITransportHeaders reqHeaders = new TransportHeaders(); 142 | reqHeaders["__Uri"] = mcm.Uri; 143 | reqHeaders["Content-Type"] = "text/xml; charset=\"utf-8\""; 144 | reqHeaders["__RequestVerb"] = "POST"; 145 | 146 | MethodInfo mi = (MethodInfo) mcm.MethodBase; 147 | string methodName = GetRpcMethodName(mi); 148 | XmlRpcRequest xmlRpcReq = new XmlRpcRequest(methodName, mcm.InArgs); 149 | // TODO: possibly call GetRequestStream from next sink in chain? 150 | // TODO: SoapClientFormatter sink uses ChunkedStream - check why? 151 | Stream stm = new MemoryStream(); 152 | var serializer = new XmlRpcRequestSerializer(); 153 | serializer.SerializeRequest(stm, xmlRpcReq); 154 | stm.Position = 0; 155 | 156 | headers = reqHeaders; 157 | stream = stm; 158 | } 159 | 160 | IMessage DeserializeMessage( 161 | IMethodCallMessage mcm, 162 | ITransportHeaders headers, 163 | Stream stream) 164 | { 165 | var deserializer = new XmlRpcResponseDeserializer(); 166 | object tp = mcm.MethodBase; 167 | System.Reflection.MethodInfo mi = (System.Reflection.MethodInfo)tp; 168 | System.Type t = mi.ReturnType; 169 | XmlRpcResponse xmlRpcResp = deserializer.DeserializeResponse(stream, t); 170 | IMessage imsg = new ReturnMessage(xmlRpcResp.retVal, null, 0, null, mcm); 171 | return imsg; 172 | } 173 | 174 | string GetRpcMethodName(MethodInfo mi) 175 | { 176 | Attribute attr = Attribute.GetCustomAttribute(mi, 177 | typeof(XmlRpcMethodAttribute)); 178 | // TODO: do methods need attribute? 179 | // if (attr == null) 180 | // { 181 | // throw new Exception("missing method attribute"); 182 | // } 183 | string rpcMethod = ""; 184 | if (attr != null) 185 | { 186 | XmlRpcMethodAttribute xrmAttr = attr as XmlRpcMethodAttribute; 187 | rpcMethod = xrmAttr.Method; 188 | } 189 | if (rpcMethod == "") 190 | rpcMethod = mi.Name; 191 | return rpcMethod; 192 | } 193 | 194 | // data 195 | // 196 | IClientChannelSink m_next; 197 | } 198 | } 199 | -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcClientFormatterSinkProvider.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2006, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | using System; 27 | using System.Collections; 28 | using System.Runtime.Remoting.Channels; 29 | 30 | namespace CookComputing.XmlRpc 31 | { 32 | public class XmlRpcClientFormatterSinkProvider : IClientFormatterSinkProvider 33 | { 34 | // constructors 35 | // 36 | public XmlRpcClientFormatterSinkProvider( 37 | IDictionary properties, 38 | ICollection providerData) 39 | { 40 | // this constructor required when registering via a config file 41 | } 42 | 43 | public XmlRpcClientFormatterSinkProvider() 44 | { 45 | // this constructor used when registering provider programmatically 46 | } 47 | 48 | // public methods 49 | // 50 | public IClientChannelSink CreateSink( 51 | IChannelSender channel, 52 | string url, 53 | object remoteChannelData) 54 | { 55 | IClientChannelSink ccs = null; 56 | if (m_next != null) 57 | { 58 | ccs = m_next.CreateSink(channel, url, remoteChannelData); 59 | if (ccs == null) 60 | return null; 61 | } 62 | return new XmlRpcClientFormatterSink(ccs); 63 | } 64 | 65 | public IClientChannelSinkProvider Next 66 | { 67 | get { return m_next; } 68 | set { m_next = value; } 69 | } 70 | 71 | // data 72 | // 73 | IClientChannelSinkProvider m_next; 74 | } 75 | } 76 | 77 | -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcClientProtocol.resx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isRight/Aria2-CSharp/a7e9f96493df136ca18f8c519becdb32f91aaa96/XmlRpcNet/XmlRpcClientProtocol.resx -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcDebugLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.IO; 4 | 5 | namespace CookComputing.XmlRpc 6 | { 7 | public class XmlRpcDebugLogger : XmlRpcLogger 8 | { 9 | protected override void OnRequest(object sender, XmlRpcRequestEventArgs e) 10 | { 11 | DumpStream(e.RequestStream); 12 | } 13 | 14 | protected override void OnResponse(object sender, XmlRpcResponseEventArgs e) 15 | { 16 | DumpStream(e.ResponseStream); 17 | } 18 | 19 | private void DumpStream(Stream stm) 20 | { 21 | TextReader trdr = new StreamReader(stm); 22 | String s = trdr.ReadToEnd(); 23 | Debug.WriteLine(s); 24 | stm.Position = 0; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcEndAttribute.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2006, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | namespace CookComputing.XmlRpc 27 | { 28 | using System; 29 | 30 | [AttributeUsage(AttributeTargets.Method)] 31 | public class XmlRpcEndAttribute : Attribute 32 | { 33 | public XmlRpcEndAttribute() 34 | { 35 | } 36 | 37 | public XmlRpcEndAttribute(string method) 38 | { 39 | this.method = method; 40 | } 41 | 42 | public string Method 43 | { 44 | get 45 | { return method; } 46 | } 47 | 48 | public bool IntrospectionMethod 49 | { 50 | get { return introspectionMethod; } 51 | set { introspectionMethod = value; } 52 | } 53 | 54 | public override string ToString() 55 | { 56 | string value = "Method : " + method; 57 | return value; 58 | } 59 | 60 | public string Description = ""; 61 | public bool Hidden = false; 62 | private string method = ""; 63 | private bool introspectionMethod = false; 64 | } 65 | } 66 | 67 | -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcEnumMapping.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2011, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | namespace CookComputing.XmlRpc 27 | { 28 | using System; 29 | 30 | public enum EnumMapping 31 | { 32 | Number, 33 | String 34 | } 35 | 36 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Struct 37 | | AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Parameter 38 | | AttributeTargets.Method | AttributeTargets.ReturnValue 39 | | AttributeTargets.Interface)] 40 | public class XmlRpcEnumMappingAttribute : Attribute 41 | { 42 | public XmlRpcEnumMappingAttribute() 43 | { 44 | } 45 | 46 | public XmlRpcEnumMappingAttribute(EnumMapping mapping) 47 | { 48 | _mapping = mapping; 49 | } 50 | 51 | public EnumMapping Mapping 52 | { 53 | get 54 | { return _mapping; } 55 | } 56 | 57 | public override string ToString() 58 | { 59 | string value = _mapping.ToString(); 60 | return value; 61 | } 62 | 63 | private EnumMapping _mapping = EnumMapping.Number; 64 | } 65 | } -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcException.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2006, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | namespace CookComputing.XmlRpc 27 | { 28 | using System; 29 | 30 | public class XmlRpcException : 31 | #if (!SILVERLIGHT) 32 | ApplicationException 33 | #else 34 | Exception 35 | #endif 36 | { 37 | public XmlRpcException() {} 38 | 39 | public XmlRpcException(string msg) 40 | : base(msg) {} 41 | 42 | public XmlRpcException(string msg, Exception innerEx) 43 | : base(msg, innerEx){} 44 | } 45 | 46 | public class XmlRpcUnsupportedTypeException : XmlRpcException 47 | { 48 | Type _unsupportedType; 49 | 50 | public XmlRpcUnsupportedTypeException(Type t) 51 | : base(string.Format("Unable to map type {0} onto XML-RPC type", t)) 52 | { 53 | _unsupportedType = t; 54 | } 55 | 56 | public XmlRpcUnsupportedTypeException(Type t, string msg) 57 | : base(msg) 58 | { 59 | _unsupportedType = t; 60 | } 61 | 62 | public XmlRpcUnsupportedTypeException(Type t, string msg, Exception innerEx) 63 | : base(msg, innerEx) 64 | { 65 | _unsupportedType = t; 66 | } 67 | 68 | public Type UnsupportedType { get { return _unsupportedType; } } 69 | } 70 | 71 | public class XmlRpcUnexpectedTypeException : XmlRpcException 72 | { 73 | public XmlRpcUnexpectedTypeException() {} 74 | 75 | public XmlRpcUnexpectedTypeException(string msg) 76 | : base(msg) {} 77 | 78 | public XmlRpcUnexpectedTypeException(string msg, Exception innerEx) 79 | : base(msg, innerEx){} 80 | } 81 | 82 | public class XmlRpcIllFormedXmlException : XmlRpcException 83 | { 84 | public XmlRpcIllFormedXmlException() {} 85 | 86 | public XmlRpcIllFormedXmlException(string msg) 87 | : base(msg) {} 88 | 89 | public XmlRpcIllFormedXmlException(string msg, Exception innerEx) 90 | : base(msg, innerEx){} 91 | } 92 | 93 | public class XmlRpcUnsupportedMethodException : XmlRpcException 94 | { 95 | public XmlRpcUnsupportedMethodException() {} 96 | 97 | public XmlRpcUnsupportedMethodException(string msg) 98 | : base(msg) {} 99 | 100 | public XmlRpcUnsupportedMethodException(string msg, Exception innerEx) 101 | : base(msg, innerEx){} 102 | } 103 | 104 | public class XmlRpcInvalidParametersException : XmlRpcException 105 | { 106 | public XmlRpcInvalidParametersException() {} 107 | 108 | public XmlRpcInvalidParametersException(string msg) 109 | : base(msg) {} 110 | 111 | public XmlRpcInvalidParametersException(string msg, Exception innerEx) 112 | : base(msg, innerEx){} 113 | } 114 | 115 | public class XmlRpcNonRegularArrayException : XmlRpcException 116 | { 117 | public XmlRpcNonRegularArrayException() {} 118 | 119 | public XmlRpcNonRegularArrayException(string msg) 120 | : base(msg) {} 121 | 122 | public XmlRpcNonRegularArrayException(string msg, Exception innerEx) 123 | : base(msg, innerEx){} 124 | } 125 | 126 | public class XmlRpcInvalidXmlRpcException : XmlRpcException 127 | { 128 | public XmlRpcInvalidXmlRpcException() {} 129 | 130 | public XmlRpcInvalidXmlRpcException(string msg) 131 | : base(msg) {} 132 | 133 | public XmlRpcInvalidXmlRpcException(string msg, Exception innerEx) 134 | : base(msg, innerEx){} 135 | } 136 | 137 | public class XmlRpcMethodAttributeException : XmlRpcException 138 | { 139 | public XmlRpcMethodAttributeException() {} 140 | 141 | public XmlRpcMethodAttributeException(string msg) 142 | : base(msg) {} 143 | 144 | public XmlRpcMethodAttributeException(string msg, Exception innerEx) 145 | : base(msg, innerEx){} 146 | } 147 | 148 | public class XmlRpcTypeMismatchException : XmlRpcException 149 | { 150 | public XmlRpcTypeMismatchException() {} 151 | 152 | public XmlRpcTypeMismatchException(string msg) 153 | : base(msg) {} 154 | 155 | public XmlRpcTypeMismatchException(string msg, Exception innerEx) 156 | : base(msg, innerEx){} 157 | } 158 | 159 | public class XmlRpcNullReferenceException : XmlRpcException 160 | { 161 | public XmlRpcNullReferenceException() {} 162 | 163 | public XmlRpcNullReferenceException(string msg) 164 | : base(msg) {} 165 | 166 | public XmlRpcNullReferenceException(string msg, Exception innerEx) 167 | : base(msg, innerEx){} 168 | } 169 | 170 | public class XmlRpcServerException : XmlRpcException 171 | { 172 | public XmlRpcServerException() {} 173 | 174 | public XmlRpcServerException(string msg) 175 | : base(msg) {} 176 | 177 | public XmlRpcServerException(string msg, Exception innerEx) 178 | : base(msg, innerEx){} 179 | } 180 | 181 | public class XmlRpcInvalidReturnType : XmlRpcException 182 | { 183 | public XmlRpcInvalidReturnType() {} 184 | 185 | public XmlRpcInvalidReturnType(string msg) 186 | : base(msg) {} 187 | 188 | public XmlRpcInvalidReturnType(string msg, Exception innerEx) 189 | : base(msg, innerEx){} 190 | } 191 | 192 | public class XmlRpcMappingSerializeException : XmlRpcException 193 | { 194 | public XmlRpcMappingSerializeException() { } 195 | 196 | public XmlRpcMappingSerializeException(string msg) 197 | : base(msg) { } 198 | 199 | public XmlRpcMappingSerializeException(string msg, Exception innerEx) 200 | : base(msg, innerEx) { } 201 | } 202 | 203 | public class XmlRpcNullParameterException : XmlRpcException 204 | { 205 | public XmlRpcNullParameterException() { } 206 | 207 | public XmlRpcNullParameterException(string msg) 208 | : base(msg) { } 209 | 210 | public XmlRpcNullParameterException(string msg, Exception innerEx) 211 | : base(msg, innerEx) { } 212 | } 213 | 214 | public class XmlRpcMissingUrl : XmlRpcException 215 | { 216 | public XmlRpcMissingUrl() { } 217 | 218 | public XmlRpcMissingUrl(string msg) 219 | : base(msg) { } 220 | } 221 | 222 | public class XmlRpcDupXmlRpcMethodNames : XmlRpcException 223 | { 224 | public XmlRpcDupXmlRpcMethodNames() { } 225 | 226 | public XmlRpcDupXmlRpcMethodNames(string msg) 227 | : base(msg) { } 228 | } 229 | 230 | public class XmlRpcNonSerializedMember : XmlRpcException 231 | { 232 | public XmlRpcNonSerializedMember() { } 233 | 234 | public XmlRpcNonSerializedMember(string msg) 235 | : base(msg) { } 236 | 237 | public XmlRpcNonSerializedMember(string msg, Exception innerEx) 238 | : base(msg, innerEx) { } 239 | } 240 | 241 | public class XmlRpcInvalidEnumValue : XmlRpcException 242 | { 243 | public XmlRpcInvalidEnumValue() { } 244 | 245 | public XmlRpcInvalidEnumValue(string msg) 246 | : base(msg) { } 247 | 248 | public XmlRpcInvalidEnumValue(string msg, Exception innerEx) 249 | : base(msg, innerEx) { } 250 | } 251 | } 252 | -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcFaultException.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2006, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | namespace CookComputing.XmlRpc 27 | { 28 | using System; 29 | #if (!COMPACT_FRAMEWORK) 30 | using System.Runtime.Serialization; 31 | #endif 32 | 33 | // used to return server-side errors to client code - also can be 34 | // thrown by Service implmentation code to return custom Fault Responses 35 | #if (!COMPACT_FRAMEWORK && !SILVERLIGHT) 36 | [Serializable] 37 | #endif 38 | public class XmlRpcFaultException : 39 | #if (!SILVERLIGHT) 40 | ApplicationException 41 | #else 42 | Exception 43 | #endif 44 | { 45 | // constructors 46 | // 47 | public XmlRpcFaultException(int TheCode, string TheString) 48 | : base("Server returned a fault exception: [" + TheCode.ToString() + 49 | "] " + TheString) 50 | { 51 | m_faultCode = TheCode; 52 | m_faultString = TheString; 53 | } 54 | #if (!COMPACT_FRAMEWORK && !SILVERLIGHT) 55 | // deserialization constructor 56 | protected XmlRpcFaultException( 57 | SerializationInfo info, 58 | StreamingContext context) 59 | : base(info, context) 60 | { 61 | m_faultCode = (int)info.GetValue("m_faultCode", typeof(int)); 62 | m_faultString = (String)info.GetValue("m_faultString", typeof(string)); 63 | } 64 | #endif 65 | // properties 66 | // 67 | public int FaultCode 68 | { 69 | get { return m_faultCode; } 70 | } 71 | 72 | public string FaultString 73 | { 74 | get { return m_faultString; } 75 | } 76 | #if (!COMPACT_FRAMEWORK && !SILVERLIGHT) 77 | // public methods 78 | // 79 | public override void GetObjectData( 80 | SerializationInfo info, 81 | StreamingContext context) 82 | { 83 | info.AddValue("m_faultCode", m_faultCode); 84 | info.AddValue("m_faultString", m_faultString); 85 | base.GetObjectData(info, context); 86 | } 87 | #endif 88 | // data 89 | // 90 | int m_faultCode; 91 | string m_faultString; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcFormatSettings.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2011, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | using System; 27 | using System.Collections.Generic; 28 | using System.Text; 29 | 30 | namespace CookComputing.XmlRpc 31 | { 32 | public class XmlRpcFormatSettings 33 | { 34 | public int Indentation 35 | { 36 | get { return m_indentation; } 37 | set { m_indentation = value; } 38 | } 39 | int m_indentation = 2; 40 | 41 | public bool UseEmptyElementTags 42 | { 43 | get { return m_bUseEmptyElementTag; } 44 | set { m_bUseEmptyElementTag = value; } 45 | } 46 | bool m_bUseEmptyElementTag = true; 47 | 48 | public bool UseEmptyParamsTag 49 | { 50 | get { return m_bUseEmptyParamsTag; } 51 | set { m_bUseEmptyParamsTag = value; } 52 | } 53 | bool m_bUseEmptyParamsTag = true; 54 | 55 | public bool UseIndentation 56 | { 57 | get { return m_bUseIndentation; } 58 | set { m_bUseIndentation = value; } 59 | } 60 | bool m_bUseIndentation = true; 61 | 62 | public bool UseIntTag 63 | { 64 | get { return m_useIntTag; } 65 | set { m_useIntTag = value; } 66 | } 67 | bool m_useIntTag; 68 | 69 | public bool UseStringTag 70 | { 71 | get { return m_useStringTag; } 72 | set { m_useStringTag = value; } 73 | } 74 | bool m_useStringTag = true; 75 | 76 | public Encoding XmlEncoding 77 | { 78 | get { return m_encoding; } 79 | set { m_encoding = value; } 80 | } 81 | Encoding m_encoding = null; 82 | 83 | public bool OmitXmlDeclaration { get; set; } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcLogger.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2006, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | using System; 27 | using System.IO; 28 | using System.Diagnostics; 29 | 30 | namespace CookComputing.XmlRpc 31 | { 32 | public abstract class XmlRpcLogger 33 | { 34 | public void SubscribeTo(IXmlRpcProxy proxy) 35 | { 36 | proxy.RequestEvent += new XmlRpcRequestEventHandler(OnRequest); 37 | proxy.ResponseEvent += new XmlRpcResponseEventHandler(OnResponse); 38 | } 39 | 40 | [Obsolete("This method is obsolete; use SubscribeTo instead")] 41 | public void Attach(IXmlRpcProxy proxy) 42 | { 43 | SubscribeTo(proxy); 44 | } 45 | 46 | public void UnsubscribeFrom(IXmlRpcProxy proxy) 47 | { 48 | proxy.RequestEvent -= new XmlRpcRequestEventHandler(OnRequest); 49 | proxy.ResponseEvent -= new XmlRpcResponseEventHandler(OnResponse); 50 | } 51 | 52 | [Obsolete("This method is obsolete; use UnsubcribeFrom instead")] 53 | public void Detach(IXmlRpcProxy proxy) 54 | { 55 | UnsubscribeFrom(proxy); 56 | } 57 | 58 | protected virtual void OnRequest(object sender, XmlRpcRequestEventArgs e) 59 | { 60 | } 61 | 62 | protected virtual void OnResponse(object sender, XmlRpcResponseEventArgs e) 63 | { 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcMemberAttribute.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2006, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | namespace CookComputing.XmlRpc 27 | { 28 | using System; 29 | 30 | [AttributeUsage(AttributeTargets.Field|AttributeTargets.Property)] 31 | public class XmlRpcMemberAttribute : Attribute 32 | { 33 | public XmlRpcMemberAttribute() 34 | { 35 | } 36 | 37 | public XmlRpcMemberAttribute(string member) 38 | { 39 | _member = member; 40 | } 41 | 42 | public string Member 43 | { 44 | get 45 | { return _member; } 46 | set 47 | { _member = value; } 48 | } 49 | 50 | public string Description 51 | { 52 | get { return _description; } 53 | set { _description = value; } 54 | } 55 | 56 | public override string ToString() 57 | { 58 | string value = "Member : " + _member; 59 | return value; 60 | } 61 | 62 | private string _member = ""; 63 | private string _description = ""; 64 | } 65 | } -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcMethodAttribute.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2006, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | namespace CookComputing.XmlRpc 27 | { 28 | using System; 29 | 30 | [AttributeUsage(AttributeTargets.Method)] 31 | public class XmlRpcMethodAttribute : Attribute 32 | { 33 | public XmlRpcMethodAttribute() 34 | { 35 | } 36 | 37 | public XmlRpcMethodAttribute(string method) 38 | { 39 | this.method = method; 40 | } 41 | 42 | public string Method 43 | { 44 | get 45 | { return method; } 46 | } 47 | 48 | public bool IntrospectionMethod 49 | { 50 | get { return introspectionMethod; } 51 | set { introspectionMethod = value; } 52 | } 53 | 54 | public bool StructParams 55 | { 56 | get { return structParams; } 57 | set { structParams = value; } 58 | } 59 | 60 | public override string ToString() 61 | { 62 | string value = "Method : " + method; 63 | return value; 64 | } 65 | 66 | public string Description = ""; 67 | public bool Hidden = false; 68 | private string method = ""; 69 | private bool introspectionMethod = false; 70 | private bool structParams = false; 71 | } 72 | } -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcMethodInfo.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2006, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | namespace CookComputing.XmlRpc 27 | { 28 | using System; 29 | using System.Reflection; 30 | 31 | public class XmlRpcMethodInfo : IComparable 32 | { 33 | public XmlRpcMethodInfo() 34 | { 35 | } 36 | 37 | public bool IsHidden 38 | { 39 | get { return isHidden; } 40 | set { isHidden = value; } 41 | } 42 | 43 | public String Doc 44 | { 45 | get { return doc; } 46 | set { doc = value; } 47 | } 48 | 49 | public MethodInfo MethodInfo 50 | { 51 | get { return mi; } 52 | set { mi = value; } 53 | } 54 | 55 | public String MiName 56 | { 57 | get { return name; } 58 | set { name = value; } 59 | } 60 | 61 | public XmlRpcParameterInfo[] Parameters 62 | { 63 | get { return paramInfos; } 64 | set { paramInfos = value; } 65 | } 66 | 67 | public Type ReturnType 68 | { 69 | get { return returnType; } 70 | set { returnType = value; } 71 | } 72 | 73 | public string ReturnXmlRpcType 74 | { 75 | get { return returnXmlRpcType; } 76 | set { returnXmlRpcType = value; } 77 | } 78 | 79 | public String ReturnDoc 80 | { 81 | get { return returnDoc; } 82 | set { returnDoc = value; } 83 | } 84 | 85 | public String XmlRpcName 86 | { 87 | get { return xmlRpcName; } 88 | set { xmlRpcName = value; } 89 | } 90 | 91 | public int CompareTo(object obj) 92 | { 93 | XmlRpcMethodInfo xmi = (XmlRpcMethodInfo)obj; 94 | return this.xmlRpcName.CompareTo(xmi.xmlRpcName); 95 | } 96 | 97 | MethodInfo mi; 98 | bool isHidden; 99 | string doc=""; 100 | string name=""; 101 | string xmlRpcName=""; 102 | string returnDoc=""; 103 | Type returnType; 104 | string returnXmlRpcType; 105 | XmlRpcParameterInfo[] paramInfos; 106 | } 107 | } -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcMissingMappingAttribute.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2006, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | namespace CookComputing.XmlRpc 27 | { 28 | using System; 29 | 30 | public enum MappingAction 31 | { 32 | Ignore, 33 | Error, 34 | } 35 | 36 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Struct 37 | | AttributeTargets.Property | AttributeTargets.Class)] 38 | public class XmlRpcMissingMappingAttribute : Attribute 39 | { 40 | public XmlRpcMissingMappingAttribute() 41 | { 42 | } 43 | 44 | public XmlRpcMissingMappingAttribute(MappingAction action) 45 | { 46 | _action = action; 47 | } 48 | 49 | public MappingAction Action 50 | { 51 | get 52 | { return _action; } 53 | } 54 | 55 | public override string ToString() 56 | { 57 | string value = _action.ToString(); 58 | return value; 59 | } 60 | 61 | private MappingAction _action = MappingAction.Error; 62 | } 63 | } -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcNet.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Local 5 | 9.0.30729 6 | 2.0 7 | {1B4B0A58-0AFB-4090-91DD-18912CC7DE65} 8 | Debug 9 | AnyCPU 10 | 11 | 12 | 13 | 14 | XmlRpcNet 15 | $(KeyFile) 16 | JScript 17 | Grid 18 | IE50 19 | false 20 | Library 21 | CookComputing.XmlRpc 22 | OnBuildSuccess 23 | 24 | 25 | 26 | 27 | 28 | 29 | false 30 | 3.5 31 | v2.0 32 | false 33 | publish\ 34 | true 35 | Disk 36 | false 37 | Foreground 38 | 7 39 | Days 40 | false 41 | false 42 | true 43 | 0 44 | 1.0.0.%2a 45 | false 46 | true 47 | 48 | 49 | bin\Debug\ 50 | false 51 | 285212672 52 | false 53 | 54 | 55 | TRACE;DEBUG 56 | 57 | 58 | true 59 | 4096 60 | false 61 | 649 62 | false 63 | false 64 | false 65 | false 66 | 4 67 | full 68 | prompt 69 | AllRules.ruleset 70 | 71 | 72 | bin\Release\ 73 | false 74 | 285212672 75 | false 76 | 77 | 78 | TRACE 79 | 80 | 81 | false 82 | 4096 83 | false 84 | 649 85 | true 86 | false 87 | false 88 | false 89 | 4 90 | none 91 | prompt 92 | AllRules.ruleset 93 | 94 | 95 | true 96 | bin\x64\Debug\ 97 | TRACE;DEBUG 98 | 285212672 99 | 4096 100 | 649 101 | full 102 | x64 103 | prompt 104 | AllRules.ruleset 105 | 106 | 107 | bin\x64\Release\ 108 | TRACE 109 | 285212672 110 | true 111 | 4096 112 | 649 113 | x64 114 | prompt 115 | AllRules.ruleset 116 | 117 | 118 | 119 | System 120 | 121 | 122 | System.Data 123 | 124 | 125 | System.Drawing 126 | 127 | 128 | System.Web 129 | 130 | 131 | System.Windows.Forms 132 | 133 | 134 | System.XML 135 | 136 | 137 | 138 | 139 | Code 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | Code 149 | 150 | 151 | 152 | 153 | 154 | Code 155 | 156 | 157 | 158 | Code 159 | 160 | 161 | Code 162 | 163 | 164 | Code 165 | 166 | 167 | Code 168 | 169 | 170 | Component 171 | 172 | 173 | 174 | Code 175 | 176 | 177 | Code 178 | 179 | 180 | Code 181 | 182 | 183 | Code 184 | 185 | 186 | Code 187 | 188 | 189 | Code 190 | 191 | 192 | Code 193 | 194 | 195 | Code 196 | 197 | 198 | 199 | 200 | Code 201 | 202 | 203 | Code 204 | 205 | 206 | 207 | 208 | Code 209 | 210 | 211 | Code 212 | 213 | 214 | 215 | 216 | Code 217 | 218 | 219 | 220 | 221 | Code 222 | 223 | 224 | Code 225 | 226 | 227 | Code 228 | 229 | 230 | 231 | Code 232 | 233 | 234 | 235 | 236 | 237 | 238 | False 239 | .NET Framework 3.5 SP1 Client Profile 240 | false 241 | 242 | 243 | False 244 | .NET Framework 3.5 SP1 245 | true 246 | 247 | 248 | False 249 | Windows Installer 3.1 250 | true 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcNonStandard.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2006, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | using System; 27 | using System.Text; 28 | 29 | namespace CookComputing.XmlRpc 30 | { 31 | [Flags] 32 | public enum XmlRpcNonStandard 33 | { 34 | None = 0x00, 35 | AllowStringFaultCode = 0x01, 36 | AllowNonStandardDateTime = 0x02, 37 | IgnoreDuplicateMembers = 0x4, 38 | MapZerosDateTimeToMinValue = 0x8, 39 | MapEmptyDateTimeToMinValue = 0x10, 40 | AllowInvalidHTTPContent = 0x20, 41 | All = 0x7fff, 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcNullMappingAttribute.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2011, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | namespace CookComputing.XmlRpc 27 | { 28 | using System; 29 | 30 | public enum NullMappingAction 31 | { 32 | Error, 33 | Ignore, 34 | Nil 35 | } 36 | 37 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Struct 38 | | AttributeTargets.Property | AttributeTargets.Class)] 39 | public class XmlRpcNullMappingAttribute : Attribute 40 | { 41 | public XmlRpcNullMappingAttribute() 42 | { 43 | } 44 | 45 | public XmlRpcNullMappingAttribute(NullMappingAction action) 46 | { 47 | _action = action; 48 | } 49 | 50 | public NullMappingAction Action 51 | { 52 | get 53 | { return _action; } 54 | } 55 | 56 | public override string ToString() 57 | { 58 | string value = _action.ToString(); 59 | return value; 60 | } 61 | 62 | private NullMappingAction _action = NullMappingAction.Error; 63 | } 64 | } -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcParameterAttribute.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2006, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | namespace CookComputing.XmlRpc 27 | { 28 | using System; 29 | 30 | [AttributeUsage(AttributeTargets.Parameter)] 31 | public class XmlRpcParameterAttribute : Attribute 32 | { 33 | public XmlRpcParameterAttribute() 34 | { 35 | } 36 | 37 | public XmlRpcParameterAttribute(string name) 38 | { 39 | this.name = name; 40 | } 41 | 42 | public string Name 43 | { 44 | get { return name; } 45 | } 46 | 47 | public string Description 48 | { 49 | get { return description; } 50 | set { description = value; } 51 | } 52 | 53 | public override string ToString() 54 | { 55 | string value = "Description : " + description; 56 | return value; 57 | } 58 | 59 | private string name = ""; 60 | private string description = ""; 61 | } 62 | } -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcParameterInfo.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2006, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | namespace CookComputing.XmlRpc 27 | { 28 | using System; 29 | 30 | public class XmlRpcParameterInfo 31 | { 32 | public XmlRpcParameterInfo() 33 | { 34 | } 35 | 36 | public String Doc 37 | { 38 | get { return doc; } 39 | set { doc = value; } 40 | } 41 | 42 | public bool IsParams 43 | { 44 | get { return isparams; } 45 | set { isparams = value; } 46 | } 47 | 48 | public String Name 49 | { 50 | get { return name; } 51 | set 52 | { 53 | name = value; 54 | if (xmlRpcName == "") 55 | xmlRpcName = name; 56 | } 57 | } 58 | 59 | public String XmlRpcName 60 | { 61 | get { return xmlRpcName; } 62 | set { xmlRpcName = value; } 63 | } 64 | 65 | public Type Type 66 | { 67 | get { return type; } 68 | set { type = value; } 69 | } 70 | 71 | public string XmlRpcType 72 | { 73 | get { return xmlRpcType; } 74 | set { xmlRpcType = value; } 75 | } 76 | 77 | string doc; 78 | string name; 79 | Type type; 80 | string xmlRpcName; 81 | string xmlRpcType; 82 | bool isparams; 83 | } 84 | } -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcRequest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2006, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | namespace CookComputing.XmlRpc 27 | { 28 | using System; 29 | using System.IO; 30 | using System.Reflection; 31 | 32 | public class XmlRpcRequest 33 | { 34 | public XmlRpcRequest() 35 | { 36 | } 37 | 38 | public XmlRpcRequest(string methodName, object[] parameters, MethodInfo methodInfo) 39 | { 40 | method = methodName; 41 | args = parameters; 42 | mi = methodInfo; 43 | } 44 | 45 | public XmlRpcRequest(string methodName, object[] parameters, 46 | MethodInfo methodInfo, string XmlRpcMethod, Guid proxyGuid) 47 | { 48 | method = methodName; 49 | args = parameters; 50 | mi = methodInfo; 51 | if (XmlRpcMethod != null) 52 | method = XmlRpcMethod; 53 | proxyId = proxyGuid; 54 | if (mi != null) 55 | ReturnType = mi.ReturnType; 56 | } 57 | 58 | public XmlRpcRequest(string methodName, Object[] parameters) 59 | { 60 | method = methodName; 61 | args = parameters; 62 | } 63 | 64 | public String method = null; 65 | public Object[] args = null; 66 | public MethodInfo mi = null; 67 | public Guid proxyId; 68 | static int _created; 69 | public int number = System.Threading.Interlocked.Increment(ref _created); 70 | public Type ReturnType; 71 | } 72 | } -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcRequestEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2006, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | using System; 27 | using System.IO; 28 | 29 | namespace CookComputing.XmlRpc 30 | { 31 | public class XmlRpcRequestEventArgs : EventArgs 32 | { 33 | private Guid _guid; 34 | private long _request; 35 | private Stream _requestStream; 36 | 37 | public XmlRpcRequestEventArgs(Guid guid, long request, Stream requestStream) 38 | { 39 | _guid = guid; 40 | _request = request; 41 | _requestStream = requestStream; 42 | } 43 | 44 | public Guid ProxyID 45 | { 46 | get { return _guid; } 47 | } 48 | 49 | public long RequestNum 50 | { 51 | get { return _request; } 52 | } 53 | 54 | public Stream RequestStream 55 | { 56 | get { return _requestStream; } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcRequestSerializer.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2011, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | // TODO: overriding default mapping action in a struct should not affect nested structs 27 | 28 | namespace CookComputing.XmlRpc 29 | { 30 | using System; 31 | using System.Collections; 32 | using System.Globalization; 33 | using System.IO; 34 | using System.Reflection; 35 | using System.Text; 36 | using System.Text.RegularExpressions; 37 | using System.Threading; 38 | using System.Xml; 39 | using System.Collections.Generic; 40 | 41 | public class XmlRpcRequestSerializer : XmlRpcSerializer 42 | { 43 | public XmlRpcRequestSerializer() { } 44 | public XmlRpcRequestSerializer(XmlRpcFormatSettings settings) : base(settings) { } 45 | 46 | public void SerializeRequest(Stream stm, XmlRpcRequest request) 47 | { 48 | XmlWriter xtw = XmlRpcXmlWriter.Create(stm, base.XmlRpcFormatSettings); 49 | xtw.WriteStartDocument(); 50 | xtw.WriteStartElement("", "methodCall", ""); 51 | { 52 | var mappingActions = new MappingActions(); 53 | mappingActions = GetTypeMappings(request.mi, mappingActions); 54 | mappingActions = GetMappingActions(request.mi, mappingActions); 55 | WriteFullElementString(xtw, "methodName", request.method); 56 | if (request.args.Length > 0 || UseEmptyParamsTag) 57 | { 58 | xtw.WriteStartElement("params"); 59 | try 60 | { 61 | if (!IsStructParamsMethod(request.mi)) 62 | SerializeParams(xtw, request, mappingActions); 63 | else 64 | SerializeStructParams(xtw, request, mappingActions); 65 | } 66 | catch (XmlRpcUnsupportedTypeException ex) 67 | { 68 | throw new XmlRpcUnsupportedTypeException(ex.UnsupportedType, 69 | String.Format("A parameter is of, or contains an instance of, " 70 | + "type {0} which cannot be mapped to an XML-RPC type", 71 | ex.UnsupportedType)); 72 | } 73 | WriteFullEndElement(xtw); 74 | } 75 | } 76 | WriteFullEndElement(xtw); 77 | xtw.Flush(); 78 | } 79 | 80 | void SerializeParams(XmlWriter xtw, XmlRpcRequest request, 81 | MappingActions mappingActions) 82 | { 83 | ParameterInfo[] pis = null; 84 | if (request.mi != null) 85 | { 86 | pis = request.mi.GetParameters(); 87 | } 88 | for (int i = 0; i < request.args.Length; i++) 89 | { 90 | var paramMappingActions = pis == null ? mappingActions 91 | : GetMappingActions(pis[i], mappingActions); 92 | if (pis != null) 93 | { 94 | if (i >= pis.Length) 95 | throw new XmlRpcInvalidParametersException("Number of request " 96 | + "parameters greater than number of proxy method parameters."); 97 | if (i == pis.Length - 1 98 | && Attribute.IsDefined(pis[i], typeof(ParamArrayAttribute))) 99 | { 100 | Array ary = (Array)request.args[i]; 101 | foreach (object o in ary) 102 | { 103 | //if (o == null) 104 | // throw new XmlRpcNullParameterException( 105 | // "Null parameter in params array"); 106 | xtw.WriteStartElement("", "param", ""); 107 | Serialize(xtw, o, paramMappingActions); 108 | WriteFullEndElement(xtw); 109 | } 110 | break; 111 | } 112 | } 113 | //if (request.args[i] == null) 114 | //{ 115 | // throw new XmlRpcNullParameterException(String.Format( 116 | // "Null method parameter #{0}", i + 1)); 117 | //} 118 | xtw.WriteStartElement("", "param", ""); 119 | Serialize(xtw, request.args[i], paramMappingActions); 120 | WriteFullEndElement(xtw); 121 | } 122 | } 123 | 124 | void SerializeStructParams(XmlWriter xtw, XmlRpcRequest request, 125 | MappingActions mappingActions) 126 | { 127 | ParameterInfo[] pis = request.mi.GetParameters(); 128 | if (request.args.Length > pis.Length) 129 | throw new XmlRpcInvalidParametersException("Number of request " 130 | + "parameters greater than number of proxy method parameters."); 131 | if (Attribute.IsDefined(pis[request.args.Length - 1], 132 | typeof(ParamArrayAttribute))) 133 | { 134 | throw new XmlRpcInvalidParametersException("params parameter cannot " 135 | + "be used with StructParams."); 136 | } 137 | xtw.WriteStartElement("", "param", ""); 138 | xtw.WriteStartElement("", "value", ""); 139 | xtw.WriteStartElement("", "struct", ""); 140 | for (int i = 0; i < request.args.Length; i++) 141 | { 142 | if (request.args[i] == null) 143 | { 144 | throw new XmlRpcNullParameterException(String.Format( 145 | "Null method parameter #{0}", i + 1)); 146 | } 147 | xtw.WriteStartElement("", "member", ""); 148 | WriteFullElementString(xtw, "name", pis[i].Name); 149 | Serialize(xtw, request.args[i], mappingActions); 150 | WriteFullEndElement(xtw); 151 | } 152 | WriteFullEndElement(xtw); 153 | WriteFullEndElement(xtw); 154 | WriteFullEndElement(xtw); 155 | } 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcResponse.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2011, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | using System; 27 | using System.Reflection; 28 | 29 | namespace CookComputing.XmlRpc 30 | { 31 | public class XmlRpcResponse 32 | { 33 | public XmlRpcResponse() 34 | { 35 | retVal = null; 36 | } 37 | public XmlRpcResponse(object retValue) 38 | { 39 | retVal = retValue; 40 | } 41 | 42 | public XmlRpcResponse(object retValue, MethodInfo mi) 43 | { 44 | retVal = retValue; 45 | MethodInfo = mi; 46 | } 47 | 48 | public Object retVal; 49 | public MethodInfo MethodInfo { get; set; } 50 | } 51 | } -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcResponseDeserializer.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2011, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | // TODO: overriding default mapping action in a struct should not affect nested structs 27 | 28 | namespace CookComputing.XmlRpc 29 | { 30 | using System; 31 | using System.Collections; 32 | using System.Globalization; 33 | using System.IO; 34 | using System.Reflection; 35 | using System.Text; 36 | using System.Text.RegularExpressions; 37 | using System.Threading; 38 | using System.Xml; 39 | using System.Diagnostics; 40 | using System.Collections.Generic; 41 | 42 | 43 | struct Fault 44 | { 45 | public int faultCode; 46 | public string faultString; 47 | } 48 | 49 | public class XmlRpcResponseDeserializer : XmlRpcDeserializer 50 | { 51 | public XmlRpcResponse DeserializeResponse(Stream stm, Type svcType) 52 | { 53 | if (stm == null) 54 | throw new ArgumentNullException("stm", 55 | "XmlRpcSerializer.DeserializeResponse"); 56 | if (AllowInvalidHTTPContent) 57 | { 58 | Stream newStm = new MemoryStream(); 59 | Util.CopyStream(stm, newStm); 60 | stm = newStm; 61 | stm.Position = 0; 62 | while (true) 63 | { 64 | // for now just strip off any leading CR-LF characters 65 | int byt = stm.ReadByte(); 66 | if (byt == -1) 67 | throw new XmlRpcIllFormedXmlException( 68 | "Response from server does not contain valid XML."); 69 | if (byt != 0x0d && byt != 0x0a && byt != ' ' && byt != '\t') 70 | { 71 | stm.Position = stm.Position - 1; 72 | break; 73 | } 74 | } 75 | } 76 | XmlReader xmlRdr = XmlRpcXmlReader.Create(stm); 77 | return DeserializeResponse(xmlRdr, svcType); 78 | } 79 | 80 | public XmlRpcResponse DeserializeResponse(TextReader txtrdr, Type svcType) 81 | { 82 | if (txtrdr == null) 83 | throw new ArgumentNullException("txtrdr", 84 | "XmlRpcSerializer.DeserializeResponse"); 85 | XmlReader xmlRdr = XmlRpcXmlReader.Create(txtrdr); 86 | return DeserializeResponse(xmlRdr, svcType); 87 | } 88 | 89 | public XmlRpcResponse DeserializeResponse(XmlReader rdr, Type returnType) 90 | { 91 | try 92 | { 93 | 94 | IEnumerator iter = new XmlRpcParser().ParseResponse(rdr).GetEnumerator(); 95 | iter.MoveNext(); 96 | if (iter.Current is FaultNode) 97 | { 98 | var xmlRpcException = DeserializeFault(iter); 99 | throw xmlRpcException; 100 | } 101 | if (returnType == typeof(void) || !iter.MoveNext()) 102 | return new XmlRpcResponse { retVal = null }; 103 | var valueNode = iter.Current as ValueNode; 104 | object retObj = MapValueNode(iter, returnType, new MappingStack("response"), 105 | MappingAction.Error); 106 | var response = new XmlRpcResponse { retVal = retObj }; 107 | return response; 108 | } 109 | catch (XmlException ex) 110 | { 111 | throw new XmlRpcIllFormedXmlException("Response contains invalid XML", ex); 112 | } 113 | } 114 | 115 | private XmlRpcException DeserializeFault(IEnumerator iter) 116 | { 117 | MappingStack faultStack = new MappingStack("fault response"); 118 | // TODO: use global action setting 119 | MappingAction mappingAction = MappingAction.Error; 120 | XmlRpcFaultException faultEx = ParseFault(iter, faultStack, // TODO: fix 121 | mappingAction); 122 | throw faultEx; 123 | } 124 | 125 | XmlRpcFaultException ParseFault( 126 | IEnumerator iter, 127 | MappingStack parseStack, 128 | MappingAction mappingAction) 129 | { 130 | iter.MoveNext(); // move to StructValue 131 | Type parsedType; 132 | var faultStruct = MapHashtable(iter, null, parseStack, mappingAction, 133 | out parsedType) as XmlRpcStruct; 134 | object faultCode = faultStruct["faultCode"]; 135 | object faultString = faultStruct["faultString"]; 136 | if (faultCode is string) 137 | { 138 | int value; 139 | if (!Int32.TryParse(faultCode as string, out value)) 140 | throw new XmlRpcInvalidXmlRpcException("faultCode not int or string"); 141 | faultCode = value; 142 | } 143 | return new XmlRpcFaultException((int)faultCode, (string)faultString); 144 | } 145 | 146 | struct FaultStruct 147 | { 148 | public int faultCode; 149 | public string faultString; 150 | } 151 | 152 | struct FaultStructStringCode 153 | { 154 | public string faultCode; 155 | public string faultString; 156 | } 157 | 158 | } 159 | } 160 | 161 | 162 | -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcResponseEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2006, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | using System; 27 | using System.IO; 28 | 29 | namespace CookComputing.XmlRpc 30 | { 31 | public class XmlRpcResponseEventArgs : EventArgs 32 | { 33 | private Guid _guid; 34 | private long _request; 35 | private Stream _responseStream; 36 | 37 | public XmlRpcResponseEventArgs(Guid guid, long request, 38 | Stream responseStream) 39 | { 40 | _guid = guid; 41 | _request = request; 42 | _responseStream = responseStream; 43 | } 44 | 45 | public Guid ProxyID 46 | { 47 | get { return _guid; } 48 | } 49 | 50 | public long RequestNum 51 | { 52 | get { return _request; } 53 | } 54 | 55 | public Stream ResponseStream 56 | { 57 | get { return _responseStream; } 58 | } 59 | } 60 | } 61 | 62 | -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcReturnValueAttribute.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2006, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | namespace CookComputing.XmlRpc 27 | { 28 | using System; 29 | 30 | [AttributeUsage(AttributeTargets.ReturnValue)] 31 | public class XmlRpcReturnValueAttribute : Attribute 32 | { 33 | public XmlRpcReturnValueAttribute() 34 | { 35 | } 36 | public string Description 37 | { 38 | get { return description; } 39 | set { description = value; } 40 | } 41 | public override string ToString() 42 | { 43 | string value = "Description : " + description; 44 | return value; 45 | } 46 | private string description = ""; 47 | } 48 | } -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcStruct.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2009, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | using System; 26 | using System.Collections; 27 | using System.Collections.Generic; 28 | using System.Runtime.Serialization; 29 | 30 | namespace CookComputing.XmlRpc 31 | { 32 | public class XmlRpcStruct : IDictionary, ICollection, IEnumerable 33 | #if (!SILVERLIGHT) 34 | , ISerializable, IDeserializationCallback, ICloneable 35 | #endif 36 | { 37 | private List _keys = new List(); 38 | private List _values = new List(); 39 | private Dictionary _base = new Dictionary(); 40 | private object _syncRoot = new object(); 41 | 42 | public void Add(object key, object value) 43 | { 44 | if (!(key is string)) 45 | { 46 | throw new ArgumentException("XmlRpcStruct key must be a string."); 47 | } 48 | //if (XmlRpcServiceInfo.GetXmlRpcType(value.GetType()) 49 | // == XmlRpcType.tInvalid) 50 | //{ 51 | // throw new ArgumentException(String.Format( 52 | // "Type {0} cannot be mapped to an XML-RPC type", value.GetType())); 53 | //} 54 | _base.Add(key as string, value); 55 | _keys.Add(key as string); 56 | _values.Add(value); 57 | } 58 | 59 | public void Clear() 60 | { 61 | _base.Clear(); 62 | _keys.Clear(); 63 | _values.Clear(); 64 | } 65 | 66 | public bool Contains(object key) 67 | { 68 | return _base.ContainsKey(key as string); 69 | } 70 | 71 | public bool ContainsKey(object key) 72 | { 73 | return _base.ContainsKey(key as string); 74 | } 75 | 76 | public bool ContainsValue(object value) 77 | { 78 | return _base.ContainsValue(value as string); 79 | } 80 | 81 | public IDictionaryEnumerator GetEnumerator() 82 | { 83 | return new XmlRpcStruct.Enumerator(_keys, _values); 84 | } 85 | 86 | public bool IsFixedSize 87 | { 88 | get { return false; } 89 | } 90 | 91 | public bool IsReadOnly 92 | { 93 | get { return false; } 94 | } 95 | 96 | public ICollection Keys 97 | { 98 | get { return _keys; } 99 | } 100 | 101 | public void Remove(object key) 102 | { 103 | _base.Remove(key as string); 104 | int idx = _keys.IndexOf(key as string); 105 | if (idx >= 0) 106 | { 107 | _keys.RemoveAt(idx); 108 | _values.RemoveAt(idx); 109 | } 110 | } 111 | 112 | public ICollection Values 113 | { 114 | get { return _values; } 115 | } 116 | 117 | public object this[object key] 118 | { 119 | get 120 | { 121 | return _base[key as string]; 122 | } 123 | set 124 | { 125 | if (!(key is string)) 126 | { 127 | throw new ArgumentException("XmlRpcStruct key must be a string."); 128 | } 129 | //if (XmlRpcServiceInfo.GetXmlRpcType(value.GetType()) 130 | // == XmlRpcType.tInvalid) 131 | //{ 132 | // throw new ArgumentException(String.Format( 133 | // "Type {0} cannot be mapped to an XML-RPC type", value.GetType())); 134 | //} 135 | _base[key as string] = value; 136 | _keys.Add(key as string); 137 | _values.Add(value); 138 | } 139 | } 140 | 141 | public void CopyTo(Array array, int index) 142 | { 143 | throw new NotImplementedException(); // TODO: implement 144 | } 145 | 146 | public int Count 147 | { 148 | get { return _base.Count; } 149 | } 150 | 151 | public bool IsSynchronized 152 | { 153 | get { return false; } 154 | } 155 | 156 | public object SyncRoot 157 | { 158 | get { return _syncRoot; } 159 | } 160 | 161 | IEnumerator IEnumerable.GetEnumerator() 162 | { 163 | return new XmlRpcStruct.Enumerator(_keys, _values); 164 | } 165 | 166 | void ICollection.CopyTo(Array array, int index) 167 | { 168 | throw new NotImplementedException(); // TODO: implement 169 | } 170 | 171 | int ICollection.Count 172 | { 173 | get { return _base.Count; } 174 | } 175 | 176 | bool ICollection.IsSynchronized 177 | { 178 | get { return false; } 179 | } 180 | 181 | object ICollection.SyncRoot 182 | { 183 | get { return _syncRoot; } 184 | } 185 | 186 | #if (!SILVERLIGHT) 187 | public void GetObjectData(SerializationInfo info, StreamingContext context) 188 | { 189 | throw new NotImplementedException(); // TODO: implement 190 | } 191 | 192 | public void OnDeserialization(object sender) 193 | { 194 | throw new NotImplementedException(); // TODO: implement 195 | } 196 | #endif 197 | 198 | public object Clone() 199 | { 200 | throw new NotImplementedException(); // TODO: implement 201 | } 202 | 203 | private class Enumerator : IDictionaryEnumerator 204 | { 205 | private List _keys; 206 | private List _values; 207 | private int _index; 208 | 209 | public Enumerator(List keys, List values) 210 | { 211 | _keys = keys; 212 | _values = values; 213 | _index = -1; 214 | } 215 | 216 | public void Reset() 217 | { 218 | _index = -1; 219 | } 220 | 221 | public object Current 222 | { 223 | get 224 | { 225 | CheckIndex(); 226 | return new DictionaryEntry(_keys[_index], _values[_index]); 227 | } 228 | } 229 | 230 | public bool MoveNext() 231 | { 232 | _index++; 233 | if (_index >= _keys.Count) 234 | return false; 235 | else 236 | return true; 237 | } 238 | 239 | public DictionaryEntry Entry 240 | { 241 | get 242 | { 243 | CheckIndex(); 244 | return new DictionaryEntry(_keys[_index], _values[_index]); 245 | } 246 | } 247 | 248 | public object Key 249 | { 250 | get 251 | { 252 | CheckIndex(); 253 | return _keys[_index]; 254 | } 255 | } 256 | 257 | public object Value 258 | { 259 | get 260 | { 261 | CheckIndex(); 262 | return _values[_index]; 263 | } 264 | } 265 | 266 | private void CheckIndex() 267 | { 268 | if (_index < 0 || _index >= _keys.Count) 269 | throw new InvalidOperationException( 270 | "Enumeration has either not started or has already finished."); 271 | } 272 | } 273 | } 274 | 275 | public class XmlRpcStructs : Dictionary 276 | { 277 | //private ArrayList _keys = new ArrayList(); 278 | //private ArrayList _values = new ArrayList(); 279 | 280 | //public override void Add(object key, object value) 281 | //{ 282 | // if (!(key is string)) 283 | // { 284 | // throw new ArgumentException("XmlRpcStruct key must be a string."); 285 | // } 286 | // if (XmlRpcServiceInfo.GetXmlRpcType(value.GetType()) 287 | // == XmlRpcType.tInvalid) 288 | // { 289 | // throw new ArgumentException(String.Format( 290 | // "Type {0} cannot be mapped to an XML-RPC type", value.GetType())); 291 | // } 292 | // base.Add(key, value); 293 | // _keys.Add(key); 294 | // _values.Add(value); 295 | //} 296 | 297 | //public override object this[object key] 298 | //{ 299 | // get 300 | // { 301 | // return base[key]; 302 | // } 303 | // set 304 | // { 305 | // if (!(key is string)) 306 | // { 307 | // throw new ArgumentException("XmlRpcStruct key must be a string."); 308 | // } 309 | // if (XmlRpcServiceInfo.GetXmlRpcType(value.GetType()) 310 | // == XmlRpcType.tInvalid) 311 | // { 312 | // throw new ArgumentException(String.Format( 313 | // "Type {0} cannot be mapped to an XML-RPC type", value.GetType())); 314 | // } 315 | // base[key] = value; 316 | // _keys.Add(key); 317 | // _values.Add(value); 318 | // } 319 | //} 320 | 321 | //public override bool Equals(Object obj) 322 | //{ 323 | // if (obj.GetType() != typeof(XmlRpcStruct)) 324 | // return false; 325 | // XmlRpcStruct xmlRpcStruct = (XmlRpcStruct)obj; 326 | // if (this.Keys.Count != xmlRpcStruct.Count) 327 | // return false; 328 | // foreach (String key in this.Keys) 329 | // { 330 | // if (!xmlRpcStruct.ContainsKey(key)) 331 | // return false; 332 | // if (!this[key].Equals(xmlRpcStruct[key])) 333 | // return false; 334 | // } 335 | // return true; 336 | //} 337 | 338 | //public override int GetHashCode() 339 | //{ 340 | // int hash = 0; 341 | // foreach (object obj in Values) 342 | // { 343 | // hash ^= obj.GetHashCode(); 344 | // } 345 | // return hash; 346 | //} 347 | 348 | //public override void Clear() 349 | //{ 350 | // base.Clear(); 351 | // _keys.Clear(); 352 | // _values.Clear(); 353 | //} 354 | 355 | //public new IDictionaryEnumerator GetEnumerator() 356 | //{ 357 | // return new XmlRpcStruct.Enumerator(_keys, _values); 358 | //} 359 | 360 | //public override ICollection Keys 361 | //{ 362 | // get 363 | // { 364 | // return _keys; 365 | // } 366 | //} 367 | 368 | //public override void Remove(object key) 369 | //{ 370 | // base.Remove(key); 371 | // int idx = _keys.IndexOf(key); 372 | // if (idx >= 0) 373 | // { 374 | // _keys.RemoveAt(idx); 375 | // _values.RemoveAt(idx); 376 | // } 377 | //} 378 | 379 | //public override ICollection Values 380 | //{ 381 | // get 382 | // { 383 | // return _values; 384 | // } 385 | //} 386 | 387 | //private class Enumerator : IDictionaryEnumerator 388 | //{ 389 | // private ArrayList _keys; 390 | // private ArrayList _values; 391 | // private int _index; 392 | 393 | // public Enumerator(ArrayList keys, ArrayList values) 394 | // { 395 | // _keys = keys; 396 | // _values = values; 397 | // _index = -1; 398 | // } 399 | 400 | // public void Reset() 401 | // { 402 | // _index = -1; 403 | // } 404 | 405 | // public object Current 406 | // { 407 | // get 408 | // { 409 | // CheckIndex(); 410 | // return new DictionaryEntry(_keys[_index], _values[_index]); 411 | // } 412 | // } 413 | 414 | // public bool MoveNext() 415 | // { 416 | // _index++; 417 | // if (_index >= _keys.Count) 418 | // return false; 419 | // else 420 | // return true; 421 | // } 422 | 423 | // public DictionaryEntry Entry 424 | // { 425 | // get 426 | // { 427 | // CheckIndex(); 428 | // return new DictionaryEntry(_keys[_index], _values[_index]); 429 | // } 430 | // } 431 | 432 | // public object Key 433 | // { 434 | // get 435 | // { 436 | // CheckIndex(); 437 | // return _keys[_index]; 438 | // } 439 | // } 440 | 441 | // public object Value 442 | // { 443 | // get 444 | // { 445 | // CheckIndex(); 446 | // return _values[_index]; 447 | // } 448 | // } 449 | 450 | // private void CheckIndex() 451 | // { 452 | // if (_index < 0 || _index >= _keys.Count) 453 | // throw new InvalidOperationException( 454 | // "Enumeration has either not started or has already finished."); 455 | // } 456 | //} 457 | } 458 | } -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcTypeInfo.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2006, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | namespace CookComputing.XmlRpc 27 | { 28 | using System; 29 | using System.Collections; 30 | using System.Collections.Generic; 31 | using System.Reflection; 32 | using System.Text.RegularExpressions; 33 | 34 | public enum XmlRpcType 35 | { 36 | tInvalid, 37 | tInt32, 38 | tInt64, 39 | tBoolean, 40 | tString, 41 | tDouble, 42 | tDateTime, 43 | tBase64, 44 | tStruct, 45 | tHashtable, 46 | tArray, 47 | tMultiDimArray, 48 | tVoid, 49 | tNil 50 | } 51 | 52 | public class XmlRpcTypeInfo 53 | { 54 | static bool IsVisibleXmlRpcMethod(MethodInfo mi) 55 | { 56 | bool ret = false; 57 | Attribute attr = Attribute.GetCustomAttribute(mi, 58 | typeof(XmlRpcMethodAttribute)); 59 | if (attr != null) 60 | { 61 | XmlRpcMethodAttribute mattr = (XmlRpcMethodAttribute)attr; 62 | ret = !(mattr.Hidden || mattr.IntrospectionMethod == true); 63 | } 64 | return ret; 65 | } 66 | 67 | public static string GetXmlRpcMethodName(MethodInfo mi) 68 | { 69 | XmlRpcMethodAttribute attr = (XmlRpcMethodAttribute) 70 | Attribute.GetCustomAttribute(mi, 71 | typeof(XmlRpcMethodAttribute)); 72 | if (attr != null 73 | && attr.Method != null 74 | && attr.Method != "") 75 | { 76 | return attr.Method; 77 | } 78 | else 79 | { 80 | return mi.Name; 81 | } 82 | } 83 | 84 | public static XmlRpcType GetXmlRpcType(object o) 85 | { 86 | return o == null ? XmlRpcType.tNil : GetXmlRpcType(o.GetType()); 87 | } 88 | 89 | public static XmlRpcType GetXmlRpcType(Type t) 90 | { 91 | return GetXmlRpcType(t, new Stack()); 92 | } 93 | 94 | private static XmlRpcType GetXmlRpcType(Type t, Stack typeStack) 95 | { 96 | XmlRpcType ret; 97 | if (t == typeof(Int32)) 98 | ret = XmlRpcType.tInt32; 99 | else if (t == typeof(Int64)) 100 | ret = XmlRpcType.tInt64; 101 | else if (t == typeof(Boolean)) 102 | ret = XmlRpcType.tBoolean; 103 | else if (t == typeof(String)) 104 | ret = XmlRpcType.tString; 105 | else if (t == typeof(Double)) 106 | ret = XmlRpcType.tDouble; 107 | else if (t == typeof(DateTime)) 108 | ret = XmlRpcType.tDateTime; 109 | else if (t == typeof(byte[])) 110 | ret = XmlRpcType.tBase64; 111 | else if (t == typeof(XmlRpcStruct)) 112 | { 113 | ret = XmlRpcType.tHashtable; 114 | } 115 | else if (t == typeof(Array)) 116 | ret = XmlRpcType.tArray; 117 | else if (t.IsArray) 118 | { 119 | #if (!COMPACT_FRAMEWORK) 120 | Type elemType = t.GetElementType(); 121 | if (elemType != typeof(Object) 122 | && GetXmlRpcType(elemType, typeStack) == XmlRpcType.tInvalid) 123 | { 124 | ret = XmlRpcType.tInvalid; 125 | } 126 | else 127 | { 128 | if (t.GetArrayRank() == 1) // single dim array 129 | ret = XmlRpcType.tArray; 130 | else 131 | ret = XmlRpcType.tMultiDimArray; 132 | } 133 | #else 134 | //!! check types of array elements if not Object[] 135 | Type elemType = null; 136 | string[] checkSingleDim = Regex.Split(t.FullName, "\\[\\]$"); 137 | if (checkSingleDim.Length > 1) // single dim array 138 | { 139 | elemType = Type.GetType(checkSingleDim[0]); 140 | ret = XmlRpcType.tArray; 141 | } 142 | else 143 | { 144 | string[] checkMultiDim = Regex.Split(t.FullName, "\\[,[,]*\\]$"); 145 | if (checkMultiDim.Length > 1) 146 | { 147 | elemType = Type.GetType(checkMultiDim[0]); 148 | ret = XmlRpcType.tMultiDimArray; 149 | } 150 | else 151 | ret = XmlRpcType.tInvalid; 152 | } 153 | if (elemType != null) 154 | { 155 | if (elemType != typeof(Object) 156 | && GetXmlRpcType(elemType, typeStack) == XmlRpcType.tInvalid) 157 | { 158 | ret = XmlRpcType.tInvalid; 159 | } 160 | } 161 | #endif 162 | 163 | } 164 | else if (t == typeof(int?)) 165 | ret = XmlRpcType.tInt32; 166 | else if (t == typeof(long?)) 167 | ret = XmlRpcType.tInt64; 168 | else if (t == typeof(Boolean?)) 169 | ret = XmlRpcType.tBoolean; 170 | else if (t == typeof(Double?)) 171 | ret = XmlRpcType.tDouble; 172 | else if (t == typeof(DateTime?)) 173 | ret = XmlRpcType.tDateTime; 174 | else if (t == typeof(void)) 175 | { 176 | ret = XmlRpcType.tVoid; 177 | } 178 | else if ((t.IsValueType && !t.IsPrimitive && !t.IsEnum) 179 | || t.IsClass) 180 | { 181 | // if type is struct or class its only valid for XML-RPC mapping if all 182 | // its members have a valid mapping or are of type object which 183 | // maps to any XML-RPC type 184 | MemberInfo[] mis = t.GetMembers(); 185 | foreach (MemberInfo mi in mis) 186 | { 187 | if (Attribute.IsDefined(mi, typeof(NonSerializedAttribute))) 188 | continue; 189 | if (mi.MemberType == MemberTypes.Field) 190 | { 191 | FieldInfo fi = (FieldInfo)mi; 192 | if (typeStack.Contains(fi.FieldType)) 193 | continue; 194 | try 195 | { 196 | typeStack.Push(fi.FieldType); 197 | if ((fi.FieldType != typeof(Object) 198 | && GetXmlRpcType(fi.FieldType, typeStack) == XmlRpcType.tInvalid)) 199 | { 200 | return XmlRpcType.tInvalid; 201 | } 202 | } 203 | finally 204 | { 205 | typeStack.Pop(); 206 | } 207 | } 208 | else if (mi.MemberType == MemberTypes.Property) 209 | { 210 | PropertyInfo pi = (PropertyInfo)mi; 211 | if (pi.GetIndexParameters().Length > 0) 212 | return XmlRpcType.tInvalid; 213 | if (typeStack.Contains(pi.PropertyType)) 214 | continue; 215 | try 216 | { 217 | typeStack.Push(pi.PropertyType); 218 | if ((pi.PropertyType != typeof(Object) 219 | && GetXmlRpcType(pi.PropertyType, typeStack) == XmlRpcType.tInvalid)) 220 | { 221 | return XmlRpcType.tInvalid; 222 | } 223 | } 224 | finally 225 | { 226 | typeStack.Pop(); 227 | } 228 | } 229 | } 230 | ret = XmlRpcType.tStruct; 231 | } 232 | else if (t.IsEnum) 233 | { 234 | Type enumBaseType = Enum.GetUnderlyingType(t); 235 | if (enumBaseType == typeof(int) || enumBaseType == typeof(byte) 236 | || enumBaseType == typeof(sbyte) || enumBaseType == typeof(short) 237 | || enumBaseType == typeof(ushort)) 238 | ret = XmlRpcType.tInt32; 239 | else if (enumBaseType == typeof(long) || enumBaseType == typeof(UInt32)) 240 | ret = XmlRpcType.tInt64; 241 | else 242 | ret = XmlRpcType.tInvalid; 243 | } 244 | else 245 | ret = XmlRpcType.tInvalid; 246 | return ret; 247 | } 248 | 249 | static public string GetXmlRpcTypeString(Type t) 250 | { 251 | XmlRpcType rpcType = GetXmlRpcType(t); 252 | return GetXmlRpcTypeString(rpcType); 253 | } 254 | 255 | static public string GetXmlRpcTypeString(XmlRpcType t) 256 | { 257 | string ret = null; 258 | if (t == XmlRpcType.tInt32) 259 | ret = "integer"; 260 | else if (t == XmlRpcType.tInt64) 261 | ret = "i8"; 262 | else if (t == XmlRpcType.tBoolean) 263 | ret = "boolean"; 264 | else if (t == XmlRpcType.tString) 265 | ret = "string"; 266 | else if (t == XmlRpcType.tDouble) 267 | ret = "double"; 268 | else if (t == XmlRpcType.tDateTime) 269 | ret = "dateTime"; 270 | else if (t == XmlRpcType.tBase64) 271 | ret = "base64"; 272 | else if (t == XmlRpcType.tStruct) 273 | ret = "struct"; 274 | else if (t == XmlRpcType.tHashtable) 275 | ret = "struct"; 276 | else if (t == XmlRpcType.tArray) 277 | ret = "array"; 278 | else if (t == XmlRpcType.tMultiDimArray) 279 | ret = "array"; 280 | else if (t == XmlRpcType.tVoid) 281 | ret = "void"; 282 | else 283 | ret = null; 284 | return ret; 285 | } 286 | 287 | public static string GetUrlFromAttribute(Type type) 288 | { 289 | XmlRpcUrlAttribute urlAttr = Attribute.GetCustomAttribute(type, typeof(XmlRpcUrlAttribute)) 290 | as XmlRpcUrlAttribute; 291 | return urlAttr != null ? urlAttr.Uri : null; 292 | } 293 | 294 | public static string GetRpcMethodName(MethodInfo mi) 295 | { 296 | string rpcMethod; 297 | string MethodName = mi.Name; 298 | Attribute attr = Attribute.GetCustomAttribute(mi, 299 | typeof(XmlRpcBeginAttribute)); 300 | if (attr != null) 301 | { 302 | rpcMethod = ((XmlRpcBeginAttribute)attr).Method; 303 | if (rpcMethod == "") 304 | { 305 | if (!MethodName.StartsWith("Begin") || MethodName.Length <= 5) 306 | throw new Exception(String.Format( 307 | "method {0} has invalid signature for begin method", 308 | MethodName)); 309 | rpcMethod = MethodName.Substring(5); 310 | } 311 | return rpcMethod; 312 | } 313 | // if no XmlRpcBegin attribute, must have XmlRpcMethod attribute 314 | attr = Attribute.GetCustomAttribute(mi, typeof(XmlRpcMethodAttribute)); 315 | if (attr == null) 316 | { 317 | throw new Exception("missing method attribute"); 318 | } 319 | XmlRpcMethodAttribute xrmAttr = attr as XmlRpcMethodAttribute; 320 | rpcMethod = xrmAttr.Method; 321 | if (rpcMethod == "") 322 | { 323 | rpcMethod = mi.Name; 324 | } 325 | return rpcMethod; 326 | } 327 | } 328 | } -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcUrlAttribute.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2006, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | namespace CookComputing.XmlRpc 27 | { 28 | using System; 29 | 30 | [AttributeUsage(AttributeTargets.Class|AttributeTargets.Interface)] 31 | public class XmlRpcUrlAttribute : Attribute 32 | { 33 | public XmlRpcUrlAttribute(string UriString) 34 | { 35 | this.uri = UriString; 36 | } 37 | public string Uri 38 | { 39 | get 40 | { return uri; } 41 | } 42 | public override string ToString() 43 | { 44 | string value = "Uri : " + uri; 45 | return value; 46 | } 47 | private string uri; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcXmlReader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Xml; 5 | using System.IO; 6 | 7 | namespace CookComputing.XmlRpc 8 | { 9 | public static class XmlRpcXmlReader 10 | { 11 | public static XmlReader Create(Stream stm) 12 | { 13 | XmlTextReader xmlRdr = new XmlTextReader(stm); 14 | ConfigureXmlTextReader(xmlRdr); 15 | return xmlRdr; 16 | } 17 | 18 | public static XmlReader Create(TextReader textReader) 19 | { 20 | XmlTextReader xmlRdr = new XmlTextReader(textReader); 21 | ConfigureXmlTextReader(xmlRdr); 22 | return xmlRdr; 23 | } 24 | 25 | private static void ConfigureXmlTextReader(XmlTextReader xmlRdr) 26 | { 27 | xmlRdr.Normalization = false; 28 | xmlRdr.ProhibitDtd = true; 29 | xmlRdr.WhitespaceHandling = WhitespaceHandling.All; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /XmlRpcNet/XmlRpcXmlWriter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Xml; 5 | using System.IO; 6 | 7 | namespace CookComputing.XmlRpc 8 | { 9 | public static class XmlRpcXmlWriter 10 | { 11 | public static XmlWriter Create(Stream stm, XmlRpcFormatSettings settings) 12 | { 13 | var stmWriter = new EncodingStreamWriter(stm, settings.XmlEncoding); 14 | XmlWriter xtw = XmlWriter.Create(stmWriter, ConfigureXmlFormat(settings)); 15 | return xtw; 16 | } 17 | 18 | private static XmlWriterSettings ConfigureXmlFormat(XmlRpcFormatSettings settings) 19 | { 20 | if (settings.UseIndentation) 21 | { 22 | return new XmlWriterSettings 23 | { 24 | Indent = true, 25 | IndentChars = new string(' ', settings.Indentation), 26 | Encoding = settings.XmlEncoding, 27 | NewLineHandling = NewLineHandling.None, 28 | OmitXmlDeclaration = settings.OmitXmlDeclaration, 29 | }; 30 | } 31 | else 32 | { 33 | return new XmlWriterSettings 34 | { 35 | Indent = false, 36 | Encoding = settings.XmlEncoding, 37 | OmitXmlDeclaration = settings.OmitXmlDeclaration, 38 | }; 39 | } 40 | } 41 | 42 | private class EncodingStreamWriter : StreamWriter 43 | { 44 | Encoding _encoding; 45 | 46 | public EncodingStreamWriter(Stream stm, Encoding encoding) 47 | : base(stm) 48 | { 49 | _encoding = encoding; 50 | } 51 | 52 | public override Encoding Encoding 53 | { 54 | get { return _encoding; } 55 | } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /XmlRpcNet/util.cs: -------------------------------------------------------------------------------- 1 | /* 2 | XML-RPC.NET library 3 | Copyright (c) 2001-2006, Charles Cook 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | namespace CookComputing.XmlRpc 27 | { 28 | using System; 29 | using System.Diagnostics; 30 | using System.IO; 31 | using System.Text; 32 | 33 | public class Util 34 | { 35 | // protect constructor because static only class 36 | protected Util() 37 | { 38 | } 39 | 40 | static public void CopyStream(Stream src, Stream dst) 41 | { 42 | byte[] buff = new byte[4096]; 43 | while (true) 44 | { 45 | int read = src.Read(buff, 0, 4096); 46 | if (read == 0) 47 | break; 48 | dst.Write(buff, 0, read); 49 | } 50 | } 51 | 52 | public static Stream StringAsStream(string S) 53 | { 54 | MemoryStream mstm = new MemoryStream(); 55 | StreamWriter sw = new StreamWriter(mstm); 56 | sw.Write(S); 57 | sw.Flush(); 58 | mstm.Seek(0, SeekOrigin.Begin); 59 | return mstm; 60 | } 61 | 62 | #if (!COMPACT_FRAMEWORK && !SILVERLIGHT) 63 | public static void TraceStream(Stream stm) 64 | { 65 | TextReader trdr = new StreamReader(stm, new UTF8Encoding(), true, 4096); 66 | String s = trdr.ReadLine(); 67 | while (s != null) 68 | { 69 | Trace.WriteLine(s); 70 | s = trdr.ReadLine(); 71 | } 72 | } 73 | 74 | public static void DumpStream(Stream stm) 75 | { 76 | TextReader trdr = new StreamReader(stm); 77 | String s = trdr.ReadLine(); 78 | while (s != null) 79 | { 80 | Trace.WriteLine(s); 81 | s = trdr.ReadLine(); 82 | } 83 | } 84 | #endif 85 | 86 | //#if (!COMPACT_FRAMEWORK) 87 | public static Guid NewGuid() 88 | { 89 | return Guid.NewGuid(); 90 | } 91 | //#else 92 | // public static Guid NewGuid() 93 | // { 94 | // return OpenNETCF.GuidEx.NewGuid(); 95 | // } 96 | //#endif 97 | } 98 | 99 | } 100 | --------------------------------------------------------------------------------