示例#1
0
    public void KindPropertyTest2()
    {
        const Enums.VCdKind kind = Enums.VCdKind.Application;

        var prop = new KindProperty(kind, GROUP);

        var vcard = new VCard
        {
            Kind = prop
        };

        string s = vcard.ToVcfString(Enums.VCdVersion.V4_0);

        IList <VCard> list = VCard.ParseVcf(s);

        Assert.IsNotNull(list);
        Assert.AreEqual(1, list.Count);

        vcard = list[0];

        Assert.IsNotNull(vcard.Kind);

        prop = vcard.Kind;

        Assert.AreEqual(kind, prop !.Value);
        Assert.AreEqual(GROUP, prop.Group);
        Assert.IsFalse(prop.IsEmpty);
    }
示例#2
0
        public static string GetName(KindProperty related, int index)
        {
            switch (related)
            {
            case KindProperty.STR:
            case KindProperty.SUGGESTION:
                return(Enum.GetName(typeof(StringRelated), index));

            case KindProperty.NUM64:
            case KindProperty.NUM32:
                return(Enum.GetName(typeof(NumRelated), index));

            case KindProperty.DBL:
                return(Enum.GetName(typeof(DoubleRelated), index));

            case KindProperty.BOOL:
                return(Enum.GetName(typeof(BoolRelated), index));

            case KindProperty.GEO:
                return(Enum.GetName(typeof(GeoRelated), index));

            case KindProperty.ENUM:
                return(Enum.GetName(typeof(EnumRelated), index));

            default:
                return(Enum.GetName(typeof(DateRelated), index));
            }
        }
示例#3
0
    public void KindPropertyTest1()
    {
        const Enums.VCdKind kind = Enums.VCdKind.Application;

        var prop = new KindProperty(kind, GROUP);

        Assert.AreEqual(kind, prop.Value);
        Assert.AreEqual(GROUP, prop.Group);
        Assert.IsFalse(prop.IsEmpty);
    }
示例#4
0
        /// <summary>
        /// Busqueda en el diccionario
        /// </summary>
        /// <param name="property">Propiedades de las entidades</param>
        /// <param name="index">Index de las entidades</param>
        /// <returns></returns>
        public EntitySearchDisplayInfo GetInfoFromProperty(KindProperty property, int index)
        {
            var indexName = ResourcesHelper.GetName(property, index);

            var rm = ResourcesHelper.GetResourceCollection(property);

            var info = new EntitySearchDisplayInfo
            {
                Title       = new ResourceManager(rm.Titles).GetString(indexName),
                Column      = rm.Columns == null ? null : new ResourceManager(rm.Columns).GetString(indexName),
                Description = new ResourceManager(rm.Descriptions).GetString(indexName),
                ShortName   = new ResourceManager(rm.ShortNames).GetString(indexName),
            };

            if (info.Title == null && info.Column == null && info.Description == null || info.ShortName == null)
            {
                return(null);
            }

            return(info);
        }
示例#5
0
            public static ValueContainer <T> GetPrimitiveValues <T>(object input, bool isEntity = false, KindProperty kindProperty = KindProperty.BOOL)
            {
                var values = Reflection.Attributes.GetPropertiesByAttributeWithValue(input);


                var valuesWithoutLocals = values.Where(s => Mdm.Reflection.IsPrimitiveAndCollection(s.Value.GetType()) || s.Value.GetType().IsEnum);


                if (isEntity)
                {
                    return(GetValueContainer <T>(valuesWithoutLocals.Where(g => g.Key.IsEntity)));
                }

                return(GetValueContainer <T>(valuesWithoutLocals.Where(g => !g.Key.IsEntity && g.Key.KindIndex == (int)kindProperty)));
            }
