当前位置: 首页>>代码示例>>C#>>正文


C# BindingSource类代码示例

本文整理汇总了C#中BindingSource的典型用法代码示例。如果您正苦于以下问题:C# BindingSource类的具体用法?C# BindingSource怎么用?C# BindingSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BindingSource类属于命名空间,在下文中一共展示了BindingSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetEnumerableValueProvider

 protected override IEnumerableValueProvider GetEnumerableValueProvider(
     BindingSource bindingSource,
     Dictionary<string, StringValues> values,
     CultureInfo culture)
 {
     return new JQueryFormValueProvider(bindingSource, values, culture);
 }
开发者ID:phinq19,项目名称:git_example,代码行数:7,代码来源:JQueryFormValueProviderTest.cs

示例2: SnakeCaseQueryValueProvider

 public SnakeCaseQueryValueProvider(
     BindingSource bindingSource, 
     IReadableStringCollection values, 
     CultureInfo culture)
     : base(bindingSource, values, culture)
 {
 }
开发者ID:Sorting,项目名称:SnakeCasify,代码行数:7,代码来源:SnakeCaseQueryValueProvider.cs

示例3: AddDefaultBinding

		/// <summary>
		/// Adds a default binding for the action. This will also add it to the regular bindings.
		/// </summary>
		/// <param name="binding">The BindingSource to add.</param>
		public void AddDefaultBinding( BindingSource binding )
		{
			if (binding == null)
			{
				return;
			}

			if (binding.BoundTo != null)
			{
				throw new InControlException( "Binding source is already bound to action " + binding.BoundTo.Name );
			}

			if (!defaultBindings.Contains( binding ))
			{
				defaultBindings.Add( binding );
				binding.BoundTo = this;
			}

			if (!regularBindings.Contains( binding ))
			{
				regularBindings.Add( binding );
				binding.BoundTo = this;

				if (binding.IsValid)
				{
					visibleBindings.Add( binding );
				}
			}
		}
开发者ID:ForsakenGS,项目名称:LostKids,代码行数:33,代码来源:PlayerAction.cs

示例4: GetChildBindingSources

    private static List<BindingSourceNode> GetChildBindingSources(
      IContainer container, BindingSource parent, BindingSourceNode parentNode)
    {
      List<BindingSourceNode> children = new List<BindingSourceNode>();

#if !WEBGUI
      foreach (System.ComponentModel.Component component in container.Components)
#else
      foreach (IComponent component in container.Components)
#endif
      {
        if (component is BindingSource)
        {
          BindingSource temp = component as BindingSource;
          if (temp.DataSource != null && temp.DataSource.Equals(parent))
          {
            BindingSourceNode childNode = new BindingSourceNode(temp);
            children.Add(childNode);
            childNode.Children.AddRange(GetChildBindingSources(container, temp, childNode));
            childNode.Parent = parentNode;
          }
        }
      }

      return children;
    }
开发者ID:transformersprimeabcxyz,项目名称:cslacontrib-MarimerLLC,代码行数:26,代码来源:BindingSourceHelper.cs

示例5: MainWindow

    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        Build ();

        labelError.ModifyFg (StateType.Normal, new Gdk.Color(255, 0, 0));
        gridview.AutoGenerateColumns = false;
        gridview.Columns.Add (new GridViewColumn () {
            DataPropertyName = "ProductID", HeaderText = "ID" });
        gridview.Columns.Add (new GridViewColumn () {
            DataPropertyName = "ProductName", HeaderText = "Name", Width = 160 });
        var colPrice = new GridViewColumn () {
            DataPropertyName = "Price", HeaderText = "Price", Width = 60};
        colPrice.DefaultCellStyle.Format = "C2";
        gridview.Columns.Add (colPrice);
        gridview.Columns.Add (new GridViewColumn () {
            DataPropertyName = "Favourite", HeaderText = "Favourite"});

        products = new LinqNotifiedBindingList<Product>() {};
        bsrcProducts = new BindingSource (){DataSource = products};
        gridview.DataSource = bsrcProducts;

        entryID.DataBindings.Add (new Binding ("Text", bsrcProducts, "ProductID", true, DataSourceUpdateMode.OnPropertyChanged));
        entryName.DataBindings.Add (new Binding ("Text", bsrcProducts, "ProductName", true, DataSourceUpdateMode.OnPropertyChanged));
        spinPrice.DataBindings.Add (new Binding ("Value", bsrcProducts, "Price", true, DataSourceUpdateMode.OnPropertyChanged));
        checkFavourite.DataBindings.Add (new Binding ("Active", bsrcProducts, "Favourite", true, DataSourceUpdateMode.OnPropertyChanged));
        gridview.HeadersClickable = true;
    }
