Пример #1
0
        ///// ------------------------------------------------------------------------------------
        ///// <summary>
        ///// Saves the cache to the specified file, if the cache is dirty. If the cache is
        ///// dirty and saved, then true is returned. Otherwise, false is returned.
        ///// </summary>
        ///// ------------------------------------------------------------------------------------
        //private bool SaveIfDirty(string tmxFile)
        //{
        //    if (!IsDirty || string.IsNullOrEmpty(tmxFile))
        //        return false;

        //    //_tmxFile = tmxFile;
        //    IsDirty = false;
        //    TmxDocument.Body.TransUnits.Sort(TuComparer);
        //    TmxDocument.Save(tmxFile);
        //    return true;
        //}

        #endregion

        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Compares two translation units for equality.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private static int TuComparer(TMXTransUnit tu1, TMXTransUnit tu2)
        {
            if (tu1 == null && tu2 == null)
            {
                return(0);
            }

            if (tu1 == null)
            {
                return(-1);
            }

            if (tu2 == null)
            {
                return(1);
            }

            string x = tu1.GetPropValue(kGroupPropTag);
            string y = tu2.GetPropValue(kGroupPropTag);

            if (x == y)
            {
                return(String.CompareOrdinal(tu1.Id, tu2.Id));
            }

            if (x == null)
            {
                return(-1);
            }

            if (y == null)
            {
                return(1);
            }

            return(String.CompareOrdinal(x, y));
        }
Пример #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the group for the specified id.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        internal string GetGroup(string id)
        {
            TMXTransUnit tu = TmxDocument.GetTransUnitForId(id);

            return(tu == null ? null : tu.GetPropValue(kGroupPropTag));
        }