예제 #1
0
        // TODO Unlike property trees, we don't find the _best_ aggregation

        static void TryAggregation(object component, object value)
        {
            var enumerable = value as IEnumerable;

            if (enumerable == null)
            {
                return;
            }
            var items = enumerable;

            if (!ReferenceEquals(component, items) && enumerable.GetEnumerator().MoveNext())
            {
                MethodInfo mi = Template.FindAddonMethod(component.GetType());
                if (mi == null)
                {
                    return;
                }
                foreach (var item in items)
                {
                    mi.Invoke(component, new object[] {
                        item
                    });
                }
            }
        }
예제 #2
0
            void ITemplateCommand.Apply(Template impl, Stack <object> values)
            {
                var    child       = values.Pop();
                object destination = values.Peek();
                var    addon       = Template.FindAddonMethod(destination.GetType());

                if (addon == null)
                {
                    throw new NotImplementedException();
                }
                addon.Invoke(destination, new[] { child });
            }
예제 #3
0
 internal static void DefaultCopyContent(object source, object destination)
 {
     if (destination is System.Collections.IEnumerable && source is System.Collections.IEnumerable)
     {
         var addon = Template.FindAddonMethod(destination.GetType());
         if (addon != null)
         {
             foreach (var o in (System.Collections.IEnumerable)source)
             {
                 addon.Invoke(destination, new[] { o });
             }
         }
     }
 }