Esempio n. 1
0
        public override void Make(IConfigurationType config, IExpressionsManager manager)
        {
            if (null == config) throw new ArgumentNullException("config");
            IConfigurationElement element = config as IConfigurationElement;
            if (null == element) throw new ArgumentException("config must be an IConfigurationElement");

            if (element.Elements.ContainsKey("source"))
            {
                IConfigurationElement sourceElement = element.GetElementReference("source");

                if (sourceElement.Attributes.ContainsKey("id"))
                {
                    if (null == manager) throw new ArgumentNullException("manager");

                    this.Source = manager.FindControl(sourceElement.GetAttributeReference("id").Value.ToString());
                    if (null == this.Source)
                        this.Source = sourceElement.GetAttributeReference("id").Value;
                    if (sourceElement.Attributes.ContainsKey("member"))
                        this.Member = sourceElement.GetAttributeReference("member").Value.ToString();
                }
                else
                {
                    if (sourceElement.Attributes.ContainsKey("value"))
                        this.Source = sourceElement.GetAttributeReference("value").Value;
                }
            }
        }
Esempio n. 2
0
        public override void Make(IConfigurationType config, IExpressionsManager manager)
        {
            if (null == manager)
            {
                throw new ArgumentNullException("manager");
            }
            if (null == config)
            {
                throw new ArgumentNullException("config");
            }
            IConfigurationElement element = config as IConfigurationElement;

            if (null == element)
            {
                throw new ArgumentException("config must be an IConfigurationElement");
            }

            if (element.Elements.ContainsKey("operands"))
            {
                foreach (IConfigurationElement operandElement in element.GetElementReference("operands").Elements.Values)
                {
                    string type  = operandElement.GetAttributeReference("type").Value.ToString();
                    IToken token = manager.Token(type);
                    if (null == token)
                    {
                        throw new InvalidOperationException(string.Format("Cannot make the type '{0}'", type));
                    }

                    token.Make(operandElement, manager);
                    this.Operands.Add(token);
                }
            }
        }
Esempio n. 3
0
        public override void Make(IConfigurationType config, IExpressionsManager manager)
        {
            if (null == config)
            {
                throw new ArgumentNullException("config");
            }
            if (null == manager)
            {
                throw new ArgumentNullException("manager");
            }

            IConfigurationElement tokenElement = config as IConfigurationElement;

            if (null == tokenElement)
            {
                throw new ArgumentException("config is not an IConfigurationElement");
            }
            if (!tokenElement.Elements.ContainsKey("source"))
            {
                throw new ConfigurationException("Bad views token configuration: 'source' element not found");
            }
            IConfigurationElement sourceElement = tokenElement.GetElementReference("source");

            if (!sourceElement.Attributes.ContainsKey("parameter"))
            {
                throw new ConfigurationException("Bad views token configuration: 'source' element has no 'parameter' attribute");
            }
            this.ParameterName = sourceElement.GetAttributeReference("parameter").Value.ToString();
        }
Esempio n. 4
0
        public override void Make(IConfigurationType config, IExpressionsManager manager)
        {
            if (null == config)
            {
                throw new ArgumentNullException("config");
            }
            if (null == manager)
            {
                throw new ArgumentNullException("manager");
            }

            IConfigurationElement tokenElement = config as IConfigurationElement;

            if (null == tokenElement)
            {
                throw new ArgumentException("config is not an IConfigurationElement");
            }
            if (!tokenElement.Elements.ContainsKey("source"))
            {
                throw new ConfigurationException("Bad views field token configuration: 'source' element not found");
            }
            IConfigurationElement sourceElement = tokenElement.GetElementReference("source");

            Make(sourceElement, manager);
        }
Esempio n. 5
0
 public ConfigurationElementsCollection(IConfigurationType parent)
 {
     if (!(parent is IConfigurationSection) && !(parent is IConfigurationElement))
     {
         throw new InvalidOperationException("Parent must be a section or an element");
     }
     this._parent = parent;
 }
Esempio n. 6
0
 public ConfigurationElementsCollection(IConfigurationType parent, IConfigurationElementsCollection copy) : base(copy as Dictionary <string, IConfigurationElement>)
 {
     if (!(parent is IConfigurationSection) && !(parent is IConfigurationElement))
     {
         throw new InvalidOperationException("Parent must be a section or an element");
     }
     this._parent = parent;
 }
 public MissingConfigurationException(IConfigurationType configElementAttribute, IConfigurationType configElement, IConfigurationType configSection, IConfigurationType configSource)
 {
     this._message = string.Format("Missing attribute {0} of element {1} in section {2} in configuration source {3}", new object[]
     {
         configElementAttribute.ConfigKey,
         configElement.ConfigKey,
         configSection.ConfigKey,
         configSource.ConfigKey
     });
 }
Esempio n. 8
0
        public IConfigurationElementsCollection Clone(IConfigurationType parent)
        {
            ConfigurationElementsCollection clone = new ConfigurationElementsCollection(parent);

            foreach (IConfigurationElement element in this.Values)
            {
                clone.Add(element.ConfigKey, element.Clone());
            }
            return(clone);
        }
 public MissingConfigurationException(IConfigurationType configElementAttribute, IConfigurationType configElement, IConfigurationType configSection, IConfigurationType configSource)
 {
     this._message = string.Format("Missing attribute {0} of element {1} in section {2} in configuration source {3}", new object[]
     {
         configElementAttribute.ConfigKey,
         configElement.ConfigKey,
         configSection.ConfigKey,
         configSource.ConfigKey
     });
 }
Esempio n. 10
0
        public override void Make(IConfigurationType config, IExpressionsManager manager)
        {
            if (null == config) throw new ArgumentNullException("config");
            if (null == manager) throw new ArgumentNullException("manager");

            IConfigurationElement tokenElement = config as IConfigurationElement;
            if (null == tokenElement) throw new ArgumentException("config is not an IConfigurationElement");
            if (!tokenElement.Elements.ContainsKey("source")) throw new ConfigurationException("Bad views field token configuration: 'source' element not found");
            IConfigurationElement sourceElement = tokenElement.GetElementReference("source");

            Make(sourceElement, manager);
        }
Esempio n. 11
0
        public override void Create(Control container, IConfigurationType config, ITemplatable templatable, IEnumerable registry, WebPartManager manager)
        {
            if (null == container)
            {
                throw new ArgumentNullException("container");
            }
            if (null == config)
            {
                throw new ArgumentNullException("config");
            }
            if (!(config is IConfigurationSection))
            {
                throw new ArgumentException("config must be an IConfigurationSection");
            }
            if (!(registry is Dictionary <string, Control>))
            {
                throw new ArgumentException("registry must be a Dictionary<string,Control>");
            }
            Dictionary <string, Control> commanders = registry as Dictionary <string, Control>;

            commanders.Clear();
            IDictionary <string, IConfigurationElement> itemElements = (config as IConfigurationSection).Elements;

            if (itemElements.ContainsKey("commanders"))
            {
                Table table;
                if (container is Table)
                {
                    table = (container as Table);
                }
                else
                {
                    table = new Table();
                }
                if (string.IsNullOrEmpty(table.ID))
                {
                    table.ID = container.ID + "commanders";
                }
                table.ApplyStyle(templatable.CommandersStyle);
                foreach (IConfigurationElement element in itemElements["commanders"].Elements.Values)
                {
                    this.DisplayItem(table, element, element.ConfigKey, null, null, templatable.CommandersRowStyle, templatable.InvalidItemStyle, commanders, manager);
                }
                if (!(container is Table))
                {
                    container.Controls.Add(table);
                }
            }
        }
