ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/xmltv_parser/trunk/libxmltv/Interfaces/Interfaces.cs
Revision: 118
Committed: Sun Mar 10 17:41:52 2013 UTC (10 years, 9 months ago) by william
File size: 8900 byte(s)
Log Message:

File Contents

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