1 |
william |
10 |
using System; |
2 |
|
|
using System.Collections.Generic; |
3 |
|
|
using System.Linq; |
4 |
|
|
using System.Text; |
5 |
william |
11 |
using System.IO; |
6 |
william |
22 |
using System.Xml.Linq; |
7 |
william |
26 |
using libxmltv.Core; |
8 |
william |
54 |
using System.ComponentModel; |
9 |
william |
90 |
using System.Collections; |
10 |
william |
92 |
using System.Runtime.InteropServices; |
11 |
william |
10 |
|
12 |
|
|
namespace libxmltv.Interfaces |
13 |
|
|
{ |
14 |
william |
72 |
//public interface IXMLTVLoader |
15 |
|
|
//{ |
16 |
|
|
// FileInfo XmlFile { get; } |
17 |
|
|
// string XmlDoc { get; } |
18 |
|
|
//} |
19 |
|
|
//public interface IXMLTVParser |
20 |
|
|
//{ |
21 |
|
|
// IXMLTVSource Source { get; } |
22 |
|
|
// Dictionary<string, IXMLTVChannel> Channels { get; } |
23 |
|
|
// Dictionary<int, IXMLTVProgram> Programs { get; } |
24 |
|
|
//} |
25 |
william |
25 |
|
26 |
|
|
public interface IXMLTVSource |
27 |
|
|
{ |
28 |
|
|
string SourceName { get; } |
29 |
|
|
string GeneratorName { get; } |
30 |
|
|
string GeneratorUrl { get; } |
31 |
|
|
string ToString(); |
32 |
|
|
} |
33 |
william |
26 |
public interface IXMLTVChannel |
34 |
|
|
{ |
35 |
william |
28 |
string Id { get; } |
36 |
|
|
int Number { get; } |
37 |
|
|
string CallSign { get; } |
38 |
|
|
string Name { get; } |
39 |
|
|
string ToString(); |
40 |
william |
64 |
} |
41 |
william |
90 |
public interface IXMLTVProgram |
42 |
william |
86 |
{ |
43 |
william |
91 |
PropertyDictionary MetaData { get; } |
44 |
william |
86 |
} |
45 |
william |
72 |
|
46 |
william |
73 |
public interface IXMLTVProgramCollection : IXMLTVDictionaryCollection<string, IXMLTVProgram> { } |
47 |
|
|
public interface IXMLTVChannelCollection : IXMLTVDictionaryCollection<string, IXMLTVChannel> { } |
48 |
|
|
public interface IXMLTVDictionaryCollection<TKey, TValue> { Dictionary<TKey, TValue> Collection { get; } } |
49 |
|
|
public interface IXMLTVListCollection<TValue> { List<TValue> Collection { get; } } |
50 |
william |
72 |
|
51 |
william |
81 |
public interface IXMLTVHandler : IXMLTVHandler<object> { } |
52 |
william |
73 |
public interface IXMLTVHandler<T> { T Handler { get; } } |
53 |
|
|
|
54 |
william |
72 |
//public interface IXMLTVBase : IXMLTVBase<object> { } |
55 |
william |
81 |
public interface IXMLTVBase<T> : IGetInstance<T>, IXMLTVHandler { } |
56 |
william |
72 |
public interface IXMLTVRuntimeInstance : IOnInstanceCreated |
57 |
|
|
{ |
58 |
|
|
bool IsAborting { get; } |
59 |
|
|
//FileInfo XmlFile { get; } |
60 |
|
|
string XmlFile_Name { get; } |
61 |
|
|
string XmlFile_FullName { get; } |
62 |
|
|
string XmlDoc { get; } |
63 |
william |
77 |
IXMLTVSource Source { get; } |
64 |
william |
73 |
List<IXMLTVChannel> Channels { get; } |
65 |
|
|
List<IXMLTVProgram> Programs { get; } |
66 |
william |
72 |
|
67 |
|
|
} |
68 |
william |
64 |
public interface IXMLTVSerializer : IXMLTVSerializer<object> { } |
69 |
william |
49 |
public interface IXMLTVSerializer<T> |
70 |
|
|
{ |
71 |
|
|
bool Serialize(string file); |
72 |
|
|
bool Serialize(Stream stream); |
73 |
william |
50 |
T DeSerialize(string file, out bool status); |
74 |
|
|
T DeSerialize(Stream stream, out bool status); |
75 |
william |
49 |
} |
76 |
william |
64 |
public interface IXMLTV<INTERFACE, CLASS> : IXMLTV<INTERFACE, CLASS, EventArgs> where CLASS : class,INTERFACE { } |
77 |
|
|
public interface IXMLTV<INTERFACE, CLASS, INSTANCECREATED_EVENTAGS> : IXMLTVSerializer<INTERFACE>, IDestroyInstance, IOnInstanceCreated, IGetInstance<INTERFACE> |
78 |
william |
50 |
where CLASS : class,INTERFACE |
79 |
william |
64 |
where INSTANCECREATED_EVENTAGS : EventArgs { } |
80 |
william |
72 |
|
81 |
|
|
public interface IInstance : IInstance<object> { } |
82 |
|
|
public interface IInstance<T> { T Instance { get; set; } } |
83 |
william |
64 |
public interface ICreateSerializer : ICreateSerializer<object> { } |
84 |
|
|
public interface ICreateSerializer<CLASS> { IXMLTVSerializer<CLASS> CreateSerializer(); } |
85 |
william |
72 |
|
86 |
|
|
//public interface IGetInstanceT : IGetInstanceT<object> { } |
87 |
|
|
//public interface IGetInstanceT<T> { T GetInstance<T>(); } |
88 |
william |
64 |
public interface IGetInstance : IGetInstance<object> { } |
89 |
|
|
public interface IGetInstance<T> { T GetInstance(); } |
90 |
william |
72 |
|
91 |
william |
64 |
public interface IOnInstanceCreated : IOnInstanceCreated<EventArgs> { } |
92 |
|
|
public interface IOnInstanceCreated<T> where T : EventArgs { EventHandler<T> OnInstanceCreated { get; set; } } |
93 |
|
|
public interface ISerializer<T> { IXMLTVSerializer<T> Serializer { get; } } |
94 |
|
|
public interface IDestroyInstance { void DestroyInstance(); } |
95 |
|
|
public interface IGetCreatedInstanceEvent : IGetCreatedInstanceEvent<EventArgs> { } |
96 |
|
|
public interface IGetCreatedInstanceEvent<T> where T : EventArgs { EventHandler<T> GetOnInstanceCreated(); } |
97 |
|
|
public interface ISetCreatedInstanceEvent : ISetCreatedInstanceEvent<EventArgs> { } |
98 |
|
|
public interface ISetCreatedInstanceEvent<T> where T : EventArgs { void SetOnInstanceCreated(EventHandler<T> event_instance); } |
99 |
|
|
public interface IRuntimeInstanceLoader : IRuntimeInstanceLoader<object> { } |
100 |
|
|
public interface IRuntimeInstanceLoader<T> { T LoadFromInstance(T instance); } |
101 |
william |
90 |
|
102 |
|
|
|
103 |
william |
91 |
#region Property Dictionary support |
104 |
william |
90 |
public interface IPropertyDictionary : IPropertyDictionary<string,object> { } |
105 |
william |
92 |
public interface IPropertyDictionary<TKey, TValue> : IPropertyCollection<PropertyValuePair<TKey, TValue>>, IEnumerable<PropertyValuePair<TKey, TValue>>, IEnumerable |
106 |
william |
90 |
{ |
107 |
|
|
IPropertyCollection<TKey> PropertyKeys { get; } |
108 |
|
|
IPropertyCollection<TValue> PropertyValues { get; } |
109 |
|
|
TValue this[TKey key] { get; set; } |
110 |
|
|
void AddProperty(TKey key, TValue value); |
111 |
|
|
bool ContainsProperty(TKey key); |
112 |
|
|
bool RemoveProperty(TKey key); |
113 |
|
|
bool TryGetPropertyValue(TKey key, out TValue value); |
114 |
|
|
} |
115 |
|
|
public interface IPropertyCollection<T> : IEnumerable<T>, IEnumerable |
116 |
|
|
{ |
117 |
|
|
int PropertyCount { get; } |
118 |
|
|
bool IsReadOnly { get; } |
119 |
|
|
void AddProperty(T item); |
120 |
|
|
void ClearProperties(); |
121 |
|
|
bool ContainsProperty(T item); |
122 |
|
|
void CopyPropertiesTo(T[] array, int arrayIndex); |
123 |
|
|
bool RemoveProperty(T item); |
124 |
|
|
} |
125 |
|
|
#endregion |
126 |
william |
92 |
#region Property List support |
127 |
|
|
public interface IPropertyList : IPropertyList<PropertyValuePair<string, object>> { } |
128 |
|
|
public interface IPropertyList<T> : IPropertyCollection<T>, IEnumerable<List<T>>, IEnumerable |
129 |
|
|
{ |
130 |
|
|
T this[int index] { get; set; } |
131 |
|
|
int IndexOfProperty(T item); |
132 |
|
|
void InsertPropertyAtIndex(int index, T item); |
133 |
|
|
void RemovePropertyAt(int index); |
134 |
|
|
} |
135 |
|
|
#endregion |
136 |
|
|
|
137 |
|
|
#region PropertyValuePair support |
138 |
|
|
public struct PropertyValuePair<TKey, TValue> |
139 |
|
|
{ |
140 |
|
|
#region KeyValuePair support |
141 |
|
|
public static implicit operator PropertyValuePair<TKey, TValue>(KeyValuePair<TKey, TValue> i) { return new PropertyValuePair<TKey, TValue>(i.Key, i.Value); } |
142 |
|
|
public static implicit operator KeyValuePair<TKey, TValue>(PropertyValuePair<TKey, TValue> i) { return new KeyValuePair<TKey, TValue>(i.Name, i.Value); } |
143 |
|
|
#endregion |
144 |
|
|
public PropertyValuePair(TKey name, TValue value) |
145 |
|
|
{ |
146 |
|
|
this.name = name; |
147 |
|
|
this.value = value; |
148 |
|
|
} |
149 |
|
|
private TKey name; |
150 |
|
|
public TKey Name { get { return this.name; } } |
151 |
|
|
private TValue value; |
152 |
|
|
public TValue Value { get { return this.value; } } |
153 |
|
|
public override string ToString() |
154 |
|
|
{ |
155 |
|
|
StringBuilder builder = new StringBuilder(); |
156 |
|
|
builder.Append('['); |
157 |
|
|
if (this.Name != null) |
158 |
|
|
{ |
159 |
|
|
builder.Append(this.Name.ToString()); |
160 |
|
|
} |
161 |
|
|
builder.Append(", "); |
162 |
|
|
if (this.Value != null) |
163 |
|
|
{ |
164 |
|
|
builder.Append(this.Value.ToString()); |
165 |
|
|
} |
166 |
|
|
builder.Append(']'); |
167 |
|
|
return builder.ToString(); |
168 |
|
|
|
169 |
|
|
} |
170 |
|
|
} |
171 |
|
|
#endregion |
172 |
|
|
|
173 |
william |
28 |
} |