public void Insert(int index, StiService service) { lock (List) { service.PackService(); List.Insert(index, service); lock (keysHashtable) { string key = GetStringFromService(service); if (keysHashtable[key] == null) { keysHashtable.Add(key, service); if (!noTypes) { lock (typesHashtable) { StiServiceContainer services = typesHashtable[service.ServiceType] as StiServiceContainer; if (services == null) { services = new StiServiceContainer(true); typesHashtable.Add(service.ServiceType, services); } lock (services) { services.Add(service); } } } } } } }
/// <summary> /// Resets a report to null state. /// </summary> public void ResetReport() { StiConfig.Load(); Stimulsoft.Base.Services.StiService aa = Stimulsoft.Report.StiConfig.Services.GetService(typeof(Stimulsoft.Report.Components.StiText)); report = new StiReport(); Stimulsoft.Report.StiConfig.Load(); }
/// <summary> /// Gets array of services, that contains in this service container. /// </summary> /// <returns></returns> public StiService[] ToArray() { var services = new StiService[Count]; int index = 0; foreach (StiService service in this) { services[index++] = service; } return(services); }
/// <summary> /// Adds service to the container. /// </summary> /// <param name="service">Service.</param> public void Add(StiService service, bool callBeforeGetService) { if (service.ServiceType != null) { if (callBeforeGetService && BeforeGetService != null) { var args = new StiServiceActionEventArgs(StiServiceActionType.Add) { Services = new List <StiService> { service } }; BeforeGetService(service.ServiceType, args); if (args.Processed) { return; } } service.PackService(); lock (List) { lock (keysHashtable) { string key = GetStringFromService(service); if (keysHashtable[key] == null) { keysHashtable.Add(key, service); List.Add(service); if (!noTypes) { lock (typesHashtable) { StiServiceContainer services = typesHashtable[service.ServiceType] as StiServiceContainer; if (services == null) { services = new StiServiceContainer(true); typesHashtable.Add(service.ServiceType, services); } lock (services) { services.Add(service); } } } } } } } }
/// <summary> /// Removes service from the container. /// </summary> /// <param name="service">Service.</param> public void Remove(StiService service) { lock (List) { List.Remove(service); keysHashtable.Remove(GetStringFromService(service)); if (!noTypes) { lock (typesHashtable) { StiServiceContainer services = typesHashtable[service.ServiceType] as StiServiceContainer; lock (services) { services.Remove(service); } } } } }
/// <summary> /// Adds service to the container. /// </summary> /// <param name="service">Service.</param> public void Add(StiService service) { Add(service, true); }
/// <summary> /// Loads container of services. /// </summary> /// <param name="tr">XmlReader.</param> public void Load(XmlReader tr) { var converter = new StiObjectStringConverter(); StiService service = null; tr.Read(); while (tr.Read()) { if (tr.IsStartElement()) { #region service if (tr.Name == "service") { string assembly = tr.GetAttribute("assembly"); string serviceType = tr.GetAttribute("type"); if (assemlyToSkip[assembly.ToLower(System.Globalization.CultureInfo.InvariantCulture)] == null) { try { service = CreateService(assembly, serviceType); if (service != null) { Add(service, false); } } catch { } } } #endregion #region property else if (tr.Name == "property" && service != null) { string propName = tr.GetAttribute("name"); string typeStr = tr.GetAttribute("type"); var propInfo = service.GetType().GetProperty(propName); if (propInfo != null) { if (tr.GetAttribute("isNull") != null) { propInfo.SetValue(service, null, null); } else if (tr.GetAttribute("isList") != null) { int count = int.Parse(tr.GetAttribute("count")); Type elementType = StiTypeFinder.GetType(typeStr); Array list = Array.CreateInstance(elementType, count); int index = 0; while (tr.Read()) { if (tr.IsStartElement()) { string nm = tr.Name; string valueStr = tr.ReadString(); object value = converter.StringToObject(valueStr, elementType); if (value != null) { list.SetValue(value, new int[] { index++ }); } if (index >= count) { break; } } } propInfo.SetValue(service, list, null); } else { string valueStr = tr.GetAttribute("value"); object value = converter.StringToObject(valueStr, StiTypeFinder.GetType(typeStr)); if (value != null) { propInfo.SetValue(service, value, null); } } } } #endregion } } }
/// <summary> /// Returns string presentation of the service. /// </summary> /// <param name="service">Service.</param> /// <returns>String.</returns> public static string GetStringFromService(StiService service) { return(GetStringFromService(service.GetType())); }
public int IndexOf(StiService service) { return(List.IndexOf(service)); }
public bool Contains(StiService service) { string str = GetStringFromService(service); return(keysHashtable[str] != null); }