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

  ViewVC Help
Powered by ViewVC 1.1.22