private IDataSourceFieldSchema[] GetFieldSchemas()
 {
     if (this._fieldSchemas == null)
     {
         IDataSourceViewSchema  schema       = null;
         DesignerDataSourceView designerView = this._controlDesigner.DesignerView;
         if (designerView != null)
         {
             try
             {
                 schema = designerView.Schema;
             }
             catch (Exception exception)
             {
                 IComponentDesignerDebugService service = (IComponentDesignerDebugService)base.ServiceProvider.GetService(typeof(IComponentDesignerDebugService));
                 if (service != null)
                 {
                     service.Fail(System.Design.SR.GetString("DataSource_DebugService_FailedCall", new object[] { "DesignerDataSourceView.Schema", exception.Message }));
                 }
             }
         }
         if (schema != null)
         {
             this._fieldSchemas = schema.GetFields();
         }
     }
     return(this._fieldSchemas);
 }
Esempio n. 2
0
        public override string GetDesignTimeHtml()
        {
            IEnumerable selectedDataSource = null;
            bool        templatesExist     = this.TemplatesExist;
            Repeater    viewControl        = (Repeater)base.ViewControl;

            if (templatesExist)
            {
                DesignerDataSourceView designerView         = this.DesignerView;
                IEnumerable            designTimeDataSource = null;
                bool   flag2        = false;
                string dataSourceID = string.Empty;
                if (designerView == null)
                {
                    selectedDataSource   = this.GetResolvedSelectedDataSource();
                    designTimeDataSource = this.GetDesignTimeDataSource(selectedDataSource, 5);
                }
                else
                {
                    try
                    {
                        bool flag3;
                        designTimeDataSource = designerView.GetDesignTimeData(5, out flag3);
                    }
                    catch (Exception exception)
                    {
                        if (base.Component.Site != null)
                        {
                            IComponentDesignerDebugService service = (IComponentDesignerDebugService)base.Component.Site.GetService(typeof(IComponentDesignerDebugService));
                            if (service != null)
                            {
                                service.Fail(System.Design.SR.GetString("DataSource_DebugService_FailedCall", new object[] { "DesignerDataSourceView.GetDesignTimeData", exception.Message }));
                            }
                        }
                    }
                }
                try
                {
                    viewControl.DataSource   = designTimeDataSource;
                    dataSourceID             = viewControl.DataSourceID;
                    viewControl.DataSourceID = string.Empty;
                    flag2 = true;
                    viewControl.DataBind();
                    return(base.GetDesignTimeHtml());
                }
                catch (Exception exception2)
                {
                    return(this.GetErrorDesignTimeHtml(exception2));
                }
                finally
                {
                    viewControl.DataSource = null;
                    if (flag2)
                    {
                        viewControl.DataSourceID = dataSourceID;
                    }
                }
            }
            return(this.GetEmptyDesignTimeHtml());
        }
        protected virtual IEnumerable GetDesignTimeDataSource()
        {
            bool                   flag;
            IEnumerable            designTimeData = null;
            DesignerDataSourceView designerView   = this.DesignerView;

            if (designerView != null)
            {
                try
                {
                    designTimeData = designerView.GetDesignTimeData(this.SampleRowCount, out flag);
                }
                catch (Exception exception)
                {
                    if (base.Component.Site != null)
                    {
                        IComponentDesignerDebugService service = (IComponentDesignerDebugService)base.Component.Site.GetService(typeof(IComponentDesignerDebugService));
                        if (service != null)
                        {
                            service.Fail(System.Design.SR.GetString("DataSource_DebugService_FailedCall", new object[] { "DesignerDataSourceView.GetDesignTimeData", exception.Message }));
                        }
                    }
                }
            }
            else
            {
                IEnumerable resolvedSelectedDataSource = ((IDataSourceProvider)this).GetResolvedSelectedDataSource();
                if (resolvedSelectedDataSource != null)
                {
                    designTimeData = DesignTimeData.GetDesignTimeDataSource(DesignTimeData.CreateSampleDataTable(resolvedSelectedDataSource), this.SampleRowCount);
                    flag           = true;
                }
            }
            if (designTimeData != null)
            {
                ICollection is2 = designTimeData as ICollection;
                if ((is2 == null) || (is2.Count > 0))
                {
                    return(designTimeData);
                }
            }
            flag = true;
            return(this.GetSampleDataSource());
        }
