/// <summary> /// Process the specified name or object type ref. /// </summary> /// <param name="nameRefAttribute">the attribute to look for</param> /// <param name="lookupOnly">whether this is just a lookup (not a bind). if true, fieldOrProperty and object can be null.</param> /// <param name="isObjectTypeRef">true if this is an object type ref lookup, false if it is a nameref lookup</param> /// <param name="element">the element to examine</param> /// <param name="fieldOrProperty">the field or property to set the value on</param> /// <param name="o">the object instance to set the value on</param> /// <returns>A post process action, or null if none is appropriate.</returns> IXmlPostProcessAction _CheckNameRef(string nameRefAttribute, bool lookupOnly, bool isObjectTypeRef, XmlNode element, IFieldOrProperty fieldOrProperty, ref object o) { Assert.Fatal(lookupOnly || (fieldOrProperty != null && o != null), "field and instance required for name bind operations"); // see if the element has a nameRef IXmlPostProcessAction action = null; XmlNode nameRefAttr = element.Attributes[nameRefAttribute]; if (nameRefAttr != null) { if (lookupOnly) action = new LookupNameRefAction(isObjectTypeRef, nameRefAttr.Value, this); else action = new BindNameRefAction(isObjectTypeRef, nameRefAttr.Value, fieldOrProperty, ref o, this); _postProcessActions.Add(action); return action; } return action; }
/// <summary> /// Sets the various properties associated with this action. /// </summary> /// <param name="isObjTypeRef">True if the name is an object type, false if it is a named object.</param> /// <param name="nameRef">The name.</param> /// <param name="fieldOrProperty">The field or property instance to set.</param> /// <param name="targetInstance">The object whose property is being set.</param> /// <param name="d">The deserializer.</param> public BindNameRefAction(bool isObjTypeRef, string nameRef, IFieldOrProperty fieldOrProperty, ref object targetInstance, TorqueXmlDeserializer d) : base(d) { Assert.Fatal(nameRef != null && nameRef != string.Empty, "BindNameRefAction Constructor - Invalid name specified!"); Assert.Fatal(fieldOrProperty != null, "BindNameRefAction Constructor - Invalid field or property specified!"); Assert.Fatal(targetInstance != null, "BindNameRefAction Constructor - Invalid target instance specified!"); _lookup = new LookupNameRefAction(isObjTypeRef, nameRef, d); _fieldOrProperty = fieldOrProperty; _targetInstance = targetInstance; }