/// <summary>
        /// Tries to create an element information structure based on the provided runtime element
        /// information.
        /// </summary>
        /// <param name="constructionContext">Context for the construction.</param>
        /// <param name="runtimeElement">The runtime element.</param>
        /// <returns>
        /// A new element information based on the provided runtime element information, or <c>null</c>if
        /// the runtime element information is not supported.
        /// </returns>
        public INamedElement TryCreateModelElement(IModelConstructionContext constructionContext, object runtimeElement)
        {
            Contract.Requires(constructionContext != null);
            Contract.Requires(runtimeElement != null);

            return Contract.Result<INamedElement>();
        }
        /// <summary>
        /// Tries to get the named element information.
        /// </summary>
        /// <param name="constructionContext">Context for the construction.</param>
        /// <param name="runtimeElement">The runtime element.</param>
        /// <returns>
        /// A named element information or <c>null</c>.
        /// </returns>
        public INamedElement TryCreateModelElement(IModelConstructionContext constructionContext, object runtimeElement)
        {
            if (runtimeElement == null)
            {
                return null;
            }

            // TODO optimize querying the factories by selecting first
            // those ones matching the runtime type
            // keep some dictionary indexed by type for this purpose.
            var element = this.modelElementConstructors
                    .Select(factoryPair => factoryPair.Key.TryCreateModelElement(constructionContext, runtimeElement))
                    .FirstOrDefault(elementInfo => elementInfo != null);

            // apply the configurators in the indicated order.
            var runtimeDynamicType = runtimeElement as IRuntimeTypeInfo;
            if (runtimeDynamicType != null)
            {
                var configurators = this.modelElementConfigurators.TryGetValue(runtimeDynamicType);
                configurators?.ForEach(cfg => cfg.With(element).Configure());
            }

            return element;
        }
        /// <summary>
        /// Tries to compute the name for the provided runtime element.
        /// </summary>
        /// <param name="constructionContext">Context for the construction.</param>
        /// <param name="runtimeElement">The runtime element.</param>
        /// <returns>
        /// A string containing the name, or <c>null</c> if the name could not be computed.
        /// </returns>
        public string TryComputeName(IModelConstructionContext constructionContext, object runtimeElement)
        {
            Contract.Requires(constructionContext != null);
            Contract.Requires(runtimeElement != null);

            return Contract.Result<string>();
        }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MixinAnnotation"/> class.
 /// </summary>
 /// <param name="constructionContext">Context for the construction.</param>
 /// <param name="name">The model element name.</param>
 public MixinAnnotation(IModelConstructionContext constructionContext, string name)
     : base(constructionContext, name)
 {
 }
        /// <summary>
        /// Creates the model space.
        /// </summary>
        /// <param name="constructionContext">Context for the construction.</param>
        /// <returns>
        /// The new model space.
        /// </returns>
        protected virtual IModelSpace CreateModelSpace(IModelConstructionContext constructionContext)
        {
            Contract.Requires(constructionContext != null);

            return new DefaultModelSpace(constructionContext);
        }