public IDEListController RegisterList(string id, IDEListController controller, bool publish = false) { lock (controllerList) { if (controller == null) { throw new ArgumentNullException("list", "Keine Liste gefunden."); } if (FindController(id) != null) { throw new ArgumentException(String.Format("Collection '{0}' ist schon registriert.", id)); } // Füge den Controller ein controllerList.Add(controller); // Veröffentlichen if (publish) { PublishItem(controller); } return(controller); } } // func RegisterList
/// <summary></summary> /// <param name="sp"></param> /// <param name="name"></param> public DEConfigLogItem(IServiceProvider sp, string name) : base(sp, name) { logFileName = new Lazy <string>(() => Path.Combine(Server.LogPath, GetFullLogName())); RegisterList(LogLineListId, logListController = new LogLineController(this), true); } // ctor
} // proc LuaPublishAction /// <summary>Wird durch den List-Controller aufgerufen, wenn er zerstört wird.</summary> /// <param name="controller"></param> public void UnregisterList(IDEListController controller) { lock (controllerList) { controllerList.Remove(controller); lock (publishedItems) { if (publishedItems.TryGetValue(controller.Id, out var item) && item == controller) { publishedItems.Remove(controller.Id); } } } } // proc UnregisterList
public DECronEngine(IServiceProvider sp, string name) : base(sp, name) { this.cronItemCacheController = new CronItemCacheController(this); this.currentJobs = new DEList <CurrentRunningJob>(this, "tw_cron_running", "Cron running"); PublishItem(this.currentJobs); // Register Engine var sc = sp.GetService <IServiceContainer>(true); sc.AddService(typeof(IDECronEngine), this, false); // Register Server events Server.Queue.RegisterEvent(CancelJobs, DEServerEvent.Shutdown); Server.Queue.RegisterEvent(RefreshCronServices, DEServerEvent.Reconfiguration); } // ctor
} // proc UnregisterList #endregion #region -- Controller Http -------------------------------------------------------- private XElement GetControllerXmlNode(string sId, object item) { IDEListController configController = item as IDEListController; DEConfigItemPublicAction configAction; DEConfigItemPublicPanel configPanel; if (configController != null) { var indexAccess = configController.List as IList; XElement x = new XElement("list", new XAttribute("id", configController.Id), Procs.XAttributeCreate("displayname", configController.DisplayName) ); if (indexAccess != null) { x.Add(new XAttribute("count", indexAccess.Count)); } return(x); } else if ((configAction = item as DEConfigItemPublicAction) != null) { XElement x = new XElement("action", new XAttribute("id", configAction.ActionId), Procs.XAttributeCreate("displayname", configAction.DisplayName) ); return(x); } else if ((configPanel = item as DEConfigItemPublicPanel) != null) { XElement x = new XElement("panel", new XAttribute("id", configPanel.Id), Procs.XAttributeCreate("displayname", configPanel.DisplayName), new XText(configPanel.Uri) ); return(x); } else { return(null); } } // func GetControllerXmlNode
} // proc WriteListFetchList #endregion void IDEListService.WriteList(IDEContext r, IDEListController controller, int startAt, int count) { var sendTypeDefinition = String.Compare(r.GetProperty("desc", Boolean.FalseString), Boolean.TrueString, StringComparison.OrdinalIgnoreCase) == 0; // Suche den passenden Descriptor var descriptor = controller.Descriptor; if (descriptor == null) { throw new HttpResponseException(HttpStatusCode.BadRequest, String.Format("Liste '{0}' besitzt kein Format.", controller.Id)); } controller.OnBeforeList(); // Rückgabe using (var tw = r.GetOutputTextWriter(MimeTypes.Text.Xml)) using (var xml = XmlWriter.Create(tw, GetSettings(tw))) { xml.WriteStartDocument(); xml.WriteStartElement("list"); // Sollen die Strukturinformationen übertragen werdem if (sendTypeDefinition) { xml.WriteStartElement("typedef"); descriptor.WriteType(new DEListTypeWriter(xml)); xml.WriteEndElement(); } // Gib die Daten aus using (controller.EnterReadLock()) { var list = controller.List; // Prüfe auf Indexierte Listen var useInterface = ListEnumeratorType.Enumerable; Type useInterfaceType = null; foreach (var ii in list.GetType().GetTypeInfo().ImplementedInterfaces) { if (ii.IsGenericType) { Type genericType = ii.GetGenericTypeDefinition(); if (genericType == typeof(IList <>)) { if (useInterface < ListEnumeratorType.ListTyped) { useInterface = ListEnumeratorType.ListTyped; useInterfaceType = ii; } } else if (genericType == typeof(IReadOnlyList <>)) { if (useInterface < ListEnumeratorType.ReadOnlyList) { useInterface = ListEnumeratorType.ReadOnlyList; useInterfaceType = ii; } } else if (genericType == typeof(IDERangeEnumerable2 <>)) { if (useInterface < ListEnumeratorType.RangeEnumerator) { useInterface = ListEnumeratorType.RangeEnumerator; useInterfaceType = ii; } } } else if (ii == typeof(System.Collections.IList)) { if (useInterface < ListEnumeratorType.ListUntyped) { useInterface = ListEnumeratorType.ListUntyped; } } } // Gib die entsprechende Liste aus xml.WriteStartElement("items"); switch (useInterface) { case ListEnumeratorType.Enumerable: var enumerator = list.GetEnumerator(); try { WriteListFetchEnum(xml, descriptor, enumerator, startAt, count); } finally { var tmp = enumerator as IDisposable; if (tmp != null) { tmp.Dispose(); } } break; case ListEnumeratorType.ReadOnlyList: case ListEnumeratorType.ListTyped: case ListEnumeratorType.RangeEnumerator: WriteListFetchTyped(useInterfaceType, r, xml, descriptor, list, startAt, count); break; case ListEnumeratorType.ListUntyped: WriteListFetchList(xml, descriptor, (IList)list, startAt, count); break; default: throw new HttpResponseException(System.Net.HttpStatusCode.InternalServerError, String.Format("Liste '{0}' nicht aufzählbar.", controller.Id)); } xml.WriteEndElement(); } xml.WriteEndElement(); xml.WriteEndDocument(); } } // proc IDEListService.WriteList
public DEEnumerator(IDEListController controller, IEnumerable <T> enumerable) { this.lockScope = controller.EnterReadLock(); this.enumBase = enumerable.GetEnumerator(); } // ctor