Esempio n. 1
0
        private Task <string> GetHeaderAsync(TreeDefinition treeModel, List <TreeEntry> data, TreeSetup setup)
        {
            HtmlBuilder hb = new HtmlBuilder();

            if (treeModel.ShowHeader)
            {
                PropertyData prop = ObjectSupport.GetPropertyData(treeModel.RecordType, nameof(TreeEntry.Text));
                // Caption
                string caption = treeModel.Header.ToString();
                if (string.IsNullOrWhiteSpace(caption))
                {
                    caption = prop.GetCaption(null);
                }
                // Description
                string description = treeModel.HeaderTooltip.ToString();
                if (string.IsNullOrWhiteSpace(description))
                {
                    description = prop.GetDescription(null);
                }

                string alignCss = "tg_left";

                // Render column header
                hb.Append($@"
    <div class='{alignCss} tg_header{(treeModel.UseSkinFormatting ? " ui-state-default" : "")}' {Basics.CssTooltip}='{HAE(description ?? "")}'>
        <span>{HE(caption)}</span>
    </div>");
            }
            return(Task.FromResult(hb.ToString()));
        }
Esempio n. 2
0
            /// <summary>
            /// Add all string properties of an object as search terms.
            /// </summary>
            public void AddObjectContents(object searchObject)
            {
                if (searchObject == null)
                {
                    return;
                }
                Type tp = searchObject.GetType();

                foreach (var propData in ObjectSupport.GetPropertyData(tp))
                {
                    if (propData.PropInfo.CanRead && propData.PropInfo.CanWrite)
                    {
                        if (propData.PropInfo.PropertyType == typeof(string))
                        {
                            string s = (string)propData.PropInfo.GetValue(searchObject, null);
                            AddContent(s);
                        }
                        else if (propData.PropInfo.PropertyType == typeof(MultiString))
                        {
                            MultiString ms = (MultiString)propData.PropInfo.GetValue(searchObject, null);
                            AddContent(ms);
                        }
                    }
                }
            }
Esempio n. 3
0
 // returns all properties for an object that have a description, in sorted order
 private IEnumerable <PropertyData> GetProperties(Type objType)
 {
     return(from property in ObjectSupport.GetPropertyData(objType)
            where property.Description != null   // This means it has to be a DescriptionAttribute (not a resource redirect)
            orderby property.Order
            select property);
 }
Esempio n. 4
0
            protected override IList <JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
            {
                IList <JsonProperty> properties = base.CreateProperties(type, memberSerialization);

                if (type != typeof(object))
                {
                    List <string>       propList = new List <string>();
                    List <PropertyData> props    = ObjectSupport.GetPropertyData(type);
                    foreach (PropertyData prop in props)
                    {
                        if (prop.Name.StartsWith("__") || (prop.PropInfo.CanRead && prop.PropInfo.CanWrite))
                        {
                            propList.Add(prop.Name);
                        }
                    }
                    properties = (from p in properties where propList.Contains(p.PropertyName) select p).ToList();
                }
                return(properties);
            }
Esempio n. 5
0
        internal static List <PropertyListEntry> GetHiddenProperties(object obj)
        {
            List <PropertyListEntry> properties = new List <PropertyListEntry>();
            List <PropertyData>      props      = ObjectSupport.GetPropertyData(obj.GetType());

            foreach (var prop in props)
            {
                if (!prop.PropInfo.CanRead)
                {
                    continue;
                }
                if (prop.UIHint != "Hidden")
                {
                    continue;
                }
                properties.Add(new PropertyListEntry(prop.Name, prop.GetPropertyValue <object>(obj), "Hidden", false, false, null, null, false, null, SubmitFormOnChangeAttribute.SubmitTypeEnum.None));
            }
            return(properties);
        }