/[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 100 - (show annotations) (download)
Sun Mar 10 10:34:07 2013 UTC (7 years, 7 months ago) by william
File size: 7978 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 IEnumerable<PropertyValuePair<TKey, TValue>> this[TKey name] { get; }//set; }
133
134 int IndexOfProperty(PropertyValuePair<TKey, TValue> item);
135 void InsertPropertyAtIndex(int index, PropertyValuePair<TKey, TValue> item);
136 void RemovePropertyAt(int index);
137
138 bool ContainsProperty(TKey name, TValue value);
139 void AddProperty(TKey name, TValue value);
140 void RemoveProperty(TKey TKey, TValue value);
141 }
142 #endregion
143
144 #region PropertyValuePair support
145 public class PropertyValuePair : PropertyValuePair<string, object>
146 {
147 public PropertyValuePair() :base() { }
148 public PropertyValuePair(string name, object value) : base(name,value) { }
149 }
150 public class PropertyValuePair<TKey, TValue>
151 {
152 #region KeyValuePair support
153 public static implicit operator PropertyValuePair<TKey, TValue>(KeyValuePair<TKey, TValue> i) { return new PropertyValuePair<TKey, TValue>(i.Key, i.Value); }
154 public static implicit operator KeyValuePair<TKey, TValue>(PropertyValuePair<TKey, TValue> i) { return new KeyValuePair<TKey, TValue>(i.Name, i.Value); }
155 #endregion
156 public PropertyValuePair() : this(default(TKey),default(TValue)) { }
157 public PropertyValuePair(TKey name, TValue value)
158 {
159 this.name = name;
160 this.value = value;
161 }
162 private TKey name;
163 public TKey Name { get { return this.name; } }
164 private TValue value;
165 public TValue Value { get { return this.value; } }
166 public override string ToString()
167 {
168 StringBuilder builder = new StringBuilder();
169 builder.Append('[');
170 if (this.Name != null)
171 {
172 builder.Append(this.Name.ToString());
173 }
174 builder.Append(", ");
175 if (this.Value != null)
176 {
177 builder.Append(this.Value.ToString());
178 }
179 builder.Append(']');
180 return builder.ToString();
181
182 }
183 }
184 #endregion
185
186 }

  ViewVC Help
Powered by ViewVC 1.1.22