/[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 105 - (show annotations) (download)
Sun Mar 10 11:35:26 2013 UTC (7 years, 7 months ago) by william
File size: 8386 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
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
48 {
49 }
50 //public interface IExtraMetaData : IPro
51 //{
52 //}
53 public interface IXMLTVProgramCollection : IXMLTVDictionaryCollection<string, IXMLTVProgram> { }
54 public interface IXMLTVChannelCollection : IXMLTVDictionaryCollection<string, IXMLTVChannel> { }
55 public interface IXMLTVDictionaryCollection<TKey, TValue> { Dictionary<TKey, TValue> Collection { get; } }
56 public interface IXMLTVListCollection<TValue> { List<TValue> Collection { get; } }
57
58 public interface IXMLTVHandler : IXMLTVHandler<object> { }
59 public interface IXMLTVHandler<T> { T Handler { get; } }
60
61 //public interface IXMLTVBase : IXMLTVBase<object> { }
62 public interface IXMLTVBase<T> : IGetInstance<T>, IXMLTVHandler { }
63 public 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
74 }
75 public interface IXMLTVSerializer : IXMLTVSerializer<object> { }
76 public 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 public interface IXMLTV<INTERFACE, CLASS> : IXMLTV<INTERFACE, CLASS, EventArgs> where CLASS : class,INTERFACE { }
84 public interface IXMLTV<INTERFACE, CLASS, INSTANCECREATED_EVENTAGS> : IXMLTVSerializer<INTERFACE>, IDestroyInstance, IOnInstanceCreated, IGetInstance<INTERFACE>
85 where CLASS : class,INTERFACE
86 where INSTANCECREATED_EVENTAGS : EventArgs { }
87
88 public interface IInstance : IInstance<object> { }
89 public interface IInstance<T> { T Instance { get; set; } }
90 public interface ICreateSerializer : ICreateSerializer<object> { }
91 public interface ICreateSerializer<CLASS> { IXMLTVSerializer<CLASS> CreateSerializer(); }
92
93 //public interface IGetInstanceT : IGetInstanceT<object> { }
94 //public interface IGetInstanceT<T> { T GetInstance<T>(); }
95 public interface IGetInstance : IGetInstance<object> { }
96 public interface IGetInstance<T> { T GetInstance(); }
97
98 public interface IOnInstanceCreated : IOnInstanceCreated<EventArgs> { }
99 public interface IOnInstanceCreated<T> where T : EventArgs { EventHandler<T> OnInstanceCreated { get; set; } }
100 public interface ISerializer<T> { IXMLTVSerializer<T> Serializer { get; } }
101 public interface IDestroyInstance { void DestroyInstance(); }
102 public interface IGetCreatedInstanceEvent : IGetCreatedInstanceEvent<EventArgs> { }
103 public interface IGetCreatedInstanceEvent<T> where T : EventArgs { EventHandler<T> GetOnInstanceCreated(); }
104 public interface ISetCreatedInstanceEvent : ISetCreatedInstanceEvent<EventArgs> { }
105 public interface ISetCreatedInstanceEvent<T> where T : EventArgs { void SetOnInstanceCreated(EventHandler<T> event_instance); }
106 public interface IRuntimeInstanceLoader : IRuntimeInstanceLoader<object> { }
107 public interface IRuntimeInstanceLoader<T> { T LoadFromInstance(T instance); }
108
109
110 #region Property Dictionary support
111 public interface IPropertyDictionary : IPropertyDictionary<string,object> { }
112 public interface IPropertyDictionary<TKey, TValue> : IPropertyCollection<IPropertyValuePair<TKey, TValue>>, IEnumerable<IPropertyValuePair<TKey, TValue>>, IEnumerable
113 {
114 IPropertyCollection<TKey> PropertyKeys { get; }
115 IPropertyCollection<TValue> PropertyValues { get; }
116 TValue this[TKey key] { get; set; }
117 void AddProperty(TKey key, TValue value);
118 bool ContainsProperty(TKey key);
119 bool RemoveProperty(TKey key);
120 bool TryGetPropertyValue(TKey key, out TValue value);
121 }
122 public interface IPropertyCollection<T> : IEnumerable<T>, IEnumerable
123 {
124 int PropertyCount { get; }
125 bool IsReadOnly { get; }
126 void AddProperty(T item);
127 void ClearProperties();
128 bool ContainsProperty(T item);
129 void CopyPropertiesTo(T[] array, int arrayIndex);
130 bool RemoveProperty(T item);
131 }
132 #endregion
133 #region Property List support
134 public interface IPropertyList : IPropertyList<string, object> { }
135 public interface IPropertyList<TKey, TValue> : IPropertyCollection<IPropertyValuePair<TKey, TValue>>, IEnumerable<IPropertyValuePair<TKey, TValue>>, IEnumerable
136 {
137 IPropertyValuePair<TKey, TValue> this[int index] { get; set; }
138 IEnumerable<IPropertyValuePair<TKey, TValue>> this[TKey name] { get; }//set; }
139
140 int IndexOfProperty(IPropertyValuePair<TKey, TValue> item);
141 void InsertPropertyAtIndex(int index, IPropertyValuePair<TKey, TValue> item);
142 void RemovePropertyAt(int index);
143
144 bool ContainsProperty(TKey name, TValue value);
145 void AddProperty(TKey name, TValue value);
146 void RemoveProperty(TKey TKey, TValue value);
147 }
148 #endregion
149
150 #region PropertyValuePair support
151
152 public interface IPropertyValuePair : IPropertyValuePair<string,object> {
153 }
154 public interface IPropertyValuePair<TKey, TValue>
155 {
156 TKey Name { get; }
157 TValue Value { get; }
158 }
159 internal class PropertyValuePair : PropertyValuePair<string, object>, IPropertyValuePair
160 {
161 public PropertyValuePair() :base() { }
162 public PropertyValuePair(string name, object value) : base(name,value) { }
163 }
164 internal class PropertyValuePair<TKey, TValue> : IPropertyValuePair<TKey,TValue>
165 {
166 #region KeyValuePair support
167 public static implicit operator PropertyValuePair<TKey, TValue>(KeyValuePair<TKey, TValue> i) { return new PropertyValuePair<TKey, TValue>(i.Key, i.Value); }
168 public static implicit operator KeyValuePair<TKey, TValue>(PropertyValuePair<TKey, TValue> i) { return new KeyValuePair<TKey, TValue>(i.Name, i.Value); }
169 #endregion
170 public PropertyValuePair() : this(default(TKey),default(TValue)) { }
171 public PropertyValuePair(TKey name, TValue value)
172 {
173 this.name = name;
174 this.value = value;
175 }
176 private TKey name;
177 public TKey Name { get { return this.name; } }
178 private TValue value;
179 public TValue Value { get { return this.value; } }
180 public override string ToString()
181 {
182 StringBuilder builder = new StringBuilder();
183 builder.Append('[');
184 if (this.Name != null)
185 {
186 builder.Append(this.Name.ToString());
187 }
188 builder.Append(", ");
189 if (this.Value != null)
190 {
191 builder.Append(this.Value.ToString());
192 }
193 builder.Append(']');
194 return builder.ToString();
195
196 }
197 }
198 #endregion
199
200 }

  ViewVC Help
Powered by ViewVC 1.1.22