Exemplo n.º 1
0
 /// <Summary>
 /// Creates a one-dimensional Array instance containing the collection items.
 /// </Summary>
 /// <Returns>Array of type LocaleFileInfo</Returns>
 public LocaleFileInfo[] ToArray()
 {
     LocaleFileInfo[] arr = new LocaleFileInfo[((this.Count - 1) + 1)];
     arr = ((LocaleFileInfo[])Utils.CopyArray(((Array)arr), ((Array) new LocaleFileInfo[((this.Count - 1) + 1)])));
     this.CopyTo(arr, 0);
     return(arr);
 }
Exemplo n.º 2
0
        private LocaleFileInfo GetLocaleFile(ref string RootPath, LocaleType ResType, FileInfo objFile)
        {
            LocaleFileInfo LocaleFile = new LocaleFileInfo();

            LocaleFile.LocaleFileName = objFile.Name;
            LocaleFile.LocalePath     = StripCommonDirectory(RootPath, objFile.DirectoryName);
            LocaleFile.LocaleModule   = GetModuleName(LocaleFile.LocalePath);
            LocaleFile.LocalePath     = StripModuleName(LocaleFile.LocalePath, LocaleFile.LocaleModule);
            LocaleFile.LocaleFileType = ResType;
            LocaleFile.Buffer         = GetFileAsByteArray(objFile);

            return(LocaleFile);
        }
Exemplo n.º 3
0
        public void SetLocaleFile(string FullFileName, LocaleFileInfo value)
        {
            LocaleFileInfo LocaleFile = GetLocaleFile(FullFileName);

            if (LocaleFile != null)
            {
                LocaleFile = value;
            }
            else
            {
                throw (new ArgumentOutOfRangeException(FullFileName, FullFileName + " does not exist in this collection."));
            }
        }
 protected string GetFullLocaleFileName(string RootPath, LocaleFileInfo LocaleFile)
 {
     string Result = RootPath + "/";
     if (LocaleFile.LocaleModule != null)
     {
         Result += LocaleFile.LocaleModule + "/";
     }
     if (LocaleFile.LocalePath != null)
     {
         Result += LocaleFile.LocalePath + "/";
     }
     Result += Localization.LocalResourceDirectory + "/" + LocaleFile.LocaleFileName;
     return Result;
 }
Exemplo n.º 5
0
        protected string GetFullLocaleFileName(string RootPath, LocaleFileInfo LocaleFile)
        {
            string Result = RootPath + "/";

            if (LocaleFile.LocaleModule != null)
            {
                Result += LocaleFile.LocaleModule + "/";
            }
            if (LocaleFile.LocalePath != null)
            {
                Result += LocaleFile.LocalePath + "/";
            }
            Result += Localization.LocalResourceDirectory + "/" + LocaleFile.LocaleFileName;
            return(Result);
        }
Exemplo n.º 6
0
        private void GetGlobalResourceFiles(LocaleFileCollection ResFileList, string LocaleCode)
        {
            FileInfo      objFile;
            DirectoryInfo objFolder = new DirectoryInfo(GetServerPath(Localization.ApplicationResourceDirectory));

            FileInfo[] Files;
            FileInfo   TimeZoneFile;

            if (LocaleCode == Localization.SystemLocale)
            {
                // This is the case for en-US which is the default locale
                Files = objFolder.GetFiles("*.resx");
                int LastIndex = Files.Length;
                Files            = (FileInfo[])Utils.CopyArray((Array)Files, new FileInfo[LastIndex + 1]);
                TimeZoneFile     = new FileInfo(Path.Combine(objFolder.FullName, "TimeZones.xml"));
                Files[LastIndex] = TimeZoneFile;
            }
            else
            {
                Files = objFolder.GetFiles("*." + LocaleCode + ".resx");
                int LastIndex = Files.Length;
                Files            = (FileInfo[])Utils.CopyArray((Array)Files, new FileInfo[LastIndex + 1]);
                TimeZoneFile     = new FileInfo(Path.Combine(objFolder.FullName, "TimeZones." + LocaleCode + ".xml"));
                Files[LastIndex] = TimeZoneFile;
            }

            foreach (FileInfo tempLoopVar_objFile in Files)
            {
                objFile = tempLoopVar_objFile;
                if ((!objFile.Name.StartsWith("Template")) && (LocaleCode != Localization.SystemLocale || (LocaleCode == Localization.SystemLocale && objFile.Name.IndexOf('.') == objFile.Name.LastIndexOf('.'))))
                {
                    LocaleFileInfo LocaleFile = new LocaleFileInfo();
                    LocaleFile.LocaleFileName = objFile.Name;
                    //Since paths are relative and all global resources exist in a known directory,
                    // we don't need a path.
                    LocaleFile.LocalePath     = null;
                    LocaleFile.LocaleFileType = LocaleType.GlobalResource;
                    LocaleFile.Buffer         = GetFileAsByteArray(objFile);

                    ResFileList.Add(LocaleFile);
                    ProgressLog.AddInfo(string.Format(Localization.GetString("LOG.LangPack.LoadFileName"), objFile.Name));
                }
            }
        }
