Beispiel #1
0
        public void CheckInItem(int assetId)//, int libraryCardId)
        {
            LibraryAsset item = _asset.GetById(assetId);

            // Remove any existing CheckOuts on the item
            RemoveExistingCheckOuts(assetId);
            // Close any existing CheckOut history
            CloseExistingCheckOutHistory(assetId, DateTime.Now);
            // Look for existing holds on the item
            IQueryable <Hold> currentHolds = _context.Holds
                                             .Include(c => c.LibraryAsset)
                                             .Include(c => c.LibraryCard)
                                             .Where(h => h.LibraryAsset.Id == assetId);

            // If there are holds, CheckOut the item to the librarycard with earliest hold
            if (currentHolds.Any())
            {
                CheckOutToEarliestHold(assetId, currentHolds);
            }
            else
            {
                // Otherwise, update item status to Available
                UpdateAssetStatus(assetId, Status.Available);
            }

            _context.SaveChanges();
        }
        private LibraryAsset createNewLibraryAsset(AssetModel asset)
        {
            var discriminator = Enum.GetName(typeof(Discriminator), asset.Discriminator);
            var newAsset      = new LibraryAsset
            {
                Title          = asset.Title,
                Discriminator  = discriminator,
                DeweyIndex     = asset.DeweyCallNumber,
                NumberOfCopies = asset.NumberOfCopies,
                Year           = asset.Year,
                ISBN           = asset.ISBN,
                Cost           = asset.Cost,
                ImageUrl       = asset.ImageUrl,
                Location       = _branchService.Get(asset.CurrentLocation),
                Status         = _libraryAssetService.GetStatusById(2)
            };

            if (discriminator == "Book")
            {
                newAsset.Author = asset.AuthorOrDirector;
            }
            else
            {
                newAsset.Director = asset.AuthorOrDirector;
            }

            return(newAsset);
        }
Beispiel #3
0
        public void CheckOutItem(int assetId, int libraryCardId)
        {
            if (IsCheckedOut(assetId))
            {
                return; //add logic to handle user feedback here
            }

            LibraryAsset item = _context.LibraryAssets.
                                FirstOrDefault(a => a.Id == assetId);
            LibraryCard libraryCard = _context.LibraryCards
                                      .Include(c => c.CheckOuts)
                                      .FirstOrDefault(c => c.Id == libraryCardId);

            if (libraryCard != null)
            {
                UpdateAssetStatus(assetId, Status.CheckedOut);

                CheckOut CheckOut = new CheckOut(item, libraryCard, DateTime.Now);
                _context.Add(CheckOut);

                /**add a new CheckOut history. This could be handled in a
                 * shadow table in SQL Server or in a database trigger */
                CheckOutHistory CheckOutHistory = new CheckOutHistory(item, libraryCard);

                _context.Add(CheckOutHistory);
                _context.SaveChanges();
            }
            else
            {
                return;
            }
        }
Beispiel #4
0
        public void Add(LibraryAsset newAsset)
        {
            _context.Add(newAsset);
            _context.SaveChanges();

            //throw new NotImplementedException();
        }
Beispiel #5
0
        public void Add(LibraryAsset newAsset)
        {
            _context.Add(newAsset);

            // This method commits changes to db
            _context.SaveChanges();
        }
Beispiel #6
0
        private AssemblyReferenceInfo GetAssemblyInfo(LibraryAsset arg)
        {
            using (var peReader = new PEReader(File.OpenRead(arg.ResolvedPath)))
            {
                var metadataReader = peReader.GetMetadataReader();

                var definition = metadataReader.GetAssemblyDefinition();

                var identity = new AssemblyIdentity(
                    metadataReader.GetString(definition.Name),
                    definition.Version,
                    metadataReader.GetString(definition.Culture),
                    GetPublicKeyToken(metadataReader.GetBlobBytes(definition.PublicKey))
                    );

                var references = new List <AssemblyIdentity>(metadataReader.AssemblyReferences.Count);

                foreach (var assemblyReferenceHandle in metadataReader.AssemblyReferences)
                {
                    var assemblyReference = metadataReader.GetAssemblyReference(assemblyReferenceHandle);
                    references.Add(new AssemblyIdentity(
                                       metadataReader.GetString(assemblyReference.Name),
                                       assemblyReference.Version,
                                       metadataReader.GetString(assemblyReference.Culture),
                                       GetPublicKeyToken(metadataReader.GetBlobBytes(assemblyReference.PublicKeyOrToken))
                                       ));
                }

                return(new AssemblyReferenceInfo(identity, references.ToArray()));
            }
        }
