예제 #1
0
        }         // proc WriteListCheckRange

        #endregion

        #region -- WriteListFetchEnum -----------------------------------------------------

        private void WriteListFetchEnum(XmlWriter xml, IDEListDescriptor descriptor, IEnumerator enumerator, int startAt, int count)
        {
            if (startAt < 0 || count < 0)
            {
                throw new ArgumentException("start oder count dürfen nicht negativ sein.");
            }

            // Überspringe die ersten
            while (startAt > 0)
            {
                if (!enumerator.MoveNext())
                {
                    break;
                }
                startAt--;
            }

            // Gib die Element aus
            while (count > 0)
            {
                if (!enumerator.MoveNext())
                {
                    break;
                }

                descriptor.WriteItem(new DEListItemWriter(xml), enumerator.Current);
                count--;
            }
        }         // func WriteListFetchEnum
예제 #2
0
        public DEListControllerBase(DEConfigItem configItem, IDEListDescriptor descriptor, string id, string displayName)
        {
            this.configItem  = configItem;
            this.id          = id;
            this.displayName = displayName;
            this.descriptor  = descriptor;
            this.listLock    = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);

            configItem.RegisterList(id, this);
        }         // ctor
예제 #3
0
        }         // func GetListTypeString

        private static string GetListItemString(IDEListDescriptor descriptor, object item)
        {
            using (var s = new StringWriter())
                using (var x = XmlWriter.Create(s))
                {
                    descriptor.WriteItem(new DEListItemWriter(x), item);

                    x.Flush();
                    s.Flush();
                    return(s.GetStringBuilder().ToString());
                }
        }         // func GetListItemString
예제 #4
0
        private static string GetListTypeString(IDEListDescriptor descriptor)
        {
            using (var s = new StringWriter())
                using (var x = XmlWriter.Create(s))
                {
                    descriptor.WriteType(new DEListTypeWriter(x));

                    x.Flush();
                    s.Flush();
                    return(s.GetStringBuilder().ToString());
                }
        }         // func GetListTypeString
예제 #5
0
        }         // proc WriteListFetchListTyped

        #endregion

        #region -- WriteListFetchList -----------------------------------------------------

        private void WriteListFetchList(XmlWriter xml, IDEListDescriptor descriptor, IList list, int startAt, int count)
        {
            WriteListCheckRange(xml, ref startAt, ref count, list.Count, false);

            if (count > 0)
            {
                var end = startAt + count;
                for (int i = startAt; i < end; i++)
                {
                    descriptor.WriteItem(new DEListItemWriter(xml), list[i]);
                }
            }
        }         // proc WriteListFetchList
예제 #6
0
        }         // class GenericWriter

        #endregion

        private void WriteListFetchTyped(Type type, IPropertyReadOnlyDictionary r, XmlWriter xml, IDEListDescriptor descriptor, object list, int startAt, int count)
        {
            Type typeGeneric = type.GetGenericTypeDefinition();             // Hole den generischen Typ ab

            // Suche die passende procedure
            var miWriteList = typeof(GenericWriter).GetTypeInfo().DeclaredMethods.Where(mi => mi.IsStatic && mi.Name == "WriteList" && mi.IsGenericMethodDefinition && mi.GetParameters()[3].ParameterType.Name == typeGeneric.Name).FirstOrDefault();

            if (miWriteList == null)
            {
                throw new ArgumentNullException("writelist", String.Format("Keinen generische Implementierung gefunden ({0}).", typeGeneric.FullName));
            }

            // Aufruf des Writers
            var typeDelegate     = typeof(Action <, , , , ,>).MakeGenericType(typeof(IPropertyReadOnlyDictionary), typeof(XmlWriter), typeof(IDEListDescriptor), type, typeof(int), typeof(int));
            var miWriteListTyped = miWriteList.MakeGenericMethod(type.GetTypeInfo().GenericTypeArguments[0]);
            var dlg = Delegate.CreateDelegate(typeDelegate, miWriteListTyped);

            dlg.DynamicInvoke(r, xml, descriptor, list, startAt, count);
        }         // proc WriteListFetchListTyped
예제 #7
0
            }             // proc WriteList

            private static void WriteList <T>(IPropertyReadOnlyDictionary r, XmlWriter xml, IDEListDescriptor descriptor, IDERangeEnumerable2 <T> list, int startAt, int count)
            {
                WriteListCheckRange(xml, ref startAt, ref count, list.Count, true);

                if (count > 0)
                {
                    using (var enumerator = list.GetEnumerator(startAt, count, r))
                    {
                        while (count > 0)
                        {
                            if (!enumerator.MoveNext())
                            {
                                break;
                            }

                            descriptor.WriteItem(new DEListItemWriter(xml), enumerator.Current);
                            count--;
                        }
                    }
                }
            }     // proc WriteList
예제 #8
0
            }             // proc WriteList

            private static void WriteList <T>(IPropertyReadOnlyDictionary r, XmlWriter xml, IDEListDescriptor descriptor, IList <T> list, int startAt, int count)
            {
                WriteListCheckRange(xml, ref startAt, ref count, list.Count, false);

                if (count > 0)
                {
                    var end = startAt + count;
                    for (int i = startAt; i < end; i++)
                    {
                        descriptor.WriteItem(new DEListItemWriter(xml), (T)list[i]);
                    }
                }
            }             // proc WriteList
예제 #9
0
        }         // func CreateDictionary

        /// <summary></summary>
        /// <param name="configItem"></param>
        /// <param name="id"></param>
        /// <param name="displayName"></param>
        /// <param name="listDescriptor"></param>
        /// <param name="comparer"></param>
        /// <returns></returns>
        public static DEDictionary <TKey, TItem> CreateSortedList(DEConfigItem configItem, string id, string displayName, IDEListDescriptor listDescriptor = null, IComparer <TKey> comparer = null)
        {
            return(new DEDictionary <TKey, TItem>(configItem, id, displayName,
                                                  listDescriptor ?? DEConfigItem.CreateListDescriptorFromType(typeof(KeyValuePair <TKey, TItem>)),
                                                  new SortedDictionary <TKey, TItem>(comparer ?? Comparer <TKey> .Default)
                                                  ));
        } // func CreateSortedList
예제 #10
0
 private DEDictionary(DEConfigItem configItem, string id, string displayName, IDEListDescriptor listDescriptor, IDictionary <TKey, TItem> innerDictionary)
     : base(configItem, listDescriptor, id, displayName)
 {
     this.innerDictionary = innerDictionary;
 }         // ctor