예제 #1
0
파일: EAModel.cs 프로젝트: jcurl/EAExport
        private void BuildTree()
        {
            foreach (EATree element in m_PackageElements.Values)
            {
                string package = "EAPK" + element.Id.Substring(4);
                if (m_Elements.TryGetValue(package, out EATree packageElement))
                {
                    packageElement.Text = element.Text;
                    m_Elements.Remove(element.Id);
                }
            }

            foreach (EATree element in m_Elements.Values)
            {
                if (element.ParentId != null)
                {
                    if (!m_Elements.TryGetValue(element.ParentId, out EATree parent))
                    {
                        EATrace.XmiImport(TraceEventType.Warning, "Element: {0} disassociated with parent {1}. Object Heading is {2}.",
                                          element.Id, element.ParentId, element.Heading);
                    }
                    else
                    {
                        parent.AddChild(element);
                    }
                }
            }
        }
예제 #2
0
파일: EAModel.cs 프로젝트: jcurl/EAExport
        private void LoadUmlModel(XmlReader xmlReader)
        {
            EATrace.XmiImport(xmlReader, TraceEventType.Verbose, "{0}", xmlReader.Name);

            EATree element;

            if (Root == null)
            {
                element = new EATree(xmlReader["xmi.id"], xmlReader["name"], string.Empty, 0);
                Root    = element;
                AddElement(element);
            }
            else
            {
                // We only support a single model in our XMI for now.
                xmlReader.Skip();
                return;
            }

            if (xmlReader.IsEmptyElement)
            {
                return;
            }
            string endElement = xmlReader.Name;

            while (xmlReader.Read())
            {
                switch (xmlReader.NodeType)
                {
                case XmlNodeType.Element:
                    // This is where you would add support for more fields in the configuration file
                    if (xmlReader.Name.Equals("UML:Namespace.ownedElement"))
                    {
                        LoadUmlNamespaceOwnedElement(xmlReader, element);
                    }
                    else
                    {
                        xmlReader.Skip();
                        break;
                    }
                    break;

                case XmlNodeType.EndElement:
                    if (xmlReader.Name.Equals(endElement))
                    {
                        return;
                    }
                    FileFormatException(xmlReader, "Invalid XML format (expected </{0}>)", endElement);
                    return;
                }
            }

            FileFormatException(xmlReader, "Unexpected end of stream");
        }
예제 #3
0
파일: EAModel.cs 프로젝트: jcurl/EAExport
        private void LoadUmlPackage(XmlReader xmlReader, EATree parent)
        {
            EATrace.XmiImport(xmlReader, TraceEventType.Verbose, "{0}", xmlReader.Name);

            EATree package = new EATree(parent.Id, xmlReader["xmi.id"], xmlReader["name"], string.Empty, 0);

            AddElement(package);

            if (xmlReader.IsEmptyElement)
            {
                return;
            }
            string endElement = xmlReader.Name;

            while (xmlReader.Read())
            {
                switch (xmlReader.NodeType)
                {
                case XmlNodeType.Element:
                    // This is where you would add support for more fields in the configuration file
                    if (xmlReader.Name.Equals("UML:ModelElement.taggedValue"))
                    {
                        LoadUmlModelElementTaggedValue(xmlReader, package);
                    }
                    else if (xmlReader.Name.Equals("UML:ModelElement.stereotype"))
                    {
                        LoadUmlModelElementStereotype(xmlReader, package);
                    }
                    else if (xmlReader.Name.Equals("UML:Namespace.ownedElement"))
                    {
                        LoadUmlNamespaceOwnedElement(xmlReader, package);
                    }
                    else
                    {
                        xmlReader.Skip();
                        break;
                    }
                    break;

                case XmlNodeType.EndElement:
                    if (xmlReader.Name.Equals(endElement))
                    {
                        return;
                    }
                    FileFormatException(xmlReader, "Invalid configuration XML format (expected </{0}>)", endElement);
                    return;
                }
            }

            FileFormatException(xmlReader, "Unexpected end of stream");
        }
