/[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 128 - (show annotations) (download)
Wed Mar 13 13:45:05 2013 UTC (7 years, 7 months ago) by william
File size: 10114 byte(s)
+ current wip

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

  ViewVC Help
Powered by ViewVC 1.1.22