Exemplo n.º 1
0
        public static CIMModelLoaderResult LoadCIMModelForDifference(ref CIMDifference cimDifference)
        {
            CIMModelLoaderResult result = new CIMModelLoaderResult();

            if (cimDifference != null)
            {
                try
                {
                    bool     success;
                    TimeSpan durationOfParsing;

                    //// call parsing for begin version:
                    CIMRDFComparerXMLHandler handler = new CIMRDFComparerXMLHandler();
                    handler = (CIMRDFComparerXMLHandler)XMLParsingManager.DoParse(handler, XMLParsingManager.ParsingFileTypes.CIMModelFile, cimDifference.Extract, out success, out durationOfParsing);
                    if (success)
                    {
                        cimDifference.Model        = handler.Model;
                        cimDifference.Model.Header = handler.Start;
                        cimDifference.AddRDFNamespaces(handler.Namespaces);
                    }
                    else
                    {
                        throw new Exception("Failed to parse extract RDF. ");
                    }

                    //// call parsing for after version:
                    CIMDifferenceXMLHandler diffHandler = new CIMDifferenceXMLHandler();
                    diffHandler = new CIMDifferenceXMLHandler();
                    diffHandler = (CIMDifferenceXMLHandler)XMLParsingManager.DoParse(diffHandler, XMLParsingManager.ParsingFileTypes.CIMModelFile, cimDifference.Difference, out success, out durationOfParsing);
                    if (success)
                    {
                        cimDifference.Added   = diffHandler.Added;
                        cimDifference.Removed = diffHandler.Removed;
                        cimDifference.AddRDFNamespaces(handler.Namespaces);
                    }
                    else
                    {
                        throw new Exception("Failed to parse difference RDF. ");
                    }
                }
                catch (Exception e)
                {
                    result.Report.AppendLine("Error loading CIM/XML model: " + e.Message);
                    result.Success = false;
                }
            }
            else
            {
                result.Report.AppendLine("CIMDifference is null.");
                result.Success = false;
            }

            return(result);
        }
Exemplo n.º 2
0
        public static void LoadCIMObject(ref CIMObject cimObject, CIMModelContext cimModelContext, string text)
        {
            if (!string.IsNullOrEmpty(text))
            {
                bool     success;
                TimeSpan durationOfParsing;

                CIMRDFObjectXMLHandler handler = new CIMRDFObjectXMLHandler();
                handler.CimModelContext = cimModelContext;
                //// call parsing:
                handler = (CIMRDFObjectXMLHandler)XMLParsingManager.DoParseText(handler, XMLParsingManager.ParsingFileTypes.CIMModelFile, text, out success, out durationOfParsing);

                if (success)
                {
                    cimObject = handler.Object;
                }
            }
        }