internal static MetaProperty FromConstructor(MetaConstructor c, PropertyInfo propertyInfo)
        {
            MetaProperty p;

            if (!c.Contains(propertyInfo))
            {
                AbstractMeta placeHolder = c.Claim(propertyInfo);
                p = new MetaProperty(c.Clone(propertyInfo))
                {
                    I = placeHolder.I
                };
                c.UpdateClaim(p, propertyInfo);
            }
            else
            {
                p = new MetaProperty(c.GetId(propertyInfo));
            }

            return(p);
        }
Exemplo n.º 2
0
        internal static MetaAttribute FromConstructor(MetaConstructor c, AttributeWrapper wrapper)
        {
            MetaAttribute a;

            if (!c.Contains(wrapper))
            {
                AbstractMeta placeHolder = c.Claim(wrapper);

                //Drop the type the attribute is declared on so we dont think we're trying to override the attribute.GetType()
                a = new MetaAttribute(c.Clone(new ObjectConstructor(wrapper.PropertyInfo, wrapper.Attribute.Instance.GetType(), wrapper.Attribute)))
                {
                    I = placeHolder.I
                };
                c.UpdateClaim(a, wrapper);
            }
            else
            {
                a = new MetaAttribute(c.GetId(wrapper));
            }

            return(a);
        }
        /// <summary>
        /// Creates a new MetaType from a given type
        /// </summary>
        /// <param name="c">The constructor to use</param>
        /// <param name="t">The type to base the MetaType on</param>
        /// <returns>A new instance of MetaType</returns>
        public static MetaType FromConstructor(MetaConstructor c, Type t) // Leave this public. Its used by the Reporting Type Serializer
        {
            if (c is null)
            {
                throw new ArgumentNullException(nameof(c));
            }

            if (t is null)
            {
                throw new ArgumentNullException(nameof(t));
            }

            string Name = t.Name;

            foreach (System.Func <Type, Type> typeOverride in c.Settings.TypeGetterOverride)
            {
                t = typeOverride.Invoke(t);
            }

            MetaType i;

            if (!c.Contains(t))
            {
                AbstractMeta placeHolder = c.Claim(t);
                i = new MetaType(c.Clone(t))
                {
                    I = placeHolder.I
                };
                c.UpdateClaim(i, t);

                i = new MetaType(c.GetId(t));
            }
            else
            {
                i = new MetaType(c.GetId(t));
            }

            return(i);
        }