Esempio n. 4
0
        protected virtual IHierarchicalEnumerable GetDesignTimeDataSource()
        {
            bool flag;
            IHierarchicalEnumerable            designTimeData = null;
            DesignerHierarchicalDataSourceView designerView   = this.DesignerView;

            if (designerView != null)
            {
                try
                {
                    designTimeData = designerView.GetDesignTimeData(out flag);
                }
                catch (Exception exception)
                {
                    if (base.Component.Site != null)
                    {
                        IComponentDesignerDebugService service = (IComponentDesignerDebugService)base.Component.Site.GetService(typeof(IComponentDesignerDebugService));
                        if (service != null)
                        {
                            service.Fail(System.Design.SR.GetString("DataSource_DebugService_FailedCall", new object[] { "DesignerHierarchicalDataSourceView.GetDesignTimeData", exception.Message }));
                        }
                    }
                }
            }
            else
            {
                DataBinding binding = base.DataBindings["DataSource"];
                if (binding != null)
                {
                    designTimeData = DesignTimeData.GetSelectedDataSource(base.Component, binding.Expression, null) as IHierarchicalEnumerable;
                }
            }
            if (designTimeData != null)
            {
                ICollection is2 = designTimeData as ICollection;
                if ((is2 == null) || (is2.Count > 0))
                {
                    return(designTimeData);
                }
            }
            flag = true;
            return(this.GetSampleDataSource());
        }
        private IDataSourceViewSchema GetDataSourceSchema()
        {
            DesignerDataSourceView designerView = base.DesignerView;

            if (designerView != null)
            {
                try
                {
                    return(designerView.Schema);
                }
                catch (Exception exception)
                {
                    IComponentDesignerDebugService service = (IComponentDesignerDebugService)base.Component.Site.GetService(typeof(IComponentDesignerDebugService));
                    if (service != null)
                    {
                        service.Fail(System.Design.SR.GetString("DataSource_DebugService_FailedCall", new object[] { "DesignerDataSourceView.Schema", exception.Message }));
                    }
                }
            }
            return(null);
        }
