/[xmltv_parser]/trunk/libxmltv/Interfaces/Interfaces.cs
ViewVC logotype

Annotation of /trunk/libxmltv/Interfaces/Interfaces.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 106 - (hide annotations) (download)
Sun Mar 10 12:25:54 2013 UTC (7 years, 7 months ago) by william
File size: 8489 byte(s)

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

  ViewVC Help
Powered by ViewVC 1.1.22