static private bool DenormalizeMessenger <E>(ICard2 card, ITypedProperty <E> prop, int index) where E : ExtendibleEnum
        {
            string typeVal = prop.RawProperty.TextValue.Split(':').FirstOrDefault() ?? "Messenger";

            if (typeVal.Length > 1)
            {
                typeVal = typeVal.First().ToString().ToUpper() + typeVal.Substring(1); // Make first letter capital.
            }
            // Add "itemX.PROP" property.
            string applePropName = string.Format("item10{0}.IMPP", index);

            prop.RawProperty.Parameters.Add(new Parameter("X-SERVICE-TYPE", typeVal));

            card.AddProperty(applePropName, prop.RawProperty);

            // Add itemN.X-ABLabel property.

            string        appleLabelPropName = string.Format("item10{0}.X-ABLabel", index);
            ITextProperty appleLabelProp     = card.CreateTextProp(typeVal);

            appleLabelProp.RawProperty.SortIndex = prop.RawProperty.SortIndex;
            card.AddProperty(appleLabelPropName, appleLabelProp.RawProperty);

            return(true);
        }
 public override void Visit(ITextProperty property)
 {
     if (property.Name == "o_s_name")
     {
         property.CopyTo.Should().NotBeNull();
     }
 }
Ejemplo n.º 3
0
			public override void Visit(ITextProperty property)
			{
				if (property.Name == "o_s_name")
				{
					property.CopyTo.Should().NotBeNull();
				}
			}
Ejemplo n.º 4
0
        /// <exception cref="T:System.Reflection.AmbiguousMatchException">More than one of the requested attributes was found.</exception>
        /// <exception cref="T:System.TypeLoadException">A custom attribute type cannot be loaded.</exception>
        public override void Visit(ITextProperty type,
                                   PropertyInfo propertyInfo,
                                   ElasticsearchPropertyAttributeBase attribute)
        {
            // if a custom attribute has been applied, let it take precedence
            if (propertyInfo.GetCustomAttribute <ElasticsearchPropertyAttributeBase>() == null &&
                propertyInfo.PropertyType == typeof(string))
            {
                type.Fields = new Properties
                {
                    {
                        "keyword", new KeywordProperty
                        {
                            Normalizer = "case_insensitive",
                        }
                    },
                    {
                        "ngram", new TextProperty
                        {
                            Analyzer       = "edge_ngram_analyzer",
                            SearchAnalyzer = "edge_ngram_analyzer"
                        }
                    }
                };
                type.Analyzer       = "standard";
                type.SearchAnalyzer = "standard";
            }

            base.Visit(type, propertyInfo, attribute);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 访客模式
 /// </summary>
 public override void Visit(
     ITextProperty type,
     PropertyInfo propertyInfo,
     ElasticsearchPropertyAttributeBase attribute)
 {
     type.Type   = "keyword";
     type.Fields = null;
 }
        public override void Visit(ITextProperty property)
        {
            property.Should().NotBeNull();
            property.LocalMetadata.Should().NotBeNull();

            MetadataCount += property.LocalMetadata.Count;

            property.LocalMetadata.Should().Contain("Test", "TestValue");
        }
Ejemplo n.º 7
0
 public override void Visit(ITextProperty type, PropertyInfo propertyInfo, ElasticsearchPropertyAttributeBase attribute)
 {
     if (type.Type.ToString() == "string" & type.Index != null && type.Index.Value)
     {
         var properties = new Properties();
         properties.Add("sort", new TextProperty {
             Analyzer = "case_insensitive_sort"
         });
         type.Fields = properties;
     }
     base.Visit(type, propertyInfo, attribute);
 }
Ejemplo n.º 8
0
        public void auto_implement_interface()
        {
            RuntimeTypeBuilder typeBuilder = new RuntimeTypeBuilder("AutoImplenetInterface", typeof(BasePropertyClass));

            typeBuilder.AutoImplementInterface(typeof(ITextProperty));

            Type          newType     = typeBuilder.Create();
            ITextProperty newInstance = (ITextProperty)Activator.CreateInstance(newType);

            newInstance.Text = "test text";

            Assert.Equal("test text", newInstance.Text);
        }
        static private bool DenormalizeTypedProperty <E>(ICard2 card, ITypedProperty <E> prop, string propName, int index,
                                                         IEnumerable <string> supportedStandardTypes, IEnumerable <string> customLabelMetaTypes) where E : ExtendibleEnum
        {
            // Find first non-standard type param and move it to item2.X-ABLabel property.
            foreach (E type in prop.Types)
            {
                string typeVal = type.Name;
                if (supportedStandardTypes.Contains(typeVal.ToUpper()))
                {
                    continue; // No need to change, continue searching.
                }

                if (customLabelMetaTypes.Contains(typeVal.ToUpper()))
                {
                    // Must be converted to itemN.X-ABLabel:_$!<Other>!$_
                    typeVal = string.Format("_$!<{0}>!$_", typeVal);
                }

                // Remove this param value from TYPE.
                prop.Types = prop.Types.Where(x => x != type).ToArray();

                // Add "itemX.PROP" property.
                string applePropName = string.Format("item10{0}.{1}", index, propName);
                card.AddProperty(applePropName, prop.RawProperty);

                // Add itemN.X-ABLabel property.
                string        appleLabelPropName = string.Format("item10{0}.X-ABLabel", index);
                ITextProperty appleLabelProp     = card.CreateTextProp(typeVal);
                appleLabelProp.RawProperty.SortIndex = prop.RawProperty.SortIndex;
                card.AddProperty(appleLabelPropName, appleLabelProp.RawProperty);

                return(true);
            }

            return(false);
        }
Ejemplo n.º 10
0
 public virtual void Visit(ITextProperty type, PropertyInfo propertyInfo, ElasticsearchPropertyAttributeBase attribute)
 {
 }
Ejemplo n.º 11
0
#pragma warning restore 618
        public virtual void Visit(ITextProperty property)
        {
        }
Ejemplo n.º 12
0
 public void Visit(ITextProperty mapping)
 {
     Increment("text");
 }
Ejemplo n.º 13
0
		public virtual void Visit(ITextProperty type, PropertyInfo propertyInfo, ElasticsearchPropertyAttributeBase attribute)
		{
		}
 public override void Visit(ITextProperty property) => AddAlias(property);
Ejemplo n.º 15
0
#pragma warning restore 618
		public virtual void Visit(ITextProperty property) { }