Example #1
0
 //////////////////////////////////////////////////////////////////////////
 public CBundle(long id, string location, CManifest manifest, DateTime lastModified, CSystemBundle systemBundle)
 {
     m_id = id;
     m_location = location;
     m_manifest = manifest;
     m_lastModified = lastModified;
     m_systemBundle = systemBundle;
     m_state = BundleState.INSTALLED;
 }
Example #2
0
        //////////////////////////////////////////////////////////////////////////

        public CBundle(long id, string location, CManifest manifest, DateTime lastModified, CSystemBundle systemBundle)
        {
            m_id           = id;
            m_location     = location;
            m_manifest     = manifest;
            m_lastModified = lastModified;
            m_systemBundle = systemBundle;
            m_state        = BundleState.INSTALLED;
        }
        //////////////////////////////////////////////////////////////////////////
        public IFramework NewFramework(FrameworkConfig configuration)
        {
            if (configuration == null)
                configuration = new FrameworkConfig();

            CManifest manifest = new CManifest();

            manifest.SymbolicName = "Sekai Framework";
            manifest.Version = Assembly.GetExecutingAssembly().GetName().Version;
            manifest.AssemblyPath = Assembly.GetExecutingAssembly().Location;

            CSystemBundle sys_bundle = new CSystemBundle(configuration, manifest);
            return sys_bundle;
        }
        //////////////////////////////////////////////////////////////////////////
        // TODO: unify config and system bundle's manifest
        public CSystemBundle(FrameworkConfig config, CManifest manifest)
            : base(0
			, "System Bundle"
			, manifest
			, DateTime.MinValue
			, null)
        {
            m_systemBundle = this;
            m_config = config;

            m_config.FrameworkWorkingDirectory = Path.GetDirectoryName(manifest.AssemblyPath);

            if (string.IsNullOrEmpty(m_config.BundleRegistryPath))
                m_config.BundleRegistryPath = Path.Combine(m_config.FrameworkWorkingDirectory, "repository");
        }
        //////////////////////////////////////////////////////////////////////////
        // TODO: unify config and system bundle's manifest
        public CSystemBundle(FrameworkConfig config, CManifest manifest)
            : base(0
			, "System Bundle"
			, manifest
			, DateTime.MinValue
			, null)
        {
            m_systemBundle = this;
            m_config = config;

            m_config.FrameworkWorkingDirectory = Path.GetDirectoryName(manifest.AssemblyPath);

            if (string.IsNullOrEmpty(m_config.BundleRegistryPath))
                m_config.BundleRegistryPath = Path.Combine(m_config.FrameworkWorkingDirectory, "repository");
        }
        //////////////////////////////////////////////////////////////////////////

        public CBundle InstallBundle(string location, System.IO.Stream input)
        {
            /*
             * 1.If a bundle containing the same location identifier is already installed, the Bundle object for that bundle is returned.
             * 2.The bundle's content is read from the input stream. If this fails, a BundleException is thrown.
             * 3.The bundle's associated resources are allocated. The associated resources minimally consist
             * of a unique identifier and a persistent storage area if the platform has file system support.
             * If this step fails, a BundleException is thrown.
             * 4.The bundle's state is set to INSTALLED.
             * 5.A bundle event of type BundleEvent.INSTALLED is fired.
             * 6.The Bundle object for the newly or previously installed bundle is returned.
             */
            lock (m_lock)
            {
                if (input != null)
                {
                    throw new NotImplementedException();
                }

                CBundle bndl = getBundle(location);
                if (bndl != null)
                {
                    return(bndl);
                }

                CManifest manifest = new CManifest();
                manifest.SymbolicName = "<symbolic_name>";
                manifest.Version      = new Version(6, 6, 6, 6);
                manifest.AssemblyPath = Path.Combine(m_systemBundle.getConfig().BundleRegistryPath, location);
                manifest.AssemblyPath = Path.Combine(manifest.AssemblyPath, location + ".dll");

                bndl = new CBundle(m_firstFreeID++, location, manifest, DateTime.Now, m_systemBundle);
                m_bundlesByID.Add(bndl.getBundleId(), bndl);
                m_bundlesByLocation.Add(bndl.getLocation(), bndl);

                m_systemBundle.RaiseBundleEvent(new BundleEvent(BundleEvent.Type.INSTALLED, bndl));
                return(bndl);
            }
        }
        //////////////////////////////////////////////////////////////////////////
        public CBundle InstallBundle(string location, System.IO.Stream input)
        {
            /*
            1.If a bundle containing the same location identifier is already installed, the Bundle object for that bundle is returned.
            2.The bundle's content is read from the input stream. If this fails, a BundleException is thrown.
            3.The bundle's associated resources are allocated. The associated resources minimally consist
             * of a unique identifier and a persistent storage area if the platform has file system support.
             * If this step fails, a BundleException is thrown.
            4.The bundle's state is set to INSTALLED.
            5.A bundle event of type BundleEvent.INSTALLED is fired.
            6.The Bundle object for the newly or previously installed bundle is returned.
            */
            lock (m_lock)
            {
                if (input != null)
                    throw new NotImplementedException();

                CBundle bndl = getBundle(location);
                if (bndl != null)
                    return bndl;

                CManifest manifest = new CManifest();
                manifest.SymbolicName = "<symbolic_name>";
                manifest.Version = new Version(6, 6, 6, 6);
                manifest.AssemblyPath = Path.Combine(m_systemBundle.getConfig().BundleRegistryPath, location);
                manifest.AssemblyPath = Path.Combine(manifest.AssemblyPath, location + ".dll");

                bndl = new CBundle(m_firstFreeID++, location, manifest, DateTime.Now, m_systemBundle);
                m_bundlesByID.Add(bndl.getBundleId(), bndl);
                m_bundlesByLocation.Add(bndl.getLocation(), bndl);

                m_systemBundle.RaiseBundleEvent(new BundleEvent(BundleEvent.Type.INSTALLED, bndl));
                return bndl;
            }
        }