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

  ViewVC Help
Powered by ViewVC 1.1.22