コード例 #1
0
        /// <summary>
        /// Creates an instance
        /// </summary>
        /// <param name="artifactLinkType"></param>
        /// <param name="modelElement"></param>
        /// <param name="mappingTable"></param>
        /// <returns></returns>
        public static ArtifactLink CreateInstance(Type artifactLinkType, ModelElement modelElement, string mappingTable,
                                                  ICustomAttributeProvider attributeProvider)
        {
            Guard.ArgumentNotNull(artifactLinkType, "artifactLinkType");
            Guard.ArgumentNotNull(modelElement, "modelElement");
            Guard.ArgumentNotNull(attributeProvider, "attributeProvider");

            Tuple <Type, Guid, string> key = new Tuple <Type, Guid, string>(artifactLinkType, modelElement.Id, mappingTable);

            return(GlobalCache.AddOrGetExisting <ArtifactLink>(key.ToString(), k =>
            {
                ArtifactLink link = CreateLink(artifactLinkType, modelElement);
                if (!String.IsNullOrEmpty(mappingTable))
                {
                    try
                    {
                        link.Container = GetContainer(mappingTable, attributeProvider);
                        link.Path = GetProjectPath(mappingTable, link.Container);
                        link.Project = GetProject(modelElement, link.Container);
                    }
                    catch (Exception e)
                    {
                        Logger.Write(e);
                    }
                }
                return link;
            }));
        }
コード例 #2
0
        public static ModelElement ResolveAndCache(ModelBusReference reference)
        {
            if (reference == null)
            {
                return(null);
            }
            ModelBusAdapter modelAdapter = GlobalCache.AddOrGetExisting <ModelBusAdapter>(reference.ModelDisplayName, c => CreateModelBusAdapter(reference));

            return(modelAdapter.ResolveElementReference(reference) as ModelElement);
        }
コード例 #3
0
        private static XmlSerializer GetXmlSerializer(Type type, ICollection <Type> extraTypes)
        {
            if (extraTypes == null ||
                extraTypes.Count == 0)
            {
                return(CreateSerializer(type));
            }

            List <Type>   etypes = new List <Type>(extraTypes);
            StringBuilder b      = new StringBuilder();

            etypes.ForEach(t => b.Append(t.FullName));
            return(GlobalCache.AddOrGetExisting <XmlSerializer>(b.ToString(), k =>
            {
                return new XmlSerializer(type, etypes.ToArray());
            }));
        }
コード例 #4
0
        /// <summary>
        /// Creates the instance.
        /// </summary>
        /// <param name="linkType">Type of the link.</param>
        /// <param name="modelElement">The model element.</param>
        /// <param name="projectUniqueName">Name of the project unique.</param>
        /// <param name="itemPath">The item path.</param>
        /// <returns></returns>
        public static ArtifactLink CreateInstance(Type linkType, ModelElement modelElement, string projectUniqueName, string itemPath)
        {
            Guard.ArgumentNotNull(linkType, "linkType");
            Guard.ArgumentNotNull(modelElement, "modelElement");
            Guard.ArgumentNotNullOrEmptyString(projectUniqueName, "projectUniqueName");
            Guard.ArgumentNotNull(itemPath, "itemPath");

            Tuple <Type, Guid, string> key = new Tuple <Type, Guid, string>(linkType, modelElement.Id, projectUniqueName);

            return(GlobalCache.AddOrGetExisting <ArtifactLink>(key.ToString(), k =>
            {
                ArtifactLink link = CreateLink(linkType, modelElement);
                try
                {
                    link.Path = itemPath;
                    SetLinkContainerProperties(modelElement, projectUniqueName, link);
                }
                catch (Exception e)
                {
                    Logger.Write(e);
                }
                return link;
            }));
        }