Reset() публичный Метод

public Reset ( int ichMin, int ichLim ) : void
ichMin int
ichLim int
Результат void
Пример #1
0
        private static HashSet <string> GetOwnees(byte[] xmlBytes)
        {
            var ownees       = new HashSet <string>();
            var ichEnd       = xmlBytes.Length;
            var objsurBounds = new ElementBounds(xmlBytes, s_tagsObjsur);

            while (objsurBounds.IsValid)
            {
                var type = objsurBounds.GetAttributeValue(s_tAttr);
                if (type == "o")
                {
                    var guid = objsurBounds.GetAttributeValue(s_guidAttr);
                    if (!String.IsNullOrEmpty(guid))
                    {
                        ownees.Add(guid.ToLowerInvariant());
                    }
                }
                objsurBounds.Reset(objsurBounds.EndTagOffset, ichEnd);
            }
            return(ownees);
        }
Пример #2
0
		private static HashSet<string> GetOwnees(byte[] xmlBytes)
		{
			var ownees = new HashSet<string>();
			var ichEnd = xmlBytes.Length;
			var objsurBounds = new ElementBounds(xmlBytes, s_tagsObjsur);
			while (objsurBounds.IsValid)
			{
				var type = objsurBounds.GetAttributeValue(s_tAttr);
				if (type == "o")
				{
					var guid = objsurBounds.GetAttributeValue(s_guidAttr);
					if (!String.IsNullOrEmpty(guid))
						ownees.Add(guid.ToLowerInvariant());
				}
				objsurBounds.Reset(objsurBounds.EndTagOffset, ichEnd);
			}
			return ownees;
		}
Пример #3
0
		private static List<string> GetAppliesToObjsurGuids(byte[] xmlBytes)
		{
			var retval = new List<string>();
			var indirectBounds = new ElementBounds(xmlBytes, s_tagsCmIndirect);
			if (!indirectBounds.IsValid)
				return retval;
			var appliesToBounds = new ElementBounds(xmlBytes, s_tagsAppliesTo,
				indirectBounds.BeginTagOffset, indirectBounds.EndTagOffset);
			var ichNext = appliesToBounds.BeginTagOffset + s_tagsAppliesTo.BeginTag.Length;
			var objsurBounds = new ElementBounds(xmlBytes, s_tagsObjsur,
				appliesToBounds.BeginTagOffset, appliesToBounds.EndTagOffset);
			while (objsurBounds.IsValid)
			{
				var guid = GetGuid(xmlBytes, objsurBounds.BeginTagOffset, objsurBounds.EndTagOffset);
				if (!String.IsNullOrEmpty(guid))
					retval.Add(guid.ToLowerInvariant());
				objsurBounds.Reset(objsurBounds.EndTagOffset, appliesToBounds.EndTagOffset);
			}
			return retval;
		}
Пример #4
0
		private static void RemoveMismatchedAppliesToRefs(byte[] xmlBytes, ICollection<string> appliesToGuids)
		{
			var cmIndirectBounds = new ElementBounds(xmlBytes, s_tagsCmIndirect);
			if (!cmIndirectBounds.IsValid)
				return;
			var appliesToBounds = new ElementBounds(xmlBytes, s_tagsAppliesTo,
				cmIndirectBounds.BeginTagOffset, cmIndirectBounds.EndTagOffset);
			if (!appliesToBounds.IsValid)
				return;
			var objsurBounds = new ElementBounds(xmlBytes, s_tagsObjsur,
				appliesToBounds.BeginTagOffset, appliesToBounds.EndTagOffset);
			while (objsurBounds.IsValid)
			{
				var ichMin = objsurBounds.BeginTagOffset;
				var guid = objsurBounds.GetAttributeValue(s_guidAttr);
				if (!String.IsNullOrEmpty(guid))
					guid = guid.ToLowerInvariant();
				objsurBounds.Reset(objsurBounds.EndTagOffset, appliesToBounds.EndTagOffset);
				if (!String.IsNullOrEmpty(guid) && !appliesToGuids.Contains(guid))
				{
					var ichLim = objsurBounds.BeginTagOffset;
					if (ichLim < 0)
						ichLim = appliesToBounds.EndTagOffset;
					// Remove the <objsur> element by overwriting it with spaces.
					for (var i = ichMin; i < ichLim; ++i)
						xmlBytes[i] = 0x20;
				}
			}
		}
Пример #5
0
		private static List<string> GetParagraphContentRuns(byte[] xmlStTxtPara, out List<string> writingSystems)
		{
			var retval = new List<string>();
			writingSystems = new List<string>();
			var stTxtParaBounds = new ElementBounds(xmlStTxtPara, s_tagsStTxtPara);
			var contentsBounds = new ElementBounds(xmlStTxtPara, s_tagsContents,
				stTxtParaBounds.BeginTagOffset, stTxtParaBounds.EndTagOffset);
			var strBounds = new ElementBounds(xmlStTxtPara, s_tagsStr,
				contentsBounds.BeginTagOffset, contentsBounds.EndTagOffset);
			if (!strBounds.IsValid)
				return retval;
			var runBounds = new ElementBounds(xmlStTxtPara, s_tagsRun,
				strBounds.BeginTagOffset, strBounds.EndTagOffset);
			while (runBounds.IsValid)
			{
				var ws = runBounds.GetAttributeValue(s_wsAttr);
				writingSystems.Add(ws);
				var ichText = runBounds.EndOfStartTag + 1;	// move past the >
				var runText = Encoding.UTF8.GetString(xmlStTxtPara, ichText, runBounds.EndTagOffset - ichText);
				retval.Add(XmlUtils.DecodeXmlAttribute(runText));
				runBounds.Reset(runBounds.EndTagOffset, contentsBounds.EndTagOffset);
			}
			return retval;
		}
Пример #6
0
		private static List<XElement> GetAStrElements(byte[] xmlBytes, int ichMin, int ichLim)
		{
			var retval = new List<XElement>();
			var astrBounds = new ElementBounds(xmlBytes, s_tagsAStr, ichMin, ichLim);
			while (astrBounds.IsValid)
			{
				var astr = Encoding.UTF8.GetString(xmlBytes, astrBounds.BeginTagOffset, astrBounds.Length);
				var xAStr = XElement.Parse(astr);
				retval.Add(xAStr);
				astrBounds.Reset(astrBounds.EndTagOffset, ichLim);
			}
			return retval;
		}
Пример #7
0
		private static ElementBounds GetEnglishCommentBounds(byte[] xmlBytes, int ichMin, int ichLim)
		{
			var commentBounds = new ElementBounds(xmlBytes, s_tagsComment, ichMin, ichLim);
			if (!commentBounds.IsValid)
				return null;
			var astrBounds = new ElementBounds(xmlBytes, s_tagsAStr,
				commentBounds.BeginTagOffset, commentBounds.EndTagOffset);
			while (astrBounds.IsValid)
			{
				var ws = astrBounds.GetAttributeValue(s_wsAttr);
				if (ws == "en")
					return astrBounds;
				astrBounds.Reset(astrBounds.EndTagOffset, commentBounds.EndTagOffset);
			}
			return null;
		}