Esempio n. 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);
            }
        }
Esempio n. 2
0
        protected override void OnComponentRefs(ComponentWrapper component)
        {
            ReferenceData  refData = this.References[component];
            FeatureWrapper feature = refData.Wrapper as FeatureWrapper;

            if (feature != null)
            {
                foreach (ComponentWrapper dependency in feature.FeatureDependencies)
                {
                    MutualReference(component, dependency);
                }
            }
        }
Esempio n. 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();
        }
Esempio n. 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;
            }
        }
Esempio n. 5
0
        private bool ValidateLibrary(LibraryWrapper library)
        {
            if (((library.ProcessorSpecific != null) && !string.IsNullOrEmpty(library.ProcessorSpecific.Guid)) && (string.Compare(library.ProcessorSpecific.Guid, this.Solution.Processor.Guid, true) != 0))
            {
                return(false);
            }
            if (!string.IsNullOrEmpty(library.CustomFilter))
            {
                bool found = false;
                //CustomFilter содержит список процессоров через разделитель ';'
                //Идем вдоль процессоров библиотеки
                foreach (string libfilter in library.CustomFilter.Split(new char[] { ';' }))
                {
                    //Идем вдоль процессоров процессора
                    foreach (string procfilter in this.Processor.CustomFilter.Split(new char[] { ';' }))
                    {
                        //Если найдено соответствие, то найдено
                        if (string.Compare(procfilter, libfilter, true) == 0)
                        {
                            found = true;
                            break;
                        }
                    }
                    //Если соответствия не найдено
                    if (found == false)
                    {
                        //Ищем в процессорах решения
                        foreach (string solutionfilter in this.Solution.CustomFilter.Split(new char[] { ';' }))
                        {
                            if (string.Compare(solutionfilter, libfilter, true) == 0)
                            {
                                found = true;
                                break;
                            }
                        }
                    }
                    //Если не найдено
                    if (found == false)
                    {
                        //Находим проект CLR
                        Collection <ComponentWrapper> features = null;
                        if (this.Project.IsClrProject)
                        {
                            features = this.FeaturesInfo.CheckedComponents;
                        }
                        else
                        {
                            foreach (ProjectWrapper project in this.Solution.Projects)
                            {
                                if (project.IsClrProject)
                                {
                                    features = GetComponents(project.Features);
                                    break;
                                }
                            }
                        }
                        if (features != null)
                        {
                            //Идем вдоль фич проекта CLR
                            foreach (ComponentWrapper component in features)
                            {
                                //Находим соответствующую фичу
                                FeatureWrapper feature = this[component].Wrapper as FeatureWrapper;
                                //И проверяем ее фильтр, если совпало, устанавливаем флаг
                                if ((feature != null) && (string.Compare(feature.Filter, libfilter, true) == 0))
                                {
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }
                    //Если не найдено, в конечном итоге сравниваем с именем решения
                    if (!found)
                    {
                        found = 0 == string.Compare(library.CustomFilter, this.Solution.Name, true);
                    }
                    //Если найдено хоть одно соответствие выходим
                    if (found)
                    {
                        break;
                    }
                }
                if (!found)
                {
                    return(false);
                }
            }
            //Если проект не Загрузчик а библиотека - загрузчик, то валидация не проходит
            if (!this.Project.IsBootloaderProject() && library.IsBootloaderLibrary())
            {
                return(false);
            }
            //Есби библиотека - CLR а проект - нет, то валидация не проходит
            if ((library.Level == LibraryLevelWrapper.CLR) && !this.Project.IsClrProject)
            {
                return(false);
            }
            string libProjectPath = library.ProjectPath.ToLower();

            //Если библиотека лежит в примерах, то валидация не проходит
            if (libProjectPath.Contains(@"\devicecode\drivers\sample\"))
            {
                return(false);
            }
            //Если библиотека находится в другом проекте, то валидация не проходит
            if (libProjectPath.Contains(@"\solutions\") && !libProjectPath.Contains(@"\solutions\" + this.Solution.Name.ToLower() + @"\"))
            {
                return(false);
            }

            return(true);
        }
Esempio n. 6
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;
            }
        }
Esempio n. 7
0
 public static ComponentWrapper GetComponentWrapper(FeatureWrapper feature)
 {
     return(GetComponentWrapper(feature, ComponentTypeWrapper.Feature));
 }
Esempio n. 8
0
 public FeatureReferenceEnumerator(FeatureWrapper This)
     : this(This, false)
 {
 }
Esempio n. 9
0
 public FeatureReferenceEnumerator(FeatureWrapper This, bool onlyChecked)
 {
     this.This        = This;
     this.OnlyChecked = onlyChecked;
 }