/// ------------------------------------------------------------------------------------
 /// <summary>
 /// Mini constructor (used for testing)
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public ImportMappingInfo(string beginMarker, string endMarker, bool isExcluded,
                          MappingTargetType mappingTarget, MarkerDomain domain, string styleName,
                          string wsId)
     : this(beginMarker, endMarker, isExcluded, mappingTarget,
            domain, styleName, wsId, null)
 {
 }
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Mega constructor with style name
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public ImportMappingInfo(string beginMarker, string endMarker, bool isExcluded,
                          MappingTargetType mappingTarget, MarkerDomain domain, string styleName,
                          string wsId, ICmAnnotationDefn noteType) :
     this(beginMarker, endMarker, isExcluded, mappingTarget, domain, styleName,
          wsId, noteType, false, ImportDomain.Main /*This will be ignored*/)
 {
 }
Exemplo n.º 3
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Mega constructor with style name
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public ImportMappingInfo(string beginMarker, string endMarker, bool isExcluded,
			MappingTargetType mappingTarget, MarkerDomain domain, string styleName,
			string wsId, ICmAnnotationDefn noteType) :
			this(beginMarker, endMarker, isExcluded, mappingTarget, domain, styleName,
			wsId, noteType, false, ImportDomain.Main /*This will be ignored*/)
		{
		}
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Mega constructor with style
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public ImportMappingInfo(string beginMarker, string endMarker, bool isExcluded,
                          MappingTargetType mappingTarget, MarkerDomain domain, IStStyle style,
                          string wsId, ICmAnnotationDefn noteType) :
     this(beginMarker, endMarker, isExcluded, mappingTarget, domain,
          style == null ? null : style.Name, wsId, noteType)
 {
     m_style = style;
 }
Exemplo n.º 5
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Mega constructor with style
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public ImportMappingInfo(string beginMarker, string endMarker, bool isExcluded,
			MappingTargetType mappingTarget, MarkerDomain domain, IStStyle style,
			string wsId, ICmAnnotationDefn noteType) :
			this(beginMarker, endMarker, isExcluded, mappingTarget, domain,
			style == null ? null : style.Name, wsId, noteType)
		{
			m_style = style;
		}
Exemplo n.º 6
0
 public override int GetHashCode()
 {
     unchecked
     {
         var result = (MappingSourceType != null ? MappingSourceType.GetHashCode() : 0);
         result = (result * 397) ^ (MappingTargetType != null ? MappingTargetType.GetHashCode() : 0);
         result = (result * 397) ^ (MapIntoExistingTargetInstance.GetHashCode());
         return(result);
     }
 }
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="copy"></param>
 /// ------------------------------------------------------------------------------------
 public ImportMappingInfo(ImportMappingInfo copy)
 {
     m_beginMarker   = copy.m_beginMarker;
     m_endMarker     = copy.m_endMarker;
     m_isExcluded    = copy.m_isExcluded;
     m_mappingTarget = copy.m_mappingTarget;
     m_domain        = copy.m_domain;
     m_styleName     = copy.m_styleName;
     m_style         = copy.m_style;
     m_wsId          = copy.m_wsId;
     m_noteType      = copy.m_noteType;
 }
Exemplo n.º 8
0
		/// ----------------------------------------------------------------------------------------
		/// <summary>Constructor</summary>
		/// ----------------------------------------------------------------------------------------
		public MappingInfo(string beginMarker, string endMarker, bool isInline,
			string dataEncoding, MarkerDomain domain,string styleName, string ws,
			bool isExcluded, MappingTargetType mappingTarget)
		{
			this.beginMarker = beginMarker;
			this.endMarker = endMarker;
			this.isInline = isInline;
			this.dataEncoding = dataEncoding;
			this.domain = domain;
			this.styleName = styleName;
			this.ws = ws;
			this.isExcluded = isExcluded;
			this.mappingTarget = mappingTarget;
		}
Exemplo n.º 9
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Mega constructor with style name
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public ImportMappingInfo(string beginMarker, string endMarker, bool isExcluded,
                          MappingTargetType mappingTarget, MarkerDomain domain, string styleName,
                          string icuLocale, ICmAnnotationDefn noteType, bool isInUse, ImportDomain importDomain)
 {
     m_beginMarker   = beginMarker;
     m_endMarker     = endMarker;
     m_isExcluded    = isExcluded;
     m_mappingTarget = mappingTarget;
     m_domain        = domain;
     m_styleName     = styleName;
     m_style         = null;
     m_icuLocale     = icuLocale;
     m_noteType      = noteType;
     if (isInUse)
     {
         m_inUse[ScrImportSet.CreateImportSourceKey(importDomain, icuLocale,
                                                    noteType == null ? 0 : noteType.Hvo)] = isInUse;
     }
 }
