예제 #1
0
 public override void Add(BaseAssembly assembly)
 {
     //if assembly is not root add else throw error
     if (assembly.GetType() != typeof(Root))
     {
         elements.Add(assembly);
     }
     else
     {
         Console.WriteLine("Root element cannot depend on a branch!");
     }
 }
        public static AssemblyMetadata MapUp(BaseAssembly model)
        {
            AssemblyMetadata assemblyModel = new AssemblyMetadata();
            Type             type          = model.GetType();

            assemblyModel.Name = model.Name;
            PropertyInfo namespaceModelsProperty = type.GetProperty("NamespaceModels",
                                                                    BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);
            List <BaseNamespace> namespaceModels = (List <BaseNamespace>)Helper.ConvertList(typeof(BaseNamespace), (IList)namespaceModelsProperty?.GetValue(model));

            if (namespaceModels != null)
            {
                assemblyModel.NamespaceModels = namespaceModels.Select(n => new NamespaceMapper().MapUp(n)).ToList();
            }
            return(assemblyModel);
        }