CustomAttributeWriter(ICustomAttributeWriterHelper helper) {
			this.helper = helper;
			this.recursionCounter = new RecursionCounter();
			this.outStream = new MemoryStream();
			this.writer = new BinaryWriter(outStream);
			this.genericArguments = null;
		}
Пример #2
0
        void Write(CustomAttribute ca)
        {
            if (ca == null)
            {
                helper.Error("The custom attribute is null");
                return;
            }

            // Check whether it's raw first. If it is, we don't care whether the ctor is
            // invalid. Just use the raw data.
            if (ca.IsRawBlob)
            {
                if ((ca.ConstructorArguments != null && ca.ConstructorArguments.Count > 0) || (ca.NamedArguments != null && ca.NamedArguments.Count > 0))
                {
                    helper.Error("Raw custom attribute contains arguments and/or named arguments");
                }
                writer.Write(ca.RawData);
                return;
            }

            if (ca.Constructor == null)
            {
                helper.Error("Custom attribute ctor is null");
                return;
            }

            var methodSig = GetMethodSig(ca.Constructor);

            if (methodSig == null)
            {
                helper.Error("Custom attribute ctor's method signature is invalid");
                return;
            }

            if (ca.ConstructorArguments.Count != methodSig.Params.Count)
            {
                helper.Error("Custom attribute arguments count != method sig arguments count");
            }
            if (methodSig.ParamsAfterSentinel != null && methodSig.ParamsAfterSentinel.Count > 0)
            {
                helper.Error("Custom attribute ctor has parameters after the sentinel");
            }
            if (ca.NamedArguments.Count > ushort.MaxValue)
            {
                helper.Error("Custom attribute has too many named arguments");
            }

            // A generic custom attribute isn't allowed by most .NET languages (eg. C#) but
            // the CLR probably supports it.
            var mrCtor = ca.Constructor as MemberRef;

            if (mrCtor != null)
            {
                var owner = mrCtor.Class as TypeSpec;
                if (owner != null)
                {
                    var gis = owner.TypeSig as GenericInstSig;
                    if (gis != null)
                    {
                        genericArguments = new GenericArguments();
                        genericArguments.PushTypeArgs(gis.GenericArguments);
                    }
                }
            }

            writer.Write((ushort)1);

            int numArgs = Math.Min(methodSig.Params.Count, ca.ConstructorArguments.Count);

            for (int i = 0; i < numArgs; i++)
            {
                WriteValue(FixTypeSig(methodSig.Params[i]), ca.ConstructorArguments[i]);
            }

            int numNamedArgs = Math.Min((int)ushort.MaxValue, ca.NamedArguments.Count);

            writer.Write((ushort)numNamedArgs);
            for (int i = 0; i < numNamedArgs; i++)
            {
                Write(ca.NamedArguments[i]);
            }
        }
Пример #3
0
 public Method()
 {
     Data             = new DataDictionary();
     GenericArguments = new GenericArguments();
     Parameters       = new ParameterCollection();
 }
Пример #4
0
 protected bool Equals(Method other)
 {
     return(IsSignatureTarget == other.IsSignatureTarget && string.Equals(DeclaringNamespace, other.DeclaringNamespace) && string.Equals(DeclaringType, other.DeclaringType) && string.Equals(Name, other.Name) && Equals(Data, other.Data) && GenericArguments.CollectionEquals(other.GenericArguments) && Parameters.CollectionEquals(other.Parameters));
 }
Пример #5
0
 public GenericTypeReference(string name, params TypeReference[] genericArguments) : base(name)
 {
     GenericArguments.AddRange(genericArguments);
 }
