private FilterColumnProfile[] GetFilterProfile(IEnumerable <XElement> query, string filterObjectSchemaTypeName)
        {
            List <FilterColumnProfile> list = new List <FilterColumnProfile>();

            foreach (XElement xelement in query)
            {
                string text  = (string)xelement.Attribute("Name");
                Type   type  = this.HasValue(xelement.Attribute("ColumnType")) ? ObjectSchemaLoader.GetTypeByString((string)xelement.Attribute("ColumnType")) : null;
                string text2 = (string)xelement.Attribute("Operators");
                string value = (string)xelement.Attribute("FormatMode");
                string text3 = this.HasValue(xelement.Attribute("ObjectSchemaField")) ? ((string)xelement.Attribute("ObjectSchemaField")) : text;
                ProviderPropertyDefinition providerPropertyDefinition = (type == null) ? ((ProviderPropertyDefinition)ObjectSchemaLoader.GetStaticField(filterObjectSchemaTypeName, text3)) : FilterControlHelper.GenerateEmptyPropertyDefinition(text3, type);
                List <FilterColumnProfile> list2 = list;
                FilterColumnProfile        filterColumnProfile = new FilterColumnProfile();
                filterColumnProfile.ColumnType           = type;
                filterColumnProfile.FilterableListSource = this.GetFilterableListSource(providerPropertyDefinition.Type, (string)xelement.Attribute("FilterableListSource"));
                FilterColumnProfile      filterColumnProfile2 = filterColumnProfile;
                PropertyFilterOperator[] operators;
                if (!string.IsNullOrEmpty(text2))
                {
                    operators = (from opera in text2.Split(new char[]
                    {
                        ','
                    })
                                 select(PropertyFilterOperator) Enum.Parse(typeof(PropertyFilterOperator), opera)).ToArray <PropertyFilterOperator>();
                }
                else
                {
                    operators = FilterControlHelper.GetFilterOperators(providerPropertyDefinition.Type);
                }
                filterColumnProfile2.Operators         = operators;
                filterColumnProfile.DisplayMember      = (string)xelement.Attribute("DisplayMember");
                filterColumnProfile.FormatMode         = (string.IsNullOrEmpty(value) ? 0 : ((DisplayFormatMode)Enum.Parse(typeof(DisplayFormatMode), value)));
                filterColumnProfile.Name               = text;
                filterColumnProfile.PickerProfile      = (string)xelement.Attribute("PickerProfile");
                filterColumnProfile.ValueMember        = (string)xelement.Attribute("ValueMember");
                filterColumnProfile.PropertyDefinition = ((providerPropertyDefinition.Name == text) ? providerPropertyDefinition : FilterControlHelper.CopyPropertyDefinition(text, providerPropertyDefinition));
                filterColumnProfile.RefDisplayedColumn = (this.HasValue(xelement.Attribute("RefDisplayedColumn")) ? ((string)xelement.Attribute("RefDisplayedColumn")) : text);
                list2.Add(filterColumnProfile);
            }
            return(list.ToArray());
        }
        private UIPresentationProfile CreateUIPresentationProfile(XElement po, XElement configuration)
        {
            UIPresentationProfile result;

            if (configuration == null)
            {
                result = new UIPresentationProfile();
            }
            else
            {
                IEnumerable <XElement> query = configuration.Elements("DisplayedColumns").Elements("RefColumns").SelectMany((XElement r) => (from c in po.Element("RefColumnsSection").Elements("RefColumns")
                                                                                                                                             where c.Attribute("Name").Value == r.Attribute("Name").Value
                                                                                                                                             select c).Elements("Column")).Union(configuration.Elements("DisplayedColumns").Elements("Column"));
                FilterColumnProfile[] filterColumnCollection = new FilterColumnProfile[0];
                ObjectSchema          filterObjectSchema     = null;
                FilterLanguage        filterLanguage         = FilterLanguage.Ado;
                XElement xelement = configuration.Element("FilterColumns");
                if (this.HasValue(xelement))
                {
                    string text = (string)xelement.Attribute("ObjectSchema");
                    filterColumnCollection = this.GetFilterProfile(xelement.Elements("Column"), text);
                    filterObjectSchema     = ObjectSchema.GetInstance(ObjectSchemaLoader.GetTypeByString(text));
                    filterLanguage         = (this.HasValue(xelement.Attribute("FilterLanguage")) ? ((FilterLanguage)Enum.Parse(typeof(FilterLanguage), (string)xelement.Attribute("FilterLanguage"))) : FilterLanguage.Ado);
                }
                result = new UIPresentationProfile(this.GetColumnProfile(query), filterColumnCollection)
                {
                    DisplayName          = this.GetLocalizedString(configuration.Element("Caption").Value),
                    HideIcon             = (this.HasValue(configuration.Element("HideIcon")) && string.Equals("true", (string)configuration.Element("HideIcon"), StringComparison.InvariantCultureIgnoreCase)),
                    ImageProperty        = (this.HasValue(configuration.Element("ImageColumn")) ? configuration.Element("ImageColumn").Value : string.Empty),
                    UseTreeViewForm      = (this.HasValue(configuration.Element("UseTreeView")) && bool.Parse((string)configuration.Element("UseTreeView"))),
                    SortProperty         = (this.HasValue(configuration.Element("SortProperty")) ? configuration.Element("SortProperty").Value : string.Empty),
                    HelpTopic            = (this.HasValue(configuration.Element("HelpTopic")) ? configuration.Element("HelpTopic").Value : string.Empty),
                    ScopeSupportingLevel = (this.HasValue(configuration.Element("ScopeSupportingLevel")) ? ((ScopeSupportingLevel)Enum.Parse(typeof(ScopeSupportingLevel), (string)configuration.Element("ScopeSupportingLevel"))) : ScopeSupportingLevel.NoScoping),
                    FilterObjectSchema   = filterObjectSchema,
                    FilterLanguage       = filterLanguage,
                    SerializationLevel   = (this.HasValue(configuration.Element("SerializationLevel")) ? ((ExchangeRunspaceConfigurationSettings.SerializationLevel)Enum.Parse(typeof(ExchangeRunspaceConfigurationSettings.SerializationLevel), (string)configuration.Element("SerializationLevel"))) : ExchangeRunspaceConfigurationSettings.SerializationLevel.Partial),
                    MultiSelect          = (!this.HasValue(configuration.Element("MultiSelect")) || bool.Parse((string)configuration.Element("MultiSelect")))
                };
            }
            return(result);
        }