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


C# CompositeNode.FullNameWithoutIndexer方法代码示例

本文整理汇总了C#中Castle.Components.Binder.CompositeNode.FullNameWithoutIndexer方法的典型用法代码示例。如果您正苦于以下问题:C# CompositeNode.FullNameWithoutIndexer方法的具体用法?C# CompositeNode.FullNameWithoutIndexer怎么用?C# CompositeNode.FullNameWithoutIndexer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Castle.Components.Binder.CompositeNode的用法示例。


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

示例1: InternalRecursiveBindObjectInstance

		protected void InternalRecursiveBindObjectInstance(object instance, String prefix, CompositeNode node)
		{
			if (node == null || instance == null)
			{
				return;
			}

			BeforeBinding(instance, prefix, node);

			if (PerformCustomBinding(instance, prefix, node))
			{
				return;
			}

			PushInstance(instance, prefix);

			var summary = new ErrorSummary();

			validationErrorSummaryPerInstance[instance] = summary;

			Type instanceType = instance.GetType();

			PropertyInfo[] props = instanceType.GetProperties(PropertiesBindingFlags);
			var nodeFullName = node.FullNameWithoutIndexer();

			foreach (PropertyInfo prop in props)
			{
				if (ShouldIgnoreProperty(prop, nodeFullName))
				{
					continue;
				}

				Type propType = prop.PropertyType;
				String paramName = prop.Name;

				String translatedParamName = Translate(instanceType, paramName);

				if (translatedParamName == null)
				{
					continue;
				}

				bool isSimpleProperty = IsSimpleProperty(propType);

				BeforeBindingProperty(instance, prop, prefix, node);

				try
				{
					bool conversionSucceeded;

					if (isSimpleProperty)
					{
						object value = ConvertToSimpleValue(propType, translatedParamName, node, out conversionSucceeded);

						if (conversionSucceeded)
						{
							SetPropertyValue(instance, prop, value);
						}
					}
					else
					{
						// if the property is an object, we look if it is already instantiated
						Node nestedNode = node.GetChildNode(paramName);

						if (nestedNode != null)
						{
							object value = prop.GetValue(instance, null);

							if (ShouldRecreateInstance(value, propType, paramName, nestedNode))
							{
								value = InternalBindObject(propType, paramName, nestedNode, out conversionSucceeded);

								if (conversionSucceeded)
								{
									SetPropertyValue(instance, prop, value);
								}
							}
							else
							{
								InternalRecursiveBindObjectInstance(value, paramName, nestedNode);
							}
						}
					}
				}
				catch (Exception ex)
				{
					errors.Add(new DataBindError(prefix, prop.Name, ex));
				}
			}

			CheckForValidationFailures(instance, prefix, summary);

			PopInstance(instance, prefix);

			AfterBinding(instance, prefix, node);
		}
开发者ID:radiy,项目名称:Castle.Components.Binder,代码行数:96,代码来源:DataBinder.cs


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