Пример #6
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //uint v = EgateAPI.egGetVersion();
            //string d = EgateAPI.egGetVersionDescription().GetString();
            //MessageBox.Show(String.Format("v{0} {1}", v, d));
            //return;

            //string s1 = "00600215,600008,032,0001,548999******5026,1512,1000,0,1000,2706,1645,400,MC-сети-ГПБ,643,0,0,314804,002504314804,,140150148,,270614,164523,000,OK,,,,\x80\x80\x80,,,1,,";
            //string s2 = ",,032,0001,,0000,,0,1000,0000,0000,399,Mastercard,643,0,0,,,,000000,,,,000,OK,,,,\x80\x80\x80,,,5,,";
            //AuthResponse a1 = AuthResponse.Parse(s1);
            //AuthResponse a2 = AuthResponse.Parse(s2);
            //return;

            //string s = @"30 30 36 30 30 32 31 35 2C 36 30 30 30 30 38 2C 30 33 32 2C 30 30 30 30 2C 35 34 38 39 39 39 2A 2A 2A 2A 2A 2A 35 30 32 36 2C 31 35 31 32 2C 31 30 30 30 30 2C 30 2C 31 30 30 30 30 2C 31 34 30 37 2C 31 32 33 33 2C 34 33 32 2C 4D 43 2D 3F 3F 3F 3F 2D 3F 3F 3F 2C 36 34 33 2C 30 2C 30 2C 33 37 36 30 38 32 2C 30 30 32 35 30 34 33 37 36 30 38 32 2C 2C 31 34 30 31 35 30 31 34 38 2C 2C 31 34 30 37 31 34 2C 31 32 33 33 32 35 2C 30 30 30 2C 4F 4B 2C 2C 2C 2C 5C 78 38 30 5C 78 38 30 5C 78 38 30 2C 2C 2C 31 2C 2C";
            //string s = "1F,26,0B,4D,43,20,F1,E5,F2,E8,20,C3,CF,C1";
            //string s = "30 30 36 30 30 32 31 35 2C 36 30 30 30 30 38 2C 30 33 32 2C 30 30 30 30 2C 35 34 38 39 39 39 2A 2A 2A 2A 2A 2A 30 30 31 33 2C 31 35 31 32 2C 31 30 30 30 30 2C 30 2C 31 30 30 30 30 2C 31 37 30 37 2C 31 33 30 35 2C 34 37 32 2C 4D 61 73 74 65 72 63 61 72 64 2C 36 34 33 2C 30 2C 30 2C 33 38 35 32 39 31 2C 30 30 32 35 30 34 33 38 35 32 39 31 2C 61 30 30 30 30 30 30 30 30 34 31 30 31 30 2C 31 34 30 31 35 38 31 32 38 2C 4D 61 73 74 65 72 43 61 72 64 2C 31 37 30 37 31 34 2C 31 33 30 36 34 30 2C 30 30 30 2C 4F 4B 2C 2C 2C 2C 5C 78 38 30 5C 78 38 30 5C 78 38 31 2C 2C 2C 31 2C 2C";
            //string[] sa = s.Split(' ');
            //byte[] ba = sa.Select(x => { long l; x.FromHex(out l); return (byte)(l & 0xFF); }).ToArray();
            //s = Encoding.GetEncoding(1251).GetString(ba);
            //return;

            //проверка повторного запуска
            if (!ApplicationFormServices.EnsureNotRunning())
            {
                return;
            }

            //обработчик исключений
            LoggedExceptionHandler xh = new LoggedExceptionHandler();

            //статическая инициализация
            AssemblyInitializer.UseCurrentDomain();

            //создаём контейнер и регистрируем классы
            using (IServiceContainer container = new ServiceContainer())
            {
                //получаем агрументы
                GenericArguments args = new GenericArguments();

                //получаем настройки
                Settings settings = Settings.Default;
                settings.SettingsSaving += AssemblyConfigurationHelper.SettingsSaveHandler;

                //менеджер путей
                GazpromPathManager pathManager = new GazpromPathManager();
                container.RegisterInstance <PathManager>(pathManager);

                //логгер
                ILogger logger = container.RegisterLogger(settings.LogLevel, pathManager.LogPath);
                //if (!args.IsNoTrace && ((settings.Mode & GazpromMode.NoTrace) == 0))
                //{
                //  container.RegisterTraceLogWriter(TraceHelper.GazpromTraceName, LogCategoryMap.Load(CommonHelper.GetCategoryMapFileName(pathManager, GazpromHelper.LogFileName)), GazpromHelper.GazpromTraceMessageFilter);
                //  container.RegisterTraceLogWriter(TraceHelper.GazpromPollingTraceName, LogCategoryMap.Load(CommonHelper.GetCategoryMapFileName(pathManager, GazpromHelper.LogFileNamePolling)), GazpromHelper.PollingTraceMessageFilter);
                //}
                container.Rebuild <ILogger>();

                //BankingDevice d = new BankingDevice(32);
                //d.Message += (s, e) => { logger.Write(e ? LogLevel.Error : LogLevel.Verbose, s); };
                //d.StateChanged += (s, i) => { logger.Write(LogLevel.Debug, String.Format("{0}\r\n{1}", s, i)); };
                //d.TransactionCompleted += (r, z) => { logger.Write(LogLevel.Information, String.Format("{0}\r\n{1}", r, z)); };
                //try
                //{
                //  if (d.Start())
                //  {
                //    int r = 1;
                //    int a = 1000;
                //    while (true)
                //    {
                //      if (d.BeginTransaction(r++, a))
                //      {
                //        while (d.State != EquipmentState.CardTaken)
                //          System.Threading.Thread.Sleep(500);

                //        d.EndTransaction();
                //        a += 100;
                //      }

                //      if (MessageBox.Show("Следующий платеж?", "Debug", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
                //        break;
                //    }
                //  }
                //}
                //catch (Exception e)
                //{
                //  logger.Write(e);
                //}
                //finally
                //{
                //  d.Stop();
                //}

                //return;

                //создаём список предупреждений для записи в лог после запуска
                List <ILogMessage> warnings = new List <ILogMessage>();

                //обработчик исключений и окно отображения ошибок (до создания любого окна)
                container.RegisterInstance <IApplicationReportProvider>(new ApplicationReportProvider(true));
                container.RegisterErrorServices(xh);
                container.RegisterErrorWindow();

                //значок панели задач
                container.RegisterInstance <TrayService>(new GazpromTray());

                //заставка (она же окно "О программе")
                container.RegisterAboutWindow(!args.IsNoSplash, new GazpromAboutForm());

                //сеть
                container.RegisterInstance <INetworkProtocol>(new SerialPortProtocol());

                //сервер
                container.RegisterInstance <IApplication>(new Gazprom(settings.Mode));
                container.RegisterInstance <Form>(new MainForm());

                //инъектируем зависимости
                container.Rebuild();

                //write warnings
                foreach (LogMessage m in warnings)
                {
                    logger.Write(m);
                }

                //запускаем приложение с помощью зарегистрированных в контейнере классов
                container.Run(false);
            }
        }