Beispiel #7
0
 public CheckOutModel(int id, LibraryAsset asset, ICheckOut CheckOuts) : this(id)
 {
     ImageUrl      = asset.ImageUrl;
     Title         = asset.Title;
     LibraryCardId = string.Empty;//
     IsCheckedOut  = CheckOuts.IsCheckedOut(id);
 }
Beispiel #8
0
        public IActionResult Detail(int id)
        {
            LibraryAsset asset = _assets.GetById(id);

            IEnumerable <AssetHoldModel> currentHolds = _checkouts.GetCurrentHolds(asset.Id)
                                                        .Select(h => new AssetHoldModel
            {
                HoldPlaced = h.HoldPlaced.ToShortDateString(),
                PatronName = _checkouts.GetCurrentHoldPatronName(h.Id)
            });

            AssetDetailModel model = new AssetDetailModel()
            {
                AssetId          = asset.Id,
                Title            = asset.Title,
                Year             = asset.Year,
                DeweyCallNumber  = _assets.GetDeweyIndex(asset.Id),
                ISBN             = _assets.GetIsbn(asset.Id),
                Type             = _assets.GetType(asset.Id),
                ImageUrl         = asset.ImageUrl,
                Cost             = asset.Cost,
                AuthorOrDirector = _assets.GetAuthorOrDirector(asset.Id),
                CurrentLocation  = _assets.GetCurrentLocation(asset.Id).Name,
                Status           = asset.Status.Name,
                CheckoutHistory  = _checkouts.GetCheckoutHistory(asset.Id),
                CurrentHolds     = currentHolds,
                LatestCheckout   = _checkouts.GetLatestCheckout(asset.Id),
                PatronName       = _checkouts.GetCurrentCheckoutPatron(asset.Id),
            };

            return(View(model));
        }
        public void ReadLibraryAssets()
        {
            ReadStartElement("library");
            while (Name == "asset")
            {
                string path = OSPath(GetAttribute("path"));
                string mode = GetAttribute("mode");

                if (path == null)
                    throw new Exception("All library assets must have a 'path' attribute.");

                LibraryAsset asset = new LibraryAsset(project, path);
                project.LibraryAssets.Add(asset);

                asset.ManualID = GetAttribute("id"); // could be null
                asset.UpdatePath = OSPath(GetAttribute("update")); // could be null
                asset.FontGlyphs = GetAttribute("glyphs"); // could be null

                if (mode != null)
                    asset.SwfMode = (SwfAssetMode)Enum.Parse(typeof(SwfAssetMode), mode, true);

                if (asset.SwfMode == SwfAssetMode.Shared)
                    asset.Sharepoint = GetAttribute("sharepoint"); // could be null

                if (asset.IsImage && GetAttribute("bitmap") != null)
                    asset.BitmapLinkage = Boolean.Parse(GetAttribute("bitmap"));

                Read();
            }
            ReadEndElement();
        }
Beispiel #10
0
        public IActionResult CheckOut(int id)
        {
            LibraryAsset  asset = _assets.GetById(id);
            CheckOutModel model = new CheckOutModel(id, asset, _checkOuts);

            return(View(model));
        }
