Example #1
0
 public static AssemblyType CreateAssemblyType(AssemblyImporter importer, System.Type systemType)
 {
     AssemblyType assemblyType = null;
     if (systemType.IsEnum)
     {
         assemblyType = new AssemblyEnumeration (importer, systemType);
         assemblyType.Begin ();
     }
     else if (systemType.IsInterface)
     {
         assemblyType = new AssemblyInterface (importer, systemType);
         assemblyType.Begin ();
     }
     else if (systemType.IsClass)
     {
         assemblyType = new AssemblyClass (importer, systemType);
         assemblyType.Begin ();
     }
     else if (systemType.IsPrimitive)
     {
         assemblyType = new AssemblyDataType (importer, systemType);
         assemblyType.Begin ();
     }
     else if (systemType.IsValueType)
     {
         if (systemType.GetMembers (AssemblyHelper.BINDING_FLAGS).Length == 1)
         {
             assemblyType = new AssemblyDataType (importer, systemType);
             assemblyType.Begin ();
         }
         else
         {
             assemblyType = new AssemblyStruct (importer, systemType);
             assemblyType.Begin ();
         }
     }
     else
     {
         System.Console.WriteLine ("System.FullName: "+systemType.FullName+" sealed: "+systemType.IsSealed );
     }
     return assemblyType;
 }
        protected void GetInterfaces()
        {
            Type[] interfaces = _systemType.GetInterfaces ();
            Type[] baseTypeIfaces = _systemType.BaseType == null ? new Type[0] : _systemType.BaseType.GetInterfaces ();
            bool crossIfaceImpl;

            foreach (Type iface in interfaces)
            {
                // if the interface isn't inherited from the base class,
                // generate an InterfaceRealization representation.
                if (Array.IndexOf(baseTypeIfaces, iface) == -1)
                {
                    // checks that the current interface is not implemented by another interface
                    crossIfaceImpl = false;
                    foreach (Type otherIface in interfaces)
                    {
                        if (Array.IndexOf(otherIface.GetInterfaces(), iface) != -1)
                        {
                            crossIfaceImpl = true;
                            break;
                        }
                    }
                    if (!crossIfaceImpl)
                    {
                        AssemblyInterface intrface = new AssemblyInterface (_importer, iface);
                        intrface.Begin ();
                        try
                        {
                            Uml2.InterfaceRealization interfaceRealization = Uml2.Create.InterfaceRealization ();
                            interfaceRealization.Name = intrface.Name+"Contract";
                            interfaceRealization.Contract = (Uml2.Interface) intrface.UmlType;
                            if (_dType == AssemblyDataStructureType.Class
                                || _dType == AssemblyDataStructureType.Struct)
                            {
                                ((Uml2.Class) _umlType).InterfaceRealization.Add (interfaceRealization);
                            }
                        }
                        catch (Exception ex)
                        {
                            System.Console.WriteLine ("AssemblyDataStructure.GetInterfaces> ignored exception: " + ex.Message);
                        }
                    }
                }
            }
        }
Example #3
0
 private void BeginWithType(System.Type type)
 {
     if (type.IsEnum)
     {
         if (Elements [type.FullName] == null && ImportEnumerations)
         {
             AssemblyEnumeration enm = new AssemblyEnumeration (this, type);
             enm.Begin ();
         }
     }
     else if (type.IsInterface)
     {
         if (Elements [type.FullName] == null && ImportInterfaces)
         {
             AssemblyInterface intrface = new AssemblyInterface (this, type);
             intrface.Begin ();
         }
     }
     else if (type.IsClass)
     {
         if (Elements [type.FullName] == null && ImportClasses)
         {
             AssemblyClass cls = new AssemblyClass (this, type);
             cls.Begin ();
         }
     }
     else if (type.IsPrimitive)
     {
         if (Elements [type.FullName] == null)
         {
             AssemblyDataType dataType = new AssemblyDataType (this, type);
             dataType.Begin ();
         }
     }
     else if (type.IsValueType)
     {
         if (Elements [type.FullName] == null)
         {
             if (type.GetMembers (AssemblyHelper.BINDING_FLAGS).Length == 1)
             {
                 AssemblyDataType dataType = new AssemblyDataType (this, type);
                 dataType.Begin ();
             }
             else if (ImportStructs)
             {
                 AssemblyStruct structure = new AssemblyStruct (this, type);
                 structure.Begin ();
             }
         }
     }
 }