Esempio n. 6
0
        private IDataSourceViewSchema GetDataSourceSchema()
        {
            DesignerDataSourceView designerView = base.DesignerView;

            if (designerView != null)
            {
                try
                {
                    return(designerView.Schema);
                }
                catch (Exception)
                {
                    IComponentDesignerDebugService componentDesignerDebugService = (IComponentDesignerDebugService)base.Component.Site.GetService(typeof(IComponentDesignerDebugService));
                    if (componentDesignerDebugService != null)
                    {
                        componentDesignerDebugService.Fail("DataSource_DebugService_FailedCall");
                    }
                }
            }
            return(null);
        }
        public override string GetDesignTimeHtml()
        {
            bool templatesExist = this.TemplatesExist;

            if (templatesExist)
            {
                IEnumerable            designTimeDataSource;
                DataList               viewControl     = (DataList)base.ViewControl;
                bool                   dummyDataSource = false;
                DesignerDataSourceView designerView    = base.DesignerView;
                if (designerView == null)
                {
                    designTimeDataSource = base.GetDesignTimeDataSource(5, out dummyDataSource);
                }
                else
                {
                    try
                    {
                        designTimeDataSource = designerView.GetDesignTimeData(5, out dummyDataSource);
                    }
                    catch (Exception exception)
                    {
                        if (base.Component.Site != null)
                        {
                            IComponentDesignerDebugService service = (IComponentDesignerDebugService)base.Component.Site.GetService(typeof(IComponentDesignerDebugService));
                            if (service != null)
                            {
                                service.Fail(System.Design.SR.GetString("DataSource_DebugService_FailedCall", new object[] { "DesignerDataSourceView.GetDesignTimeData", exception.Message }));
                            }
                        }
                        designTimeDataSource = null;
                    }
                }
                bool   flag3        = false;
                string dataKeyField = null;
                bool   flag4        = false;
                string dataSourceID = null;
                try
                {
                    viewControl.DataSource = designTimeDataSource;
                    dataKeyField           = viewControl.DataKeyField;
                    if (dataKeyField.Length != 0)
                    {
                        flag3 = true;
                        viewControl.DataKeyField = string.Empty;
                    }
                    dataSourceID             = viewControl.DataSourceID;
                    viewControl.DataSourceID = string.Empty;
                    flag4 = true;
                    viewControl.DataBind();
                    return(base.GetDesignTimeHtml());
                }
                catch (Exception exception2)
                {
                    return(this.GetErrorDesignTimeHtml(exception2));
                }
                finally
                {
                    viewControl.DataSource = null;
                    if (flag3)
                    {
                        viewControl.DataKeyField = dataKeyField;
                    }
                    if (flag4)
                    {
                        viewControl.DataSourceID = dataSourceID;
                    }
                }
            }
            return(this.GetEmptyDesignTimeHtml());
        }
 public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
 {
     object[] objArray1 = null;
     if (context != null)
     {
         IComponent component1 = context.Instance as IComponent;
         if (component1 != null)
         {
             ISite site1 = component1.Site;
             if (site1 != null)
             {
                 IDesignerHost host1 = (IDesignerHost)site1.GetService(typeof(IDesignerHost));
                 if (host1 != null)
                 {
                     IDesigner designer1          = host1.GetDesigner(component1);
                     DesignerDataSourceView view1 = this.GetView(designer1);
                     if (view1 != null)
                     {
                         IDataSourceViewSchema schema1 = null;
                         try
                         {
                             schema1 = view1.Schema;
                         }
                         catch (Exception exception1)
                         {
                             IComponentDesignerDebugService service1 = (IComponentDesignerDebugService)site1.GetService(typeof(IComponentDesignerDebugService));
                             if (service1 != null)
                             {
                                 service1.Fail("DataSource DebugService FailedCall\r\n" + exception1.ToString());
                             }
                         }
                         if (schema1 != null)
                         {
                             IDataSourceFieldSchema[] schemaArray1 = schema1.GetFields();
                             if (schemaArray1 != null)
                             {
                                 objArray1 = new object[schemaArray1.Length];
                                 for (int num1 = 0; num1 < schemaArray1.Length; num1++)
                                 {
                                     objArray1[num1] = schemaArray1[num1].Name;
                                 }
                             }
                         }
                     }
                     if (((objArray1 == null) && (designer1 != null)) && (designer1 is IDataSourceProvider))
                     {
                         IDataSourceProvider provider1   = designer1 as IDataSourceProvider;
                         IEnumerable         enumerable1 = null;
                         if (provider1 != null)
                         {
                             enumerable1 = provider1.GetResolvedSelectedDataSource();
                         }
                         if (enumerable1 != null)
                         {
                             PropertyDescriptorCollection collection1 = DesignTimeData.GetDataFields(enumerable1);
                             if (collection1 != null)
                             {
                                 ArrayList list1 = new ArrayList();
                                 foreach (PropertyDescriptor descriptor1 in collection1)
                                 {
                                     list1.Add(descriptor1.Name);
                                 }
                                 objArray1 = list1.ToArray();
                             }
                         }
                     }
                 }
             }
         }
     }
     return(new TypeConverter.StandardValuesCollection(objArray1));
 }
        public override string GetDesignTimeHtml()
        {
            int      minimumRows = 5;
            DataGrid viewControl = (DataGrid)base.ViewControl;

            if (viewControl.AllowPaging && (viewControl.PageSize != 0))
            {
                minimumRows = Math.Min(viewControl.PageSize, 100) + 1;
            }
            bool                   dummyDataSource      = false;
            IEnumerable            designTimeDataSource = null;
            bool                   flag2               = false;
            bool                   flag3               = false;
            bool                   flag4               = false;
            DesignerDataSourceView designerView        = base.DesignerView;
            bool                   autoGenerateColumns = viewControl.AutoGenerateColumns;
            string                 dataKeyField        = string.Empty;
            string                 dataSourceID        = string.Empty;
            string                 designTimeHtml      = null;

            if (designerView == null)
            {
                designTimeDataSource = base.GetDesignTimeDataSource(minimumRows, out dummyDataSource);
            }
            else
            {
                try
                {
                    designTimeDataSource = designerView.GetDesignTimeData(minimumRows, out dummyDataSource);
                }
                catch (Exception exception)
                {
                    if (base.Component.Site != null)
                    {
                        IComponentDesignerDebugService service = (IComponentDesignerDebugService)base.Component.Site.GetService(typeof(IComponentDesignerDebugService));
                        if (service != null)
                        {
                            service.Fail(System.Design.SR.GetString("DataSource_DebugService_FailedCall", new object[] { "DesignerDataSourceView.GetDesignTimeData", exception.Message }));
                        }
                    }
                }
                if (designTimeDataSource == null)
                {
                    return(this.GetEmptyDesignTimeHtml());
                }
            }
            if (!autoGenerateColumns && (viewControl.Columns.Count == 0))
            {
                flag2 = true;
                viewControl.AutoGenerateColumns = true;
            }
            if (dummyDataSource)
            {
                dataKeyField = viewControl.DataKeyField;
                if (dataKeyField.Length != 0)
                {
                    flag3 = true;
                    viewControl.DataKeyField = string.Empty;
                }
            }
            try
            {
                viewControl.DataSource   = designTimeDataSource;
                dataSourceID             = viewControl.DataSourceID;
                viewControl.DataSourceID = string.Empty;
                flag4 = true;
                viewControl.DataBind();
                designTimeHtml = base.GetDesignTimeHtml();
            }
            catch (Exception exception2)
            {
                designTimeHtml = this.GetErrorDesignTimeHtml(exception2);
            }
            finally
            {
                viewControl.DataSource = null;
                if (flag2)
                {
                    viewControl.AutoGenerateColumns = false;
                }
                if (flag3)
                {
                    viewControl.DataKeyField = dataKeyField;
                }
                if (flag4)
                {
                    viewControl.DataSourceID = dataSourceID;
                }
            }
            return(designTimeHtml);
        }
            public StringCollection GetStandardValues(Component component)
            {
                StringCollection fields = new StringCollection();

                if (component != null)
                {
                    ISite site1 = component.Site;
                    if (site1 != null)
                    {
                        IDesignerHost host1 = (IDesignerHost)site1.GetService(typeof(IDesignerHost));
                        if (host1 != null)
                        {
                            IDesigner designer1          = host1.GetDesigner(component);
                            DesignerDataSourceView view1 = ((DataBoundControlDesigner)designer1).DesignerView;
                            if (view1 != null)
                            {
                                IDataSourceViewSchema schema1 = null;
                                try
                                {
                                    schema1 = view1.Schema;
                                }
                                catch (Exception exception1)
                                {
                                    IComponentDesignerDebugService service1 = (IComponentDesignerDebugService)site1.GetService(typeof(IComponentDesignerDebugService));
                                    if (service1 != null)
                                    {
                                        service1.Fail("DataSource DebugService FailedCall\r\n" + exception1.ToString());
                                    }
                                }
                                if (schema1 != null)
                                {
                                    IDataSourceFieldSchema[] schemaArray1 = schema1.GetFields();
                                    if (schemaArray1 != null)
                                    {
                                        for (int num1 = 0; num1 < schemaArray1.Length; num1++)
                                        {
                                            fields.Add(schemaArray1[num1].Name);
                                        }
                                    }
                                }
                            }
                            if (((fields.Count == 0) && (designer1 != null)) && (designer1 is IDataSourceProvider))
                            {
                                IDataSourceProvider provider1   = designer1 as IDataSourceProvider;
                                IEnumerable         enumerable1 = null;
                                if (provider1 != null)
                                {
                                    enumerable1 = provider1.GetResolvedSelectedDataSource();
                                }
                                if (enumerable1 != null)
                                {
                                    PropertyDescriptorCollection collection1 = DesignTimeData.GetDataFields(enumerable1);
                                    if (collection1 != null)
                                    {
                                        foreach (PropertyDescriptor descriptor1 in collection1)
                                        {
                                            fields.Add(descriptor1.Name);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                return(fields);
            }
        private static string LocalizeObject(IServiceProvider serviceProvider, object obj, ObjectPersistData persistData, ResourceExpressionEditor resEditor, IDesignTimeResourceWriter resourceWriter, string resourceKey, string objectModelName, object topLevelObject, string filter, bool shouldLocalizeInnerContent, bool isComplexProperty, bool implicitlyLocalizeComplexProperty)
        {
            bool flag;

            if (isComplexProperty)
            {
                flag = implicitlyLocalizeComplexProperty;
            }
            else
            {
                flag = (persistData == null) || persistData.Localize;
            }
            PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(obj);

            for (int i = 0; i < properties.Count; i++)
            {
                try
                {
                    PropertyDescriptor propertyDescriptor = properties[i];
                    if (string.Equals(propertyDescriptor.Name, "Controls", StringComparison.Ordinal))
                    {
                        Control control = obj as Control;
                        if ((control != null) && shouldLocalizeInnerContent)
                        {
                            if (!ParseChildren(control.GetType()))
                            {
                                foreach (Control control2 in control.Controls)
                                {
                                    IControlBuilderAccessor accessor       = control2;
                                    ControlBuilder          controlBuilder = accessor.ControlBuilder;
                                    if (controlBuilder != null)
                                    {
                                        string str = controlBuilder.GetResourceKey();
                                        string b   = LocalizeObject(serviceProvider, control2, controlBuilder.GetObjectPersistData(), resEditor, resourceWriter, str, string.Empty, control2, string.Empty, true, false, false);
                                        if (!string.Equals(str, b, StringComparison.OrdinalIgnoreCase))
                                        {
                                            controlBuilder.SetResourceKey(b);
                                        }
                                    }
                                }
                            }
                            continue;
                        }
                    }
                    PersistenceModeAttribute attribute = (PersistenceModeAttribute)propertyDescriptor.Attributes[typeof(PersistenceModeAttribute)];
                    string str3 = (objectModelName.Length > 0) ? (objectModelName + '.' + propertyDescriptor.Name) : propertyDescriptor.Name;
                    if ((attribute.Mode == PersistenceMode.Attribute) && (propertyDescriptor.SerializationVisibility == DesignerSerializationVisibility.Content))
                    {
                        resourceKey = LocalizeObject(serviceProvider, propertyDescriptor.GetValue(obj), persistData, resEditor, resourceWriter, resourceKey, str3, topLevelObject, filter, true, true, flag);
                    }
                    else if ((attribute.Mode == PersistenceMode.Attribute) || (propertyDescriptor.PropertyType == typeof(string)))
                    {
                        bool   flag2 = false;
                        bool   flag3 = false;
                        object obj2  = null;
                        string name  = string.Empty;
                        if (persistData != null)
                        {
                            PropertyEntry filteredProperty = persistData.GetFilteredProperty(string.Empty, str3);
                            if (filteredProperty is BoundPropertyEntry)
                            {
                                BoundPropertyEntry entry2 = (BoundPropertyEntry)filteredProperty;
                                if (!entry2.Generated)
                                {
                                    if (string.Equals(entry2.ExpressionPrefix, "resources", StringComparison.OrdinalIgnoreCase))
                                    {
                                        System.Web.Compilation.ResourceExpressionFields parsedExpressionData = entry2.ParsedExpressionData as System.Web.Compilation.ResourceExpressionFields;
                                        if ((parsedExpressionData != null) && string.IsNullOrEmpty(parsedExpressionData.ClassKey))
                                        {
                                            name = parsedExpressionData.ResourceKey;
                                            obj2 = resEditor.EvaluateExpression(entry2.Expression, entry2.ParsedExpressionData, propertyDescriptor.PropertyType, serviceProvider);
                                            if (obj2 != null)
                                            {
                                                flag3 = true;
                                            }
                                            flag2 = true;
                                        }
                                    }
                                }
                                else
                                {
                                    flag2 = true;
                                }
                            }
                            else
                            {
                                flag2 = flag && IsPropertyLocalizable(propertyDescriptor);
                            }
                        }
                        else
                        {
                            flag2 = flag && IsPropertyLocalizable(propertyDescriptor);
                        }
                        if (flag2)
                        {
                            if (!flag3)
                            {
                                obj2 = propertyDescriptor.GetValue(obj);
                            }
                            if (name.Length == 0)
                            {
                                if (string.IsNullOrEmpty(resourceKey))
                                {
                                    resourceKey = resourceWriter.CreateResourceKey(null, topLevelObject);
                                }
                                name = resourceKey + '.' + str3;
                                if (filter.Length != 0)
                                {
                                    name = filter + ':' + name;
                                }
                            }
                            resourceWriter.AddResource(name, obj2);
                        }
                        if (persistData != null)
                        {
                            foreach (PropertyEntry entry3 in persistData.GetPropertyAllFilters(str3))
                            {
                                if (entry3.Filter.Length > 0)
                                {
                                    if (entry3 is SimplePropertyEntry)
                                    {
                                        if (flag && IsPropertyLocalizable(propertyDescriptor))
                                        {
                                            if (name.Length == 0)
                                            {
                                                if (string.IsNullOrEmpty(resourceKey))
                                                {
                                                    resourceKey = resourceWriter.CreateResourceKey(null, topLevelObject);
                                                }
                                                name = resourceKey + '.' + str3;
                                            }
                                            string str5 = entry3.Filter + ':' + name;
                                            resourceWriter.AddResource(str5, ((SimplePropertyEntry)entry3).Value);
                                        }
                                    }
                                    else if (!(entry3 is ComplexPropertyEntry) && (entry3 is BoundPropertyEntry))
                                    {
                                        BoundPropertyEntry entry4 = (BoundPropertyEntry)entry3;
                                        if (!entry4.Generated && string.Equals(entry4.ExpressionPrefix, "resources", StringComparison.OrdinalIgnoreCase))
                                        {
                                            System.Web.Compilation.ResourceExpressionFields fields2 = entry4.ParsedExpressionData as System.Web.Compilation.ResourceExpressionFields;
                                            if ((fields2 != null) && string.IsNullOrEmpty(fields2.ClassKey))
                                            {
                                                object obj3 = resEditor.EvaluateExpression(entry4.Expression, entry4.ParsedExpressionData, entry3.PropertyInfo.PropertyType, serviceProvider);
                                                if (obj3 == null)
                                                {
                                                    obj3 = string.Empty;
                                                }
                                                resourceWriter.AddResource(fields2.ResourceKey, obj3);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else if (shouldLocalizeInnerContent)
                    {
                        if (typeof(ICollection).IsAssignableFrom(propertyDescriptor.PropertyType))
                        {
                            if (persistData != null)
                            {
                                foreach (ComplexPropertyEntry entry5 in persistData.GetPropertyAllFilters(propertyDescriptor.Name))
                                {
                                    foreach (ComplexPropertyEntry entry6 in entry5.Builder.GetObjectPersistData().CollectionItems)
                                    {
                                        ControlBuilder builder = entry6.Builder;
                                        object         obj4    = builder.BuildObject();
                                        string         str6    = builder.GetResourceKey();
                                        string         str7    = LocalizeObject(serviceProvider, obj4, builder.GetObjectPersistData(), resEditor, resourceWriter, str6, string.Empty, obj4, string.Empty, true, false, false);
                                        if (!string.Equals(str6, str7, StringComparison.OrdinalIgnoreCase))
                                        {
                                            builder.SetResourceKey(str7);
                                        }
                                    }
                                }
                            }
                        }
                        else if (typeof(ITemplate).IsAssignableFrom(propertyDescriptor.PropertyType))
                        {
                            if (persistData != null)
                            {
                                foreach (TemplatePropertyEntry entry7 in persistData.GetPropertyAllFilters(propertyDescriptor.Name))
                                {
                                    TemplateBuilder builder3     = (TemplateBuilder)entry7.Builder;
                                    IDesignerHost   designerHost = (IDesignerHost)serviceProvider.GetService(typeof(IDesignerHost));
                                    Control[]       controlArray = ControlParser.ParseControls(designerHost, builder3.Text);
                                    for (int j = 0; j < controlArray.Length; j++)
                                    {
                                        if (!(controlArray[j] is LiteralControl) && !(controlArray[j] is DesignerDataBoundLiteralControl))
                                        {
                                            LocalizeControl(controlArray[j], serviceProvider, resourceWriter, true);
                                        }
                                    }
                                    StringBuilder builder4 = new StringBuilder();
                                    for (int k = 0; k < controlArray.Length; k++)
                                    {
                                        if (controlArray[k] is LiteralControl)
                                        {
                                            builder4.Append(((LiteralControl)controlArray[k]).Text);
                                        }
                                        else
                                        {
                                            builder4.Append(ControlPersister.PersistControl(controlArray[k], designerHost));
                                        }
                                    }
                                    builder3.Text = builder4.ToString();
                                }
                            }
                        }
                        else if (persistData != null)
                        {
                            object               obj5 = propertyDescriptor.GetValue(obj);
                            ObjectPersistData    objectPersistData = null;
                            ComplexPropertyEntry entry8            = (ComplexPropertyEntry)persistData.GetFilteredProperty(string.Empty, propertyDescriptor.Name);
                            if (entry8 != null)
                            {
                                objectPersistData = entry8.Builder.GetObjectPersistData();
                            }
                            resourceKey = LocalizeObject(serviceProvider, obj5, objectPersistData, resEditor, resourceWriter, resourceKey, str3, topLevelObject, string.Empty, true, true, flag);
                            foreach (ComplexPropertyEntry entry9 in persistData.GetPropertyAllFilters(propertyDescriptor.Name))
                            {
                                if (entry9.Filter.Length > 0)
                                {
                                    ControlBuilder builder5 = entry9.Builder;
                                    objectPersistData = builder5.GetObjectPersistData();
                                    obj5        = builder5.BuildObject();
                                    resourceKey = LocalizeObject(serviceProvider, obj5, objectPersistData, resEditor, resourceWriter, resourceKey, str3, topLevelObject, entry9.Filter, true, true, flag);
                                }
                            }
                        }
                    }
                }
                catch (Exception exception)
                {
                    if (serviceProvider != null)
                    {
                        IComponentDesignerDebugService service = serviceProvider.GetService(typeof(IComponentDesignerDebugService)) as IComponentDesignerDebugService;
                        if (service != null)
                        {
                            service.Fail(exception.Message);
                        }
                    }
                }
            }
            return(resourceKey);
        }
 private string[] GetControlDataFieldNames()
 {
     if (this._dataFields == null)
     {
         ITypeDescriptorContext   context = this.editor.Context;
         IDataSourceFieldSchema[] fields  = null;
         IDataSourceViewSchema    dataSourceViewSchema = null;
         if ((context != null) && (context.Instance != null))
         {
             System.Web.UI.Control instance = context.Instance as System.Web.UI.Control;
             if (instance != null)
             {
                 ISite site = instance.Site;
                 if (site != null)
                 {
                     IDesignerHost host = (IDesignerHost)site.GetService(typeof(IDesignerHost));
                     if (host != null)
                     {
                         DataBoundControlDesigner designer = host.GetDesigner(instance) as DataBoundControlDesigner;
                         if (designer != null)
                         {
                             DesignerDataSourceView designerView = designer.DesignerView;
                             if (designerView != null)
                             {
                                 try
                                 {
                                     dataSourceViewSchema = designerView.Schema;
                                 }
                                 catch (Exception exception)
                                 {
                                     IComponentDesignerDebugService service = (IComponentDesignerDebugService)site.GetService(typeof(IComponentDesignerDebugService));
                                     if (service != null)
                                     {
                                         service.Fail(System.Design.SR.GetString("DataSource_DebugService_FailedCall", new object[] { "DesignerDataSourceView.Schema", exception.Message }));
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             else
             {
                 IDataSourceViewSchemaAccessor accessor = context.Instance as IDataSourceViewSchemaAccessor;
                 if (accessor != null)
                 {
                     dataSourceViewSchema = accessor.DataSourceViewSchema as IDataSourceViewSchema;
                 }
             }
         }
         if (dataSourceViewSchema != null)
         {
             fields = dataSourceViewSchema.GetFields();
             if (fields != null)
             {
                 int length = fields.Length;
                 this._dataFields = new string[length];
                 for (int i = 0; i < length; i++)
                 {
                     this._dataFields[i] = fields[i].Name;
                 }
             }
         }
     }
     return(this._dataFields);
 }
Esempio n. 13
0
 public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
 {
     object[] values = null;
     if (context != null)
     {
         IComponent instance = context.Instance as IComponent;
         if (instance != null)
         {
             ISite site = instance.Site;
             if (site != null)
             {
                 IDesignerHost host = (IDesignerHost)site.GetService(typeof(IDesignerHost));
                 if (host != null)
                 {
                     IDesigner dataBoundControlDesigner = host.GetDesigner(instance);
                     DesignerDataSourceView view        = this.GetView(dataBoundControlDesigner);
                     if (view != null)
                     {
                         IDataSourceViewSchema schema = null;
                         try
                         {
                             schema = view.Schema;
                         }
                         catch (Exception exception)
                         {
                             IComponentDesignerDebugService service = (IComponentDesignerDebugService)site.GetService(typeof(IComponentDesignerDebugService));
                             if (service != null)
                             {
                                 service.Fail(System.Design.SR.GetString("DataSource_DebugService_FailedCall", new object[] { "DesignerDataSourceView.Schema", exception.Message }));
                             }
                         }
                         if (schema != null)
                         {
                             IDataSourceFieldSchema[] fields = schema.GetFields();
                             if (fields != null)
                             {
                                 values = new object[fields.Length];
                                 for (int i = 0; i < fields.Length; i++)
                                 {
                                     values[i] = fields[i].Name;
                                 }
                             }
                         }
                     }
                     if (((values == null) && (dataBoundControlDesigner != null)) && (dataBoundControlDesigner is IDataSourceProvider))
                     {
                         IDataSourceProvider provider   = dataBoundControlDesigner as IDataSourceProvider;
                         IEnumerable         dataSource = null;
                         if (provider != null)
                         {
                             dataSource = provider.GetResolvedSelectedDataSource();
                         }
                         if (dataSource != null)
                         {
                             PropertyDescriptorCollection dataFields = DesignTimeData.GetDataFields(dataSource);
                             if (dataFields != null)
                             {
                                 ArrayList list = new ArrayList();
                                 foreach (PropertyDescriptor descriptor in dataFields)
                                 {
                                     list.Add(descriptor.Name);
                                 }
                                 values = list.ToArray();
                             }
                         }
                     }
                 }
             }
         }
     }
     return(new TypeConverter.StandardValuesCollection(values));
 }