Exemplo n.º 10
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Mega constructor with style name
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public ImportMappingInfo(string beginMarker, string endMarker, bool isExcluded,
                          MappingTargetType mappingTarget, MarkerDomain domain, string styleName,
                          string wsId, ICmAnnotationDefn noteType, bool isInUse, ImportDomain importDomain)
 {
     m_beginMarker   = beginMarker;
     m_endMarker     = endMarker;
     m_isExcluded    = isExcluded;
     m_mappingTarget = mappingTarget;
     m_domain        = domain;
     m_styleName     = styleName;
     m_style         = null;
     m_wsId          = wsId;
     m_noteType      = noteType;
     if (isInUse)
     {
         m_inUse[ScriptureServices.CreateImportSourceKey(importDomain, wsId,
                                                         noteType)] = isInUse;
     }
 }
Exemplo n.º 11
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Mega constructor with style name
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public ImportMappingInfo(string beginMarker, string endMarker, bool isExcluded,
			MappingTargetType mappingTarget, MarkerDomain domain, string styleName,
			string wsId, ICmAnnotationDefn noteType, bool isInUse, ImportDomain importDomain)
		{
			m_beginMarker = beginMarker;
			m_endMarker = endMarker;
			m_isExcluded = isExcluded;
			m_mappingTarget = mappingTarget;
			m_domain = domain;
			m_styleName = styleName;
			m_style = null;
			m_wsId = wsId;
			m_noteType = noteType;
			if (isInUse)
			{
				m_inUse[ScriptureServices.CreateImportSourceKey(importDomain, wsId,
					noteType)] = isInUse;
			}
		}
Exemplo n.º 12
0
        public int CompareTo(MappingInfo other)
        {
            if (other == null)
            {
                return(1);
            }
            if (ReferenceEquals(other, this))
            {
                return(0);
            }
            var result = MappingSourceType.ToString().CompareTo(other.MappingSourceType.ToString());

            if (result != 0)
            {
                return(result);
            }
            result = MappingTargetType.ToString().CompareTo(other.MappingTargetType.ToString());
            if (result != 0)
            {
                return(result);
            }
            result = mapIntoExistingTargetInstance.CompareTo(other.mapIntoExistingTargetInstance);
            return(result);
        }
Exemplo n.º 13
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Determine the default mapping for the given marker
		/// </summary>
		/// <param name="marker">The begin marker</param>
		/// <param name="styleName">The stylename, or null (output)</param>
		/// <param name="excluded">Flag indicating whether data marked up with this marker
		/// should be excluded (output)</param>
		/// <param name="target">Target type (output)</param>
		/// <param name="markerDomain"></param>
		/// <returns><c>true</c> if a default mapping was found for the given marker;
		/// <c>false</c> otherwise.</returns>
		/// ------------------------------------------------------------------------------------
		private bool GetDefaultMapping(string marker, out string styleName, out bool excluded,
			out MappingTargetType target, ref MarkerDomain markerDomain)
		{
			styleName = null;
			excluded = false;
			target = MappingTargetType.TEStyle;

			if (s_defaultMappings.ContainsKey(marker))
			{
				styleName = s_defaultMappings[marker];
				markerDomain = ScrMarkerMapping.GetDefaultDomainForStyle(m_stylesheet, styleName);
				return true;
			}
			if (s_defaultExclusions.ContainsKey(marker))
			{
				excluded = true;
				return true;
			}
			if (s_defaultProperties.ContainsKey(marker))
			{
				switch(s_defaultProperties[marker])
				{
					case "Figure":
						target = MappingTargetType.Figure;
						return true;

					case "FigureCaption":
						target = MappingTargetType.FigureCaption;
						return true;

					case "FigureCopyright":
						target = MappingTargetType.FigureCopyright;
						return true;

					case "FigureDescription":
						target = MappingTargetType.FigureDescription;
						return true;

					case "FigureFilename":
						target = MappingTargetType.FigureFilename;
						return true;

					case "FigureLayoutPosition":
						target = MappingTargetType.FigureLayoutPosition;
						return true;

					case "FigureRefRange":
						target = MappingTargetType.FigureRefRange;
						return true;

					case "FigureScale":
						target = MappingTargetType.FigureScale;
						return true;

					case "ChapterLabel":
						target = MappingTargetType.ChapterLabel;
						return true;

					case "TitleShort":
						target = MappingTargetType.TitleShort;
						return true;

					case "DefaultParagraphCharacters":
						target = MappingTargetType.TEStyle;
						styleName = FdoResources.DefaultParaCharsStyleName;
						return true;

					case "DefaultFootnoteCharacters":
						target = MappingTargetType.TEStyle;
						styleName = FdoResources.DefaultParaCharsStyleName;
						markerDomain = MarkerDomain.Footnote;
						return true;
				}
			}
			return false;
		}
		public override Dictionary<string, List<string>> MapDocumentFieldsToType(Type type, MappingTargetType target, IEnumerable<string> documentFieldNames)
		{
			return _innerTranslator.MapDocumentFieldsToType(type, target, documentFieldNames);
		}
 public override Dictionary <string, List <string> > MapFieldsToType(IEnumerable <string> fieldNames, Type type, MappingTargetType target)
 {
     return(_innerTranslator.MapFieldsToType(fieldNames, type, target));
 }
