private DataBinding TranslateBinding(DataBinding binding) { string path = binding.Path; int?index; if (path != null && indexAliases.TryGetValue(path, out index)) { return(binding.ReplaceIndex(index)); } return(binding); }
private ResolvedBinding ResolveBinding(DataBinding binding) { var resolvedBinding = binding as ResolvedBinding; if (resolvedBinding != null && resolvedBinding.DataSetInfo.IsOwnedBy(this)) { return(resolvedBinding); } int?externalIndex = binding.Index; if (!externalIndex.HasValue) { foreach (IDataSet dataSet in DataSets) { if (dataSet.CanBind(binding)) { return(new ResolvedBinding(lookupTable[dataSet], binding, null)); } } } else { DataBinding nullIndexBinding = null; int currentOffset = 0; foreach (IDataSet dataSet in DataSets) { int currentColumnCount = dataSet.ColumnCount; DataBinding currentBinding; if (currentOffset == 0) { currentBinding = binding; } else { int internalIndex = externalIndex.Value - currentOffset; if (internalIndex < 0 || internalIndex >= currentColumnCount) { if (nullIndexBinding == null) { nullIndexBinding = binding.ReplaceIndex(null); } currentBinding = nullIndexBinding; } else { currentBinding = binding.ReplaceIndex(internalIndex); } } if (dataSet.CanBind(currentBinding)) { return(new ResolvedBinding(lookupTable[dataSet], currentBinding, binding.Index)); } currentOffset += currentColumnCount; } } return(null); }