public void Apply(IInversionContainer locator){
     lock (this){
         base.Reload();
         foreach (var pair in Registry){
             if (pair.Value != null){
                 Container.set(pair.Key, pair.Value);
             }
         }
     }
 }
Ejemplo n.º 2
0
		public void InstallFrom(Assembly assembly,IInversionContainer c) {
			var types = assembly.getTypesWithAttribute<ActionAttribute>();
			foreach (var type in types) {
				var qatr = type.getFirstAttribute<ActionAttribute>();
				c.set(qatr.Name + ".qweb.action", type);
			}
			types = assembly.getTypesWithAttribute<RenderAttribute>();
			foreach (var type in types)
			{
				var qatr = type.getFirstAttribute<RenderAttribute>();
				c.set(qatr.Name + ".qweb.render", type);
			}
		}
Ejemplo n.º 3
0
		public static void PrepareQWeb(IInversionContainer container) {
			container.set("wiki.qweb.render", typeof (WikiRender));
			Qorpent.Applications.Application.Current.Container.RegisterSubResolver(new OldAssoiTypeLocator{Idx=-1}); //регистриуем контейнер АССОИ в качестве приоритетного
			Qorpent.Applications.Application.Current.Container.Register(
				Qorpent.Applications.Application.Current.Container.NewComponent<IViewEngine, BooViewEngineAdapterForQWeb>(Lifestyle.Singleton)
			);
			var f = Qorpent.Applications.Application.Current.MvcFactory;
			foreach (var file in Directory.GetFiles (Qorpent.Applications.Application.Current.BinDirectory,"*.dll")) {
				var fname = Path.GetFileNameWithoutExtension(file);
				if(fname.StartsWith("Comdiv.")||fname.StartsWith("Qorpent.")||fname.StartsWith("mia.")||fname.StartsWith("Zeta")) {
					var assembly = Assembly.Load(fname);
					f.Register(assembly);
				}
			}

		}
Ejemplo n.º 4
0
 void _containerDispose(object sender,EventArgs eventArgs){
     if (sender.Equals(_container)){
         _container = null;
     }
 }
        public void Execute(IInversionContainer container, MasConfiguration config) {

            container.ensureService<IConnectionsSource, DefaultConnectionsSource>("default.connectionssource");
            var connections = container.get<IConnectionsSource>();
            if (!connections.Exists(config.System))
            {
                connections.Set(config.System, string.Format("Data Source={0};Initial Catalog={1};Integrated Security=True", config.Server, config.Database));
            }

            if (!config.CheckDatabase) return;
            using (var c = connections.Get(config.System).CreateConnection())
            {
                try
                {
                    c.WellOpen();
                }
                catch (Exception ex)
                {
                    throw new MasSetupException("cannot open configured MAS database", ex);
                }
                string schemahash = "";
                try
                {
                    schemahash =
                        c.ExecuteScalar<string>("select comdiv.get_prop_value('comdiv.mas.schema.hashcode')", (IParametersProvider)null);
                }
                catch (Exception ex)
                {
                    throw new MasSetupException("MAS database is not configured properly, cannot get standard comdiv property", ex);
                }

                var schemasqlresourcename =
                    Enumerable.FirstOrDefault<string>(Assembly.GetExecutingAssembly().GetManifestResourceNames(), x => x.Contains("schema.sql"));
                if (null == schemasqlresourcename)
                {
                    throw new MasSetupException("cannot find schema definition resource");
                }
                string script = "";
                using (var sr = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(schemasqlresourcename)))
                {
                    script = sr.ReadToEnd();
                }
                var actualhash = Convert.ToBase64String(System.Security.Cryptography.MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(script)));
                if (schemahash != actualhash)
                {
                    try
                    {
                        new SqlService().ExecuteBatch(script, null, null, config.System);
                    }
                    catch (Exception ex)
                    {
                        throw new MasSetupException("cannot apply schema to database", ex);
                    }
                }

                try
                {
                    c.ExecuteNonQuery("exec comdiv.set_prop_value 'comdiv.mas.schema.hashcode','" + actualhash + "'", (IParametersProvider)null);
                }
                catch (Exception ex)
                {
                    throw new MasSetupException("cannot setup schema hash in database", ex);
                }
            }
            

        }
Ejemplo n.º 6
0
 public InversionComponent(IInversionContainer container){
     this.container = container;
 }