Beispiel #11
0
    public async void GetAssetById_ExistingAsset_ReturnAsset()
    {
        // Arrange
        using (var context = _factory.Create())
        {
            var asset = new LibraryAsset
            {
                Id     = 40,
                Author = new Author {
                    Id = 1
                },
                Photo = new Photo {
                    Id = 1
                }
            };
            context.Add(asset);
            context.SaveChanges();
        }
        // Act
        using (var context = _factory.Create())
        {
            var service = new LibraryAssetService(context);
            var actual  = await service.GetAsset(40);

            // Assert
            Assert.Equal(40, actual.Id);
            Assert.Equal(1, actual.Author.Id);
            Assert.Equal(1, actual.Photo.Id);
        }
    }
        private void UpdateAssetStatus(int assetId, string status)
        {
            LibraryAsset item = _context.LibraryAssets.FirstOrDefault(asset => asset.Id == assetId);

            _context.Update(item);
            item.Status = _context.Statuses.FirstOrDefault(stat => stat.Name == status);
        }
        public async Task <IActionResult> PutLibraryAssett([FromRoute] int id, [FromBody] LibraryAsset libraryAssett)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != libraryAssett.Id)
            {
                return(BadRequest());
            }

            _context.Entry(libraryAssett).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LibraryAssettExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #14
0
        private void EditAsset(LibraryAsset asset, FormCollection formCollection)
        {
            HttpPostedFileBase file = Request.Files["file"];

            assets.UpdateAsset(asset, file);
            assets.Save();
        }
        public void CheckInItem(int assetId)
        {
            DateTime now = DateTime.Now;
            LibraryAsset item = _context.LibraryAssets.FirstOrDefault(a => a.Id == assetId);

            _context.Update(item);

            //remove any existing checkouts on the item
            RemoveExistingCheckouts(assetId);
            
            // close any exisiting checkout history
            CloseExistingCheckoutHistory(assetId, now);
            
            // look for existing holds
            var currentHolds = _context.Holds
                .Include(h => h.LibraryAsset)
                .Include(h => h.LibraryCard)
                .Where(h=>h.LibraryAsset.Id == assetId);

            // if there are holds, checkout the item to the librarycard 
            //with the earliest hold, otherwise update the item status to avaiable

            if (currentHolds.Any())
            {
                CheckoutToEarliestHold(assetId, currentHolds);
            }
            else
            {
                UpdateAssetStatus(assetId, "Available");
                _context.SaveChanges();
            }
        }
