示例#1
0
        /// <summary>
        /// Creates a new Property.
        /// </summary>
        /// <param name="name">Unique name for the new Property.</param>
        /// <param name="value">Object guiding the type of the property.</param>
        /// <param name="kind">Property kind.</param>
        /// <returns>a Property.</returns>
        internal PropertyType NewProperty(string name, object value, PropertyKind kind)
        {
            PropertyType aType;

            if (stringToPropertyType.TryGetValue(name, out aType) == false)
            {
                int pos = graph.propertyType.Length;
                graph.Update();
                Array.Resize(ref graph.propertyType, pos + 1);
                switch (Type.GetTypeCode(value.GetType()))
                {
                case TypeCode.Boolean:
                    aType = new PropertyTypeT <bool>(false, this.TypeId, pos, name, kind, graph);
                    break;

                case TypeCode.Int32:
                    aType = new PropertyTypeT <int>(false, this.TypeId, pos, name, kind, graph);
                    break;

                case TypeCode.Int64:
                    aType = new PropertyTypeT <long>(false, this.TypeId, pos, name, kind, graph);
                    break;

                case TypeCode.Single:
                    aType = new PropertyTypeT <Single>(false, this.TypeId, pos, name, kind, graph);
                    break;

                case TypeCode.Double:
                    aType = new PropertyTypeT <double>(false, this.TypeId, pos, name, kind, graph);
                    break;

                case TypeCode.DateTime:
                    aType = new PropertyTypeT <DateTime>(false, this.TypeId, pos, name, kind, graph);
                    break;

                case TypeCode.String:
                    aType = new PropertyTypeT <string>(false, this.TypeId, pos, name, kind, graph);
                    break;

                case TypeCode.Object:
                    aType = new PropertyTypeT <IComparable>(false, this.TypeId, pos, name, kind, graph);
                    break;
                }
                graph.propertyType[pos] = aType;
                stringToPropertyType.AddFast(name, aType);
            }
            return(aType);
        }
示例#2
0
        /// <summary>
        /// Creates a new Property.
        /// </summary>
        /// <param name="name">Unique name for the new Property.</param>
        /// <param name="value">Object guiding the type of the property.</param>
        /// <param name="kind">Property kind.</param>
        /// <returns>a Property.</returns>
        internal PropertyType NewProperty(string name, object value, PropertyKind kind)
        {
            PropertyType aType;

            if (m_stringToPropertyType.TryGetValue(name, out aType) == false)
            {
                int pos = MyGraph.PropertyTypes.Count;
                switch (Type.GetTypeCode(value.GetType()))
                {
                case TypeCode.Boolean:
                    aType = new PropertyTypeT <bool>(false, this.TypeId, pos, name, kind, MyGraph);
                    break;

                case TypeCode.Int32:
                    aType = new PropertyTypeT <int>(false, this.TypeId, pos, name, kind, MyGraph);
                    break;

                case TypeCode.Int64:
                    aType = new PropertyTypeT <long>(false, this.TypeId, pos, name, kind, MyGraph);
                    break;

                case TypeCode.Single:
                    aType = new PropertyTypeT <Single>(false, this.TypeId, pos, name, kind, MyGraph);
                    break;

                case TypeCode.Double:
                    aType = new PropertyTypeT <double>(false, this.TypeId, pos, name, kind, MyGraph);
                    break;

                case TypeCode.DateTime:
                    aType = new PropertyTypeT <DateTime>(false, this.TypeId, pos, name, kind, MyGraph);
                    break;

                case TypeCode.String:
                    aType = new PropertyTypeNoDuplicateValues <string>(false, this.TypeId, pos, name, kind, MyGraph);
                    break;

                case TypeCode.Object:
                    aType = new PropertyTypeT <IComparable>(false, this.TypeId, pos, name, kind, MyGraph);
                    break;
                }
                MyGraph.PropertyTypes[pos] = aType;
                m_stringToPropertyType.AddFast(name, aType);
            }
            return(aType);
        }
示例#3
0
        /// <summary>
        /// Creates a new Property.
        /// </summary>
        /// <param name="name">Unique name for the new Property.</param>
        /// <param name="dt">Data type for the new Property.</param>
        /// <param name="kind">Property kind.</param>
        /// <returns>a Property.</returns>
        public PropertyType NewProperty(string name, DataType dt, PropertyKind kind)
        {
            PropertyType aType;

            if (stringToPropertyType.TryGetValue(name, out aType) == false)
            {
                graph.Update();
                int pos = -1;
                int i   = 0;
                foreach (PropertyType pt in graph.propertyType)
                {
                    if (pt == null)
                    {
                        pos = i;
                        break;
                    }
                    else
                    {
                        ++i;
                    }
                }
                if (pos < 0)
                {
                    pos = graph.propertyType.Length;
                    Array.Resize(ref graph.propertyType, pos + 1);
                }
                switch (dt)
                {
                case DataType.Boolean:
                    aType = new PropertyTypeT <bool>(false, this.TypeId, pos, name, kind, graph);
                    break;

                case DataType.Integer:
                    aType = new PropertyTypeT <int>(false, this.TypeId, pos, name, kind, graph);
                    break;

                case DataType.Long:
                    aType = new PropertyTypeT <long>(false, this.TypeId, pos, name, kind, graph);
                    break;

                case DataType.Double:
                    aType = new PropertyTypeT <double>(false, this.TypeId, pos, name, kind, graph);
                    break;

                case DataType.DateTime:
                    aType = new PropertyTypeT <DateTime>(false, this.TypeId, pos, name, kind, graph);
                    break;

                case DataType.String:
                    aType = new PropertyTypeT <string>(false, this.TypeId, pos, name, kind, graph);
                    break;

                case DataType.Object:
                    aType = new PropertyTypeT <IComparable>(false, this.TypeId, pos, name, kind, graph);
                    break;
                }
                graph.propertyType[pos] = aType;
                stringToPropertyType.AddFast(name, aType);
            }
            return(aType);
        }