Пример #7
0
 public Method() {
     GenericArguments = new GenericArguments();
     Parameters = new ParameterCollection();
 }
Пример #8
0
        public TypeDefinition(Type type)
        {
            Type = type;
            Name = type.Name;

            var typeInfo      = type.GetTypeInfo();
            var isGenericType = typeInfo.IsGenericType;

            if (isGenericType)
            {
                var types = type.GetGenericArguments();

                if (type.GetGenericTypeDefinition() == typeof(Nullable <>))
                {
                    Type = type.GetGenericArguments()[0];
                }

                Name = Name.Replace("`" + types.Length, "Of" + string.Join("", types.Select(p => p.Name)));
            }

            FullName = type.FullName;

            GetPrimitiveInfo(Type);

            IsArray = typeInfo.IsArray;

            IsEnumerable = !IsPrimitive && typeof(IEnumerable).IsAssignableFrom(type);

            if (IsEnumerable)
            {
                IsDictionary = typeof(IDictionary).IsAssignableFrom(type);

                var elementType = ElementTypeLocator.Default.Locate(type);
                if (isGenericType)
                {
                    GenericArguments = type.GetGenericArguments();
                }
                else if (elementType != null)
                {
                    GenericArguments = new[] { elementType };
                }

                Name = IsArray || isGenericType
                                        ? $"ArrayOf{string.Join(string.Empty, GenericArguments.Select(p => p.Name))}"
                                        : type.Name;

                if (IsDictionary)
                {
                    MethodAddToDictionary = ObjectAccessors.CreateMethodAddToDictionary(type);
                }
                else if (elementType != null && !IsArray)
                {
                    MethodAddToCollection = ObjectAccessors.CreateMethodAddCollection(type, elementType);
                }
            }

            var attribute = typeInfo.GetCustomAttribute <XmlRootAttribute>();

            if (attribute != null)
            {
                Name = attribute.ElementName;
            }

            IsObjectToSerialize =             // !typeInfo.IsPrimitive && !typeInfo.IsValueType &&
                                  !IsPrimitive &&
                                  !typeInfo.IsEnum && type != typeof(string) &&
                                  //not generic or generic but not List<> and Set<>
                                  (!isGenericType || !IsEnumerable);
            _properties = new Lazy <IEnumerable <PropertieDefinition> >(GetPropertieToSerialze);

            ObjectActivator = ObjectAccessors.CreateObjectActivator(type, IsPrimitive);
        }
