Пример #1
0
        public ReferenceInfo(Dictionary <ComponentWrapper, ReferenceData> references, ProjectWrapper Project, SolutionWrapper Solution, OnAddComponentHandler OnAddComponent)
        {
            this.ReadOnlyComponents = new List <ComponentWrapper>();
            this.Project            = Project;
            this.Solution           = Solution;
            this.OnAddComponent     = OnAddComponent;
            this.AddedComponents    = new Collection <ComponentWrapper>();
            this.RemovedComponents  = new Collection <ComponentWrapper>();

            if (references != null)
            {
                this.References = references;
            }
            else
            {
                this.References = new Dictionary <ComponentWrapper, ReferenceData>();

                foreach (BaseWrapper wrapper in GetComponents())
                {
                    ComponentWrapper component = ComponentWrapper.GetComponentWrapper(wrapper);
                    References.Add(component, new ReferenceData(wrapper));
                }
                foreach (ComponentWrapper component in this.References.Keys)
                {
                    BaseWrapper wrapper = this[component].Wrapper;
                    switch (component.ComponentType)
                    {
                    case ComponentTypeWrapper.Library:
                        LibraryWrapper library = wrapper as LibraryWrapper;
                        Debug.Assert(library != null);
                        library.Dependencies = GetComponents(library.Dependencies);
                        if ((library.LibraryCategory != null) && (library.HasLibraryCategory))
                        {
                            library.LibraryCategory = GetComponent(library.LibraryCategory);
                        }
                        break;

                    case ComponentTypeWrapper.Feature:
                        FeatureWrapper feature = wrapper as FeatureWrapper;
                        Debug.Assert(feature != null);
                        feature.FeatureDependencies   = GetComponents(feature.FeatureDependencies);
                        feature.ComponentDependencies = GetComponents(feature.ComponentDependencies);
                        break;

                    case ComponentTypeWrapper.LibraryCategory:
                        LibraryCategoryWrapper libcat = wrapper as LibraryCategoryWrapper;
                        Debug.Assert(libcat != null);
                        libcat.FeatureAssociations = GetComponents(libcat.FeatureAssociations);
                        break;

                    default:
                        Debug.Assert(false);
                        break;
                    }
                }
                this.Solution.TransportType.FeatureAssociations = GetComponents(this.Solution.TransportType.FeatureAssociations);
            }
        }