Exemplo n.º 16
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Verify the next mapping in the collection that was created in the database
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void VerifyNextMapping(IEnumerator<IScrMarkerMapping> mappings, string beginMarker, string endMarker,
			MarkerDomain domain, string styleName, string ws, bool excluded, MappingTargetType target)
		{
			Assert.IsTrue(mappings.MoveNext());
			IScrMarkerMapping mapping = mappings.Current;

			Assert.AreEqual(beginMarker, mapping.BeginMarker, "Begin marker did not match for marker " + beginMarker);
			Assert.AreEqual(endMarker, mapping.EndMarker, "End marker did not match for marker " + beginMarker);
			Assert.AreEqual(domain, (MarkerDomain)mapping.Domain, "Domain did not match for marker " + beginMarker);
			if (styleName != null)
				Assert.AreEqual(styleName, mapping.StyleRA.Name, "Style name did not match for marker " + beginMarker);
			else
				Assert.IsNull(mapping.StyleRA, "Style should not have been set for marker " + beginMarker);
			Assert.AreEqual(ws, mapping.WritingSystem, "Writing system did not match for marker " + beginMarker);
			Assert.AreEqual(excluded, mapping.Excluded, "Excluded state was wrong for marker " + beginMarker);
			Assert.AreEqual(target, (MappingTargetType)mapping.Target, "Mapping target type did not match for marker " + beginMarker);
		}
Exemplo n.º 17
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Mega constructor with style name
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public ImportMappingInfo(string beginMarker, string endMarker, bool isExcluded,
			MappingTargetType mappingTarget, MarkerDomain domain, string styleName,
			string icuLocale, ICmAnnotationDefn noteType, bool isInUse, ImportDomain importDomain)
		{
			m_beginMarker = beginMarker;
			m_endMarker = endMarker;
			m_isExcluded = isExcluded;
			m_mappingTarget = mappingTarget;
			m_domain = domain;
			m_styleName = styleName;
			m_style = null;
			m_icuLocale = icuLocale;
			m_noteType = noteType;
			if (isInUse)
			{
				m_inUse[ScrImportSet.CreateImportSourceKey(importDomain, icuLocale,
					noteType == null ? 0 : noteType.Hvo)] = isInUse;
			}
		}
Exemplo n.º 18
0
 public override Dictionary <string, List <string> > MapDocumentFieldsToType(Type type, MappingTargetType target, IEnumerable <string> documentFieldNames)
 {
     throw new NotImplementedException();
 }
 public override Dictionary<string, List<string>> MapDocumentFieldsToType(Type type, MappingTargetType target, IEnumerable<string> documentFieldNames)
 {
     if (target == MappingTargetType.Indexer)
         return this.MapDocumentFieldsToTypeIndexer(type, documentFieldNames);
     if (target == MappingTargetType.Properties)
         return this.MapDocumentFieldsToTypeProperties(type, documentFieldNames);
     throw new ArgumentException("Invalid mapping target type: " + (object)target, "target");
 }