Exemplo n.º 7
0
        protected void LoadLocaleFilesFromZip(LocaleFilePack LangPack, Stream LangPackStream)
        {
            LangPackStream.Position = 0;
            ZipInputStream unzip = new ZipInputStream(LangPackStream);

            try
            {
                ZipEntry entry = unzip.GetNextEntry();

                while (!(entry == null))
                {
                    if (entry.Name.ToLower() != "manifest.xml" && (!entry.IsDirectory))
                    {
                        LocaleFileInfo LocaleFile = LangPack.Files.LocaleFile(entry.Name);
                        if (LocaleFile != null)
                        {
                            ProgressLog.AddInfo(string.Format(LOG_LangPack_LoadFiles, LocaleFile.LocaleFileName));
                            LocaleFile.Buffer = new byte[Convert.ToInt32(entry.Size) - 1 + 1];
                            int size = 0;
                            while (size < LocaleFile.Buffer.Length)
                            {
                                size += unzip.Read(LocaleFile.Buffer, size, LocaleFile.Buffer.Length - size);
                            }
                            if (size != LocaleFile.Buffer.Length)
                            {
                                throw (new Exception(EXCEPTION_FileRead + LocaleFile.Buffer.Length + "/" + size));
                            }
                        }
                        else
                        {
                            ProgressLog.AddInfo(string.Format(EXCEPTION_LangPack_FileMissing, entry.Name));
                        }
                    }
                    entry = unzip.GetNextEntry();
                }
            }
            catch (Exception ex)
            {
                Exceptions.Exceptions.LogException(ex);
                ProgressLog.AddFailure(string.Format(EXCEPTION_LangPack_ResourceLoad, ex.Message));
            }
        }
 /// <Summary>
 /// Initializes a new instance of the LocaleFileCollection class containing the specified array of LocaleFileInfo objects.
 /// </Summary>
 /// <Param name="value">
 /// An array of LocaleFileInfo objects with which to initialize the collection.
 /// </Param>
 public LocaleFileCollection( LocaleFileInfo[] value )
 {
     this.AddRange( value );
 }
 /// <Summary>
 /// Add an element of the specified LocaleFileInfo to the end of the collection.
 /// </Summary>
 /// <Param name="value">
 /// An object of type LocaleFileInfo to add to the collection.
 /// </Param>
 public int Add( LocaleFileInfo value )
 {
     return this.List.Add( value );
 }
 /// <Summary>
 /// Remove the specified object of type LocaleFileInfo from the collection.
 /// </Summary>
 /// <Param name="value">
 /// An object of type LocaleFileInfo to remove to the collection.
 /// </Param>
 public void Remove( LocaleFileInfo value )
 {
     this.List.Remove( value );
 }
 public void SetLocaleFile( string FullFileName, LocaleFileInfo value )
 {
     LocaleFileInfo LocaleFile = GetLocaleFile(FullFileName);
     if (LocaleFile != null)
     {
         LocaleFile = value;
     }
     else
     {
         throw (new ArgumentOutOfRangeException(FullFileName, FullFileName + " does not exist in this collection."));
     }
 }
 /// <Summary>
 /// Copies the collection objects to a one-dimensional Array instance beginning at the specified index.
 /// </Summary>
 /// <Param name="array">
 /// The one-dimensional Array that is the destination of the values copied from the collection.
 /// </Param>
 /// <Param name="index">
 /// The index of the array at which to begin inserting.
 /// </Param>
 public void CopyTo( LocaleFileInfo[] array, int index )
 {
     this.List.CopyTo( ( (Array)array ), index );
 }
 /// <Summary>
 /// Add an element of the specified LocaleFileInfo to the collection at the designated index.
 /// </Summary>
 /// <Param name="index">
 /// An Integer to indicate the location to add the object to the collection.
 /// </Param>
 /// <Param name="value">
 /// An object of type LocaleFileInfo to add to the collection.
 /// </Param>
 public void Insert( int index, LocaleFileInfo value )
 {
     this.List.Insert( index, value );
 }
 /// <Summary>
 /// Creates a one-dimensional Array instance containing the collection items.
 /// </Summary>
 /// <Returns>Array of type LocaleFileInfo</Returns>
 public LocaleFileInfo[] ToArray()
 {
     LocaleFileInfo[] arr = new LocaleFileInfo[( ( this.Count - 1 ) + 1 )];
     arr = ( (LocaleFileInfo[])Utils.CopyArray( ( (Array)arr ), ( (Array)new LocaleFileInfo[( ( this.Count - 1 ) + 1 )] ) ) );
     this.CopyTo( arr, 0 );
     return arr;
 }
