Menu

[r744]: / phprpc_3.0 / dotNET / PHPFormatter.cs  Maximize  Restore  History

Download this file

86 lines (75 with data), 3.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**********************************************************\
| |
| The implementation of PHPRPC Protocol 3.0 |
| |
| PHPFormatter.cs |
| |
| Release 3.0.2 |
| Copyright by Team-PHPRPC |
| |
| WebSite: http://www.phprpc.org/ |
| http://www.phprpc.net/ |
| http://www.phprpc.com/ |
| http://sourceforge.net/projects/php-rpc/ |
| |
| Authors: Ma Bingyao <andot@ujn.edu.cn> |
| |
| This file may be distributed and/or modified under the |
| terms of the GNU General Public License (GPL) version |
| 2.0 as published by the Free Software Foundation and |
| appearing in the included file LICENSE. |
| |
\**********************************************************/
/* PHPFormatter class.
*
* Copyright: Ma Bingyao <andot@ujn.edu.cn>
* Version: 3.0
* LastModified: Apr 12, 2010
* This library is free. You can redistribute it and/or modify it under GPL.
*/
namespace org.phprpc.util {
using System;
using System.IO;
using System.Text;
using System.Reflection;
public sealed class PHPFormatter {
private Encoding encoding;
private Assembly[] assemblies;
public PHPFormatter() {
encoding = new UTF8Encoding();
#if (PocketPC || Smartphone || WindowsCE || SILVERLIGHT)
assemblies = new Assembly[] { Assembly.GetCallingAssembly(), Assembly.GetExecutingAssembly() };
#else
assemblies = AppDomain.CurrentDomain.GetAssemblies();
#endif
}
public PHPFormatter(Encoding encoding, Assembly[] assemblies) {
this.encoding = encoding;
this.assemblies = assemblies;
}
public Encoding Encoding {
get {
return encoding;
}
set {
encoding = value;
}
}
public Assembly[] Assemblies {
get {
return assemblies;
}
set {
assemblies = value;
}
}
public void Serialize(Stream serializationStream, Object graph) {
PHPWriter phpWriter = new PHPWriter(serializationStream, encoding);
phpWriter.Serialize(graph);
}
public Object Deserialize(Stream serializationStream) {
PHPReader phpReader = new PHPReader(encoding, assemblies);
return phpReader.Deserialize(serializationStream);
}
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.