Esempio n. 12
0
        public override void Create(Control container, IConfigurationType config, ITemplatable templatable, IEnumerable registry, IBinder binder, WebPartManager manager)
        {
            if (null == container)
            {
                throw new ArgumentNullException("container");
            }
            if (null == config)
            {
                throw new ArgumentNullException("config");
            }
            if (!(config is IConfigurationSection))
            {
                throw new ArgumentException("config must be an IConfigurationSection");
            }
            if (!(registry is ITemplatingItemsCollection))
            {
                throw new ArgumentException("registry must be an ITemplatingItemsCollection");
            }
            ITemplatingItemsCollection filters = registry as ITemplatingItemsCollection;
            IDictionary <string, IConfigurationElement> itemElements = (config as IConfigurationSection).Elements;

            if (itemElements.ContainsKey("filter"))
            {
                Table table;
                if (container is Table)
                {
                    table = (container as Table);
                }
                else
                {
                    table    = new Table();
                    table.ID = container.ID + "filter";
                }
                table.ApplyStyle(templatable.FilterStyle);
                for (int i = 0; i < filters.Count; i++)
                {
                    foreach (IConfigurationElement element in itemElements["filter"].Elements.Values)
                    {
                        string prefix = "filter" + element.ConfigKey + i.ToString();
                        this.DisplayItem(table, element, prefix, binder, filters[i], templatable.FilterRowStyle, templatable.InvalidItemStyle, manager);
                    }
                }
                if (!(container is Table))
                {
                    container.Controls.Add(table);
                }
            }
        }
Esempio n. 13
0
 public override void Create(Control container, IConfigurationType config, ITemplatable templatable, IEnumerable registry, IBinder binder, WebPartManager manager)
 {
     if (null == container)
     {
         throw new ArgumentNullException("container");
     }
     if (null == config)
     {
         throw new ArgumentNullException("config");
     }
     if (!(config is IConfigurationSection))
     {
         throw new ArgumentException("config must be an IConfigurationSection");
     }
     if (!(registry is ITemplatingItemsCollection))
     {
         throw new ArgumentException("registry must be an ITemplatingItemsCollection");
     }
     ITemplatingItemsCollection filters = registry as ITemplatingItemsCollection;
     IDictionary<string, IConfigurationElement> itemElements = (config as IConfigurationSection).Elements;
     if (itemElements.ContainsKey("filter"))
     {
         Table table;
         if (container is Table)
         {
             table = (container as Table);
         }
         else
         {
             table = new Table();
             table.ID = container.ID + "filter";
         }
         table.ApplyStyle(templatable.FilterStyle);
         for (int i = 0; i < filters.Count; i++)
         {
             foreach (IConfigurationElement element in itemElements["filter"].Elements.Values)
             {
                 string prefix = "filter" + element.ConfigKey + i.ToString();
                 this.DisplayItem(table, element, prefix, binder, filters[i], templatable.FilterRowStyle, templatable.InvalidItemStyle, manager);
             }
         }
         if (!(container is Table))
         {
             container.Controls.Add(table);
         }
     }
 }
Esempio n. 14
0
 public override void Create(Control container, IConfigurationType config, ITemplatable templatable, IEnumerable registry, WebPartManager manager)
 {
     if (null == container)
     {
         throw new ArgumentNullException("container");
     }
     if (null == config)
     {
         throw new ArgumentNullException("config");
     }
     if (!(config is IConfigurationSection))
     {
         throw new ArgumentException("config must be an IConfigurationSection");
     }
     if (!(registry is Dictionary<string, Control>))
     {
         throw new ArgumentException("registry must be a Dictionary<string,Control>");
     }
     Dictionary<string, Control> commanders = registry as Dictionary<string, Control>;
     commanders.Clear();
     IDictionary<string, IConfigurationElement> itemElements = (config as IConfigurationSection).Elements;
     if (itemElements.ContainsKey("commanders"))
     {
         Table table;
         if (container is Table)
         {
             table = (container as Table);
         }
         else
         {
             table = new Table();
         }
         if (string.IsNullOrEmpty(table.ID))
         {
             table.ID = container.ID + "commanders";
         }
         table.ApplyStyle(templatable.CommandersStyle);
         foreach (IConfigurationElement element in itemElements["commanders"].Elements.Values)
         {
             this.DisplayItem(table, element, element.ConfigKey, null, null, templatable.CommandersRowStyle, templatable.InvalidItemStyle, commanders, manager);
         }
         if (!(container is Table))
         {
             container.Controls.Add(table);
         }
     }
 }
Esempio n. 15
0
        public override void Make(IConfigurationType config, IExpressionsManager manager)
        {
            if (null == config)
            {
                throw new ArgumentNullException("config");
            }
            IConfigurationElement element = config as IConfigurationElement;

            if (null == element)
            {
                throw new ArgumentException("config must be an IConfigurationElement");
            }

            if (element.Elements.ContainsKey("source"))
            {
                IConfigurationElement sourceElement = element.GetElementReference("source");

                if (sourceElement.Attributes.ContainsKey("id"))
                {
                    if (null == manager)
                    {
                        throw new ArgumentNullException("manager");
                    }

                    this.Source = manager.FindControl(sourceElement.GetAttributeReference("id").Value.ToString());
                    if (null == this.Source)
                    {
                        this.Source = sourceElement.GetAttributeReference("id").Value;
                    }
                    if (sourceElement.Attributes.ContainsKey("member"))
                    {
                        this.Member = sourceElement.GetAttributeReference("member").Value.ToString();
                    }
                }
                else
                {
                    if (sourceElement.Attributes.ContainsKey("value"))
                    {
                        this.Source = sourceElement.GetAttributeReference("value").Value;
                    }
                }
            }
        }
Esempio n. 16
0
        public override void Make(IConfigurationType config, IExpressionsManager manager)
        {
            if (null == manager) throw new ArgumentNullException("manager");
            if (null == config)throw new ArgumentNullException("config");
            IConfigurationElement element = config as IConfigurationElement;
            if (null == element) throw new ArgumentException("config must be an IConfigurationElement");

            if (element.Elements.ContainsKey("operands"))
            {
                foreach (IConfigurationElement operandElement in element.GetElementReference("operands").Elements.Values)
                {
                    string type = operandElement.GetAttributeReference("type").Value.ToString();
                    IToken token = manager.Token(type);
                    if (null == token) throw new InvalidOperationException(string.Format("Cannot make the type '{0}'", type));

                    token.Make(operandElement, manager);
                    this.Operands.Add(token);
                }
            }
        }