Beispiel #16
0
        public override void PropertiesChanged()
        {
            // rebuild Swc assets list
            SwcLibraries.Clear();
            LibraryAsset asset;

            foreach (string path in CompilerOptions.LibraryPaths)
            {
                asset         = new LibraryAsset(this, path);
                asset.SwfMode = SwfAssetMode.Library;
                SwcLibraries.Add(asset);
            }
            foreach (string path in CompilerOptions.IncludeLibraries)
            {
                asset         = new LibraryAsset(this, path);
                asset.SwfMode = SwfAssetMode.IncludedLibrary;
                SwcLibraries.Add(asset);
            }
            foreach (string path in CompilerOptions.ExternalLibraryPaths)
            {
                asset         = new LibraryAsset(this, path);
                asset.SwfMode = SwfAssetMode.ExternalLibrary;
                SwcLibraries.Add(asset);
            }
            base.PropertiesChanged();
        }
        /// <summary>
        /// Data transfer object
        /// </summary>
        /// <typeparam name="T">Book, Journal, Brochure</typeparam>
        /// <param name="asset"></param>
        /// <returns></returns>
        public static T Dto <T>(this LibraryAsset asset) where T : class, new()
        {
            if (asset == null)
            {
                return(null);
            }

            var dest         = new T();
            var typeSource   = asset.GetType();
            var typeDest     = dest.GetType();
            var fieldsSource = typeSource.GetProperties(BindingFlags.Public | BindingFlags.Instance);
            var fieldsDest   = typeDest.GetProperties(BindingFlags.Public | BindingFlags.Instance);

            foreach (var fieldDest in fieldsDest)
            {
                foreach (var fieldSource in fieldsSource)
                {
                    if (fieldDest.Name == fieldSource.Name)
                    {
                        fieldDest.SetValue(dest, fieldSource.GetValue(asset));
                        break;
                    }
                }
            }

            return(dest);
        }
        private void AddSwfItems(MergableMenu menu, string path)
        {
            bool addLibrary = project.HasLibraries && project.IsLibraryAsset(path);

            menu.Add(Open, 0);
            menu.Add(Execute, 0);
            if (Win32.ShouldUseWin32())
            {
                menu.Add(ShellMenu, 0);
            }
            menu.Add(Insert, 0);
            if (addLibrary)
            {
                LibraryAsset asset = project.GetAsset(path);
                if (asset.SwfMode == SwfAssetMode.Library)
                {
                    menu.Add(Insert, 0);
                }
            }
            if (project.HasLibraries)
            {
                menu.Add(AddLibrary, 2, addLibrary);
            }
            if (addLibrary)
            {
                menu.Add(LibraryOptions, 2);
            }
            AddFileItems(menu, path);
        }
        private void AddSwfItems(MergableMenu menu, string path)
        {
            bool addLibrary = project.IsLibraryAsset(path);

            menu.Add(Open, 0);

            if (addLibrary)
            {
                LibraryAsset asset = project.GetAsset(path);
                if (asset.SwfMode == SwfAssetMode.Library)
                {
                    menu.Add(Insert, 0);
                }
            }

            menu.Add(Execute, 0);

            if (!project.UsesInjection)
            {
                menu.Add(AddLibrary, 2, addLibrary);
            }

            if (addLibrary)
            {
                menu.Add(LibraryOptions, 2);
            }

            AddFileItems(menu, path);
        }
        public void Delete(int id)
        {
            LibraryAsset asset = _context.LibraryAssets.Where(s => s.Id == id).First();

            _context.LibraryAssets.Remove(asset);
            _context.SaveChanges();
        }
Beispiel #21
0
 private void AddImage(LibraryAsset asset)
 {
     WriteStartElement("clip");
     WriteAttributeString("id", asset.ID);
     WriteAttributeString("import", asset.Path);
     AddStampAttributes(asset.Path);
     WriteEndElement();
 }
Beispiel #22
0
 public void Add(LibraryAsset asset)
 {
     if (asset != null)
     {
         context.Add(asset);
         context.SaveChanges();
     }
 }
Beispiel #23
0
 public void SaveAsset(LibraryAsset asset)
 {
     if (IsLocked)
     {
         throw new InvalidOperationException($"Cannot update asset {asset.Name} because library {Name} is locked.");
     }
     SaveLibrary();
 }
        public IActionResult Detail(int id)
        {
            //if (ModelState.IsValid)
            //{
            //    LibraryAsset asset = assets.GetById(id);

            //    AssetDetailModel model = new AssetDetailModel()
            //    {
            //        AssetId = id,
            //        Title = asset.Title,
            //        AuthorOrDirector = assets.GetAuthorOrDirection(id),
            //        //Type = assets.GetType(id),
            //        Year = asset.Year,
            //        ISBN = assets.GetIsbn(id),
            //        DeweyCallNumber = assets.GetDeweyIndex(id),
            //        Status = asset.Status.Name,
            //        Cost = asset.Cost,
            //        CurrentLocation = assets.GetCurrentLocation(id).Name,
            //        ImageUrl = asset.ImageUrl
            //        //PatronName = assets.

            //    };

            if (ModelState.IsValid)
            {
                LibraryAsset asset = assets.GetById(id);
                IEnumerable <AssetHoldModel> currentHolds = checkout.GetCurrentHolds(id)
                                                            .Select(a => new AssetHoldModel
                {
                    HoldIsPlaced = checkout.GetCurrentHoldPlaced(id).ToString("d"),
                    PatronName   = checkout.GetCurrentPatronName(id)
                });

                AssetDetailModel model = new AssetDetailModel()
                {
                    AssetId          = id,
                    Title            = asset.Title,
                    Type             = assets.GetType(id),
                    Year             = asset.Year,
                    Cost             = asset.Cost,
                    Status           = asset.Status.Name,
                    ImageUrl         = asset.ImageUrl,
                    AuthorOrDirector = assets.GetAuthorOrDirector(id),
                    CurrentLocation  = assets.GetCurrentLocation(id).Name,
                    DeweyCallNumber  = assets.GetDeweyIndex(id),
                    CheckoutHistory  = checkout.GetCheckoutHistory(id),
                    ISBN             = assets.GetIsbn(id),
                    LastestCheckOut  = checkout.GetLatestCheckout(id),
                    PatronName       = checkout.GetCurrentPatronName(id),
                    AssetHolds       = currentHolds
                };
                return(View(model));
            }
            return(View("Error"));
            //  return View(model);
            //  }
            //   return View("Error");
        }