예제 #4
0
파일: EAModel.cs 프로젝트: jcurl/EAExport
        private void LoadUmlNamespaceOwnedElement(XmlReader xmlReader, EATree parent)
        {
            EATrace.XmiImport(xmlReader, TraceEventType.Verbose, "{0}", xmlReader.Name);

            if (xmlReader.IsEmptyElement)
            {
                return;
            }
            string endElement = xmlReader.Name;

            while (xmlReader.Read())
            {
                switch (xmlReader.NodeType)
                {
                case XmlNodeType.Element:
                    // This is where you would add support for more fields in the configuration file
                    if (xmlReader.Name.Equals("UML:Package"))
                    {
                        LoadUmlPackage(xmlReader, parent);
                    }
                    else if (xmlReader.Name.Equals("UML:Collaboration"))
                    {
                        LoadUmlCollaboration(xmlReader, parent);
                    }
                    else if (xmlReader.Name.Equals("UML:ClassifierRole"))
                    {
                        LoadUmlClassifierRole(xmlReader);
                    }
                    else
                    {
                        xmlReader.Skip();
                        break;
                    }
                    break;

                case XmlNodeType.EndElement:
                    if (xmlReader.Name.Equals(endElement))
                    {
                        return;
                    }
                    FileFormatException(xmlReader, "Invalid configuration XML format (expected </{0}>)", endElement);
                    return;
                }
            }

            FileFormatException(xmlReader, "Unexpected end of stream");
        }
예제 #5
0
파일: EAModel.cs 프로젝트: jcurl/EAExport
        private void LoadXmiRoot(XmlReader xmlReader)
        {
            EATrace.XmiImport(xmlReader, TraceEventType.Verbose, "{0}", xmlReader.Name);

            if (!xmlReader["xmi.version"].Equals("1.1"))
            {
                FileFormatException(xmlReader, "Unexpected version. Got {0}; Expected 1.1", xmlReader["xmi.version"]);
                return;
            }

            if (xmlReader.IsEmptyElement)
            {
                return;
            }
            string endElement = xmlReader.Name;

            while (xmlReader.Read())
            {
                switch (xmlReader.NodeType)
                {
                case XmlNodeType.Element:
                    // This is where you would add support for more fields in the configuration file
                    if (xmlReader.Name.Equals("XMI.content"))
                    {
                        LoadXmiContent(xmlReader);
                    }
                    else
                    {
                        xmlReader.Skip();
                        break;
                    }
                    break;

                case XmlNodeType.EndElement:
                    if (xmlReader.Name.Equals(endElement))
                    {
                        return;
                    }
                    FileFormatException(xmlReader, "Invalid XML format (expected </{0}>)", endElement);
                    return;
                }
            }

            FileFormatException(xmlReader, "Unexpected end of stream");
        }
예제 #6
0
파일: EAModel.cs 프로젝트: jcurl/EAExport
        /// <summary>
        /// Loads the EA Model from an XMI file.
        /// </summary>
        /// <param name="fileName">Name of the file to import.</param>
        /// <returns>An EA Model object.</returns>
        public static EAModel LoadXmi(string fileName)
        {
            EAModel model = new EAModel();

            EATrace.XmiImport(TraceEventType.Information, "Time: {0}", DateTime.Now.ToString("G"));
            EATrace.XmiImport(TraceEventType.Information, "Loading file {0}", fileName);
            FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);

            using (XmlTextReader xmlReader = new XmlTextReader(fs)
            {
                XmlResolver = null,
                DtdProcessing = DtdProcessing.Prohibit
            }) {
                model.LoadXmi(xmlReader);
                model.BuildTree();
                return(model);
            }
        }
예제 #7
0
파일: EAModel.cs 프로젝트: jcurl/EAExport
        private void LoadUmlModelElementStereotype(XmlReader xmlReader, EATree parent)
        {
            EATrace.XmiImport(xmlReader, TraceEventType.Verbose, "{0}", xmlReader.Name);

            if (xmlReader.IsEmptyElement)
            {
                return;
            }
            string endElement = xmlReader.Name;

            while (xmlReader.Read())
            {
                switch (xmlReader.NodeType)
                {
                case XmlNodeType.Element:
                    if (xmlReader.Name.Equals("UML:Stereotype"))
                    {
                        parent.Stereotype = xmlReader["name"];
                    }
                    else
                    {
                        xmlReader.Skip();
                        break;
                    }
                    break;

                case XmlNodeType.EndElement:
                    if (xmlReader.Name.Equals(endElement))
                    {
                        return;
                    }
                    FileFormatException(xmlReader, "Invalid configuration XML format (expected </{0}>)", endElement);
                    return;
                }
            }

            FileFormatException(xmlReader, "Unexpected end of stream");
        }
