public override bool TryGetLocationReference(string name, out LocationReference result) { if (name == null) { LocationReferenceEnvironment parent = base.Parent; while (parent is ActivityLocationReferenceEnvironment) { parent = parent.Parent; } if (parent != null) { return(parent.TryGetLocationReference(name, out result)); } } else { if ((this.declarations != null) && this.declarations.TryGetValue(name, out result)) { return(true); } bool flag = false; LocationReferenceEnvironment environment2 = base.Parent; while ((environment2 != null) && (environment2 is ActivityLocationReferenceEnvironment)) { ActivityLocationReferenceEnvironment environment3 = (ActivityLocationReferenceEnvironment)environment2; if ((environment3.declarations != null) && environment3.declarations.TryGetValue(name, out result)) { return(true); } environment2 = environment2.Parent; } if ((!flag && (environment2 != null)) && environment2.TryGetLocationReference(name, out result)) { return(true); } } result = null; return(false); }
public override bool TryGetLocationReference(string name, out LocationReference result) { if (name == null) { // We don't allow null names in our LocationReferenceEnvironment but // a custom declared environment might. We need to walk up // to the root and see if it chains to a // non-ActivityLocationReferenceEnvironment implementation LocationReferenceEnvironment currentEnvironment = this.Parent; while (currentEnvironment is ActivityLocationReferenceEnvironment) { currentEnvironment = currentEnvironment.Parent; } if (currentEnvironment != null) { Fx.Assert(!(currentEnvironment is ActivityLocationReferenceEnvironment), "We must be at a non-ActivityLocationReferenceEnvironment implementation."); return(currentEnvironment.TryGetLocationReference(name, out result)); } } else { if (this.declarations != null && this.declarations.TryGetValue(name, out result)) { return(true); } bool found = false; LocationReferenceEnvironment currentEnvironment = this.Parent; LocationReferenceEnvironment rootEnvironment = this; // Loop through all of the ActivityLocationReferenceEnvironments we have chained together while (currentEnvironment != null && currentEnvironment is ActivityLocationReferenceEnvironment) { ActivityLocationReferenceEnvironment activityEnvironment = (ActivityLocationReferenceEnvironment)currentEnvironment; if (activityEnvironment.declarations != null && activityEnvironment.declarations.TryGetValue(name, out result)) { return(true); } rootEnvironment = currentEnvironment; currentEnvironment = currentEnvironment.Parent; } if (!found) { if (currentEnvironment != null) { // Looks like we have a non-ActivityLocationReferenceEnvironment at the root Fx.Assert(!(currentEnvironment is ActivityLocationReferenceEnvironment), "We should have some other host environment at this point."); if (currentEnvironment.TryGetLocationReference(name, out result)) { return(true); } } } } result = null; return(false); }