Beispiel #25
0
        public override void Refresh(bool recursive)
        {
            base.Refresh(recursive);

            string path = BackingPath;
            string ext  = Path.GetExtension(path).ToLower();

            if (Project.IsPathHidden(path))
            {
                ImageIndex = Icons.HiddenFile.Index;
            }
            else if ((FileInspector.IsActionScript(path, ext) || FileInspector.IsHaxeFile(path, ext)) && Project.IsCompileTarget(path))
            {
                ImageIndex = Icons.ActionScriptCompile.Index;
            }
            else if (FileInspector.IsMxml(path, ext) && Project.IsCompileTarget(path))
            {
                ImageIndex = Icons.MxmlFileCompile.Index;
            }
            else if (FileInspector.IsCss(path, ext) && Project.IsCompileTarget(path))
            {
                ImageIndex = Icons.ActionScriptCompile.Index;
            }
            else if (FileInspector.IsSwc(path) && Parent == null) // external SWC library
            {
                ImageIndex = Icons.Classpath.Index;
            }
            else
            {
                ImageIndex = Icons.GetImageForFile(path).Index;
            }

            SelectedImageIndex = ImageIndex;

            Text = Path.GetFileName(path);

            if (Project.IsLibraryAsset(path))
            {
                ForeColorRequest = Color.Blue;
                LibraryAsset asset = Project.GetAsset(path);

                if (asset != null && asset.HasManualID)
                {
                    Text += " (" + asset.ManualID + ")";
                }
            }
            else
            {
                ForeColorRequest = Color.Black;
            }

            // hook for plugins
            if (OnFileNodeRefresh != null)
            {
                OnFileNodeRefresh(this);
            }
        }
 public void UpdateAsset(LibraryAsset asset, byte[] file)
 {
     if (file != null)
     {
         DeleteImage(asset);
         asset.ImageUrl = UploadImage(asset, file);
     }
     context.Entry(asset).State = EntityState.Modified;
 }
Beispiel #27
0
 public AssetIndexListingModel(LibraryAsset result, ILibraryAsset assets) : this(result)
 {
     //this.Id = result.Id;
     //this.ImageUrl = result.ImageUrl;
     //this.Title = result.Title;
     AuthorOrDirector = assets.GetAuthorOrDirector(result.Id);
     DeweyCallNumber  = assets.GetDeweyIndex(result.Id);
     Type             = assets.GetType(result.Id);
 }
 public void UpdateAsset(LibraryAsset asset, HttpPostedFileBase file)
 {
     if (file != null && file.FileName != string.Empty)
     {
         DeleteImage(asset);
         asset.ImageUrl = UploadImage(asset, file);
     }
     context.Entry(asset).State = EntityState.Modified;
 }
        public void IncreaseAssetCopiesAvailable(LibraryAsset asset)
        {
            asset.CopiesAvailable++;

            if (asset.StatusId == (int)EnumStatus.Unavailable)
            {
                asset.StatusId = (int)EnumStatus.Available;
            }
        }
        public void ReduceAssetCopiesAvailable(LibraryAsset asset)
        {
            asset.CopiesAvailable--;

            if (asset.CopiesAvailable == 0)
            {
                asset.StatusId = (int)EnumStatus.Unavailable;
            }
        }
