--- trunk/libxmltv/Interfaces/Interfaces.cs 2013/03/08 03:41:18 45 +++ trunk/libxmltv/Interfaces/Interfaces.cs 2013/05/18 02:45:35 256 @@ -5,51 +5,250 @@ using System.IO; using System.Xml.Linq; using libxmltv.Core; +using System.ComponentModel; +using System.Collections; +using System.Runtime.InteropServices; namespace libxmltv.Interfaces { - public interface IXMLTVLoader - { - FileInfo XmlFile { get; } - XDocument XmlDoc { get; } - } - public interface IXMLTVParser - { - //IXMLTV_LOADER XMLTV_LOADER { get; } - //void TestParse(); - IXMLTVSource Source { get; } - Dictionary Channels { get; } - Dictionary Programs { get; } - } + //public interface IXMLTVLoader + //{ + // FileInfo XmlFile { get; } + // string XmlDoc { get; } + //} + //public interface IXMLTVParser + //{ + // IXMLTVSource Source { get; } + // Dictionary Channels { get; } + // Dictionary Programs { get; } + //} - public interface IXMLTVSource + public interface IXMLTVSource : IDataSourceBindable { string SourceName { get; } string GeneratorName { get; } string GeneratorUrl { get; } string ToString(); } + + public interface IRawDataSource : IRawDataSource { } + public interface IRawDataSource { + [Browsable(false)] + T RawDataSource { get; } } + public interface IProgramDefinitionList : IList, IDataSourceSortable, IDataSourceFilterable { } //, IRawDataSource { } + public interface IChannelDefintionList : IList, IDataSourceSortable, IDataSourceFilterable { }//, IRawDataSource { } + + + public interface IChannelDefintion : IEquatable, IRawDataSource + { + string ChannelId { get; } + string ChannelName { get; } + string ToString(); + } + public interface IProgramDefinition : IEquatable, IRawDataSource + { + //string ChannelId { get; } + int ChannelNumber { get; } // column index: 0 + string ChannelName { get; }// column index: 1 + string Start { get; }// column index: 2 + string Stop { get; }// column index: 3 + string Title { get; }// column index: 4 + string SubTitle { get; }// column index: 5 + string Description { get; }// column index: 6 + string Rating { get; }// column index: 7 + string ToString(); + } public interface IXMLTVChannel { string Id { get; } - int Number { get; } - string CallSign { get; } - string Name { get; } + //int Number { get; } + //string CallSign { get; } + //string Name { get; } + IPropertyList MetaData { get; } string ToString(); - } - public interface IXMLTVProgram + } + public interface IXMLTVProgram + { + IPropertyDictionary MetaData { get; } + List GetExtraMetaData(); + } + + public interface IExtraMetaData : IExtraMetaData { } + public interface IExtraMetaData : IPropertyValuePair + { + XElement AsXElement(); + } + + //public interface IDataConverter { object ConvertObjectData(object source); } + //public interface IDataConverter + //{ + // T ConvertData(object source); + //} + public interface IDataSourceBindable //: IDataConverter { - int Id { get; } - DateTime Start { get; } - DateTime Stop { get; } - IXMLTVChannel Channel { get; } - string Title { get; } - string SubTitle { get; } - string Description { get; } + object CreateBindableDataSource(out Type type); + } + + public interface IDataSourceFilterable + { + void Filter(ref object source, params string[] args); + } + public interface IDataSourceSortable + { + void Sort(ref object source, bool descending, params string[] args); + } + + internal interface IXMLTVProgramCollection : IXMLTVDictionaryCollection { } + internal interface IXMLTVChannelCollection : IXMLTVDictionaryCollection { } + internal interface IXMLTVDictionaryCollection { Dictionary Collection { get; } } + internal interface IXMLTVListCollection { List Collection { get; } } + + internal interface IXMLTVHandler : IXMLTVHandler { } + internal interface IXMLTVHandler { T Handler { get; } } + + //public interface IXMLTVBase : IXMLTVBase { } + internal interface IXMLTVBase : IGetInstance, IXMLTVHandler { } + internal interface IXMLTVRuntimeInstance : IOnInstanceCreated + { + bool IsAborting { get; } + //FileInfo XmlFile { get; } + string XmlFile_Name { get; } + string XmlFile_FullName { get; } + string XmlDoc { get; } + IXMLTVSource Source { get; } + ChannelList Channels { get; } + ProgramList Programs { get; } + ExtraList ExtraEntries { get; } + } + internal interface IXMLTVSerializer : IXMLTVSerializer { } + internal interface IXMLTVSerializer + { + bool Serialize(string file); + bool Serialize(Stream stream); + T DeSerialize(string file, out bool status); + T DeSerialize(Stream stream, out bool status); + } + internal interface IXMLTV : IXMLTV where CLASS : class,INTERFACE { } + internal interface IXMLTV : IXMLTVSerializer, IDestroyInstance, IOnInstanceCreated, IGetInstance, ISetInstance + where CLASS : class,INTERFACE + where INSTANCECREATED_EVENTAGS : EventArgs { } + + internal interface IInstance : IInstance { } + internal interface IInstance { T Instance { get; set; } } + internal interface ICreateSerializer : ICreateSerializer { } + internal interface ICreateSerializer { IXMLTVSerializer CreateSerializer(); } + + //public interface IGetInstanceT : IGetInstanceT { } + //public interface IGetInstanceT { T GetInstance(); } + internal interface IGetInstance : IGetInstance { } + internal interface IGetInstance { T GetInstance(); } + + internal interface ISetInstance : ISetInstance { } + internal interface ISetInstance { void SetInstance(T instance); } + + internal interface IOnInstanceCreated : IOnInstanceCreated { } + internal interface IOnInstanceCreated where T : EventArgs { EventHandler OnInstanceCreated { get; set; } } + internal interface ISerializer { IXMLTVSerializer Serializer { get; } } + internal interface IDestroyInstance { void DestroyInstance(); } + internal interface IGetCreatedInstanceEvent : IGetCreatedInstanceEvent { } + internal interface IGetCreatedInstanceEvent where T : EventArgs { EventHandler GetOnInstanceCreated(); } + internal interface ISetCreatedInstanceEvent : ISetCreatedInstanceEvent { } + internal interface ISetCreatedInstanceEvent where T : EventArgs { void SetOnInstanceCreated(EventHandler event_instance); } + internal interface IRuntimeInstanceLoader : IRuntimeInstanceLoader { } + internal interface IRuntimeInstanceLoader { T LoadFromInstance(T instance); } + + +#region Property Dictionary support + public interface IPropertyDictionary : IPropertyDictionary { } + public interface IPropertyDictionary : IPropertyCollection>, IEnumerable>, IEnumerable + { + IPropertyCollection PropertyKeys { get; } + IPropertyCollection PropertyValues { get; } + TValue this[TKey key] { get; set; } + void AddProperty(TKey key, TValue value); + bool ContainsProperty(TKey key); + bool RemoveProperty(TKey key); + bool TryGetPropertyValue(TKey key, out TValue value); + } + public interface IPropertyCollection : IEnumerable, IEnumerable + { + int PropertyCount { get; } + bool IsReadOnly { get; } + void AddProperty(T item); + void ClearProperties(); + bool ContainsProperty(T item); + void CopyPropertiesTo(T[] array, int arrayIndex); + bool RemoveProperty(T item); string ToString(); } - public interface IXMLTVRuntimeInstance : IXMLTVLoader, IXMLTVParser +#endregion +#region Property List support + public interface IPropertyList : IPropertyList { } + public interface IPropertyList : IPropertyCollection>, IEnumerable>, IEnumerable { - bool IsDisposing { get; } + IPropertyValuePair this[int index] { get; set; } + IEnumerable> this[TKey name] { get; }//set; } + + int IndexOfProperty(IPropertyValuePair item); + void InsertPropertyAtIndex(int index, IPropertyValuePair item); + void RemovePropertyAt(int index); + + bool ContainsProperty(TKey name, TValue value); + void AddProperty(TKey name, TValue value); + void RemoveProperty(TKey TKey, TValue value); + } +#endregion + + #region PropertyValuePair support + + public interface IPropertyValuePair : IPropertyValuePair { } + public interface IPropertyValuePair + { + TKey Name { get; } + TValue Value { get; } + string ToString(); } + [Serializable] + internal class PropertyValuePair : PropertyValuePair, IPropertyValuePair + { + public PropertyValuePair() :base() { } + public PropertyValuePair(string name, object value) : base(name,value) { } + } + [Serializable] + internal class PropertyValuePair : IPropertyValuePair + { + #region KeyValuePair support + public static implicit operator PropertyValuePair(KeyValuePair i) { return new PropertyValuePair(i.Key, i.Value); } + public static implicit operator KeyValuePair(PropertyValuePair i) { return new KeyValuePair(i.Name, i.Value); } + #endregion + public PropertyValuePair() : this(default(TKey),default(TValue)) { } + public PropertyValuePair(TKey name, TValue value) + { + this.name = name; + this.value = value; + } + private TKey name; + public TKey Name { get { return this.name; } } + private TValue value; + public TValue Value { get { return this.value; } } + public override string ToString() + { + StringBuilder builder = new StringBuilder(); + builder.Append('['); + if (this.Name != null) + { + builder.Append(this.Name.ToString()); + } + builder.Append(", "); + if (this.Value != null) + { + builder.Append(this.Value.ToString()); + } + builder.Append(']'); + return builder.ToString(); + + } + } + #endregion + } \ No newline at end of file