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

  ViewVC Help
Powered by ViewVC 1.1.22