예제 #8
0
파일: EAModel.cs 프로젝트: jcurl/EAExport
        private void FileFormatException(XmlReader xmlReader, string format, params object[] args)
        {
            string message = EATrace.XmiImport(xmlReader, TraceEventType.Warning, format, args);

            throw new FileFormatException(message);
        }
예제 #9
0
파일: EAModel.cs 프로젝트: jcurl/EAExport
        private void LoadUmlModelElementTaggedValue(XmlReader xmlReader, EATree parent)
        {
            EATrace.XmiImport(xmlReader, TraceEventType.Verbose, "{0}", xmlReader.Name);

            if (xmlReader.IsEmptyElement)
            {
                return;
            }
            string endElement = xmlReader.Name;

            string owner    = null;
            string package  = null;
            string package2 = null;
            string tpos     = null;

            while (xmlReader.Read())
            {
                switch (xmlReader.NodeType)
                {
                case XmlNodeType.Element:
                    if (xmlReader.Name.Equals("UML:TaggedValue"))
                    {
                        EATrace.XmiImport(xmlReader, TraceEventType.Verbose, "Tagged Value: {0} = {1}", xmlReader["tag"], xmlReader["value"]);
                        if (xmlReader["tag"].Equals("owner"))
                        {
                            owner = xmlReader["value"];
                        }
                        else if (xmlReader["tag"].Equals("package"))
                        {
                            package = xmlReader["value"];
                        }
                        else if (xmlReader["tag"].Equals("tpos"))
                        {
                            tpos = xmlReader["value"];
                        }
                        else if (xmlReader["tag"].Equals("documentation"))
                        {
                            parent.Text = xmlReader["value"];
                        }
                        else if (xmlReader["tag"].Equals("package2"))
                        {
                            package2 = xmlReader["value"];
                        }
                        else if (xmlReader["tag"].Equals("alias"))
                        {
                            parent.Alias = xmlReader["value"];
                        }
                        else if (xmlReader["tag"].Equals("version"))
                        {
                            parent.Version = xmlReader["value"];
                        }
                        else if (xmlReader["tag"].Equals("author"))
                        {
                            parent.Author = xmlReader["value"];
                        }
                        else if (xmlReader["tag"].Equals("status"))
                        {
                            parent.Status = xmlReader["value"];
                        }
                        else if (xmlReader["tag"].Equals("date_created"))
                        {
                            parent.CreateTime = ConvertDateTime(xmlReader["value"]);
                        }
                        else if (xmlReader["tag"].Equals("date_modified"))
                        {
                            parent.ModifiedTime = ConvertDateTime(xmlReader["value"]);
                        }

                        if (!xmlReader.IsEmptyElement)
                        {
                            xmlReader.Skip();
                        }
                    }
                    else
                    {
                        xmlReader.Skip();
                        break;
                    }
                    break;

                case XmlNodeType.EndElement:
                    if (xmlReader.Name.Equals(endElement))
                    {
                        if (parent.ParentId == null)
                        {
                            if (owner != null)
                            {
                                parent.ParentId = owner;
                            }
                            else if (package != null)
                            {
                                parent.ParentId = package;
                            }
                        }

                        if (package2 != null)
                        {
                            // In EA, we see a package contains a ClassifierRole object as well as a Package.
                            // We need to filter these ClassifierRole objects out, else they occur twice in
                            // the tree. We assume that 'package2' is the same as the element ID.
                            m_PackageElements.Add(parent.Id, parent);
                        }

                        if (tpos != null)
                        {
                            parent.Pos = int.Parse(tpos);
                        }
                        return;
                    }
                    FileFormatException(xmlReader, "Invalid configuration XML format (expected </{0}>)", endElement);
                    return;
                }
            }

            FileFormatException(xmlReader, "Unexpected end of stream");
        }
