private void ExtractTemplateValuesRecursive(ArrayList subBuilders, OrderedDictionary table, Control container)
 {
     foreach (object obj2 in subBuilders)
     {
         ControlBuilder builder = obj2 as ControlBuilder;
         if (builder != null)
         {
             ICollection boundPropertyEntries;
             if (!builder.HasFilteredBoundEntries)
             {
                 boundPropertyEntries = builder.BoundPropertyEntries;
             }
             else
             {
                 ServiceContainer serviceProvider = new ServiceContainer();
                 serviceProvider.AddService(typeof(IFilterResolutionService), builder.TemplateControl);
                 try
                 {
                     builder.SetServiceProvider(serviceProvider);
                     boundPropertyEntries = builder.GetFilteredPropertyEntrySet(builder.BoundPropertyEntries);
                 }
                 finally
                 {
                     builder.SetServiceProvider(null);
                 }
             }
             string  strA = null;
             bool    flag = true;
             Control o    = null;
             foreach (BoundPropertyEntry entry in boundPropertyEntries)
             {
                 if (entry.TwoWayBound)
                 {
                     string str2;
                     if (string.Compare(strA, entry.ControlID, StringComparison.Ordinal) != 0)
                     {
                         flag = true;
                     }
                     else
                     {
                         flag = false;
                     }
                     strA = entry.ControlID;
                     if (flag)
                     {
                         o = container.FindControl(entry.ControlID);
                         if ((o == null) || !entry.ControlType.IsInstanceOfType(o))
                         {
                             continue;
                         }
                     }
                     object target = PropertyMapper.LocatePropertyObject(o, entry.Name, out str2, base.InDesigner);
                     table[entry.FieldName] = FastPropertyAccessor.GetProperty(target, str2, base.InDesigner);
                 }
             }
             this.ExtractTemplateValuesRecursive(builder.SubBuilders, table, container);
         }
     }
 }
示例#2
0
        private void ExtractTemplateValuesRecursive(ArrayList subBuilders, OrderedDictionary table, Control container)
        {
            foreach (object subBuilderObject in subBuilders)
            {
                ControlBuilder subBuilderControlBuilder = subBuilderObject as ControlBuilder;
                if (subBuilderControlBuilder != null)
                {
                    ICollection entries;
                    // filter out device filtered bound entries that don't apply to this device
                    if (!subBuilderControlBuilder.HasFilteredBoundEntries)
                    {
                        entries = subBuilderControlBuilder.BoundPropertyEntries;
                    }
                    else
                    {
                        Debug.Assert(subBuilderControlBuilder.ServiceProvider == null);
                        Debug.Assert(subBuilderControlBuilder.TemplateControl != null, "TemplateControl should not be null in no-compile pages. We need it for the FilterResolutionService.");

                        ServiceContainer serviceContainer = new ServiceContainer();
                        serviceContainer.AddService(typeof(IFilterResolutionService), subBuilderControlBuilder.TemplateControl);

                        try {
                            subBuilderControlBuilder.SetServiceProvider(serviceContainer);
                            entries = subBuilderControlBuilder.GetFilteredPropertyEntrySet(subBuilderControlBuilder.BoundPropertyEntries);
                        }
                        finally {
                            subBuilderControlBuilder.SetServiceProvider(null);
                        }
                    }

                    string  previousControlName = null;
                    bool    newControl          = true;
                    Control control             = null;

                    foreach (BoundPropertyEntry entry in entries)
                    {
                        // Skip all entries that are not two-way
                        if (!entry.TwoWayBound)
                        {
                            continue;
                        }

                        // Reset the "previous" Property Entry if we're not looking at the same control.
                        // If we don't do this, Two controls that have conditionals on the same named property will have
                        // their conditionals incorrectly merged.
                        if (String.Compare(previousControlName, entry.ControlID, StringComparison.Ordinal) != 0)
                        {
                            newControl = true;
                        }
                        else
                        {
                            newControl = false;
                        }

                        previousControlName = entry.ControlID;

                        if (newControl)
                        {
                            control = container.FindControl(entry.ControlID);

                            if (control == null || !entry.ControlType.IsInstanceOfType(control))
                            {
                                Debug.Assert(false, "BoundPropertyEntry is of wrong control type or couldn't be found.  Expected " + entry.ControlType.Name);
                                continue;
                            }
                        }

                        string propertyName;
                        // map the property in case it's a complex property
                        object targetObject = PropertyMapper.LocatePropertyObject(control, entry.Name, out propertyName, InDesigner);

                        // FastPropertyAccessor uses ReflectEmit for lightning speed
                        table[entry.FieldName] = FastPropertyAccessor.GetProperty(targetObject, propertyName, InDesigner);
                    }

                    ExtractTemplateValuesRecursive(subBuilderControlBuilder.SubBuilders, table, container);
                }
            }
        }