Exemple #1
0
        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);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #2
0
        /// <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();
        }
Exemple #3
0
        /// <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);
        }
Exemple #4
0
        /// <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);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #5
0
        /// <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);
                        }
                    }
                }
            }
        }
Exemple #6
0
 /// <summary>
 /// Adds service to the container.
 /// </summary>
 /// <param name="service">Service.</param>
 public void Add(StiService service)
 {
     Add(service, true);
 }
Exemple #7
0
        /// <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
                }
            }
        }
Exemple #8
0
 /// <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()));
 }
Exemple #9
0
 public int IndexOf(StiService service)
 {
     return(List.IndexOf(service));
 }
Exemple #10
0
        public bool Contains(StiService service)
        {
            string str = GetStringFromService(service);

            return(keysHashtable[str] != null);
        }