Exemplo n.º 20
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Determine the default mapping for the given marker
        /// </summary>
        /// <param name="marker">The begin marker</param>
        /// <param name="styleName">The stylename, or null (output)</param>
        /// <param name="excluded">Flag indicating whether data marked up with this marker
        /// should be excluded (output)</param>
        /// <param name="target">Target type (output)</param>
        /// <param name="markerDomain"></param>
        /// <returns><c>true</c> if a default mapping was found for the given marker;
        /// <c>false</c> otherwise.</returns>
        /// ------------------------------------------------------------------------------------
        private bool GetDefaultMapping(string marker, out string styleName, out bool excluded,
                                       out MappingTargetType target, ref MarkerDomain markerDomain)
        {
            styleName = null;
            excluded  = false;
            target    = MappingTargetType.TEStyle;

            if (s_defaultMappings.ContainsKey(marker))
            {
                styleName    = s_defaultMappings[marker];
                markerDomain = ScriptureServices.GetDefaultDomainForStyle(m_stylesheet, styleName);
                return(true);
            }
            if (s_defaultExclusions.ContainsKey(marker))
            {
                excluded = true;
                return(true);
            }
            if (s_defaultProperties.ContainsKey(marker))
            {
                switch (s_defaultProperties[marker])
                {
                case "Figure":
                    target = MappingTargetType.Figure;
                    return(true);

                case "FigureCaption":
                    target = MappingTargetType.FigureCaption;
                    return(true);

                case "FigureCopyright":
                    target = MappingTargetType.FigureCopyright;
                    return(true);

                case "FigureDescription":
                    target = MappingTargetType.FigureDescription;
                    return(true);

                case "FigureFilename":
                    target = MappingTargetType.FigureFilename;
                    return(true);

                case "FigureLayoutPosition":
                    target = MappingTargetType.FigureLayoutPosition;
                    return(true);

                case "FigureRefRange":
                    target = MappingTargetType.FigureRefRange;
                    return(true);

                case "FigureScale":
                    target = MappingTargetType.FigureScale;
                    return(true);

                case "ChapterLabel":
                    target = MappingTargetType.ChapterLabel;
                    return(true);

                case "TitleShort":
                    target = MappingTargetType.TitleShort;
                    return(true);

                case "DefaultParagraphCharacters":
                    target    = MappingTargetType.TEStyle;
                    styleName = ResourceHelper.DefaultParaCharsStyleName;
                    return(true);

                case "DefaultFootnoteCharacters":
                    target       = MappingTargetType.TEStyle;
                    styleName    = ResourceHelper.DefaultParaCharsStyleName;
                    markerDomain = MarkerDomain.Footnote;
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 21
0
        public override Dictionary <string, List <string> > MapDocumentFieldsToType(Type type, MappingTargetType target, IEnumerable <string> documentFieldNames)
        {
            switch (target)
            {
            case MappingTargetType.Anything:
                Dictionary <string, List <string> > dictionary = new Dictionary <string, List <string> >();
                Action <Dictionary <string, List <string> >, Dictionary <string, List <string> > > action = (Action <Dictionary <string, List <string> >, Dictionary <string, List <string> > >)((result, map) =>
                {
                    foreach (KeyValuePair <string, List <string> > keyValuePair in map)
                    {
                        if (keyValuePair.Value != null && keyValuePair.Value.Count != 0)
                        {
                            List <string> list;
                            if (!result.TryGetValue(keyValuePair.Key, out list))
                            {
                                result[keyValuePair.Key] = list = new List <string>();
                            }
                            list.AddRange(keyValuePair.Value.Where <string>((Func <string, bool>)(l => !list.Contains(l))));
                        }
                    }
                });
                action(dictionary, this.MapDocumentFieldsToTypeIndexer(type, documentFieldNames));
                action(dictionary, this.MapDocumentFieldsToTypeProperties(type, documentFieldNames));
                return(dictionary);

            case MappingTargetType.Indexer:
                return(this.MapDocumentFieldsToTypeIndexer(type, documentFieldNames));

            case MappingTargetType.Properties:
                return(this.MapDocumentFieldsToTypeProperties(type, documentFieldNames));

            default:
                throw new ArgumentException("Invalid mapping target type: " + (object)target, nameof(target));
            }
        }
 public override Dictionary <string, List <string> > MapDocumentFieldsToType(Type type, MappingTargetType target, IEnumerable <string> documentFieldNames)
 {
     return(_innerTranslator.MapDocumentFieldsToType(type, target, documentFieldNames));
 }
Exemplo n.º 23
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Copy constructor
		/// </summary>
		/// <param name="copy"></param>
		/// ------------------------------------------------------------------------------------
		public ImportMappingInfo(ImportMappingInfo copy)
		{
			m_beginMarker = copy.m_beginMarker;
			m_endMarker = copy.m_endMarker;
			m_isExcluded = copy.m_isExcluded;
			m_mappingTarget = copy.m_mappingTarget;
			m_domain = copy.m_domain;
			m_styleName = copy.m_styleName;
			m_style = copy.m_style;
			m_wsId = copy.m_wsId;
			m_noteType = copy.m_noteType;
		}
Exemplo n.º 24
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Mini constructor (used for testing)
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public ImportMappingInfo(string beginMarker, string endMarker, bool isExcluded,
			MappingTargetType mappingTarget, MarkerDomain domain, string styleName,
			string wsId)
			: this(beginMarker, endMarker, isExcluded, mappingTarget,
				domain, styleName, wsId, null)
		{
		}