/[xmltv_parser]/trunk/libxmltv/Interfaces/Interfaces.cs
ViewVC logotype

Contents of /trunk/libxmltv/Interfaces/Interfaces.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 137 - (show annotations) (download)
Wed Mar 13 16:59:40 2013 UTC (7 years, 8 months ago) by william
File size: 10294 byte(s)

1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.IO;
6 using System.Xml.Linq;
7 using libxmltv.Core;
8 using System.ComponentModel;
9 using System.Collections;
10 using System.Runtime.InteropServices;
11
12 namespace libxmltv.Interfaces
13 {
14 //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
26 public interface IXMLTVSource : IDataSourceBindable
27 {
28 string SourceName { get; }
29 string GeneratorName { get; }
30 string GeneratorUrl { get; }
31 string ToString();
32 }
33
34 public interface IProgramDefinitionList : IList<IProgramDefinition>, IDataSourceSortable, IDataSourceFilterable { }
35 public interface IChannelDefintionList : IList<IChannelDefintion>, IDataSourceSortable, IDataSourceFilterable { }
36
37
38 public interface IChannelDefintion
39 {
40 string ChannelId { get; }
41 string ChannelName { get; }
42 }
43 public interface IProgramDefinition
44 {
45 //string ChannelId { get; }
46 int ChannelNumber { get; } // column index: 0
47 string ChannelName { get; }// column index: 1
48 DateTime Start { get; }// column index: 2
49 DateTime Stop { get; }// column index: 3
50 string Title { get; }// column index: 4
51 string SubTitle { get; }// column index: 5
52 string Description { get; }// column index: 6
53 }
54 public interface IXMLTVChannel
55 {
56 string Id { get; }
57 //int Number { get; }
58 //string CallSign { get; }
59 //string Name { get; }
60 IPropertyList MetaData { get; }
61 string ToString();
62 }
63 public interface IXMLTVProgram
64 {
65 IPropertyDictionary MetaData { get; }
66 ExtraList GetExtraMetaData();
67 }
68
69 public interface IExtraMetaData : IExtraMetaData<string, string> { }
70 public interface IExtraMetaData<TKey, TValue> : IPropertyValuePair<TKey, TValue>
71 {
72 XElement AsXElement();
73 }
74
75 //public interface IDataConverter { object ConvertObjectData(object source); }
76 //public interface IDataConverter<T>
77 //{
78 // T ConvertData(object source);
79 //}
80 public interface IDataSourceBindable //: IDataConverter
81 {
82 object CreateBindableDataSource(out Type type);
83 }
84
85 public interface IDataSourceFilterable
86 {
87 void Filter(ref object source, params string[] args);
88 }
89 public interface IDataSourceSortable
90 {
91 void Sort(ref object source, bool descending, params string[] args);
92 }
93
94 internal interface IXMLTVProgramCollection : IXMLTVDictionaryCollection<string, IXMLTVProgram> { }
95 internal interface IXMLTVChannelCollection : IXMLTVDictionaryCollection<string, IXMLTVChannel> { }
96 internal interface IXMLTVDictionaryCollection<TKey, TValue> { Dictionary<TKey, TValue> Collection { get; } }
97 internal interface IXMLTVListCollection<TValue> { List<TValue> Collection { get; } }
98
99 internal interface IXMLTVHandler : IXMLTVHandler<object> { }
100 internal interface IXMLTVHandler<T> { T Handler { get; } }
101
102 //public interface IXMLTVBase : IXMLTVBase<object> { }
103 internal interface IXMLTVBase<T> : IGetInstance<T>, IXMLTVHandler { }
104 internal interface IXMLTVRuntimeInstance : IOnInstanceCreated
105 {
106 bool IsAborting { get; }
107 //FileInfo XmlFile { get; }
108 string XmlFile_Name { get; }
109 string XmlFile_FullName { get; }
110 string XmlDoc { get; }
111 IXMLTVSource Source { get; }
112 ChannelList Channels { get; }
113 ProgramList Programs { get; }
114 ExtraList ExtraEntries { get; }
115 }
116 internal interface IXMLTVSerializer : IXMLTVSerializer<object> { }
117 internal interface IXMLTVSerializer<T>
118 {
119 bool Serialize(string file);
120 bool Serialize(Stream stream);
121 T DeSerialize(string file, out bool status);
122 T DeSerialize(Stream stream, out bool status);
123 }
124 internal interface IXMLTV<INTERFACE, CLASS> : IXMLTV<INTERFACE, CLASS, EventArgs> where CLASS : class,INTERFACE { }
125 internal interface IXMLTV<INTERFACE, CLASS, INSTANCECREATED_EVENTAGS> : IXMLTVSerializer<INTERFACE>, IDestroyInstance, IOnInstanceCreated, IGetInstance<INTERFACE>, ISetInstance<INTERFACE>
126 where CLASS : class,INTERFACE
127 where INSTANCECREATED_EVENTAGS : EventArgs { }
128
129 internal interface IInstance : IInstance<object> { }
130 internal interface IInstance<T> { T Instance { get; set; } }
131 internal interface ICreateSerializer : ICreateSerializer<object> { }
132 internal interface ICreateSerializer<CLASS> { IXMLTVSerializer<CLASS> CreateSerializer(); }
133
134 //public interface IGetInstanceT : IGetInstanceT<object> { }
135 //public interface IGetInstanceT<T> { T GetInstance<T>(); }
136 internal interface IGetInstance : IGetInstance<object> { }
137 internal interface IGetInstance<T> { T GetInstance(); }
138
139 internal interface ISetInstance : ISetInstance<object> { }
140 internal interface ISetInstance<T> { void SetInstance(T instance); }
141
142 internal interface IOnInstanceCreated : IOnInstanceCreated<EventArgs> { }
143 internal interface IOnInstanceCreated<T> where T : EventArgs { EventHandler<T> OnInstanceCreated { get; set; } }
144 internal interface ISerializer<T> { IXMLTVSerializer<T> Serializer { get; } }
145 internal interface IDestroyInstance { void DestroyInstance(); }
146 internal interface IGetCreatedInstanceEvent : IGetCreatedInstanceEvent<EventArgs> { }
147 internal interface IGetCreatedInstanceEvent<T> where T : EventArgs { EventHandler<T> GetOnInstanceCreated(); }
148 internal interface ISetCreatedInstanceEvent : ISetCreatedInstanceEvent<EventArgs> { }
149 internal interface ISetCreatedInstanceEvent<T> where T : EventArgs { void SetOnInstanceCreated(EventHandler<T> event_instance); }
150 internal interface IRuntimeInstanceLoader : IRuntimeInstanceLoader<object> { }
151 internal interface IRuntimeInstanceLoader<T> { T LoadFromInstance(T instance); }
152
153
154 #region Property Dictionary support
155 public interface IPropertyDictionary : IPropertyDictionary<string, object> { }
156 public interface IPropertyDictionary<TKey, TValue> : IPropertyCollection<IPropertyValuePair<TKey, TValue>>, IEnumerable<IPropertyValuePair<TKey, TValue>>, IEnumerable
157 {
158 IPropertyCollection<TKey> PropertyKeys { get; }
159 IPropertyCollection<TValue> PropertyValues { get; }
160 TValue this[TKey key] { get; set; }
161 void AddProperty(TKey key, TValue value);
162 bool ContainsProperty(TKey key);
163 bool RemoveProperty(TKey key);
164 bool TryGetPropertyValue(TKey key, out TValue value);
165 }
166 public interface IPropertyCollection<T> : IEnumerable<T>, IEnumerable
167 {
168 int PropertyCount { get; }
169 bool IsReadOnly { get; }
170 void AddProperty(T item);
171 void ClearProperties();
172 bool ContainsProperty(T item);
173 void CopyPropertiesTo(T[] array, int arrayIndex);
174 bool RemoveProperty(T item);
175 string ToString();
176 }
177 #endregion
178 #region Property List support
179 public interface IPropertyList : IPropertyList<string, object> { }
180 public interface IPropertyList<TKey, TValue> : IPropertyCollection<IPropertyValuePair<TKey, TValue>>, IEnumerable<IPropertyValuePair<TKey, TValue>>, IEnumerable
181 {
182 IPropertyValuePair<TKey, TValue> this[int index] { get; set; }
183 IEnumerable<IPropertyValuePair<TKey, TValue>> this[TKey name] { get; }//set; }
184
185 int IndexOfProperty(IPropertyValuePair<TKey, TValue> item);
186 void InsertPropertyAtIndex(int index, IPropertyValuePair<TKey, TValue> item);
187 void RemovePropertyAt(int index);
188
189 bool ContainsProperty(TKey name, TValue value);
190 void AddProperty(TKey name, TValue value);
191 void RemoveProperty(TKey TKey, TValue value);
192 }
193 #endregion
194
195 #region PropertyValuePair support
196
197 public interface IPropertyValuePair : IPropertyValuePair<string, object> { }
198 public interface IPropertyValuePair<TKey, TValue>
199 {
200 TKey Name { get; }
201 TValue Value { get; }
202 string ToString();
203 }
204 [Serializable]
205 internal class PropertyValuePair : PropertyValuePair<string, object>, IPropertyValuePair
206 {
207 public PropertyValuePair() :base() { }
208 public PropertyValuePair(string name, object value) : base(name,value) { }
209 }
210 [Serializable]
211 internal class PropertyValuePair<TKey, TValue> : IPropertyValuePair<TKey,TValue>
212 {
213 #region KeyValuePair support
214 public static implicit operator PropertyValuePair<TKey, TValue>(KeyValuePair<TKey, TValue> i) { return new PropertyValuePair<TKey, TValue>(i.Key, i.Value); }
215 public static implicit operator KeyValuePair<TKey, TValue>(PropertyValuePair<TKey, TValue> i) { return new KeyValuePair<TKey, TValue>(i.Name, i.Value); }
216 #endregion
217 public PropertyValuePair() : this(default(TKey),default(TValue)) { }
218 public PropertyValuePair(TKey name, TValue value)
219 {
220 this.name = name;
221 this.value = value;
222 }
223 private TKey name;
224 public TKey Name { get { return this.name; } }
225 private TValue value;
226 public TValue Value { get { return this.value; } }
227 public override string ToString()
228 {
229 StringBuilder builder = new StringBuilder();
230 builder.Append('[');
231 if (this.Name != null)
232 {
233 builder.Append(this.Name.ToString());
234 }
235 builder.Append(", ");
236 if (this.Value != null)
237 {
238 builder.Append(this.Value.ToString());
239 }
240 builder.Append(']');
241 return builder.ToString();
242
243 }
244 }
245 #endregion
246
247 }

  ViewVC Help
Powered by ViewVC 1.1.22