Пример #9
0
 public TypeName GetGenericTypeDefinition()
 {
     return(Create(rawName, AssemblyName,
                   GenericArguments.Select(t => Maybe <TypeName> .Empty), OrderOfArray));
 }
Пример #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GenericArgumentResolver"/> class.
 /// </summary>
 public GenericArgumentResolver()
 {
     genericArguments = new GenericArguments();
     recursionCounter = new RecursionCounter();
 }
Пример #11
0
 public Parameter()
 {
     ExtendedData     = new ExtendedDataDictionary();
     GenericArguments = new GenericArguments();
 }
Пример #12
0
 /// <summary>
 /// Returns whether the generic arguments for this type and a given type match.
 /// </summary>
 /// <param name="t">Specifier for the type to check.</param>
 /// <returns>Whether the generic arguments for the types match.</returns>
 public bool GenericArgumentsEqual(TypeSpecifier t)
 {
     return(GenericArguments.SequenceEqual(t.GenericArguments));
 }
Пример #13
0
        public bool Instantiate(MethodSpec methodSpec, out MethodDef def)
        {
            if (instantiations.TryGetValue(methodSpec, out def))
            {
                return(true);
            }

            var genericArguments = new GenericArguments();

            genericArguments.PushMethodArgs(methodSpec.GenericInstMethodSig.GenericArguments);
            var originDef = methodSpec.Method.ResolveMethodDefThrow();

            var newSig = ResolveMethod(originDef.MethodSig, genericArguments);

            newSig.Generic       = false;
            newSig.GenParamCount = 0;

            string newName = originDef.Name;

            foreach (var typeArg in methodSpec.GenericInstMethodSig.GenericArguments)
            {
                newName += ";" + typeArg.TypeName;
            }

            def = new MethodDefUser(newName, newSig, originDef.ImplAttributes, originDef.Attributes);
            var thisParam = originDef.HasThis ? originDef.Parameters[0].Type : null;

            def.DeclaringType2 = originDef.DeclaringType2;
            if (thisParam != null)
            {
                def.Parameters[0].Type = thisParam;
            }

            foreach (var declSec in originDef.DeclSecurities)
            {
                def.DeclSecurities.Add(declSec);
            }
            def.ImplMap = originDef.ImplMap;
            foreach (var ov in originDef.Overrides)
            {
                def.Overrides.Add(ov);
            }

            def.Body            = new CilBody();
            def.Body.InitLocals = originDef.Body.InitLocals;
            def.Body.MaxStack   = originDef.Body.MaxStack;
            foreach (var variable in originDef.Body.Variables)
            {
                var newVar = new Local(variable.Type);
                def.Body.Variables.Add(newVar);
            }

            var instrMap = new Dictionary <Instruction, Instruction>();

            foreach (var instr in originDef.Body.Instructions)
            {
                var newInstr = new Instruction(instr.OpCode, ResolveOperand(instr.Operand, genericArguments));
                def.Body.Instructions.Add(newInstr);
                instrMap[instr] = newInstr;
            }
            foreach (var instr in def.Body.Instructions)
            {
                if (instr.Operand is Instruction)
                {
                    instr.Operand = instrMap[(Instruction)instr.Operand];
                }
                else if (instr.Operand is Instruction[])
                {
                    var targets = (Instruction[])((Instruction[])instr.Operand).Clone();
                    for (int i = 0; i < targets.Length; i++)
                    {
                        targets[i] = instrMap[targets[i]];
                    }
                    instr.Operand = targets;
                }
            }
            def.Body.UpdateInstructionOffsets();

            foreach (var eh in originDef.Body.ExceptionHandlers)
            {
                var newEH = new ExceptionHandler(eh.HandlerType);
                newEH.TryStart     = instrMap[eh.TryStart];
                newEH.HandlerStart = instrMap[eh.HandlerStart];
                if (eh.TryEnd != null)
                {
                    newEH.TryEnd = instrMap[eh.TryEnd];
                }
                if (eh.HandlerEnd != null)
                {
                    newEH.HandlerEnd = instrMap[eh.HandlerEnd];
                }
                if (eh.CatchType != null)
                {
                    newEH.CatchType = genericArguments.Resolve(newEH.CatchType.ToTypeSig()).ToTypeDefOrRef();
                }
                else if (eh.FilterStart != null)
                {
                    newEH.FilterStart = instrMap[eh.FilterStart];
                }

                def.Body.ExceptionHandlers.Add(newEH);
            }

            instantiations[methodSpec] = def;
            return(false);
        }
        public static GenericArguments ParseGenericArguments(string type, string path, int absoluteCharOffset)
        {
            GenericArguments generics = new GenericArguments();

            var p = type.IndexOf('<');
            System.Text.StringBuilder s = new System.Text.StringBuilder();
            if (p > -1)
            {
                for (int i = p + 1; i < type.Length; i++)
                {

                    var c = type[i];

                    switch (c)
                    {

                        case '>':
                        case ',':
                            generics.Add(s.ToString().Trim());
                            s.Clear();
                            break;

                        default:
                            s.Append(c);
                            break;
                    }

                }
            }

            string txt = LoadText(path, absoluteCharOffset);
            System.Text.RegularExpressions.MatchCollection matchs = r.Matches(txt);

            foreach (System.Text.RegularExpressions.Match item in matchs)
            {
                string t = item.Value.Substring("where".Length).Trim();
                GenericArgument gen = generics.Resolve(t);
                if (gen != null)
                {
                    t = txt.Substring(item.Index + item.Length + 1).Trim();
                    var m2 = r.Match(t);
                    if (m2.Success)
                        t = t.Substring(0, m2.Index);
                    var constraints = t.Split(',');
                    foreach (string constraint in constraints)
                        gen.AddConstraint(constraint.Trim());
                }
            }

            return generics;
        }