Esempio n. 17
0
        public override void Create(Control container, IConfigurationType config, ITemplatable templatable, WebPartManager manager)
        {
            if (null == container)
            {
                throw new ArgumentNullException("container");
            }
            if (null == config)
            {
                throw new ArgumentNullException("config");
            }
            if (!(config is IConfigurationSection))
            {
                throw new ArgumentException("config must be an IConfigurationSection");
            }
            IDictionary <string, IConfigurationElement> itemElements = (config as IConfigurationSection).Elements;

            if (itemElements.ContainsKey("footer"))
            {
                Table table;
                if (container is Table)
                {
                    table = (container as Table);
                }
                else
                {
                    table    = new Table();
                    table.ID = container.ID + "footer";
                }
                table.ApplyStyle(templatable.FooterStyle);
                foreach (IConfigurationElement element in itemElements["footer"].Elements.Values)
                {
                    this.DisplayItem(table, element, "footer-" + element.ConfigKey, null, null, templatable.FooterRowStyle, templatable.InvalidItemStyle, manager);
                }
                if (!(container is Table))
                {
                    container.Controls.Add(table);
                }
            }
        }
Esempio n. 18
0
 public override void Create(Control container, IConfigurationType config, ITemplatable templatable, WebPartManager manager)
 {
     if (null == container)
     {
         throw new ArgumentNullException("container");
     }
     if (null == config)
     {
         throw new ArgumentNullException("config");
     }
     if (!(config is IConfigurationSection))
     {
         throw new ArgumentException("config must be an IConfigurationSection");
     }
     IDictionary<string, IConfigurationElement> itemElements = (config as IConfigurationSection).Elements;
     if (itemElements.ContainsKey("header"))
     {
         Table table;
         if (container is Table)
         {
             table = (container as Table);
         }
         else
         {
             table = new Table();
             table.ID = container.ID + "header";
         }
         table.ApplyStyle(templatable.HeaderStyle);
         foreach (IConfigurationElement element in itemElements["header"].Elements.Values)
         {
             this.DisplayItem(table, element, "header-" + element.ConfigKey, null, null, templatable.HeaderRowStyle, templatable.InvalidItemStyle, manager);
         }
         if (!(container is Table))
         {
             container.Controls.Add(table);
         }
     }
 }
Esempio n. 19
0
 public override void Create(Control container, IConfigurationType config, ITemplatable templatable, IBinder binder, ITemplatingItem item, int itemIndex, WebPartManager manager)
 {
     if (null == container)
     {
         throw new ArgumentNullException("container");
     }
     if (null == config)
     {
         throw new ArgumentNullException("config");
     }
     if (!(config is IConfigurationSection))
     {
         throw new ArgumentException("config must be an IConfigurationSection");
     }
     if ((config as IConfigurationSection).Elements.ContainsKey("totals"))
     {
         Table table;
         if (container is Table)
         {
             table = (container as Table);
         }
         else
         {
             table = new Table();
             table.ApplyStyle(templatable.TotalsStyle);
         }
         IConfigurationElement element = (config as IConfigurationSection).GetElementReference("totals");
         foreach (IConfigurationElement rowElement in element.Elements.Values)
         {
             this.DisplayItem(table, rowElement, "totals" + itemIndex.ToString(), binder, item, templatable.TotalsRowStyle, templatable.InvalidItemStyle, manager);
         }
         if (!(container is Table))
         {
             container.Controls.Add(table);
         }
     }
 }
Esempio n. 20
0
 public override void Create(Control container, IConfigurationType config, ITemplatable templatable, IBinder binder, ITemplatingItem item, int itemIndex, WebPartManager manager)
 {
     if (null == container)
     {
         throw new ArgumentNullException("container");
     }
     if (null == config)
     {
         throw new ArgumentNullException("config");
     }
     if (!(config is IConfigurationSection))
     {
         throw new ArgumentException("config must be an IConfigurationSection");
     }
     if ((config as IConfigurationSection).Elements.ContainsKey("totals"))
     {
         Table table;
         if (container is Table)
         {
             table = (container as Table);
         }
         else
         {
             table = new Table();
             table.ApplyStyle(templatable.TotalsStyle);
         }
         IConfigurationElement element = (config as IConfigurationSection).GetElementReference("totals");
         foreach (IConfigurationElement rowElement in element.Elements.Values)
         {
             this.DisplayItem(table, rowElement, "totals" + itemIndex.ToString(), binder, item, templatable.TotalsRowStyle, templatable.InvalidItemStyle, manager);
         }
         if (!(container is Table))
         {
             container.Controls.Add(table);
         }
     }
 }
Esempio n. 21
0
 public virtual void Create(Control container, IConfigurationType config, ITemplatable templatable, WebPartManager manager)
 {
     throw new NotImplementedException();
 }
Esempio n. 22
0
 public ConfigurationType(IConfigurationType anotherConfigurationType)
 {
     this.ConfigKey = anotherConfigurationType.ConfigKey;
 }
Esempio n. 23
0
 public ConfigurationType(IConfigurationType anotherConfigurationType)
 {
     this.ConfigKey = anotherConfigurationType.ConfigKey;
 }