开发者ID:pzsysa,项目名称:gtk-sharp-forms,代码行数:28,代码来源:MainWindow.cs

示例6: BindingSourceValueProvider

        /// <summary>
        /// Creates a new <see cref="BindingSourceValueProvider"/>.
        /// </summary>
        /// <param name="bindingSource">
        /// The <see cref="ModelBinding.BindingSource"/>. Must be a single-source (non-composite) with
        /// <see cref="ModelBinding.BindingSource.IsGreedy"/> equal to <c>false</c>.
        /// </param>
        public BindingSourceValueProvider(BindingSource bindingSource)
        {
            if (bindingSource == null)
            {
                throw new ArgumentNullException(nameof(bindingSource));
            }

            if (bindingSource.IsGreedy)
            {
                var message = Resources.FormatBindingSource_CannotBeGreedy(
                    bindingSource.DisplayName,
                    nameof(BindingSourceValueProvider));
                throw new ArgumentException(message, nameof(bindingSource));
            }

            if (bindingSource is CompositeBindingSource)
            {
                var message = Resources.FormatBindingSource_CannotBeComposite(
                    bindingSource.DisplayName,
                    nameof(BindingSourceValueProvider));
                throw new ArgumentException(message, nameof(bindingSource));
            }

            BindingSource = bindingSource;
        }
开发者ID:huoxudong125,项目名称:Mvc,代码行数:32,代码来源:BindingSourceValueProvider.cs

示例7: GetEnumerableValueProvider

 protected override IEnumerableValueProvider GetEnumerableValueProvider(
     BindingSource bindingSource,
     IDictionary<string, string[]> values,
     CultureInfo culture)
 {
     var backingStore = new ReadableStringCollection(values);
     return new ReadableStringCollectionValueProvider(bindingSource, backingStore, culture);
 }
开发者ID:ryanbrandenburg,项目名称:Mvc,代码行数:8,代码来源:ReadableStringCollectionValueProviderTest.cs

示例8: GetEnumerableValueProvider

 protected override IEnumerableValueProvider GetEnumerableValueProvider(
     BindingSource bindingSource,
     Dictionary<string, StringValues> values,
     CultureInfo culture)
 {
     var backingStore = new QueryCollection(values);
     return new QueryStringValueProvider(bindingSource, backingStore, culture);
 }
开发者ID:phinq19,项目名称:git_example,代码行数:8,代码来源:QueryStringValueProviderTest.cs

示例9: Filter

 /// <inheritdoc />
 public virtual IValueProvider Filter(BindingSource bindingSource)
 {
     if (bindingSource.CanAcceptDataFrom(BindingSource))
     {
         return this;
     }
     else
     {
         return null;
     }
 }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:12,代码来源:BindingSourceValueProvider.cs

示例10: ModelValidationContext

 public ModelValidationContext(
     BindingSource bindingSource,
     [NotNull] IModelValidatorProvider validatorProvider,
     [NotNull] ModelStateDictionary modelState,
     [NotNull] ModelExplorer modelExplorer)
 {
     ModelState = modelState;
     ValidatorProvider = validatorProvider;
     ModelExplorer = modelExplorer;
     BindingSource = bindingSource;
 }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:11,代码来源:ModelValidationContext.cs

示例11: TestArrowDemo

        public void TestArrowDemo()
        {
            Console.WriteLine("\t-- Testing arrow demo --\n");

            Arrow<int, int>.func demo1 = x => x * x + 3;

            // Simple arrow test - 'test' is passed through the function 'demo1' to 'result'
            TestSourceObject source = new TestSourceObject();
            source.value = 3;
            BindingDestination<int> result = new BindingDestination<int>(0);
            Arrow<int, int> testArrow = new Arrow<int, int>(demo1);
            ArrowTestThing.Binding<int, int> testBinding = new ArrowTestThing.Binding<int, int>(source, "value", testArrow, result);

            // Change the value of 'test' randomly and assert that 'result' changes accordingly
            Console.WriteLine("Testing single binding...");

            Random random = new Random();

            for (int i = 0; i < 500; i++)
            {
                source.value = random.Next(0, 1000);
                Assert.AreEqual(result, demo1(source.value));
            }

            Console.WriteLine("Tests passed!");
            Console.WriteLine();


            Arrow<int, int>.func2 demo2 = (b, h) => (b * h) / 2;

            // Pair arrow test - 's1' and 's2' are treated as the breadth and height of a triangle,
            // and 'result' is now bound to the area of said triangle
            BindingSource<int> s1 = new BindingSource<int>(4);
            BindingSource<int> s2 = new BindingSource<int>(3);
            Arrow<int, int> dualArrow = new Arrow<int, int>(demo2);
            PairBinding<int, int> pairBinding = new PairBinding<int, int>(s1, s2, dualArrow, result);

            // Change the values of 's1' and 's2' randomly and assert that 'result' changes accordingly
            Console.WriteLine("Testing double binding...");

            random = new Random();

            for (int i = 0; i < 500; i++)
            {
                s1.Value = random.Next(0, 1000);
                s2.Value = random.Next(0, 1000);
                Assert.AreEqual(result, demo2(s1.Value, s2.Value));
            }

            Console.WriteLine("Tests passed!");
            Console.WriteLine();

            Console.WriteLine("All tests passed successfully.\n\n");
        }