Пример #2
0
        bool IsUnresolved(ReferenceData refData)
        {
            LibraryCategoryWrapper libcat = refData.Wrapper as LibraryCategoryWrapper;

            Debug.Assert(libcat != null);
            if (libcat != null)
            {
                foreach (ComponentWrapper realization in refData.Realization)
                {
                    if (realization.Checked)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Пример #3
0
        public void CalcReferences()
        {
            this.ReadOnlyComponents.Clear();
            foreach (ComponentWrapper component in this.References.Keys)
            {
                ReferenceData refData = this[component];
                refData.Clear();
                component.Checked = false;
                if (component.ComponentType == ComponentTypeWrapper.Feature)
                {
                    FeatureWrapper feature = refData.Wrapper as FeatureWrapper;
                    Debug.Assert(feature != null);
                    if (feature != null)
                    {
                        if (feature.Required)
                        {
                            component.Checked = true;
                            AddReadonly(component);
                        }
                    }
                }
            }

            LibraryCategoryWrapper transport = this.Solution.TransportType;

            if (transport != null)
            {
                foreach (ComponentWrapper component in transport.FeatureAssociations)
                {
                    component.Checked = true;
                    AddReadonly(component);
                }
            }

            this.OnCalcReferences();

            foreach (ComponentWrapper component in this.References.Keys)
            {
                this.OnComponentRefs(component);
            }
            this.CheckComponents();
        }
Пример #4
0
        protected override void CheckComponents()
        {
            if (this.FeaturesInfo != null)
            {
                foreach (ComponentWrapper feature in this.FeaturesInfo.CheckedComponents)
                {
                    feature.Checked = true;
                }
            }

            foreach (LibraryWrapper template in this.Templates)
            {
                ComponentWrapper component = ComponentWrapper.GetComponentWrapper(template);
                this.References.Add(component, new ReferenceData(template));
                MutualReference(template.LibraryCategory, component, ReferenceType.Realization);
            }

            foreach (ComponentWrapper component in this.References.Keys)
            {
                ReferenceData refData = this[component];
                bool          add     = component.Checked;
                switch (component.ComponentType)
                {
                case ComponentTypeWrapper.LibraryCategory:
                    LibraryCategoryWrapper libcat = refData.Wrapper as LibraryCategoryWrapper;
                    Debug.Assert(libcat != null);
                    if ((libcat.Required == true) || (this.IsTransport(libcat)))
                    {
                        add = true;
                    }
                    break;

                case ComponentTypeWrapper.Library:
                    LibraryWrapper library = refData.Wrapper as LibraryWrapper;
                    if (library.IsTemplate)
                    {
                        component.Name = "Generate Template";
                    }
                    Debug.Assert(library != null);
                    if (library.Required == true)
                    {
                        component.Checked = true;
                        add = true;
                    }
                    break;

                case ComponentTypeWrapper.Feature:
                    FeatureWrapper feature = refData.Wrapper as FeatureWrapper;
                    Debug.Assert(feature != null);
                    if (feature.Required == true)
                    {
                        component.Checked = true;
                        add = true;
                    }
                    break;

                default:
                    Debug.Assert(false);
                    break;
                }
                if (add)
                {
                    RecursiveAddComponent(component);
                }
            }


            foreach (ComponentWrapper component in this.References.Keys)
            {
                if (DefaultComponents(component, this))
                {
                    this.ReadOnlyComponents.Add(component);
                }
                break;
            }
        }
Пример #5
0
        ComponentWrapper GetAutoselectLibrary(ComponentWrapper component)
        {
            Debug.Assert(component.ComponentType == ComponentTypeWrapper.LibraryCategory);
            ReferenceData          refData = this[component];
            LibraryCategoryWrapper libcat  = refData.Wrapper as LibraryCategoryWrapper;

            Debug.Assert(libcat != null);
            ComponentWrapper defaultLib     = null;
            ComponentWrapper stubLib        = null;
            ComponentWrapper templateLib    = null;
            ComponentWrapper bootloaderLib  = null;
            ComponentWrapper projectLib     = null;
            LibraryWrapper   defaultWrapper = null;
            bool             alterLib       = false;

            foreach (ComponentWrapper library in refData.Realization)
            {
                LibraryWrapper wrapper = this[library].Wrapper as LibraryWrapper;
                Debug.Assert(wrapper != null);
                if (wrapper != null)
                {
                    if (this.Project.Libraries.Contains(library))
                    {
                        if (wrapper.IsStub == false)
                        {
                            projectLib = library;
                        }
                        else
                        {
                            stubLib = library;
                        }
                    }
                    if (wrapper.IsStub)
                    {
                        if (stubLib == null)
                        {
                            stubLib = library;
                        }
                    }
                    else if (wrapper.IsBootloaderLibrary())
                    {
                        bootloaderLib = library;
                    }
                    else if (wrapper.IsTemplate)
                    {
                        templateLib = library;
                    }
                    else if (defaultLib == null)
                    {
                        defaultLib     = library;
                        defaultWrapper = wrapper;
                    }
                    else
                    {
                        alterLib = true;
                    }
                }
            }

            if (libcat != null)
            {
                if (libcat.FeatureAssociations.Count != 0)
                {
                    bool selected = false;
                    foreach (ComponentWrapper feature in libcat.FeatureAssociations)
                    {
                        if (feature.Checked == true)
                        {
                            selected = true;
                            break;
                        }
                    }
                    if (selected)
                    {
                        if (this.Project.IsBootloaderProject() == false)
                        {
                            if ((alterLib == false) && (defaultLib != null))
                            {
                                return(defaultLib);
                            }
                            if (projectLib != null)
                            {
                                return(projectLib);
                            }
                        }
                        else if (bootloaderLib == null)
                        {
                            if (this.IsTransport(libcat))
                            {
                                if (alterLib == false)
                                {
                                    return(defaultLib);
                                }
                                if (stubLib != null)
                                {
                                    return(stubLib);
                                }
                                if (((alterLib == true) || (defaultLib == null)) || (((templateLib != null) && (string.IsNullOrEmpty(defaultWrapper.CustomFilter))) && ((defaultWrapper.ProcessorSpecific != null) && (string.IsNullOrEmpty(defaultWrapper.ProcessorSpecific.Guid)))))
                                {
                                    return(null);
                                }
                                return(defaultLib);
                            }
                        }
                        else
                        {
                            return(bootloaderLib);
                        }
                    }
                    else
                    {
                        if (this.IsTransport(libcat))
                        {
                            return(null);
                        }
                        return(stubLib);
                    }
                }
                else
                {
                    if (!this.Project.IsBootloaderProject())
                    {
                        if ((alterLib == false) && (defaultLib != null))
                        {
                            if ((stubLib == null) && (templateLib == null))
                            {
                                return(defaultLib);
                            }
                            if (!string.IsNullOrEmpty(defaultWrapper.CustomFilter) || ((defaultWrapper.ProcessorSpecific != null) && (!string.IsNullOrEmpty(defaultWrapper.ProcessorSpecific.Guid))))
                            {
                                return(defaultLib);
                            }
                        }
                        if (projectLib != null)
                        {
                            return(projectLib);
                        }
                        if ((stubLib != null) && (this.Project.Libraries.Contains(stubLib)))
                        {
                            return(stubLib);
                        }
                    }
                    else if (bootloaderLib == null)
                    {
                        if (stubLib != null)
                        {
                            return(stubLib);
                        }
                        if (alterLib == false)
                        {
                            return(defaultLib);
                        }
                    }
                    else
                    {
                        return(bootloaderLib);
                    }
                }
            }
            return(null);
        }
Пример #6
0
 protected bool IsTransport(LibraryCategoryWrapper libcat)
 {
     return(libcat.IsTransport && this.Solution.TransportType.Equals(libcat));
 }
Пример #7
0
        protected override void OnComponentRefs(ComponentWrapper component)
        {
            ReferenceData refData = this.References[component];

            switch (component.ComponentType)
            {
            case ComponentTypeWrapper.Feature:
                FeatureWrapper feature = refData.Wrapper as FeatureWrapper;
                Debug.Assert(feature != null);
                if (feature != null)
                {
                    foreach (ComponentWrapper dependency in feature.ComponentDependencies)
                    {
                        MutualReference(component, dependency);
                    }
                }
                break;

            case ComponentTypeWrapper.Library:
                LibraryWrapper library = refData.Wrapper as LibraryWrapper;
                Debug.Assert(library != null);
                if (library != null)
                {
                    if ((library.LibraryCategory != null) && (library.HasLibraryCategory == true))
                    {
                        if (this.ValidateLibrary(library))
                        {
                            MutualReference(library.LibraryCategory, component, ReferenceType.Realization);
                        }
                    }
                    foreach (ComponentWrapper dependency in library.Dependencies)
                    {
                        MutualReference(component, dependency);
                    }
                }
                break;

            case ComponentTypeWrapper.LibraryCategory:
                LibraryCategoryWrapper libcat = refData.Wrapper as LibraryCategoryWrapper;
                Debug.Assert(libcat != null);
                if (libcat != null)
                {
                    //foreach (ComponentWrapper assotiation in libcat.FeatureAssociations)
                    //{
                    //    MutualReference(assotiation, component,ReferenceType.Assotiation);
                    //}

                    if ((libcat.Level != LibraryLevelWrapper.CLR) && (libcat.Templates.Count != 0))
                    {
                        LibraryWrapper template = PK.Wrapper.CreateLibrary(
                            libcat.Name + "_" + this.Solution.Name,
                            libcat.Level,
                            @"Generates template code in your solution's DeviceCode directory for the given Library Category.The project will be generated in Solutions\" + this.Solution.Name + @"\DeviceCode\" + libcat.Name,
                            PK.Wrapper.SpoClientPath + @"Solutions\" + this.Solution.Name + @"\DeviceCode\" + libcat.Name + @"\dotnetmf.proj",
                            true,
                            component);
                        this.Templates.Add(template);
                    }
                }
                break;
            }
        }
Пример #8
0
        private bool RecursiveAddComponent(ComponentWrapper component)
        {
            bool          recursive = false;
            ReferenceData refData   = this[component];

            if (component.ComponentType == ComponentTypeWrapper.LibraryCategory)
            {
                LibraryCategoryWrapper libcat = refData.Wrapper as LibraryCategoryWrapper;
                if ((component.Checked == false) && ((libcat.Level != LibraryLevelWrapper.CLR) || ((libcat.Level == LibraryLevelWrapper.CLR) && this.Project.IsClrProject)))
                {
                    component.Checked = true;
                    Debug.Assert(libcat != null);
                    bool unStub = libcat.Required;
                    bool isStub = true;
                    if (this.FeaturesInfo != null)
                    {
                        foreach (ComponentWrapper requirment in refData.RequiredBy)
                        {
                            if (requirment.ComponentType == ComponentTypeWrapper.Feature)
                            {
                                if (this.AddedFeatures.Contains(requirment))
                                {
                                    unStub = true;
                                    break;
                                }
                                if (libcat.Required == false)
                                {
                                    if (this.RemovedFeatures.Contains(requirment))
                                    {
                                        unStub = true;
                                        isStub = false;
                                        break;
                                    }
                                }
                            }
                        }
                        if (libcat != null)
                        {
                            foreach (ComponentWrapper assotiation in libcat.FeatureAssociations)
                            {
                                if (assotiation.ComponentType == ComponentTypeWrapper.Feature)
                                {
                                    if (this.AddedFeatures.Contains(assotiation))
                                    {
                                        unStub = true;
                                        break;
                                    }
                                    if (libcat.Required == false)
                                    {
                                        if (this.RemovedFeatures.Contains(assotiation))
                                        {
                                            unStub = true;
                                            isStub = false;
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (unStub == true)
                    {
                        UnResolveLibraryCategory(refData, isStub);
                    }

                    if (IsUnresolved(refData))
                    {
                        ComponentWrapper autoselect = GetAutoselectLibrary(component);
                        if (autoselect != null)
                        {
                            Debug.Assert(autoselect.ComponentType == ComponentTypeWrapper.Library);
                            autoselect.Checked = true;
                            recursive         |= RecursiveCheckComponent(autoselect);
                        }
                    }
                }
            }
            if (component.Checked == true)
            {
                foreach (ComponentWrapper dependency in refData.DependsFrom)
                {
                    switch (dependency.ComponentType)
                    {
                    case ComponentTypeWrapper.Feature:
                    case ComponentTypeWrapper.LibraryCategory:
                    case ComponentTypeWrapper.Library:
                        RecursiveAddComponent(dependency);
                        recursive = true;
                        break;
                    }
                }
            }
            return(recursive);
        }
Пример #9
0
 public static ComponentWrapper GetComponentWrapper(LibraryCategoryWrapper librarycat)
 {
     return(GetComponentWrapper(librarycat, ComponentTypeWrapper.LibraryCategory));
 }