示例#6
0
        public static ResourceModel GetResourceCollection(KindProperty related)
        {
            switch (related)
            {
            case KindProperty.STR:
            case KindProperty.SUGGESTION:
                return(new ResourceModel
                {
                    Columns = typeof(string_columns),
                    Titles = typeof(string_titles),
                    Descriptions = typeof(string_descriptions),
                    ShortNames = typeof(string_snames),
                    PlaceHolders = typeof(string_placeholders),
                });

            case KindProperty.NUM32:
            case KindProperty.NUM64:
                return(new ResourceModel
                {
                    Columns = typeof(num_columns),
                    Titles = typeof(num_titles),
                    Descriptions = typeof(num_descriptions),
                    ShortNames = typeof(num_snames),
                    PlaceHolders = typeof(num_placeholders)
                });

            case KindProperty.DBL:
                return(new ResourceModel
                {
                    Columns = typeof(double_columns),
                    Titles = typeof(double_titles),
                    Descriptions = typeof(double_descriptions),
                    ShortNames = typeof(double_snames),
                    PlaceHolders = typeof(double_placeholders),
                });

            case KindProperty.BOOL:
                return(new ResourceModel
                {
                    Columns = typeof(boolean_columns),
                    Titles = typeof(boolean_titles),
                    Descriptions = typeof(boolean_descriptions),
                    ShortNames = typeof(boolean_snames),
                    PlaceHolders = typeof(boolean_placeholder)
                });

            case KindProperty.GEO:
                return(new ResourceModel
                {
                    Columns = typeof(geo_columns),
                    Titles = typeof(geo_titles),
                    Descriptions = typeof(geo_descriptions),
                    ShortNames = typeof(geo_snames),
                    PlaceHolders = typeof(geo_placeholders),
                });

            case KindProperty.ENUM:
                return(new ResourceModel
                {
                    Columns = typeof(enum_columns),
                    Titles = typeof(enum_titles),
                    Descriptions = typeof(enum_descriptions),
                    ShortNames = typeof(enum_snames),
                    PlaceHolders = typeof(enum_placeholders),
                });

            default:
                return(new ResourceModel
                {
                    Columns = typeof(date_columns),
                    Titles = typeof(date_titles),
                    Descriptions = typeof(date_descriptions),
                    ShortNames = typeof(date_snames),
                    PlaceHolders = typeof(date_placeholders),
                });
            }
        }
示例#7
0
 set => SetValue(KindProperty, value);
                    /// <summary>
                    /// Obtiene todas las propiedades del tipo que se le indique para un objeto
                    /// estos tipos son de valor (str,num32, enum, geo, etc.)
                    /// Desde esta se especializan otro métodos
                    /// las propiedades conformar un entitySearch, base del modelo MDM.
                    /// </summary>
                    /// <typeparam name="T">Tipo de valor la propiedad</typeparam>
                    /// <param name="related">Tipo de propiedad</param>
                    /// <param name="elements">metadata y datos de un objeto</param>
                    /// <param name="castGeoToSearch">Función para convertir el elemento geo de la clase a la de la entidad de busqueda</param>
                    /// <returns>listado de propiedades de un tipo</returns>

                    public static IEnumerable <T2_Cast> GetPropertiesObjects <T, T2_Cast>(KindProperty related, Dictionary <BaseIndexAttribute, object> elements, Func <object, T> castGeoToSearch = null) where T2_Cast : IProperty <T>
                    {
                        var array = elements.Where(s => !s.Key.IsEntity && s.Key.KindIndex == (int)related).SelectMany(s => GetArrayOfElements <T>(s, typeof(T2_Cast), castGeoToSearch)).ToList();

                        return(!array.Any() ? Array.Empty <T2_Cast>() : array.Cast <T2_Cast>());
                    }
示例#9
0
    protected override void AppendKind(KindProperty value)
    {
        Debug.Assert(value != null);

        BuildProperty(VCard.PropKeys.KIND, value);
    }
示例#10
0
 /// <summary>
 /// Copy ctor
 /// </summary>
 /// <param name="prop"></param>
 private KindProperty(KindProperty prop) : base(prop)
     => Value = prop.Value;
示例#11
0
            /// <summary>
            /// Entrega la documentación de acuerdo al tipo de propiedad y su índice.
            /// </summary>
            /// <param name="mainDoc">Documentación del modelo.</param>
            /// <param name="kindProperty">Tipo de propiedad.</param>
            /// <param name="index">índice de la propiedad.</param>
            /// <returns>Info con la documentación.</returns>
            public static EntitySearchDisplayInfo GetDisplayInfoProp(MainDocumentation mainDoc, KindProperty kindProperty, int index)
            {
                // devuelve de acuerdo al índice y el tipo.
                switch (kindProperty)
                {
                case KindProperty.STR:
                    return(mainDoc.Strs[index]);

                case KindProperty.SUGGESTION:
                    return(mainDoc.Strs[index]);

                case KindProperty.NUM64 | KindProperty.NUM32:
                    return(mainDoc.Nums[index]);

                case KindProperty.DBL:
                    return(mainDoc.Dbls[index]);

                case KindProperty.BOOL:
                    return(mainDoc.Bools[index]);

                case KindProperty.GEO:
                    return(mainDoc.Geos[index]);

                case KindProperty.ENUM:
                    return(mainDoc.Enums[index]);

                case KindProperty.DATE:
                    return(mainDoc.Dates[index]);

                default:
                    throw new CustomException("Bad ENUM");
                }
            }