internal void AddCallback(Type type, AttributeCallback callback) { Fx.Assert(type != null && callback != null, "type or callback parameter is null"); AttributeList list = GetTypeList(type); list.Add(callback); }
// // Helper method that walks through an attribute list and expands all callbacks // within it. // private void ExpandAttributes(Type type, AttributeList attributes) { Fx.Assert(!attributes.IsExpanded, "Should not call expand attributes with an expanded list."); // First, expand all the callbacks. This may add more attributes // into our list // for (int idx = 0; idx < attributes.Count; idx++) { AttributeCallback callback = attributes[idx] as AttributeCallback; while (callback != null) { attributes.RemoveAt(idx); AttributeCallbackBuilder builder = new AttributeCallbackBuilder(this, type); callback(builder); if (idx < attributes.Count) { callback = attributes[idx] as AttributeCallback; } else { callback = null; } } } }
public void ForeachAttribute(TypeName attributeName, AttributeCallback callback) { foreach (var attribute in Attributes) { if (attribute.Name == attributeName) { callback(attribute); } } }
public void AddCallback(Type type, AttributeCallback callback) { if (type == null) { throw new ArgumentNullException("type"); } if (callback == null) { throw new ArgumentNullException("callback"); } this.MutableTable.AddCallback(type, callback); }
// <summary> // Adds a callback that will be invoked when metadata for the // given type is needed. The callback can add metadata to // to the attribute table on demand, which is much more efficient // than adding metadata up front. // </summary> // <param name="type"></param> // <param name="callback"></param> public void AddCallback(Type type, AttributeCallback callback) { if (type == null) { throw FxTrace.Exception.ArgumentNull("type"); } if (callback == null) { throw FxTrace.Exception.ArgumentNull("callback"); } MutableTable.AddCallback(type, callback); }
private void ExpandAttributes(Type type, MutableAttributeTable.AttributeList attributes) { if (attributes.IsExpanded) { return; } for (int index = 0; index < attributes.Count; ++index) { for (AttributeCallback attributeCallback = attributes[index] as AttributeCallback; attributeCallback != null; attributeCallback = index >= attributes.Count ? (AttributeCallback)null : attributes[index] as AttributeCallback) { attributes.RemoveAt(index); AttributeCallbackBuilder builder = new AttributeCallbackBuilder(this, type); attributeCallback(builder); } } }
public void ForeachAttribute(Type attributeType, AttributeCallback callback) { ForeachAttribute(TypeAliases.GetTypeName(attributeType), callback); }
internal void AddCallback(Type type, AttributeCallback callback) { this.GetTypeList(type).Add((object)callback); }