static LookupExpression ConvertFromBindingIdentifier(BindingIdentifier bindingIdentifier) { LookupExpression lookup = null; if (bindingIdentifier != null) { lookup = new LookupExpression(bindingIdentifier.Context) { Name = bindingIdentifier.Name, VariableField = bindingIdentifier.VariableField }; // the binding is now referenced from the lookup bindingIdentifier.VariableField.IfNotNull(v => v.References.Add(lookup)); } return(lookup); }
static BindingIdentifier ConvertToBindingIdentifier(LookupExpression lookup) { BindingIdentifier bindingIdentifier = null; if (lookup != null) { bindingIdentifier = new BindingIdentifier(lookup.Context) { Name = lookup.Name, VariableField = lookup.VariableField }; // the field now has another declaration, and one less reference lookup.VariableField.IfNotNull(v => { v.Declarations.Add(bindingIdentifier); v.References.Remove(lookup); }); } return(bindingIdentifier); }