private static bool CanSerializeAsInnerDefaultString(string filter, string name, Type type, ObjectPersistData persistData, PersistenceMode mode, DataBindingCollection dataBindings, ExpressionBindingCollection expressions)
 {
     if (((((type == typeof(string)) && (filter.Length == 0)) && ((mode == PersistenceMode.InnerDefaultProperty) || (mode == PersistenceMode.EncodedInnerDefaultProperty))) && ((dataBindings == null) || (dataBindings[name] == null))) && ((expressions == null) || (expressions[name] == null)))
     {
         if (persistData == null)
         {
             return true;
         }
         ICollection propertyAllFilters = persistData.GetPropertyAllFilters(name);
         if (propertyAllFilters.Count == 0)
         {
             return true;
         }
         if (propertyAllFilters.Count == 1)
         {
             foreach (PropertyEntry entry in propertyAllFilters)
             {
                 if ((entry.Filter.Length == 0) && (entry is ComplexPropertyEntry))
                 {
                     return true;
                 }
             }
         }
     }
     return false;
 }
 private static void SerializeAttributesRecursive(object obj, IDesignerHost host, string prefix, ObjectPersistData persistData, string filter, ArrayList attributes, DataBindingCollection dataBindings, ExpressionBindingCollection expressions, bool topLevelInDesigner)
 {
     PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(obj);
     if (obj is IDataBindingsAccessor)
     {
         dataBindings = ((IDataBindingsAccessor) obj).DataBindings;
     }
     if (obj is Control)
     {
         try
         {
             ControlCollection controls = ((Control) obj).Controls;
         }
         catch (Exception exception)
         {
             IComponentDesignerDebugService service = host.GetService(typeof(IComponentDesignerDebugService)) as IComponentDesignerDebugService;
             if (service != null)
             {
                 service.Fail(exception.Message);
             }
         }
     }
     if (obj is IExpressionsAccessor)
     {
         expressions = ((IExpressionsAccessor) obj).Expressions;
     }
     for (int i = 0; i < properties.Count; i++)
     {
         try
         {
             SerializeAttribute(obj, properties[i], dataBindings, expressions, host, prefix, persistData, filter, attributes, topLevelInDesigner);
         }
         catch (Exception exception2)
         {
             if (host != null)
             {
                 IComponentDesignerDebugService service2 = host.GetService(typeof(IComponentDesignerDebugService)) as IComponentDesignerDebugService;
                 if (service2 != null)
                 {
                     service2.Fail(exception2.Message);
                 }
             }
         }
     }
 }
 private static void SerializeAttribute(object obj, PropertyDescriptor propDesc, DataBindingCollection dataBindings, ExpressionBindingCollection expressions, IDesignerHost host, string prefix, ObjectPersistData persistData, string filter, ArrayList attributes, bool topLevelInDesigner)
 {
     DesignOnlyAttribute attribute = (DesignOnlyAttribute) propDesc.Attributes[typeof(DesignOnlyAttribute)];
     if ((attribute == null) || !attribute.IsDesignOnly)
     {
         string name = propDesc.Name;
         Type propertyType = propDesc.PropertyType;
         PersistenceMode mode = ((PersistenceModeAttribute) propDesc.Attributes[typeof(PersistenceModeAttribute)]).Mode;
         bool flag = (dataBindings != null) && (dataBindings[name] != null);
         bool flag2 = (expressions != null) && (expressions[name] != null);
         if (((flag || flag2) || (propDesc.SerializationVisibility != DesignerSerializationVisibility.Hidden)) && (((mode == PersistenceMode.Attribute) || ((flag && flag2) && (propertyType == typeof(string)))) || ((mode != PersistenceMode.InnerProperty) && (propertyType == typeof(string)))))
         {
             string str2 = string.Empty;
             if (prefix.Length > 0)
             {
                 str2 = prefix + "-" + name;
             }
             else
             {
                 str2 = name;
             }
             if (propDesc.SerializationVisibility == DesignerSerializationVisibility.Content)
             {
                 SerializeAttributesRecursive(propDesc.GetValue(obj), host, str2, persistData, filter, attributes, dataBindings, expressions, topLevelInDesigner);
             }
             else
             {
                 IAttributeAccessor accessor = obj as IAttributeAccessor;
                 if (!propDesc.IsReadOnly || ((accessor != null) && (accessor.GetAttribute(str2) != null)))
                 {
                     string str3 = ConvertPersistToObjectModelName(str2);
                     if (!FilterableAttribute.IsPropertyFilterable(propDesc))
                     {
                         filter = string.Empty;
                     }
                     if (CanSerializeAsInnerDefaultString(filter, str3, propertyType, persistData, mode, dataBindings, expressions))
                     {
                         if (topLevelInDesigner)
                         {
                             attributes.Add(new Triplet(filter, str2, null));
                         }
                     }
                     else
                     {
                         bool flag3 = true;
                         object objB = null;
                         object objA = propDesc.GetValue(obj);
                         BindingType none = BindingType.None;
                         if (dataBindings != null)
                         {
                             DataBinding binding = dataBindings[str3];
                             if (binding != null)
                             {
                                 objA = binding.Expression;
                                 none = BindingType.Data;
                             }
                         }
                         if (none == BindingType.None)
                         {
                             if (expressions != null)
                             {
                                 ExpressionBinding binding2 = expressions[str3];
                                 if ((binding2 != null) && !binding2.Generated)
                                 {
                                     objA = binding2.ExpressionPrefix + ":" + binding2.Expression;
                                     none = BindingType.Expression;
                                 }
                             }
                             else if (persistData != null)
                             {
                                 BoundPropertyEntry filteredProperty = persistData.GetFilteredProperty(filter, name) as BoundPropertyEntry;
                                 if ((filteredProperty != null) && !filteredProperty.Generated)
                                 {
                                     objB = GetPropertyDefaultValue(propDesc, str2, persistData, filter, host);
                                     if (object.Equals(objA, objB))
                                     {
                                         objA = filteredProperty.ExpressionPrefix + ":" + filteredProperty.Expression;
                                         none = BindingType.Expression;
                                     }
                                 }
                             }
                         }
                         if (filter.Length == 0)
                         {
                             bool useResult = false;
                             bool flag5 = false;
                             if (none == BindingType.None)
                             {
                                 flag5 = GetShouldSerializeValue(obj, name, out useResult);
                             }
                             if (useResult)
                             {
                                 flag3 = flag5;
                             }
                             else
                             {
                                 objB = GetPropertyDefaultValue(propDesc, str2, persistData, filter, host);
                                 flag3 = !object.Equals(objA, objB);
                             }
                         }
                         else
                         {
                             objB = GetPropertyDefaultValue(propDesc, str2, persistData, filter, host);
                             flag3 = !object.Equals(objA, objB);
                         }
                         if (flag3)
                         {
                             string z = GetPersistValue(propDesc, propertyType, objA, none, topLevelInDesigner);
                             if (((topLevelInDesigner && (objB != null)) && ((z == null) || (z.Length == 0))) && ShouldPersistBlankValue(objB, propertyType))
                             {
                                 z = string.Empty;
                             }
                             if ((z != null) && (!propertyType.IsArray || (z.Length > 0)))
                             {
                                 attributes.Add(new Triplet(filter, str2, z));
                             }
                             else if (topLevelInDesigner)
                             {
                                 attributes.Add(new Triplet(filter, str2, null));
                             }
                         }
                         else if (topLevelInDesigner)
                         {
                             attributes.Add(new Triplet(filter, str2, null));
                         }
                         if (persistData != null)
                         {
                             foreach (PropertyEntry entry2 in persistData.GetPropertyAllFilters(str3))
                             {
                                 if (string.Compare(entry2.Filter, filter, StringComparison.OrdinalIgnoreCase) != 0)
                                 {
                                     string str5 = string.Empty;
                                     if (entry2 is SimplePropertyEntry)
                                     {
                                         SimplePropertyEntry entry3 = (SimplePropertyEntry) entry2;
                                         if (entry3.UseSetAttribute)
                                         {
                                             str5 = entry3.Value.ToString();
                                         }
                                         else
                                         {
                                             str5 = GetPersistValue(propDesc, entry2.Type, entry3.Value, BindingType.None, topLevelInDesigner);
                                         }
                                     }
                                     else if (entry2 is BoundPropertyEntry)
                                     {
                                         BoundPropertyEntry entry4 = (BoundPropertyEntry) entry2;
                                         if (entry4.Generated)
                                         {
                                             continue;
                                         }
                                         string propValue = entry4.Expression.Trim();
                                         none = BindingType.Data;
                                         string expressionPrefix = entry4.ExpressionPrefix;
                                         if (expressionPrefix.Length > 0)
                                         {
                                             propValue = expressionPrefix + ":" + propValue;
                                             none = BindingType.Expression;
                                         }
                                         str5 = GetPersistValue(propDesc, entry2.Type, propValue, none, topLevelInDesigner);
                                     }
                                     else if (entry2 is ComplexPropertyEntry)
                                     {
                                         ComplexPropertyEntry entry5 = (ComplexPropertyEntry) entry2;
                                         str5 = (string) entry5.Builder.BuildObject();
                                     }
                                     attributes.Add(new Triplet(entry2.Filter, str2, str5));
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }