Ejemplo n.º 1
0
        /// <summary>
        /// Validates the resource to ensure it should be included
        /// </summary>
        /// <param name="resource"></param>
        /// <returns></returns>
        private static bool IncludeResource(MetaDataBuildGenerator.ApplicationResource resource)
        {
            bool include = true;

            if (resource.Type == MetaDataBuildGenerator.MetaData.ResourceTypes.BizTalkBinding)
            {
                MetaDataBuildGenerator.MetaData.ResourceAdapters.BindingResourceAdapter bindingAdapter = MetaDataBuildGenerator.MetaData.ResourceAdapters.BindingResourceAdapter.Create(resource);
                if (string.IsNullOrEmpty(bindingAdapter.SourceLocation))
                {
                    include = false;
                }
            }

            return(include);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads up the resource properties
        /// </summary>
        /// <param name="resource"></param>
        /// <param name="applicationResource"></param>
        private static void AddResourceProperties(
            Resource resource,
            MetaDataBuildGenerator.ApplicationResource applicationResource)
        {
            IEnumerator <KeyValuePair <string, object> > enumerator = resource.Properties.GetEnumerator();

            while (enumerator.MoveNext())
            {
                Debug.WriteLine(enumerator.Current.Key + ":" + Convert.ToString(enumerator.Current.Value));
                MetaDataBuildGenerator.ResourceProperty property = new MetaDataBuildGenerator.ResourceProperty();
                property.Name  = enumerator.Current.Key;
                property.Value = enumerator.Current.Value;
                applicationResource.Properties.Add(property);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds resources
        /// </summary>
        /// <param name="resource"></param>
        /// <param name="resources"></param>
        /// <param name="tempResources"></param>
        private static void AddResource(
            MetaDataBuildGenerator.ApplicationResource resource,
            List <MetaDataBuildGenerator.ApplicationResource> resources,
            Queue <MetaDataBuildGenerator.ApplicationResource> tempResources)
        {
            if (tempResources.Contains(resource))
            {
                return;
            }

            foreach (MetaDataBuildGenerator.ApplicationResource dependancy in resource.DependantResources)
            {
                AddResource(dependancy, resources, tempResources);
            }

            tempResources.Enqueue(resource);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Uses reflection to load the references of each application resource
        /// </summary>
        /// <param name="applicationResource"></param>
        /// <param name="resource"></param>
        private static void AddResourceReferences(
            Resource resource,
            MetaDataBuildGenerator.ApplicationResource applicationResource)
        {
            const string SourceLocationPropertyName = "SourceLocation";

            if (applicationResource.Type == MetaDataBuildGenerator.MetaData.ResourceTypes.Assembly || applicationResource.Type == MetaDataBuildGenerator.MetaData.ResourceTypes.BizTalkAssembly)
            {
                string   location = (string)resource.Properties[SourceLocationPropertyName];
                Assembly a        = Assembly.LoadFile(location);
                foreach (AssemblyName name in a.GetReferencedAssemblies())
                {
                    Trace.WriteLine(string.Format("Reflected Assembly: {0} depends on {1}", a.FullName, name.FullName));
                    applicationResource.References.Add(name.FullName);
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Describes the application
        /// </summary>
        /// <param name="applicationName"></param>
        /// <returns></returns>
        public static MetaDataBuildGenerator.ApplicationDescription DescribeApplication(string applicationName)
        {
            MetaDataBuildGenerator.ApplicationDescription applicationDescription = new MetaDataBuildGenerator.ApplicationDescription();

            using (Group group = new Group())
            {
                group.DBName   = BizTalkManagementDatabaseName;
                group.DBServer = BizTalkDatabaseServerName;
                Application app = group.Applications[applicationName];

                applicationDescription.Name        = app.Name;
                applicationDescription.Description = app.Description;

                //Add application references
                if (app.References != null)
                {
                    foreach (IApplication referencedApp in app.References)
                    {
                        applicationDescription.ReferencedApplications.Add(referencedApp.Name);
                    }
                }

                foreach (Resource resource in app.ResourceCollection)
                {
                    Debug.WriteLine("Resource Type: " + resource.ResourceType);
                    MetaDataBuildGenerator.ApplicationResource applicationResource = new MetaDataBuildGenerator.ApplicationResource();
                    applicationResource.FullName = resource.Luid;
                    applicationResource.Type     = GetResourceType(resource.ResourceType);

                    if (IncludeResource(applicationResource))
                    {
                        AddResourceReferences(resource, applicationResource);
                        AddResourceProperties(resource, applicationResource);
                        applicationDescription.Resources.Add(applicationResource);
                    }
                }

                AddDependantResources(applicationDescription);

                SortResources(applicationDescription);
            }
            return(applicationDescription);
        }