Example #1
0
        public static Type GetPropertyType(this IMixin self, string name)
        {
            var property = self.GetType().GetProperty(name);

            if (property != null)
            {
                return(self.GetType().GetProperty(name).PropertyType);
            }
            var value = self.GetPropertyInternal(name);

            return(value == null || value == Value.Undefined ? null : value.GetType());
        }
        public static void Initialize(IMixin obj)
        {
            if (obj == null)
            {
                return;
            }

            var mixinTypes = obj.GetType().FindInterfaces((tp, c) =>
            {
                return(tp != _mixinBaseType && tp.IsInterface && _mixinBaseType.IsAssignableFrom(tp));
            }, null);

            foreach (var mixinType in mixinTypes)
            {
                var constructedAttribs = mixinType.GetCustomAttributes(typeof(MixinConstructorAttribute), false);
                if (constructedAttribs != null && constructedAttribs.Length > 0)
                {
                    for (int i = 0; i < constructedAttribs.Length; i++)
                    {
                        (constructedAttribs[i] as MixinConstructorAttribute).OnConstructed(obj);
                    }
                }
            }
        }