Пример #15
0
 public Method() {
     Data = new DataDictionary();
     GenericArguments = new GenericArguments();
     Parameters = new ParameterCollection();
 }
Пример #16
0
 public override object Clone()
 {
     return(new ShaderClassSource(ClassName, GenericArguments = GenericArguments != null ? GenericArguments.ToArray() : null));
 }
Пример #17
0
 public Parameter() {
     Data = new DataDictionary();
     GenericArguments = new GenericArguments();
 }
Пример #18
0
 public Parameter()
 {
     Data             = new DataDictionary();
     GenericArguments = new GenericArguments();
 }
Пример #19
0
 public Parameter() {
     ExtendedData = new ExtendedDataDictionary();
     GenericArguments = new GenericArguments();
 }
Пример #20
0
        void Write(CustomAttribute ca)
        {
            if (ca == null)
            {
                helper.Error("The custom attribute is null");
                return;
            }

            // Check whether it's raw first. If it is, we don't care whether the ctor is
            // invalid. Just use the raw data.
            if (ca.IsRawBlob)
            {
                if ((ca.ConstructorArguments != null && ca.ConstructorArguments.Count > 0) || (ca.NamedArguments != null && ca.NamedArguments.Count > 0))
                {
                    helper.Error("Raw custom attribute contains arguments and/or named arguments");
                }
                writer.WriteBytes(ca.RawData);
                return;
            }

            if (ca.Constructor == null)
            {
                helper.Error("Custom attribute ctor is null");
                return;
            }

            var methodSig = GetMethodSig(ca.Constructor);

            if (methodSig == null)
            {
                helper.Error("Custom attribute ctor's method signature is invalid");
                return;
            }

            if (ca.ConstructorArguments.Count != methodSig.Params.Count)
            {
                helper.Error("Custom attribute arguments count != method sig arguments count");
            }
            if (methodSig.ParamsAfterSentinel != null && methodSig.ParamsAfterSentinel.Count > 0)
            {
                helper.Error("Custom attribute ctor has parameters after the sentinel");
            }
            if (ca.NamedArguments.Count > ushort.MaxValue)
            {
                helper.Error("Custom attribute has too many named arguments");
            }

            if (ca.Constructor is MemberRef mrCtor && mrCtor.Class is TypeSpec owner && owner.TypeSig is GenericInstSig gis)
            {
                genericArguments = new GenericArguments();
                genericArguments.PushTypeArgs(gis.GenericArguments);
            }

            writer.WriteUInt16((ushort)1);

            int numArgs = Math.Min(methodSig.Params.Count, ca.ConstructorArguments.Count);

            for (int i = 0; i < numArgs; i++)
            {
                WriteValue(FixTypeSig(methodSig.Params[i]), ca.ConstructorArguments[i]);
            }

            int numNamedArgs = Math.Min((int)ushort.MaxValue, ca.NamedArguments.Count);

            writer.WriteUInt16((ushort)numNamedArgs);
            for (int i = 0; i < numNamedArgs; i++)
            {
                Write(ca.NamedArguments[i]);
            }
        }
		void Write(CustomAttribute ca) {
			if (ca == null) {
				helper.Error("The custom attribute is null");
				return;
			}

			// Check whether it's raw first. If it is, we don't care whether the ctor is
			// invalid. Just use the raw data.
			if (ca.IsRawBlob) {
				if ((ca.ConstructorArguments != null && ca.ConstructorArguments.Count > 0) || (ca.NamedArguments != null && ca.NamedArguments.Count > 0))
					helper.Error("Raw custom attribute contains arguments and/or named arguments");
				writer.Write(ca.RawData);
				return;
			}

			if (ca.Constructor == null) {
				helper.Error("Custom attribute ctor is null");
				return;
			}

			var methodSig = GetMethodSig(ca.Constructor);
			if (methodSig == null) {
				helper.Error("Custom attribute ctor's method signature is invalid");
				return;
			}

			if (ca.ConstructorArguments.Count != methodSig.Params.Count)
				helper.Error("Custom attribute arguments count != method sig arguments count");
			if (methodSig.ParamsAfterSentinel != null && methodSig.ParamsAfterSentinel.Count > 0)
				helper.Error("Custom attribute ctor has parameters after the sentinel");
			if (ca.NamedArguments.Count > ushort.MaxValue)
				helper.Error("Custom attribute has too many named arguments");

			// A generic custom attribute isn't allowed by most .NET languages (eg. C#) but
			// the CLR probably supports it.
			var mrCtor = ca.Constructor as MemberRef;
			if (mrCtor != null) {
				var owner = mrCtor.Class as TypeSpec;
				if (owner != null) {
					var gis = owner.TypeSig as GenericInstSig;
					if (gis != null) {
						genericArguments = new GenericArguments();
						genericArguments.PushTypeArgs(gis.GenericArguments);
					}
				}
			}

			writer.Write((ushort)1);

			int numArgs = Math.Min(methodSig.Params.Count, ca.ConstructorArguments.Count);
			for (int i = 0; i < numArgs; i++)
				WriteValue(FixTypeSig(methodSig.Params[i]), ca.ConstructorArguments[i]);

			int numNamedArgs = Math.Min((int)ushort.MaxValue, ca.NamedArguments.Count);
			writer.Write((ushort)numNamedArgs);
			for (int i = 0; i < numNamedArgs; i++)
				Write(ca.NamedArguments[i]);
		}