Beispiel #31
0
 private void AddSound(LibraryAsset asset)
 {
     //<sound id="Funk" name="Funk" import="Funk.mp3"/>
     WriteStartElement("sound");
     WriteAttributeString("id", asset.ID);
     WriteAttributeString("name", asset.ID);
     WriteAttributeString("import", asset.Path);
     AddStampAttributes(asset.Path);
     WriteEndElement();
 }
        public void ReadLibraryAssets()
        {
            ReadStartElement("library");
            while (Name == "asset")
            {
                string path = OSPath(GetAttribute("path"));

                if (path == null)
                    throw new Exception("All library assets must have a 'path' attribute.");

                LibraryAsset asset = new LibraryAsset(project, path);
                project.LibraryAssets.Add(asset);

                asset.UpdatePath = OSPath(GetAttribute("update")); // could be null
                asset.FontGlyphs = GetAttribute("glyphs"); // could be null

                Read();
            }
            ReadEndElement();
        }
        private void ReadTheme()
        {
            if (GetAttribute("themeIsDefault") == "false")
            {
                string themeLocation = GetAttribute("themeLocation").ToString().Replace("${EXTERNAL_THEME_DIR}/",
                    GetThemeFolderPath() + Path.DirectorySeparatorChar);

                string themeFile = ".packagedThemes" + Path.DirectorySeparatorChar +
                    themeLocation.Substring(themeLocation.LastIndexOf('\\') + 1) + ".swc";

                if (File.Exists(Path.Combine(project.Directory, themeFile)) ||
                    File.Exists(themeFile = Path.Combine(themeLocation, themeLocation.Substring(themeLocation.LastIndexOf('\\') + 1) + ".swc")))
                {
                    LibraryAsset asset = new LibraryAsset(project, themeFile);
                    asset.SwfMode = SwfAssetMode.IncludedLibrary;   // Should it be a plain library instead?
                    project.SwcLibraries.Add(asset);

                    project.RebuildCompilerOptions();
                }

            }
        }
        private void ReadLibraryPaths()
        {
            if (!IsStartElement())
                return;
            ReadStartElement("libraryPath");
            LibraryAsset asset;
            bool exclude = false;
            while (Name != "libraryPath")
            {
                switch (Name)
                {
                    case "excludedEntries":
                        exclude = IsStartElement();
                        break;

                    case "libraryPathEntry":
                        string path = GetAttribute("path") ?? "";

                        if (path.StartsWith("$") && EnvironmentPaths != null)
                        {
                            string value;
                            string environmentPath = path.Substring(2, path.IndexOf('}') - 2);
                            if (EnvironmentPaths.TryGetValue(environmentPath, out value))
                                path = path.Replace("${" + environmentPath + "}", value);
                        }

                        if (path.Length > 0 && !path.StartsWith("$"))
                        {
                            asset = new LibraryAsset(project, path.Replace('/', '\\'));
                            if (exclude || GetAttribute("linkType").ToString() == "2")
                                asset.SwfMode = SwfAssetMode.ExternalLibrary;
                            else
                                asset.SwfMode = SwfAssetMode.Library;
                            project.SwcLibraries.Add(asset);
                        }
                        break;
                }
                Read();
            }
            project.RebuildCompilerOptions();
        }
Beispiel #35
0
 public override void PropertiesChanged()
 {
     // rebuild Swc assets list
     SwcLibraries.Clear();
     LibraryAsset asset;
     foreach (string path in CompilerOptions.LibraryPaths)
     {
         asset = new LibraryAsset(this, path);
         asset.SwfMode = SwfAssetMode.Library;
         SwcLibraries.Add(asset);
     }
     foreach (string path in CompilerOptions.IncludeLibraries)
     {
         asset = new LibraryAsset(this, path);
         asset.SwfMode = SwfAssetMode.IncludedLibrary;
         SwcLibraries.Add(asset);
     }
     foreach (string path in CompilerOptions.ExternalLibraryPaths)
     {
         asset = new LibraryAsset(this, path);
         asset.SwfMode = SwfAssetMode.ExternalLibrary;
         SwcLibraries.Add(asset);
     }
     base.PropertiesChanged();
 }