Esempio n. 24
0
 public override void Extract(Control container, IConfigurationType config, IEnumerable registry, WebPartManager manager)
 {
     if (null == container)
     {
         throw new ArgumentNullException("container");
     }
     if (null == config)
     {
         throw new ArgumentNullException("config");
     }
     if (!(config is IConfigurationSection))
     {
         throw new ArgumentException("config must be an IConfigurationSection");
     }
     if (!(registry is ITemplatingItemsCollection))
     {
         throw new ArgumentException("registry must be an ITemplatingItemsCollection");
     }
     ITemplatingItemsCollection filters = registry as ITemplatingItemsCollection;
     if (filters.Count != 0)
     {
         IDictionary<string, IConfigurationElement> itemElements = (config as IConfigurationSection).Elements;
         if (itemElements.ContainsKey("filter"))
         {
             for (int i = 0; i < filters.Count; i++)
             {
                 Dictionary<string, object> data = filters[i].Data as Dictionary<string, object>;
                 foreach (IConfigurationElement element in itemElements["filter"].Elements.Values)
                 {
                     string prefix = "filter" + element.ConfigKey + i.ToString();
                     foreach (IConfigurationElement fieldElement in element.Elements.Values)
                     {
                         foreach (IConfigurationElement propertyElement in fieldElement.Elements.Values)
                         {
                             if (propertyElement.Attributes.ContainsKey("push"))
                             {
                                 string propertyName = propertyElement.GetAttributeReference("member").Value.ToString();
                                 string sourcePropertyName = propertyElement.GetAttributeReference("push").Value.ToString();
                                 if (!data.ContainsKey(sourcePropertyName))
                                 {
                                     data.Add(sourcePropertyName, null);
                                 }
                                 string id = string.Concat(new string[]
                                 {
                                     container.ID,
                                     "-",
                                     element.ConfigKey,
                                     "-",
                                     prefix,
                                     "-",
                                     fieldElement.ConfigKey,
                                     "-ctrl"
                                 });
                                 Control fieldControl = ReflectionServices.FindControlEx(id, container);
                                 if (null != fieldControl)
                                 {
                                     data[sourcePropertyName] = ReflectionServices.ExtractValue(fieldControl, propertyName);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 25
0
 public virtual void Create(Control container, IConfigurationType config, ITemplatable templatable, IEnumerable registry, IBinder binder, WebPartManager manager)
 {
     throw new NotImplementedException();
 }
Esempio n. 26
0
        public virtual void PopulateItem(Control container, IConfigurationType config, ITemplatingItem item, string index)
        {
            if (null == container)
            {
                throw new ArgumentNullException("container");
            }
            if (null == config)
            {
                throw new ArgumentNullException("config");
            }
            if (!(config is IConfigurationSection))
            {
                throw new ArgumentException("config must be an IConfigurationSection");
            }
            item.Data = new Dictionary <string, object>();
            Dictionary <string, object> data = item.Data as Dictionary <string, object>;
            IDictionary <string, IConfigurationElement> itemElements = (config as IConfigurationSection).Elements;

            foreach (IConfigurationElement element in itemElements.Values)
            {
                if (!("selectors" == element.ConfigKey) && !("commanders" == element.ConfigKey) && !("filter" == element.ConfigKey) && !("header" == element.ConfigKey) && !("footer" == element.ConfigKey))
                {
                    foreach (IConfigurationElement fieldElement in element.Elements.Values)
                    {
                        foreach (IConfigurationElement propertyElement in fieldElement.Elements.Values)
                        {
                            if (propertyElement.Attributes.ContainsKey("push"))
                            {
                                string propertyName       = propertyElement.GetAttributeReference("member").Value.ToString();
                                string sourcePropertyName = propertyElement.GetAttributeReference("push").Value.ToString();
                                if (!data.ContainsKey(sourcePropertyName))
                                {
                                    data.Add(sourcePropertyName, null);
                                }
                                if (!string.IsNullOrEmpty(index))
                                {
                                    string id = string.Concat(new string[]
                                    {
                                        container.ID,
                                        "-",
                                        element.ConfigKey,
                                        "-",
                                        index,
                                        "-",
                                        fieldElement.ConfigKey,
                                        "-ctrl"
                                    });
                                    Control fieldControl = ReflectionServices.FindControlEx(id, container);
                                    if (null != fieldControl)
                                    {
                                        object val = ReflectionServices.ExtractValue(fieldControl, propertyName);
                                        if (fieldControl is DateTextBox && val == null && propertyName == "Date")
                                        {
                                            val = ((DateTextBox)fieldControl).Text;
                                        }
                                        data[sourcePropertyName] = val;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 27
0
        public override void Create(Control container, IConfigurationType config, ITemplatable templatable, IBinder binder, ITemplatingItem item, int itemIndex, WebPartManager manager)
        {
            if (null == container)
            {
                throw new ArgumentNullException("container");
            }
            if (null == config)
            {
                throw new ArgumentNullException("config");
            }
            if (!(config is IConfigurationSection))
            {
                throw new ArgumentException("config must be an IConfigurationSection");
            }
            IDictionary <string, IConfigurationElement> itemElements = (config as IConfigurationSection).Elements;
            Table table;

            if (container is Table)
            {
                table = (container as Table);
            }
            else
            {
                table = new Table();
            }
            table.ApplyStyle(templatable.DetailsStyle);

            Panel       statusPanel    = new Panel();
            HiddenField hiddenReadOnly = new HiddenField();

            hiddenReadOnly.ID    = itemIndex.ToString() + "-readOnly";
            hiddenReadOnly.Value = item.IsReadOnly.ToString();
            statusPanel.Controls.Add(hiddenReadOnly);
            HiddenField hiddenNew = new HiddenField();

            hiddenNew.ID    = itemIndex.ToString() + "-new";
            hiddenNew.Value = item.IsNew.ToString();
            statusPanel.Controls.Add(hiddenNew);
            HiddenField hiddenCurrent = new HiddenField();

            hiddenCurrent.ID    = itemIndex.ToString() + "-current";
            hiddenCurrent.Value = item.IsCurrent.ToString();
            statusPanel.Controls.Add(hiddenCurrent);
            HiddenField hiddenHasChanges = new HiddenField();

            hiddenHasChanges.ID    = itemIndex.ToString() + "-hasChanges";
            hiddenHasChanges.Value = item.HasChanges.ToString();
            statusPanel.Controls.Add(hiddenHasChanges);
            HiddenField hiddenIsValid = new HiddenField();

            hiddenIsValid.ID    = itemIndex.ToString() + "-isValid";
            hiddenIsValid.Value = item.IsValid.ToString();
            statusPanel.Controls.Add(hiddenIsValid);
            HiddenField hiddenInvalidMember = new HiddenField();

            hiddenInvalidMember.ID    = itemIndex.ToString() + "-invalidMember";
            hiddenInvalidMember.Value = item.InvalidMember;
            statusPanel.Controls.Add(hiddenInvalidMember);

            if (null != item)
            {
                item.BoundControls.Clear();
            }
            foreach (IConfigurationElement element in itemElements.Values)
            {
                if (!("selectors" == element.ConfigKey) && !("commanders" == element.ConfigKey) && !("filter" == element.ConfigKey) && !("header" == element.ConfigKey) && !("footer" == element.ConfigKey) && !("grouping" == element.ConfigKey) && !("totals" == element.ConfigKey))
                {
                    if (item.IsCurrent && !item.IsReadOnly)
                    {
                        this.DisplayItem(table, element, itemIndex.ToString(), binder, item, templatable.EditRowStyle, templatable.InvalidItemStyle, manager);
                    }
                    else
                    {
                        if (item.IsCurrent)
                        {
                            this.DisplayItem(table, element, itemIndex.ToString(), binder, item, templatable.SelectedRowStyle, templatable.InvalidItemStyle, manager);
                        }
                        else
                        {
                            if (itemIndex % 2 == 0)
                            {
                                this.DisplayItem(table, element, itemIndex.ToString(), binder, item, templatable.RowStyle, templatable.InvalidItemStyle, manager);
                            }
                            else
                            {
                                this.DisplayItem(table, element, itemIndex.ToString(), binder, item, templatable.AlternatingRowStyle, templatable.InvalidItemStyle, manager);
                            }
                        }
                    }
                }
            }
            if (table.Rows.Count > 0)
            {
                if (!(table.Rows[0].Cells.Count > 0))
                {
                    TableCell firstcell = new TableCell();
                    firstcell.ID = table.Rows[0].ID + "firstcell";
                    table.Rows[0].Cells.Add(firstcell);
                }

                table.Rows[0].Cells[0].Controls.Add(statusPanel);
            }
        }
Esempio n. 28
0
        public override void Extract(Control container, IConfigurationType config, ITemplatable templatable, IBinder binder, IEnumerable registry, ITemplatingItem item, int itemIndex, int itemsCount, WebPartManager manager)
        {
            if (null == container)
            {
                throw new ArgumentNullException("container");
            }
            if (null == config)
            {
                throw new ArgumentNullException("config");
            }
            if (!(config is IConfigurationSection))
            {
                throw new ArgumentException("config must be an IConfigurationSection");
            }
            if (!(registry is ITemplatingItemsCollection))
            {
                throw new ArgumentException("registry must be ITemplatingItemsCollection");
            }
            ITemplatingItemsCollection items = registry as ITemplatingItemsCollection;

            items.Clear();
            IDictionary <string, IConfigurationElement> itemElements = (config as IConfigurationSection).Elements;

            for (int i = 0; i < itemsCount; i++)
            {
                item = new TemplatingItem();
                Control hiddenReadOnly = ReflectionServices.FindControlEx(i.ToString() + "-readOnly", container);
                if (null != hiddenReadOnly)
                {
                    bool isReadOnly = false;
                    bool.TryParse(((HiddenField)hiddenReadOnly).Value, out isReadOnly);
                    item.IsReadOnly = isReadOnly;
                }
                Control hiddenNew = ReflectionServices.FindControlEx(i.ToString() + "-new", container);
                if (null != hiddenNew)
                {
                    bool isNew = false;
                    bool.TryParse(((HiddenField)hiddenNew).Value, out isNew);
                    item.IsNew = isNew;
                }
                Control hiddenCurrent = ReflectionServices.FindControlEx(i.ToString() + "-current", container);
                if (null != hiddenCurrent)
                {
                    bool isCurrent = false;
                    bool.TryParse(((HiddenField)hiddenCurrent).Value, out isCurrent);
                    item.IsCurrent = isCurrent;
                }
                Control hiddenHasChanges = ReflectionServices.FindControlEx(i.ToString() + "-hasChanges", container);
                if (null != hiddenHasChanges)
                {
                    bool hasChanges = false;
                    bool.TryParse(((HiddenField)hiddenHasChanges).Value, out hasChanges);
                    item.HasChanges = hasChanges;
                }
                Control hiddenIsValid = ReflectionServices.FindControlEx(i.ToString() + "-isValid", container);
                if (null != hiddenIsValid)
                {
                    bool isValid = false;
                    bool.TryParse(((HiddenField)hiddenIsValid).Value, out isValid);
                    item.IsValid = isValid;
                }
                Control hiddenInvalidMember = ReflectionServices.FindControlEx(i.ToString() + "-invalidMember", container);
                if (null != hiddenInvalidMember)
                {
                    item.InvalidMember = ((HiddenField)hiddenInvalidMember).Value;
                }
                this.PopulateItem(container, config, item, i.ToString());
                items.Add(item);
            }
        }
Esempio n. 29
0
 public virtual void CreateFilter(IConfigurationType config, ITemplatingItemsCollection filters, IBinder binder, ITemplatable templatable)
 {
     FiltersTemplate.Instance.Create(_container, config, templatable, filters, binder, this.manager);
 }
Esempio n. 30
0
 public virtual void CreateCommanders(IConfigurationType config, ITemplatable templatable, Dictionary<string, Control> commanders)
 {
     CommandersTemplate.Instance.Create(_commandersHolder, config, templatable, commanders, this.manager);
 }
Esempio n. 31
0
 public override void Create(Control container, IConfigurationType config, ITemplatable templatable, IBinder binder, ITemplatingItem item, int itemIndex, WebPartManager manager)
 {
     this.Create(container, config, templatable, binder, item, itemIndex, manager, false);
 }
Esempio n. 32
0
 public virtual void ExtractItems(IConfigurationType config, int itemsCount, ITemplatingItemsCollection items)
 {
     ItemTemplate.Instance.Extract(_container, config, null, null, items, null, -1, itemsCount, this.manager);
 }
Esempio n. 33
0
File: Token.cs Progetto: t1b1c/lwas
 public virtual void Make(IConfigurationType config, IExpressionsManager manager)
 {
 }
Esempio n. 34
0
 public override void Extract(Control container, IConfigurationType config, ITemplatable templatable, IBinder binder, IEnumerable registry, ITemplatingItem item, int itemIndex, int itemsCount, WebPartManager manager)
 {
     if (null == container)
     {
         throw new ArgumentNullException("container");
     }
     if (null == config)
     {
         throw new ArgumentNullException("config");
     }
     if (!(config is IConfigurationSection))
     {
         throw new ArgumentException("config must be an IConfigurationSection");
     }
     if (!(registry is ITemplatingItemsCollection))
     {
         throw new ArgumentException("registry must be ITemplatingItemsCollection");
     }
     ITemplatingItemsCollection items = registry as ITemplatingItemsCollection;
     items.Clear();
     IDictionary<string, IConfigurationElement> itemElements = (config as IConfigurationSection).Elements;
     for (int i = 0; i < itemsCount; i++)
     {
         item = new TemplatingItem();
         Control hiddenReadOnly = ReflectionServices.FindControlEx(i.ToString() + "-readOnly", container);
         if (null != hiddenReadOnly)
         {
             bool isReadOnly = false;
             bool.TryParse(((HiddenField)hiddenReadOnly).Value, out isReadOnly);
             item.IsReadOnly = isReadOnly;
         }
         Control hiddenNew = ReflectionServices.FindControlEx(i.ToString() + "-new", container);
         if (null != hiddenNew)
         {
             bool isNew = false;
             bool.TryParse(((HiddenField)hiddenNew).Value, out isNew);
             item.IsNew = isNew;
         }
         Control hiddenCurrent = ReflectionServices.FindControlEx(i.ToString() + "-current", container);
         if (null != hiddenCurrent)
         {
             bool isCurrent = false;
             bool.TryParse(((HiddenField)hiddenCurrent).Value, out isCurrent);
             item.IsCurrent = isCurrent;
         }
         Control hiddenHasChanges = ReflectionServices.FindControlEx(i.ToString() + "-hasChanges", container);
         if (null != hiddenHasChanges)
         {
             bool hasChanges = false;
             bool.TryParse(((HiddenField)hiddenHasChanges).Value, out hasChanges);
             item.HasChanges = hasChanges;
         }
         Control hiddenIsValid = ReflectionServices.FindControlEx(i.ToString() + "-isValid", container);
         if (null != hiddenIsValid)
         {
             bool isValid = false;
             bool.TryParse(((HiddenField)hiddenIsValid).Value, out isValid);
             item.IsValid = isValid;
         }
         Control hiddenInvalidMember = ReflectionServices.FindControlEx(i.ToString() + "-invalidMember", container);
         if (null != hiddenInvalidMember)
         {
             item.InvalidMember = ((HiddenField)hiddenInvalidMember).Value;
         }
         this.PopulateItem(container, config, item, i.ToString());
         items.Add(item);
     }
 }
Esempio n. 35
0
 public virtual void Extract(Control container, IConfigurationType config, IEnumerable registry, WebPartManager manager)
 {
     throw new NotImplementedException();
 }
Esempio n. 36
0
 public virtual void PopulateItem(Control container, IConfigurationType config, ITemplatingItem item, string index)
 {
     if (null == container)
     {
         throw new ArgumentNullException("container");
     }
     if (null == config)
     {
         throw new ArgumentNullException("config");
     }
     if (!(config is IConfigurationSection))
     {
         throw new ArgumentException("config must be an IConfigurationSection");
     }
     item.Data = new Dictionary<string, object>();
     Dictionary<string, object> data = item.Data as Dictionary<string, object>;
     IDictionary<string, IConfigurationElement> itemElements = (config as IConfigurationSection).Elements;
     foreach (IConfigurationElement element in itemElements.Values)
     {
         if (!("selectors" == element.ConfigKey) && !("commanders" == element.ConfigKey) && !("filter" == element.ConfigKey) && !("header" == element.ConfigKey) && !("footer" == element.ConfigKey))
         {
             foreach (IConfigurationElement fieldElement in element.Elements.Values)
             {
                 foreach (IConfigurationElement propertyElement in fieldElement.Elements.Values)
                 {
                     if (propertyElement.Attributes.ContainsKey("push"))
                     {
                         string propertyName = propertyElement.GetAttributeReference("member").Value.ToString();
                         string sourcePropertyName = propertyElement.GetAttributeReference("push").Value.ToString();
                         if (!data.ContainsKey(sourcePropertyName))
                         {
                             data.Add(sourcePropertyName, null);
                         }
                         if (!string.IsNullOrEmpty(index))
                         {
                             string id = string.Concat(new string[]
                             {
                                 container.ID,
                                 "-",
                                 element.ConfigKey,
                                 "-",
                                 index,
                                 "-",
                                 fieldElement.ConfigKey,
                                 "-ctrl"
                             });
                             Control fieldControl = ReflectionServices.FindControlEx(id, container);
                             if (null != fieldControl)
                             {
                                 object val = ReflectionServices.ExtractValue(fieldControl, propertyName);
                                 if (fieldControl is DateTextBox && val == null && propertyName == "Date")
                                 {
                                     val = ((DateTextBox)fieldControl).Text;
                                 }
                                 data[sourcePropertyName] = val;
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 37
0
 public void PopulateItem(IConfigurationType config, ITemplatingItem item, string prefix)
 {
     ItemTemplate.Instance.PopulateItem(_container, config, item, prefix);
 }
Esempio n. 38
0
        public override void Create(Control container, IConfigurationType config, ITemplatable templatable, IBinder binder, ITemplatingItem item, int itemIndex, WebPartManager manager)
        {
            if (null == container)
            {
                throw new ArgumentNullException("container");
            }
            if (null == config)
            {
                throw new ArgumentNullException("config");
            }
            if (!(config is IConfigurationSection))
            {
                throw new ArgumentException("config must be an IConfigurationSection");
            }
            IDictionary<string, IConfigurationElement> itemElements = (config as IConfigurationSection).Elements;
            Table table;
            if (container is Table)
            {
                table = (container as Table);
            }
            else
            {
                table = new Table();
            }
            table.ApplyStyle(templatable.DetailsStyle);

            Panel statusPanel = new Panel();
            HiddenField hiddenReadOnly = new HiddenField();
            hiddenReadOnly.ID = itemIndex.ToString() + "-readOnly";
            hiddenReadOnly.Value = item.IsReadOnly.ToString();
            statusPanel.Controls.Add(hiddenReadOnly);
            HiddenField hiddenNew = new HiddenField();
            hiddenNew.ID = itemIndex.ToString() + "-new";
            hiddenNew.Value = item.IsNew.ToString();
            statusPanel.Controls.Add(hiddenNew);
            HiddenField hiddenCurrent = new HiddenField();
            hiddenCurrent.ID = itemIndex.ToString() + "-current";
            hiddenCurrent.Value = item.IsCurrent.ToString();
            statusPanel.Controls.Add(hiddenCurrent);
            HiddenField hiddenHasChanges = new HiddenField();
            hiddenHasChanges.ID = itemIndex.ToString() + "-hasChanges";
            hiddenHasChanges.Value = item.HasChanges.ToString();
            statusPanel.Controls.Add(hiddenHasChanges);
            HiddenField hiddenIsValid = new HiddenField();
            hiddenIsValid.ID = itemIndex.ToString() + "-isValid";
            hiddenIsValid.Value = item.IsValid.ToString();
            statusPanel.Controls.Add(hiddenIsValid);
            HiddenField hiddenInvalidMember = new HiddenField();
            hiddenInvalidMember.ID = itemIndex.ToString() + "-invalidMember";
            hiddenInvalidMember.Value = item.InvalidMember;
            statusPanel.Controls.Add(hiddenInvalidMember);

            if (null != item)
            {
                item.BoundControls.Clear();
            }
            foreach (IConfigurationElement element in itemElements.Values)
            {
                if (!("selectors" == element.ConfigKey) && !("commanders" == element.ConfigKey) && !("filter" == element.ConfigKey) && !("header" == element.ConfigKey) && !("footer" == element.ConfigKey) && !("grouping" == element.ConfigKey) && !("totals" == element.ConfigKey))
                {
                    if (item.IsCurrent && !item.IsReadOnly)
                    {
                        this.DisplayItem(table, element, itemIndex.ToString(), binder, item, templatable.EditRowStyle, templatable.InvalidItemStyle, manager);
                    }
                    else
                    {
                        if (item.IsCurrent)
                        {
                            this.DisplayItem(table, element, itemIndex.ToString(), binder, item, templatable.SelectedRowStyle, templatable.InvalidItemStyle, manager);
                        }
                        else
                        {
                            if (itemIndex % 2 == 0)
                            {
                                this.DisplayItem(table, element, itemIndex.ToString(), binder, item, templatable.RowStyle, templatable.InvalidItemStyle, manager);
                            }
                            else
                            {
                                this.DisplayItem(table, element, itemIndex.ToString(), binder, item, templatable.AlternatingRowStyle, templatable.InvalidItemStyle, manager);
                            }
                        }
                    }
                }
            }
            if (table.Rows.Count > 0)
            {
                if (!(table.Rows[0].Cells.Count > 0))
                {
                    TableCell firstcell = new TableCell();
                    firstcell.ID = table.Rows[0].ID + "firstcell";
                    table.Rows[0].Cells.Add(firstcell);
                }

                table.Rows[0].Cells[0].Controls.Add(statusPanel);
            }
        }
Esempio n. 39
0
        public override void Extract(Control container, IConfigurationType config, IEnumerable registry, WebPartManager manager)
        {
            if (null == container)
            {
                throw new ArgumentNullException("container");
            }
            if (null == config)
            {
                throw new ArgumentNullException("config");
            }
            if (!(config is IConfigurationSection))
            {
                throw new ArgumentException("config must be an IConfigurationSection");
            }
            if (!(registry is ITemplatingItemsCollection))
            {
                throw new ArgumentException("registry must be an ITemplatingItemsCollection");
            }
            ITemplatingItemsCollection filters = registry as ITemplatingItemsCollection;

            if (filters.Count != 0)
            {
                IDictionary <string, IConfigurationElement> itemElements = (config as IConfigurationSection).Elements;
                if (itemElements.ContainsKey("filter"))
                {
                    for (int i = 0; i < filters.Count; i++)
                    {
                        Dictionary <string, object> data = filters[i].Data as Dictionary <string, object>;
                        foreach (IConfigurationElement element in itemElements["filter"].Elements.Values)
                        {
                            string prefix = "filter" + element.ConfigKey + i.ToString();
                            foreach (IConfigurationElement fieldElement in element.Elements.Values)
                            {
                                foreach (IConfigurationElement propertyElement in fieldElement.Elements.Values)
                                {
                                    if (propertyElement.Attributes.ContainsKey("push"))
                                    {
                                        string propertyName       = propertyElement.GetAttributeReference("member").Value.ToString();
                                        string sourcePropertyName = propertyElement.GetAttributeReference("push").Value.ToString();
                                        if (!data.ContainsKey(sourcePropertyName))
                                        {
                                            data.Add(sourcePropertyName, null);
                                        }
                                        string id = string.Concat(new string[]
                                        {
                                            container.ID,
                                            "-",
                                            element.ConfigKey,
                                            "-",
                                            prefix,
                                            "-",
                                            fieldElement.ConfigKey,
                                            "-ctrl"
                                        });
                                        Control fieldControl = ReflectionServices.FindControlEx(id, container);
                                        if (null != fieldControl)
                                        {
                                            data[sourcePropertyName] = ReflectionServices.ExtractValue(fieldControl, propertyName);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 40
0
 public virtual void ExtractFilter(IConfigurationType config, ITemplatingItemsCollection filters)
 {
     FiltersTemplate.Instance.Extract(_container, config, filters, this.manager);
 }
Esempio n. 41
0
 public abstract void Make(IConfigurationType config, IExpressionsManager manager);
Esempio n. 42
0
 public virtual void CreateSelectors(IConfigurationType config, ITemplatable templatable, Dictionary<string, Control> selectors)
 {
     SelectorsTemplate.Instance.Create(_selectorsHolder, config, templatable, selectors, this.manager);
 }
Esempio n. 43
0
 public virtual void Create(Control container, IConfigurationType config, ITemplatable templatable, IEnumerable registry, IBinder binder, ITemplatingItem item, int itemIndex, WebPartManager manager)
 {
     throw new NotImplementedException();
 }
Esempio n. 44
0
        public override void Make(IConfigurationType config, IExpressionsManager manager)
        {
            if (null == config) throw new ArgumentNullException("config");
            if (null == manager) throw new ArgumentNullException("manager");

            IConfigurationElement tokenElement = config as IConfigurationElement;
            if (null == tokenElement) throw new ArgumentException("config is not an IConfigurationElement");
            if (!tokenElement.Elements.ContainsKey("source")) throw new ConfigurationException("Bad views token configuration: 'source' element not found");
            IConfigurationElement sourceElement = tokenElement.GetElementReference("source");
            if (!sourceElement.Attributes.ContainsKey("parameter")) throw new ConfigurationException("Bad views token configuration: 'source' element has no 'parameter' attribute");
            this.ParameterName = sourceElement.GetAttributeReference("parameter").Value.ToString();
        }
Esempio n. 45
0
 public virtual void Extract(Control container, IConfigurationType config, IEnumerable registry, WebPartManager manager)
 {
     throw new NotImplementedException();
 }
Esempio n. 46
0
 public MissingConfigurationException(string missing, IConfigurationType configSource)
 {
     this._message = string.Format("Missing {0} in configuration source {1}", missing, configSource.ConfigKey);
 }
Esempio n. 47
0
 public MissingConfigurationException(IConfigurationType configChild, IConfigurationType configParent, IConfigurationType configSource)
 {
     this._message = string.Format("Missing element {0} in {1} in {2}", configChild.ConfigKey, configParent.ConfigKey, configSource.ConfigKey);
 }
Esempio n. 48
0
 public MissingConfigurationException(IConfigurationType configSection)
 {
     this._message = string.Format("Missing section {0}", configSection.ConfigKey);
 }
Esempio n. 49
0
        public virtual void Create(Control container, IConfigurationType config, ITemplatable templatable, IBinder binder, ITemplatingItem item, int itemIndex, WebPartManager manager, bool keepTable)
        {
            if (null == container)
            {
                throw new ArgumentNullException("container");
            }
            if (null == config)
            {
                throw new ArgumentNullException("config");
            }
            if (!(config is IConfigurationSection))
            {
                throw new ArgumentException("config must be an IConfigurationSection");
            }
            Table containerTable;

            if (container is Table)
            {
                containerTable = (container as Table);
            }
            else
            {
                containerTable    = new Table();
                containerTable.ID = container.ID + "grouping";
            }
            IConfigurationElement element = (config as IConfigurationSection).GetElementReference("grouping");
            Table table;

            if (keepTable)
            {
                table = containerTable;
            }
            else
            {
                TableRow  tr = new TableRow();
                TableCell tc = new TableCell();
                table    = new Table();
                tr.ID    = "groupingTable" + itemIndex.ToString() + "row";
                tc.ID    = "groupingTable" + itemIndex.ToString() + "cell";
                table.ID = "groupingTable" + itemIndex.ToString();
                tc.Controls.Add(table);
                tr.Cells.Add(tc);
                containerTable.Rows.Add(tr);
                if (element.Attributes.ContainsKey("span"))
                {
                    int columnSpan = 1;
                    int.TryParse(element.GetAttributeReference("span").Value.ToString(), out columnSpan);
                    tc.ColumnSpan = columnSpan;
                }
                if (element.Attributes.ContainsKey("rowspan"))
                {
                    int rowSpan = 1;
                    int.TryParse(element.GetAttributeReference("rowspan").Value.ToString(), out rowSpan);
                    tc.RowSpan = rowSpan;
                }
            }
            table.ApplyStyle(templatable.GroupingStyle);
            foreach (IConfigurationElement rowElement in element.Elements.Values)
            {
                this.DisplayItem(table, rowElement, "grouping" + itemIndex.ToString(), binder, item, templatable.GroupRowStyle, templatable.InvalidItemStyle, manager);
            }
            if (!(container is Table))
            {
                container.Controls.Add(containerTable);
            }
        }
Esempio n. 50
0
 public MissingConfigurationException(IConfigurationType configChild, IConfigurationType configParent)
 {
     this._message = string.Format("Missing section {0} in {1}", configChild.ConfigKey, configParent.ConfigKey);
 }
Esempio n. 51
0
 public MissingConfigurationException(IConfigurationType configChild, IConfigurationType configParent)
 {
     this._message = string.Format("Missing section {0} in {1}", configChild.ConfigKey, configParent.ConfigKey);
 }
Esempio n. 52
0
 public MissingConfigurationException(IConfigurationType configChild, IConfigurationType configParent, IConfigurationType configSource)
 {
     this._message = string.Format("Missing element {0} in {1} in {2}", configChild.ConfigKey, configParent.ConfigKey, configSource.ConfigKey);
 }
Esempio n. 53
0
 public virtual void Create(Control container, IConfigurationType config, ITemplatable templatable, IBinder binder, ITemplatingItem item, int itemIndex, WebPartManager manager)
 {
     throw new NotImplementedException();
 }
Esempio n. 54
0
 public virtual void CreateHeader(IConfigurationType config, ITemplatable templatable)
 {
     HeaderTemplate.Instance.Create(_container, config, templatable, this.manager);
 }
Esempio n. 55
0
 public virtual void Extract(Control container, IConfigurationType config, ITemplatable templatable, IBinder binder, IEnumerable registry, ITemplatingItem item, int itemIndex, int itemsCount, WebPartManager manager)
 {
     throw new NotImplementedException();
 }
Esempio n. 56
0
File: Token.cs Progetto: t1b1c/lwas
 public virtual void Make(IConfigurationType config, IExpressionsManager manager)
 {
 }
Esempio n. 57
0
 public abstract void Make(IConfigurationType config, IExpressionsManager manager);
Esempio n. 58
0
 public virtual void InstantiateTotalsIn(IConfigurationType config, IBinder binder, int itemIndex, ITemplatingItem item, ITemplatable templatable)
 {
     TotalsTemplate.Instance.Create(_container, config, templatable, binder, item, itemIndex, this.manager);
 }
Esempio n. 59
0
 public void Build(DataTable table, IConfigurationType config)
 {
     if (null == table)
     {
         throw new ArgumentNullException("table");
     }
     if (null == config)
     {
         throw new ArgumentNullException("config");
     }
     IDictionary<string, IConfigurationElement> elements = null;
     if (config is IConfigurationSection)
     {
         elements = ((IConfigurationSection)config).Elements;
     }
     else
     {
         if (config is IConfigurationElement)
         {
             elements = ((IConfigurationElement)config).Elements;
         }
     }
     if (null == elements)
     {
         throw new ArgumentException("config has no Elements");
     }
     Dictionary<string, object> values = new Dictionary<string, object>();
     if (!table.Columns.Contains("PK"))
     {
         DataColumn pk = table.Columns.Add("PK", typeof(int));
         pk.AutoIncrement = true;
         pk.AutoIncrementSeed = 1L;
         pk.AutoIncrementStep = 1L;
         table.Constraints.Add("PK", pk, true);
     }
     values.Add("PK", null);
     List<DataColumn> columnsToRemove = new List<DataColumn>();
     foreach (DataColumn column in table.Columns)
     {
         columnsToRemove.Add(column);
     }
     foreach (IConfigurationElement rowElement in elements.Values)
     {
         foreach (IConfigurationElement controlElement in rowElement.Elements.Values)
         {
             foreach (IConfigurationElement propertyElement in controlElement.Elements.Values)
             {
                 if (propertyElement.Attributes.ContainsKey("pull"))
                 {
                     string pull = propertyElement.GetAttributeReference("pull").Value.ToString();
                     if (!table.Columns.Contains(pull))
                     {
                         table.Columns.Add(pull);
                         columnsToRemove.Remove(table.Columns[pull]);
                     }
                 }
                 if (propertyElement.Attributes.ContainsKey("push"))
                 {
                     string push = propertyElement.GetAttributeReference("push").Value.ToString();
                     if (!table.Columns.Contains(push))
                     {
                         table.Columns.Add(push);
                         columnsToRemove.Remove(table.Columns[push]);
                     }
                 }
             }
         }
     }
     foreach (DataColumn column in columnsToRemove)
     {
         if (column.ColumnName != "PK")
         {
             table.Columns.Remove(column);
         }
     }
 }
Esempio n. 60
0
        public void Build(DataTable table, IConfigurationType config)
        {
            if (null == table)
            {
                throw new ArgumentNullException("table");
            }
            if (null == config)
            {
                throw new ArgumentNullException("config");
            }
            IDictionary <string, IConfigurationElement> elements = null;

            if (config is IConfigurationSection)
            {
                elements = ((IConfigurationSection)config).Elements;
            }
            else
            {
                if (config is IConfigurationElement)
                {
                    elements = ((IConfigurationElement)config).Elements;
                }
            }
            if (null == elements)
            {
                throw new ArgumentException("config has no Elements");
            }
            Dictionary <string, object> values = new Dictionary <string, object>();

            if (!table.Columns.Contains("PK"))
            {
                DataColumn pk = table.Columns.Add("PK", typeof(int));
                pk.AutoIncrement     = true;
                pk.AutoIncrementSeed = 1L;
                pk.AutoIncrementStep = 1L;
                table.Constraints.Add("PK", pk, true);
            }
            values.Add("PK", null);
            List <DataColumn> columnsToRemove = new List <DataColumn>();

            foreach (DataColumn column in table.Columns)
            {
                columnsToRemove.Add(column);
            }
            foreach (IConfigurationElement rowElement in elements.Values)
            {
                foreach (IConfigurationElement controlElement in rowElement.Elements.Values)
                {
                    foreach (IConfigurationElement propertyElement in controlElement.Elements.Values)
                    {
                        if (propertyElement.Attributes.ContainsKey("pull"))
                        {
                            string pull = propertyElement.GetAttributeReference("pull").Value.ToString();
                            if (!table.Columns.Contains(pull))
                            {
                                table.Columns.Add(pull);
                                columnsToRemove.Remove(table.Columns[pull]);
                            }
                        }
                        if (propertyElement.Attributes.ContainsKey("push"))
                        {
                            string push = propertyElement.GetAttributeReference("push").Value.ToString();
                            if (!table.Columns.Contains(push))
                            {
                                table.Columns.Add(push);
                                columnsToRemove.Remove(table.Columns[push]);
                            }
                        }
                    }
                }
            }
            foreach (DataColumn column in columnsToRemove)
            {
                if (column.ColumnName != "PK")
                {
                    table.Columns.Remove(column);
                }
            }
        }