Пример #1
0
        /// <summary>
        /// Build a set of specific properties by their IDs
        /// </summary>
        /// <param name="ids">Set of property IDs</param>
        /// <returns>Set of properties</returns>
        public PropertySet BuildProperties(IntSet ids)
        {
            var properties = new PropertySet();

            if (!IsValid())
            {
                return(properties);
            }

            List <PropertyCreator> creators = new List <PropertyCreator>();
            PropertyParams         parameters;

            foreach (int id in ids)
            {
                var card = db.fillCard("Property", id);

                if (card != null && card[0] is string)
                {
                    parameters.ID       = id;
                    parameters.TypeName = (string)card[0];
                    parameters.Data     = card;

                    var creator = PropertyCreator.GetPropertyCreatorByParams(parameters);
                    creators.Add(creator);
                }
            }

            foreach (var creator in creators)
            {
                var property = creator.BuildProperty();
                properties.Add(property);
            }

            return(properties);
        }
Пример #2
0
        /// <summary>
        /// Returns the specific creator of the property using the data contained in the passed parameters
        /// </summary>
        /// <param name="parameters">Property parameters</param>
        /// <returns>A specific instance of the property creator</returns>
        public static PropertyCreator GetPropertyCreatorByParams(PropertyParams parameters)
        {
            PropertyCreator creator = null;
            var             type    = parameters.TypeName;

            // TODO: Hide the implementation of selecting a specific creator, so that the registration of a specific type occurs somewhere in a separate place
            if (type == "PSHELL")
            {
                creator = new PSHELLCreator(parameters);
            }
            else
            {
                throw new ArgumentOutOfRangeException("Unknown type of property");
            }

            // TODO: Insert new type of properties

            return(creator);
        }