Пример #22
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //проверка повторного запуска
            if (!ApplicationFormServices.EnsureNotRunning())
            {
                return;
            }

            //обработчик исключений
            LoggedExceptionHandler xh = new LoggedExceptionHandler();

            //статическая инициализация
            AssemblyInitializer.UseCurrentDomain();

            //создаём контейнер и регистрируем классы
            using (IServiceContainer container = new ServiceContainer())
            {
                //получаем агрументы
                GenericArguments args = new GenericArguments();

                //получаем настройки
                Settings settings = Settings.Default;
                settings.SettingsSaving += AssemblyConfigurationHelper.SettingsSaveHandler;

                //менеджер путей
                SberBankPathManager pathManager = new SberBankPathManager();
                container.RegisterInstance <PathManager>(pathManager);

                //логгер
                ILogger logger = container.RegisterLogger(settings.LogLevel, pathManager.LogPath);

                container.Rebuild <ILogger>();



                //создаём список предупреждений для записи в лог после запуска
                var warnings = new List <ILogMessage>();

                //обработчик исключений и окно отображения ошибок (до создания любого окна)
                container.RegisterInstance <IApplicationReportProvider>(new ApplicationReportProvider(true));
                container.RegisterErrorServices(xh);
                container.RegisterErrorWindow();

                //значок панели задач
                container.RegisterInstance <TrayService>(new SberBankTray());

                //заставка (она же окно "О программе")
                container.RegisterAboutWindow(!args.IsNoSplash, new SberBankAboutForm());

                //сеть
                container.RegisterInstance <INetworkProtocol>(new SerialPortProtocol());

                //сервер
                container.RegisterInstance <IApplication>(new SberBank(settings.Mode));
                container.RegisterInstance <Form>(new MainForm());

                //инъектируем зависимости
                container.Rebuild();

                //write warnings
                foreach (LogMessage m in warnings)
                {
                    logger.Write(m);
                }

                //запускаем приложение с помощью зарегистрированных в контейнере классов
                container.Run(false);
            }
        }