Exemplo n.º 15
0
 /// <Summary>
 /// Add an element of the specified LocaleFileInfo to the collection at the designated index.
 /// </Summary>
 /// <Param name="index">
 /// An Integer to indicate the location to add the object to the collection.
 /// </Param>
 /// <Param name="value">
 /// An object of type LocaleFileInfo to add to the collection.
 /// </Param>
 public void Insert(int index, LocaleFileInfo value)
 {
     this.List.Insert(index, value);
 }
Exemplo n.º 16
0
 /// <Summary>
 /// Gets the index in the collection of the specified LocaleFileCollection, if it exists in the collection.
 /// </Summary>
 /// <Param name="value">
 /// The LocaleFileCollection to locate in the collection.
 /// </Param>
 /// <Returns>
 /// The index in the collection of the specified object, if found; otherwise, -1.
 /// </Returns>
 public int IndexOf(LocaleFileInfo value)
 {
     return(this.List.IndexOf(value));
 }
 /// <Summary>
 /// Gets the index in the collection of the specified LocaleFileCollection, if it exists in the collection.
 /// </Summary>
 /// <Param name="value">
 /// The LocaleFileCollection to locate in the collection.
 /// </Param>
 /// <Returns>
 /// The index in the collection of the specified object, if found; otherwise, -1.
 /// </Returns>
 public int IndexOf( LocaleFileInfo value )
 {
     return this.List.IndexOf( value );
 }
        private LocaleFileInfo GetLocaleFile( ref string RootPath, LocaleType ResType, FileInfo objFile )
        {
            LocaleFileInfo LocaleFile = new LocaleFileInfo();
            LocaleFile.LocaleFileName = objFile.Name;
            LocaleFile.LocalePath = StripCommonDirectory(RootPath, objFile.DirectoryName);
            LocaleFile.LocaleModule = GetModuleName(LocaleFile.LocalePath);
            LocaleFile.LocalePath = StripModuleName(LocaleFile.LocalePath, LocaleFile.LocaleModule);
            LocaleFile.LocaleFileType = ResType;
            LocaleFile.Buffer = GetFileAsByteArray(objFile);

            return LocaleFile;
        }
