/// <summary>
        /// Base type generation or shortcut for temporary instance
        /// </summary>
        /// <param name="type"></param>
        /// <param name="properties">Manually set the properties list if type is defining a temporary instance of and object</param>
        public MetaType(Type type, IEnumerable <MetaObject> properties = null) : base()
        {
            if (type is null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            if (Nullable.GetUnderlyingType(type) != null)
            {
                type = Nullable.GetUnderlyingType(type);

                Contract.Assert(type != null);

                this.IsNullable = true;
            }

            this.Name                  = type.Name;
            this.FullName              = type.FullName;
            this.Namespace             = type.Namespace;
            this.AssemblyQualifiedName = type.AssemblyQualifiedName;
            this.StringValue           = type.ToString();
            this.CoreType              = type.GetCoreType();
            this.IsArray               = type.IsArray;

            this.IsNumeric = type.IsNumericType();
            this.Default   = type.GetDefaultValue()?.ToString();
            this.Values    = GetEnumValues(type);

            if (properties != null)
            {
                this.Properties = properties.Select(p => p.Property).ToList();
            }
        }
        internal MetaType(MetaConstructor c) : this(c.Type)
        {
            Type type = c.Type;

            if (Nullable.GetUnderlyingType(type) != null)
            {
                type            = Nullable.GetUnderlyingType(type);
                this.IsNullable = true;
            }

            this.Parameters = new List <MetaType>();

            List <MetaAttribute> attributes = new List <MetaAttribute>();

            this.Attributes = attributes;

            if (type.BaseType != null)
            {
                this.BaseType = MetaType.FromConstructor(c, type.BaseType);
            }

            if (this.CoreType == CoreType.Collection)
            {
                this.CollectionType = MetaType.FromConstructor(c, type.GetCollectionType());
            }

            foreach (Type g in type.GetGenericArguments())
            {
                this.Parameters.Add(MetaType.FromConstructor(c, g));
            }

            if (c.Settings.AttributeIncludeSettings != AttributeIncludeSetting.None)
            {
                foreach (AttributeInstance a in TypeCache.GetCustomAttributes(type))
                {
                    if (c.Settings.ShouldAddAttribute(a.Instance.GetType()))
                    {
                        attributes.Add(MetaAttribute.FromConstructor(c, a, type));
                    }
                }
            }

            this.Properties = new List <MetaProperty>();

            if (this.CoreType != CoreType.Value)
            {
                foreach (PropertyInfo thisProperty in c.GetProperties())
                {
                    if (c.Validate(thisProperty))
                    {
                        this.Properties.Add(MetaProperty.FromConstructor(c, thisProperty));
                    }
                }
            }
        }
Exemplo n.º 3
0
 void StopMoving()
 {
     this.targetPosition = null;
     this.moving         = false;
     Task.current.Succeed();
 }
Exemplo n.º 4
0
 partial void OnnewIdChanging(System.Nullable <System.Guid> value);