/[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 107 - (show annotations) (download)
Sun Mar 10 12:58:40 2013 UTC (7 years, 4 months ago) by william
File size: 8617 byte(s)
+ handle unparsed root nodes, just like handling unparsed program nodes

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

  ViewVC Help
Powered by ViewVC 1.1.22