Καλώς ορίσατε στο dotNETZone.gr - Σύνδεση | Εγγραφή | Βοήθεια
σε

 

Αρχική σελίδα Ιστολόγια Συζητήσεις Εκθέσεις Φωτογραφιών Αρχειοθήκες

Φτιάξτε το δικό σας SDK για την εφαρμογή σας.

Îåêßíçóå áðü ôï ìÝëïò angarato_surion. Τελευταία δημοσίευση από το μέλος angarato_surion στις 26-04-2006, 21:29. Υπάρχουν 0 απαντήσεις.
Ταξινόμηση Δημοσιεύσεων: Προηγούμενο Επόμενο
  •  26-04-2006, 21:29 12134

    Φτιάξτε το δικό σας SDK για την εφαρμογή σας.

    Φτιάξτε το δικό σας  SDK για την εφαρμογή σας.

     

     

     

    Πρώτα από όλα ας υποθέσομε ότι έχουμε νια βιβλιοθήκη με την ονομασία plugedLib. Και τελούμαι να κάνουμε την plugedLibSDK.

     

    Προσθέτομε στα references την PlugedLib.

    Τώρα ας αρχίσουμε να γράφουμε τον κώδικα για το SDK.
    Στην αρχή του αρχείου  γράφομαι το παρακάτω τμήμα κώδικα.

    using PlugedLib;

    using System.Collections;

    Μετά  κληρονομούμε τα χαρακτηριστικά της κλάσεις που βρίσκεται στο PlugedLib (την οποία την ονομάζω PlugedClass) στην νέα μας κλάση την οποία και θα ονομάζουμε pluginClass .

    public    abstract class pluginClass:PlugedClass

    {

     Public pluginClass()

    {

     

    }

     

     

     

    }

    Έπειτα από την δημιουργία της κλάσης προχωράμε στην προσθήκη της ιδιότητας που θα λέγεται Name την οποία θα επιστρέφει string και θα είναι abstract και γράφομαι το παρακάτω τμήμα κώδικα.

    public abstract string Name

           {

               get;

     

     

     

     

     

     

           }

     

     

    Επιπρόσθετα μετά την προσθήκη που κάναμε θα πρέπει να φτιάξουμε μια μέθοδο που εδώ θα την ονομάσω με το όνομα MakeAction  την οποία την δηλώνομαι όπως παρακάτω.

    public abstract  void MakeAction(PluginContent plugcontent);

          

     Σε αυτήν την συνάρτηση  θα δίνουμε και οποία ορίσματα θέλουμε εκτός από αυτά που έδωσα.

     

    Τώρα ήρθε η στιγμή θα δηλώσουμε την PluginContent όπως στο παρακάτω  πίνακα.

    public class PluginContent:PlugedClass

        {       

     

     

        }

    Μέσα στην κλάση PluginContent μπορούμε να βάλουμε κι άλλες μεθόδους αν θέλουμε. Προχωράμε  τώρα στην δημιουργία μιας άλλης κλάσης την οποία σας την δίνω όπως είναι.

     

    public class PluginCollection : CollectionBase

        {

            /// <summary>

            /// Initializes a new instance of the <see cref="PluginCollection">PluginCollection</see> class.

            /// </summary>

            public PluginCollection()

            {

            }

     

            /// <summary>

            /// Initializes a new instance of the <see cref="PluginCollection">PluginCollection</see> class containing the elements of the specified source collection.

            /// </summary>

            /// <param name="value">A <see cref="PluginCollection">PluginCollection</see> with which to initialize the collection.</param>

            public PluginCollection(PluginCollection value)

            {

                this.AddRange(value);

            }

     

            /// <summary>

            /// Initializes a new instance of the <see cref="PluginCollection">PluginCollection</see> class containing the specified array of <see cref="PluginClass">PluginClass</see> objects.

            /// </summary>

            /// <param name="value">An array of <see cref="PluginClass">PluginClass</see> objects with which to initialize the collection. </param>

            public PluginCollection(PluginClass[] value)

            {

                this.AddRange(value);

            }

     

            /// <summary>

            /// Gets the <see cref="PluginCollection">PluginCollection</see> at the specified index in the collection.

            /// <para>

            /// In C#, this property is the indexer for the <see cref="PluginCollection">PluginCollection</see> class.

            /// </para>

            /// </summary>

            public PluginClass this[int index]

            {

                get { return ((PluginClass)(this.List[index])); }

            }

     

            public int Add(PluginClass value)

            {

                return this.List.Add(value);

            }

     

            /// <summary>

            /// Copies the elements of the specified <see cref="PluginClass">PluginClass</see> array to the end of the collection.

            /// </summary>

            /// <param name="value">An array of type <see cref="PluginClass">PluginClass</see> containing the objects to add to the collection.</param>

            public void AddRange(PluginClass[] value)

            {

                for (int i = 0; (i < value.Length); i = (i + 1))

                {

                    this.Add(valueIdea [I]);

                }

            }

     

            /// <summary>

            /// Adds the contents of another <see cref="PluginCollection">PluginCollection</see> to the end of the collection.

            /// </summary>

            /// <param name="value">A <see cref="PluginCollection">PluginCollection</see> containing the objects to add to the collection. </param>

            public void AddRange(PluginCollection value)

            {

                for (int i = 0; (i < value.Count); i = (i + 1))

                {

                    this.Add((PluginClass)value.ListIdea [I]);

                }

            }

     

            /// <summary>

            /// Gets a value indicating whether the collection contains the specified <see cref="PluginCollection">PluginCollection</see>.

            /// </summary>

            /// <param name="value">The <see cref="PluginCollection">PluginCollection</see> to search for in the collection.</param>

            /// <returns><b>true</b> if the collection contains the specified object; otherwise, <b>false</b>.</returns>

            public bool Contains(PluginClass value)

            {

                return this.List.Contains(value);

            }

     

            /// <summary>

            /// Copies the collection objects to a one-dimensional <see cref="T:System.Array">Array</see> instance beginning at the specified index.

            /// </summary>

            /// <param name="array">The one-dimensional <see cref="T:System.Array">Array</see> that is the destination of the values copied from the collection.</param>

            /// <param name="index">The index of the array at which to begin inserting.</param>

            public void CopyTo(PluginClass[] array, int index)

            {

                this.List.CopyTo(array, index);

            }

     

            /// <summary>

            /// Creates a one-dimensional <see cref="T:System.Array">Array</see> instance containing the collection items.

            /// </summary>

            /// <returns>Array of type PluginClass</returns>

            public PluginClass[] ToArray()

            {

                PluginClass[] array = new PluginClass[this.Count];

                this.CopyTo(array, 0);

     

                return array;

            }

     

            /// <summary>

            /// Gets the index in the collection of the specified <see cref="PluginCollection">PluginCollection</see>, if it exists in the collection.

            /// </summary>

            /// <param name="value">The <see cref="PluginCollection">PluginCollection</see> to locate in the collection.</param>

            /// <returns>The index in the collection of the specified object, if found; otherwise, -1.</returns>

            public int IndexOf(PluginClass value)

            {

                return this.List.IndexOf(value);

            }

     

            public void Insert(int index, PluginClass value)

            {

                List.Insert(index, value);

            }

     

            public void Remove(PluginClass value)

            {

                List.Remove(value);

            }

     

            /// <summary>

            /// Returns an enumerator that can iterate through the <see cref="PluginCollection">PluginCollection</see> instance.

            /// </summary>

            /// <returns>An <see cref="PluginCollectionEnumerator">PluginCollectionEnumerator</see> for the <see cref="PluginCollection">PluginCollection</see> instance.</returns>

            public new PluginCollectionEnumerator GetEnumerator()

            {

                return new PluginCollectionEnumerator(this);

            }

     

            /// <summary>

            /// Supports a simple iteration over a <see cref="PluginCollection">PluginCollection</see>.

            /// </summary>

            public class PluginCollectionEnumerator : IEnumerator

            {

                private IEnumerator _enumerator;

                private IEnumerable _temp;

     

                /// <summary>

                /// Initializes a new instance of the <see cref="PluginCollectionEnumerator">PluginCollectionEnumerator</see> class referencing the specified <see cref="PluginCollection">PluginCollection</see> object.

                /// </summary>

                /// <param name="mappings">The <see cref="PluginCollection">PluginCollection</see> to enumerate.</param>

                public PluginCollectionEnumerator(PluginCollection mappings)

                {

                    _temp = ((IEnumerable)(mappings));

                    _enumerator = _temp.GetEnumerator();

                }

     

                /// <summary>

                /// Gets the current element in the collection.

                /// </summary>

                public PluginClass Current

                {

                    get { return ((PluginClass)(_enumerator.Current)); }

                }

     

                object IEnumerator.Current

                {

                    get { return _enumerator.Current; }

                }

     

                /// <summary>

                /// Advances the enumerator to the next element of the collection.

                /// </summary>

                /// <returns><b>true</b> if the enumerator was successfully advanced to the next element; <b>false</b> if the enumerator has passed the end of the collection.</returns>

                public bool MoveNext()

                {

                    return _enumerator.MoveNext();

                }

     

                bool IEnumerator.MoveNext()

                {

                    return _enumerator.MoveNext();

                }

     

                /// <summary>

                /// Sets the enumerator to its initial position, which is before the first element in the collection.

                /// </summary>

                public void Reset()

                {

                    _enumerator.Reset();

                }

     

                void IEnumerator.Reset()

                {

                    _enumerator.Reset();

                }

            }

        }

     


    Υδροβάση(Hydrobase)
    profiles :
    codeplex
    sourceforge
    google code

    Υλοποιώ εφαρμογές υπό πληρωμή απλώς επικοινωνήστε μαζί μου
Προβολή Τροφοδοσίας RSS με μορφή XML
Με χρήση του Community Server (Commercial Edition), από την Telligent Systems