/[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 254 - (show annotations) (download)
Wed Apr 17 21:55:30 2013 UTC (7 years, 6 months ago) by william
File size: 10761 byte(s)
+ update binding source so that we can get an instance of the raw data

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

  ViewVC Help
Powered by ViewVC 1.1.22