CSLA.NET 5.4.2
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
BindingSourceHelper.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="BindingSourceHelper.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>Helper methods for dealing with BindingSource</summary>
7//-----------------------------------------------------------------------
8using System;
9using System.Collections.Generic;
10using System.ComponentModel;
11using System.Windows.Forms;
12using System.Text;
13using Csla.Properties;
14
15namespace Csla.Windows
16{
21 public static class BindingSourceHelper
22 {
23 private static BindingSourceNode _rootSourceNode;
24
37 public static BindingSourceNode InitializeBindingSourceTree(
38 IContainer container, BindingSource rootSource)
39 {
40 if (rootSource == null)
41 throw new ApplicationException(Resources.BindingSourceNotProvided);
42
43 _rootSourceNode = new BindingSourceNode(rootSource);
44 _rootSourceNode.Children.AddRange(GetChildBindingSources(container, rootSource, _rootSourceNode));
45
46 return _rootSourceNode;
47 }
48
49 private static List<BindingSourceNode> GetChildBindingSources(
50 IContainer container, BindingSource parent, BindingSourceNode parentNode)
51 {
52 List<BindingSourceNode> children = new List<BindingSourceNode>();
53
54 foreach (Component component in container.Components)
55 {
56 if (component is BindingSource)
57 {
58 BindingSource temp = component as BindingSource;
59 if (temp.DataSource != null && temp.DataSource.Equals(parent))
60 {
61 BindingSourceNode childNode = new BindingSourceNode(temp);
62 children.Add(childNode);
63 childNode.Children.AddRange(GetChildBindingSources(container, temp, childNode));
64 childNode.Parent = parentNode;
65 }
66 }
67 }
68
69 return children;
70 }
71
72 }
73}
A strongly-typed resource class, for looking up localized strings, etc.
static string BindingSourceNotProvided
Looks up a localized string similar to A root binding source has not been provided.