Beispiel #36
0
 public override void SetLibraryAsset(string path, bool isLibraryAsset)
 {
     if (!FileInspector.IsSwc(path)) base.SetLibraryAsset(path, isLibraryAsset);
     else
     {
         string relPath = GetRelativePath(path);
         if (isLibraryAsset)
         {
             LibraryAsset asset = new LibraryAsset(this, relPath);
             asset.SwfMode = SwfAssetMode.Library;
             SwcLibraries.Add(asset);
         }
         else
         {
             SwcLibraries.Remove(path);
             SwcLibraries.Remove(relPath);
         }
         RebuildCompilerOptions();
         OnClasspathChanged();
     }
 }
        private void ReadLibraryPaths()
        {
            if (!IsStartElement())
                return;
            ReadStartElement("libraryPath");
            LibraryAsset asset;
            bool exclude = false;
            while (Name != "libraryPath")
            {
                switch (Name)
                {
                    case "excludedEntries":
                        exclude = IsStartElement();
                        break;

                    case "libraryPathEntry":
                        string path = GetAttribute("path") ?? "";
                        if (path.Length > 0 && !path.StartsWith("$"))
                        {
                            asset = new LibraryAsset(project, path.Replace('/', '\\'));
                            if (exclude) asset.SwfMode = SwfAssetMode.ExternalLibrary;
                            else asset.SwfMode = SwfAssetMode.Library;
                            project.SwcLibraries.Add(asset);
                        }
                        break;
                }
                Read();
            }
            project.RebuildCompilerOptions();
        }
Beispiel #38
0
 public LibraryResourceAssembly(LibraryAsset asset, string locale)
 {
     Asset = asset;
     Locale = locale;
 }
        private void ReadLibraryPaths()
        {
            if (!IsStartElement())
                return;
            ReadStartElement("libraryPath");
            LibraryAsset asset;
            bool exclude = false;
            while (Name != "libraryPath")
            {
                switch (Name)
                {
                    case "excludedEntries":
                        exclude = IsStartElement();
                        break;

                    case "libraryPathEntry":
                        string path = GetAttribute("path") ?? string.Empty;
                        if (path.Length == 0) break;
                        path = OSPath(path);

                        string pathTmp = "linked-swc" + Path.DirectorySeparatorChar + 
                            path.Substring(path.LastIndexOf(Path.DirectorySeparatorChar) + 1);

                        if (!Directory.Exists(pathTmp) && !File.Exists(pathTmp))
                            pathTmp = reArgs.Replace(path, ReplaceVars);
                            
                        if (pathTmp.Length > 0 && !pathTmp.StartsWith("$"))
                        {
                            asset = new LibraryAsset(project, pathTmp);
                            if (exclude || GetAttribute("linkType").ToString() == "2")
                                asset.SwfMode = SwfAssetMode.ExternalLibrary;
                            else
                                asset.SwfMode = SwfAssetMode.Library;
                            project.SwcLibraries.Add(asset);
                        }
                        break;
                }
                Read();
            }
            project.RebuildCompilerOptions();
        }
        private string[] ReadLibrary(string name, SwfAssetMode mode)
        {
            ReadStartElement(name);
            List<string> elements = new List<string>();
            while (Name == "element")
            {
                string path = OSPath(GetAttribute("path"));
                elements.Add(path);

                if (mode != SwfAssetMode.Ignore)
                {
                    LibraryAsset asset = new LibraryAsset(project, path);
                    asset.SwfMode = mode;
                    project.SwcLibraries.Add(asset);
                }
                Read();
            }
            ReadEndElement();
            string[] result = new string[elements.Count];
            elements.CopyTo(result);
            return result;
        }