コード例 #1
0
        //
        // 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;
                    }
                }
            }
        }
コード例 #2
0
 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);
         }
     }
 }
コード例 #3
0
        internal static void AddCustomAttributes(this AttributeCallbackBuilder source, DependencyProperty property, params Attribute[] attributes)
        {
            string memberName = !(source.CallbackType.GetProperty(property.Name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.GetProperty) != (PropertyInfo)null) ? "Get" + property.Name : property.Name;

            source.AddCustomAttributes(memberName, attributes);
        }