Exemplo n.º 19
0
 /// <Summary>
 /// Gets a value indicating whether the collection contains the specified LocaleFileCollection.
 /// </Summary>
 /// <Param name="value">
 /// The LocaleFileCollection to search for in the collection.
 /// </Param>
 /// <Returns>
 /// true if the collection contains the specified object; otherwise, false.
 /// </Returns>
 public bool Contains(LocaleFileInfo value)
 {
     return(this.List.Contains(value));
 }
Exemplo n.º 20
0
 /// <Summary>
 /// Add an element of the specified LocaleFileInfo to the end of the collection.
 /// </Summary>
 /// <Param name="value">
 /// An object of type LocaleFileInfo to add to the collection.
 /// </Param>
 public int Add(LocaleFileInfo value)
 {
     return(this.List.Add(value));
 }
 /// <Summary>
 /// Gets a value indicating whether the collection contains the specified LocaleFileCollection.
 /// </Summary>
 /// <Param name="value">
 /// The LocaleFileCollection to search for in the collection.
 /// </Param>
 /// <Returns>
 /// true if the collection contains the specified object; otherwise, false.
 /// </Returns>
 public bool Contains( LocaleFileInfo value )
 {
     return this.List.Contains( value );
 }
 /// <Summary>
 /// Copies the elements of the specified LocaleFileInfo array to the end of the collection.
 /// </Summary>
 /// <Param name="value">
 /// An array of type LocaleFileInfo containing the objects to add to the collection.
 /// </Param>
 public void AddRange( LocaleFileInfo[] value )
 {                        
     for (int i = 0; i <value.Length - 1; i++)
     {
         this.Add( value[i] );
     }
 }
        private void GetGlobalResourceFiles( LocaleFileCollection ResFileList, string LocaleCode )
        {
            FileInfo objFile;
            DirectoryInfo objFolder = new DirectoryInfo(GetServerPath(Localization.ApplicationResourceDirectory));

            FileInfo[] Files;
            FileInfo TimeZoneFile;
            if (LocaleCode == Localization.SystemLocale)
            {
                // This is the case for en-US which is the default locale
                Files = objFolder.GetFiles("*.resx");
                int LastIndex = Files.Length;
                Files = (FileInfo[])Utils.CopyArray((Array)Files, new FileInfo[LastIndex + 1]);
                TimeZoneFile = new FileInfo(Path.Combine(objFolder.FullName, "TimeZones.xml"));
                Files[LastIndex] = TimeZoneFile;
            }
            else
            {
                Files = objFolder.GetFiles("*." + LocaleCode + ".resx");
                int LastIndex = Files.Length;
                Files = (FileInfo[])Utils.CopyArray((Array)Files, new FileInfo[LastIndex + 1]);
                TimeZoneFile = new FileInfo(Path.Combine(objFolder.FullName, "TimeZones." + LocaleCode + ".xml"));
                Files[LastIndex] = TimeZoneFile;
            }

            foreach (FileInfo tempLoopVar_objFile in Files)
            {
                objFile = tempLoopVar_objFile;
                if ((!objFile.Name.StartsWith("Template")) && (LocaleCode != Localization.SystemLocale || (LocaleCode == Localization.SystemLocale && objFile.Name.IndexOf('.') == objFile.Name.LastIndexOf('.'))))
                {
                    LocaleFileInfo LocaleFile = new LocaleFileInfo();
                    LocaleFile.LocaleFileName = objFile.Name;
                    //Since paths are relative and all global resources exist in a known directory,
                    // we don't need a path.
                    LocaleFile.LocalePath = null;
                    LocaleFile.LocaleFileType = LocaleType.GlobalResource;
                    LocaleFile.Buffer = GetFileAsByteArray(objFile);

                    ResFileList.Add(LocaleFile);
                    ProgressLog.AddInfo(string.Format(Localization.GetString("LOG.LangPack.LoadFileName"), objFile.Name));
                }
            }
        }
Exemplo n.º 24
0
 /// <Summary>
 /// Remove the specified object of type LocaleFileInfo from the collection.
 /// </Summary>
 /// <Param name="value">
 /// An object of type LocaleFileInfo to remove to the collection.
 /// </Param>
 public void Remove(LocaleFileInfo value)
 {
     this.List.Remove(value);
 }