Beispiel #1
0
        /// <summary>
        /// Creates an instance of the tactical data defined by this metadata type.
        /// </summary>
        /// <param name="pAttributeCreator">The creator used to affect attributes to the metadata properties.</param>
        /// <returns>The new tactical data instance.</returns>
        public MetadataSet CreateInstance(AAttributesCreator pAttributeCreator)
        {
            MetadataSet lInstance = null;

            try
            {
                PropertyDescriptorCollection lCollection = new PropertyDescriptorCollection(null);

                foreach (IMetadata lMetadata in this.mMetadata)
                {
                    Attribute[] lAttributes = null;
                    if (pAttributeCreator != null)
                    {
                        lAttributes = pAttributeCreator.Create(lMetadata);
                    }

                    DynamicTypedObjectPropertyDescriptor lProperty = lMetadata.CreateInstance(lAttributes);
                    if (lProperty != null)
                    {
                        lCollection.Add(lProperty);
                    }
                }

                lInstance = new MetadataSet(lCollection, this);

                // Initializes
                foreach (IMetadata lMetadata in this.mMetadata)
                {
                    lInstance.TrySetMember(lMetadata.Id, lMetadata.GetDefautValue());
                }
            }
            catch
            {
                return(null);
            }

            return(lInstance);
        }