/[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 141 - (show annotations) (download)
Thu Mar 14 13:08:20 2013 UTC (7 years, 8 months ago) by william
File size: 10348 byte(s)
+ fix datetime start/stop strings sometimes only showing the date and not the time

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

  ViewVC Help
Powered by ViewVC 1.1.22