예제 #10
0
 /// <summary>
 /// Initializes all ScriptCore classes that data to the App Domain
 /// and initialize any other static members in Sims3.SimIFace classes.
 /// </summary>
 public static void Initialize()
 {
     if (!sInitialized)
     {
         if (gAnimation == null)
         {
             gAnimation = new Animation();
         }
         if (gAudio == null)
         {
             gAudio = new Audio();
         }
         if (gAutomationUtils == null)
         {
             gAutomationUtils = new AutomationUtils();
         }
         if (gCacheManager == null)
         {
             gCacheManager = new CacheManager();
         }
         if (gCameraController == null)
         {
             gCameraController = new CameraController();
         }
         if (gCASUtils == null)
         {
             gCASUtils = new CASUtils();
         }
         if (gCommandSystem == null)
         {
             gCommandSystem = new CommandSystem();
         }
         if (gCTProductModularObject == null)
         {
             gCTProductModularObject = new CTProductModularObject();
         }
         if (gDataFactory == null)
         {
             gDataFactory = new DataFactory();
         }
         if (gDebugDraw == null)
         {
             gDebugDraw = new DebugDraw();
         }
         if (gDeviceConfig == null)
         {
             gDeviceConfig = new DeviceConfig();
         }
         if (gDownloadContent == null)
         {
             gDownloadContent = new DownloadContent();
         }
         if (gEAText == null)
         {
             gEAText = new EAText();
         }
         if (gEATrace == null)
         {
             gEATrace = new EATrace();
         }
         if (gEventQueueInitializer == null)
         {
             gEventQueueInitializer = new EventQueueInitializer();
         }
         if (gGameUtils == null)
         {
             gGameUtils = new GameUtils();
         }
         if (gLoadSaveManager == null)
         {
             gLoadSaveManager = new LoadSaveManager();
         }
         if (gLocalizedStringService == null)
         {
             gLocalizedStringService = new LocalizedStringService();
         }
         if (gLookAtMgr == null)
         {
             gLookAtMgr = new LookAtMgr();
         }
         if (gNameGuidMapService == null)
         {
             gNameGuidMapService = new NameGuidMapService();
         }
         if (gObjects == null)
         {
             gObjects = new Objects();
         }
         if (gOnlineFeatures == null)
         {
             gOnlineFeatures = new OnlineFeatures();
         }
         //if (gProfilerUtils == null) gProfilerUtils = new ProfilerUtils();
         if (gQueries == null)
         {
             gQueries = new Queries();
         }
         if (gRandom == null)
         {
             gRandom = new ScriptCore.Random();
         }
         if (gReflection == null)
         {
             gReflection = new ScriptCore.Reflection();
         }
         if (gRouteManager == null)
         {
             gRouteManager = new RouteManager();
         }
         if (gSACS == null)
         {
             gSACS = new SACS();
         }
         if (gSimulator == null)
         {
             gSimulator = new Simulator();
         }
         if (gSlots == null)
         {
             gSlots = new Slots();
         }
         if (gSocialFeatures == null)
         {
             gSocialFeatures = new SocialFeatures();
         }
         if (gStopWatch == null)
         {
             gStopWatch = new StopWatch();
         }
         if (gStreamHost == null)
         {
             gStreamHost = new StreamHost();
         }
         if (gSwarm == null)
         {
             gSwarm = new Swarm();
         }
         if (gThumbnailManager == null)
         {
             gThumbnailManager = new ThumbnailManager();
         }
         if (gUIManager == null)
         {
             gUIManager = new UIManager();
         }
         if (gUserToolUtils == null)
         {
             gUserToolUtils = new UserToolUtils();
         }
         if (gVideoRecorder == null)
         {
             gVideoRecorder = new VideoRecorder();
         }
         if (gWorld == null)
         {
             gWorld = new World();
         }
         // Will this still be reached if any of the constructors throw an Exception? Hopefully not
         sInitialized = true;
     }
 }