Пример #1
0
 public ComponentFolder
 (
     TFolderMetaData metaData
 )
 {
     MetaData            = metaData;
     _subFoldersBehavior = SubFolders.AddBehavior(OnAddSubFolderItem, OnRemoveSubFolderItem);
     _bbsBehavior        = ComponentInfos.AddBehavior(OnAddComponentItem, OnRemoveComponentItem);
 }
Пример #2
0
        public IEnumerable <Assembly> GetAssemblies()
        {
            if (_loadedData)
            {
                // Trying to load data twice!?
                throw new InvalidOperationException("Trying to load component assemblies twice.");
            }

            List <Assembly> loadedAssemblies = new List <Assembly>();

            // Get directory with component definition files
            string[] cddParam = _callParameterHandler["cdd"];
            if ((cddParam != null) && (cddParam.Length > 0))
            {
                // Use given directory
                _definitionPath = cddParam[0];
            }
            else
            {
                // Use "components" as default subdirectory
                _definitionPath = Path.Combine(Environment.CurrentDirectory, "components");
            }

            // Iterate through all XML component files and try to deserialize them
            string fileMask = "*.xml";

            string[] fileMaskCmd = _callParameterHandler["cdfm"];
            if ((fileMaskCmd != null) && (fileMaskCmd.Length > 0))
            {
                fileMask = fileMaskCmd[0];
            }

            foreach (string xmlFile in Directory.GetFiles(_definitionPath, fileMask))
            {
                using (FileStream fileStream = new FileStream(xmlFile, FileMode.Open))
                {
                    IComponentInfo deserializedCompInfo;
                    IServiceInfo[] deserializedServInfos;
                    _serializer.ReadComponentInfo(fileStream, out deserializedCompInfo, out deserializedServInfos);

                    // Add component and services to internal list
                    ComponentInfos.Add(deserializedCompInfo.Name, deserializedCompInfo);
                    if (deserializedServInfos != null)
                    {
                        foreach (var serviceInfo in deserializedServInfos)
                        {
                            ServiceInfos[serviceInfo.ServiceType] = serviceInfo;
                        }
                    }
                }
            }

            loadedAssemblies.AddRange(LoadComponentAssemblies());

            _loadedData = true;
            return(loadedAssemblies);
        }
Пример #3
0
 public static ComponentInfos GetComponentInfos(Type type)
 {
     if (!componentInfos.ContainsKey(type))
     {
         ComponentInfos cInfo = new ComponentInfos();
         cInfo.isComponent = type.IsSubclassOf(typeof(Component));
         if (cInfo.isComponent)
         {
             cInfo.allowMultiplyComponent = !System.Attribute.IsDefined(type, typeof(DisallowMultipleComponent), true);
         }
         componentInfos.Add(type, cInfo);
     }
     return(componentInfos[type]);
 }
Пример #4
0
 public void Add(IComponentIdWithDisplayMetadata <TId, TComponentMetaData> componentInfo)
 {
     ComponentInfos.Add(componentInfo);
 }
Пример #5
0
 public void Clear()
 {
     ComponentInfos.RemoveAll();
     SubFolders.RemoveAll();
 }