开发者ID:animatinator,项目名称:C-sharp-arrows,代码行数:54,代码来源:Tester.cs

示例12: InitializeBindingSourceTree

    /// <summary>
    /// Sets up BindingSourceNode objects for all
    /// BindingSource objects related to the provided
    /// root source.
    /// </summary>
    /// <param name="container">
    /// Container for the components.
    /// </param>
    /// <param name="rootSource">
    /// Root BindingSource object.
    /// </param>
    /// <returns></returns>
    public static BindingSourceNode InitializeBindingSourceTree(
      IContainer container, BindingSource rootSource)
    {
      if (rootSource == null)
        throw new ApplicationException(Resources.BindingSourceNotProvided);

      _rootSourceNode = new BindingSourceNode(rootSource);
      _rootSourceNode.Children.AddRange(GetChildBindingSources(container, rootSource, _rootSourceNode));

      return _rootSourceNode;
    }
开发者ID:transformersprimeabcxyz,项目名称:cslacontrib-MarimerLLC,代码行数:23,代码来源:BindingSourceHelper.cs

示例13: GetEnumerableValueProvider

        protected override IEnumerableValueProvider GetEnumerableValueProvider(
            BindingSource bindingSource,
            Dictionary<string, StringValues> values,
            CultureInfo culture)
        {
            var emptyValueProvider =
                new JQueryFormValueProvider(bindingSource, new Dictionary<string, StringValues>(), culture);
            var valueProvider = new JQueryFormValueProvider(bindingSource, values, culture);

            return new CompositeValueProvider() { emptyValueProvider, valueProvider };
        }
开发者ID:phinq19,项目名称:git_example,代码行数:11,代码来源:CompositeValueProviderTest.cs

示例14: DataContextChangeSynchronizer

        public DataContextChangeSynchronizer(BindingSource bindingSource, BindingTarget bindingTarget, ITypeConverterProvider typeConverterProvider)
        {
            _bindingTarget = bindingTarget;
            Guard.ThrowIfNull(bindingTarget.Object, nameof(bindingTarget.Object));
            Guard.ThrowIfNull(bindingTarget.Property, nameof(bindingTarget.Property));
            Guard.ThrowIfNull(bindingSource.SourcePropertyPath, nameof(bindingSource.SourcePropertyPath));
            Guard.ThrowIfNull(bindingSource.Source, nameof(bindingSource.Source));
            Guard.ThrowIfNull(typeConverterProvider, nameof(typeConverterProvider));

            _bindingEndpoint = new TargetBindingEndpoint(bindingTarget.Object, bindingTarget.Property);
            _sourceEndpoint = new ObservablePropertyBranch(bindingSource.Source, bindingSource.SourcePropertyPath);
            _targetPropertyTypeConverter = typeConverterProvider.GetTypeConverter(bindingTarget.Property.PropertyType);
        }
开发者ID:healtech,项目名称:Perspex,代码行数:13,代码来源:DataContextChangeSynchronizer.cs

示例15: Create_WhenBindingSourceIsNotFromServices_ReturnsNull

        public void Create_WhenBindingSourceIsNotFromServices_ReturnsNull(BindingSource source)
        {
            // Arrange
            var provider = new ServicesModelBinderProvider();

            var context = new TestModelBinderProviderContext(typeof(IPersonService));
            context.BindingInfo.BindingSource = source;

            // Act
            var result = provider.GetBinder(context);

            // Assert
            Assert.Null(result);
        }
开发者ID:ymd1223,项目名称:Mvc,代码行数:14,代码来源:ServicesModelBinderProviderTest.cs


注:本文中的BindingSource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。