Beispiel #1
0
        private void ApplySimpleProperties(Control control)
        {
            ICollection entries = GetFilteredPropertyEntrySet(_skinBuilder.SimplePropertyEntries);

            foreach (SimplePropertyEntry entry in entries)
            {
                try {
                    if (entry.UseSetAttribute)
                    {
                        SetSimpleProperty(entry, control);
                        continue;
                    }

                    string             propertyName = PropertyMapper.MapNameToPropertyName(entry.Name);
                    object             childObj;
                    string             actualPropName;
                    PropertyDescriptor desc = PropertyMapper.GetMappedPropertyDescriptor(control, propertyName, out childObj, out actualPropName, InDesigner);

                    if (desc != null)
                    {
                        DefaultValueAttribute defValAttr = (DefaultValueAttribute)desc.Attributes[typeof(DefaultValueAttribute)];
                        object currentValue = desc.GetValue(childObj);

                        // Only apply the themed value if different from default value.
                        if (defValAttr != null && !object.Equals(defValAttr.Value, currentValue))
                        {
                            continue;
                        }

                        object value = entry.Value;

                        // Make the UrlProperty based on theme path for control themes.
                        string str = value as string;
                        if (value != null && desc.Attributes[typeof(UrlPropertyAttribute)] != null &&
                            UrlPath.IsRelativeUrl(str))
                        {
                            value = _themePath + str;
                        }

                        SetSimpleProperty(entry, control);
                    }
                }
                catch (Exception e) {
                    Debug.Fail(e.Message);
                }
#pragma warning disable 1058
                catch {
                }
#pragma warning restore 1058
            }
        }
Beispiel #2
0
        private void ApplyComplexProperties(Control control)
        {
            ICollection entries = GetFilteredPropertyEntrySet(_skinBuilder.ComplexPropertyEntries);

            foreach (ComplexPropertyEntry entry in entries)
            {
                ControlBuilder builder = entry.Builder;
                if (builder != null)
                {
                    string propertyName = entry.Name;
                    if (entry.ReadOnly)
                    {
                        object objectValue = FastPropertyAccessor.GetProperty(control, propertyName, InDesigner);
                        if (objectValue == null)
                        {
                            continue;
                        }

                        entry.Builder.SetServiceProvider(ServiceProvider);
                        try {
                            entry.Builder.InitObject(objectValue);
                        }
                        finally {
                            entry.Builder.SetServiceProvider(null);
                        }
                    }
                    else
                    {
                        object childObj;
                        string actualPropName;
                        object value = entry.Builder.BuildObject(true);

                        // Make the UrlProperty based on theme path for control themes(Must be a string)
                        PropertyDescriptor desc = PropertyMapper.GetMappedPropertyDescriptor(control, PropertyMapper.MapNameToPropertyName(propertyName), out childObj, out actualPropName, InDesigner);
                        if (desc != null)
                        {
                            string str = value as string;
                            if (value != null && desc.Attributes[typeof(UrlPropertyAttribute)] != null &&
                                UrlPath.IsRelativeUrl(str))
                            {
                                value = _themePath + str;
                            }
                        }

                        FastPropertyAccessor.SetProperty(childObj, propertyName, value, InDesigner);
                    }
                }
            }
        }
 private void ApplySimpleProperties(Control control)
 {
     foreach (SimplePropertyEntry entry in base.GetFilteredPropertyEntrySet(this._skinBuilder.SimplePropertyEntries))
     {
         try
         {
             if (entry.UseSetAttribute)
             {
                 base.SetSimpleProperty(entry, control);
             }
             else
             {
                 object             obj2;
                 string             str2;
                 string             mappedName = PropertyMapper.MapNameToPropertyName(entry.Name);
                 PropertyDescriptor descriptor = PropertyMapper.GetMappedPropertyDescriptor(control, mappedName, out obj2, out str2, base.InDesigner);
                 if (descriptor != null)
                 {
                     DefaultValueAttribute attribute = (DefaultValueAttribute)descriptor.Attributes[typeof(DefaultValueAttribute)];
                     object objB = descriptor.GetValue(obj2);
                     if ((attribute == null) || object.Equals(attribute.Value, objB))
                     {
                         object obj4        = entry.Value;
                         string virtualPath = obj4 as string;
                         if (((obj4 != null) && (descriptor.Attributes[typeof(UrlPropertyAttribute)] != null)) && UrlPath.IsRelativeUrl(virtualPath))
                         {
                             obj4 = this._themePath + virtualPath;
                         }
                         base.SetSimpleProperty(entry, control);
                     }
                 }
             }
         }
         catch (Exception)
         {
         }
         catch
         {
         }
     }
 }
 private void ApplyComplexProperties(Control control)
 {
     foreach (ComplexPropertyEntry entry in base.GetFilteredPropertyEntrySet(this._skinBuilder.ComplexPropertyEntries))
     {
         if (entry.Builder != null)
         {
             object obj3;
             string str2;
             string name = entry.Name;
             if (entry.ReadOnly)
             {
                 object obj2 = FastPropertyAccessor.GetProperty(control, name, base.InDesigner);
                 if (obj2 == null)
                 {
                     continue;
                 }
                 entry.Builder.SetServiceProvider(base.ServiceProvider);
                 try
                 {
                     entry.Builder.InitObject(obj2);
                     continue;
                 }
                 finally
                 {
                     entry.Builder.SetServiceProvider(null);
                 }
             }
             object             val        = entry.Builder.BuildObject(true);
             PropertyDescriptor descriptor = PropertyMapper.GetMappedPropertyDescriptor(control, PropertyMapper.MapNameToPropertyName(name), out obj3, out str2, base.InDesigner);
             if (descriptor != null)
             {
                 string virtualPath = val as string;
                 if (((val != null) && (descriptor.Attributes[typeof(UrlPropertyAttribute)] != null)) && UrlPath.IsRelativeUrl(virtualPath))
                 {
                     val = this._themePath + virtualPath;
                 }
             }
             FastPropertyAccessor.SetProperty(obj3, name, val, base.InDesigner);
         }
     }
 }