当前位置: 首页>>代码示例>>C#>>正文


C# XmlTextReader.Dispose方法代码示例

本文整理汇总了C#中System.Xml.XmlTextReader.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# XmlTextReader.Dispose方法的具体用法?C# XmlTextReader.Dispose怎么用?C# XmlTextReader.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.XmlTextReader的用法示例。


在下文中一共展示了XmlTextReader.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Table_GetAll

        public List<object> Table_GetAll()
        {
            var returnValue = new List<object>();
            try
            {
                var allTables = base.GetAllFiles(this._tableDirectoryPath);
                foreach (var table in allTables)
                {
                    var fileStream = base.GetFileReadStream(table.Value);
                    var xmlTextReader = new XmlTextReader(fileStream);

                    returnValue.Add(Serializer.Deserialize(xmlTextReader));

                    fileStream.Close();
                    fileStream.Dispose();

                    xmlTextReader.Close();
                    xmlTextReader.Dispose();
                }
            }
            catch (Exception ex)
            {
                if (this._logger != null)
                {
                    this._logger.Log(ex.Message, Category.Exception, Priority.High);
                }
            }

            return returnValue;
        }
开发者ID:thpratik,项目名称:TableReservation,代码行数:30,代码来源:TableDataService.cs

示例2: VerifyTest

        public static void VerifyTest(string actResult, string expResult)
        {
            XmlDiff.XmlDiff diff = new XmlDiff.XmlDiff();
            diff.Option = XmlDiffOption.IgnoreEmptyElement | XmlDiffOption.IgnoreAttributeOrder;

            XmlTextReader xrActual = new XmlTextReader(new StringReader(actResult));
            XmlTextReader xrExpected = new XmlTextReader(new StringReader(expResult));

            bool bResult = false;

            try
            {
                bResult = diff.Compare(xrActual, xrExpected);
            }
            catch (Exception e)
            {
                bResult = false;
                s_output.WriteLine("Exception thrown in XmlDiff compare!");
                s_output.WriteLine(e.ToString());
            }
            finally
            {
                if (xrActual != null) xrActual.Dispose();
                if (xrExpected != null) xrExpected.Dispose();
            }

            s_output.WriteLine("Expected : " + expResult);
            s_output.WriteLine("Actual : " + actResult);

            if (bResult)
                return;
            else
                Assert.True(false);
        }
开发者ID:Corillian,项目名称:corefx,代码行数:34,代码来源:Utils.cs

示例3: Table_GetByID

        public object Table_GetByID(Guid tableId)
        {
            object returnValue = null;

            try
            {
                var fileStream = base.GetFileReadStream(Path.Combine(this._tableDirectoryPath, tableId.ToString() + ".xml"));
                var xmlTextReader = new XmlTextReader(fileStream);

                returnValue = Serializer.Deserialize(xmlTextReader);

                fileStream.Close();
                fileStream.Dispose();

                xmlTextReader.Close();
                xmlTextReader.Dispose();
            }
            catch (Exception ex)
            {
                if (this._logger != null)
                {
                    this._logger.Log(ex.Message, Category.Exception, Priority.High);
                }
            }

            return returnValue;
        }
开发者ID:thpratik,项目名称:TableReservation,代码行数:27,代码来源:TableDataService.cs

示例4: import

        public void import(String filename)
        {
            WindowTitle = "Importing Tags";

            XmlTextReader inFile = null;
            try
            {
                inFile = new XmlTextReader(filename);
                Type[] knownTypes = new Type[] { typeof(TagDTO), typeof(TagCategoryDTO) };

                DataContractSerializer tagSerializer = new DataContractSerializer(typeof(List<TagDTO>), knownTypes);

                List<Tag> tags = new List<Tag>();
                List<TagDTO> tagDTOs = (List<TagDTO>)tagSerializer.ReadObject(inFile);

                foreach (TagDTO tagDTO in tagDTOs)
                {
                    var tag = Mapper.Map<TagDTO, Tag>(tagDTO, new Tag());                 
                    tags.Add(tag);
                }

                TotalProgressMax = tags.Count;
                TotalProgress = 0;

                using (TagDbCommands tagCommands = new TagDbCommands())
                {
                    foreach (Tag tag in tags)
                    {
                        if (CancellationToken.IsCancellationRequested == true) return;

                        ItemInfo = "Merging: " + tag.Name;
                        ItemProgress = 0;
                        tagCommands.merge(tag);
                        ItemProgress = 100;
                        TotalProgress++;
                        InfoMessages.Add("Merged: " + tag.Name);
                    }
                }                
            }
            catch (Exception e)
            {
                InfoMessages.Add("Error importing tags " + e.Message);         
            }
            finally
            {
                operationFinished();

                if (inFile != null)
                {
                    inFile.Dispose();
                }
            }
        }
开发者ID:iejeecee,项目名称:mediaviewer,代码行数:53,代码来源:TagOperationsViewModel.cs

示例5: FullFilePath

        // --------------------------------------------------------------------------------------------------------------
        //  LoadXSL_Resolver_Evidence
        //  -------------------------------------------------------------------------------------------------------------
        /*public int LoadXSL_Resolver_Evidence(String _strXslFile, XmlResolver xr, Evidence e)
        {
            _strXslFile = FullFilePath(_strXslFile);
            xslt = new XslCompiledTransform();

            switch (_nInputXsl)
            {
                case XslInputType.Reader:
                    switch (_readerType)
                    {
                        case ReaderType.XmlTextReader:
                            XmlReader trTemp = XmlReader.Create(_strXslFile);
                            try
                            {
                                _output.WriteLine("Loading style sheet as XmlTextReader " + _strXslFile);
                                //xslt.Load(trTemp, xr, e); //Evidence is not supported on V2 XSLT Load
                                xslt.Load(trTemp, XsltSettings.TrustedXslt, xr);
                            }
                            catch (Exception ex)
                            {
                                throw (ex);
                            }
                            finally
                            {
                                if (trTemp != null)
                                    trTemp.Dispose();
                            }
                            break;

                        case ReaderType.XmlNodeReader:
                            XmlDocument docTemp = new XmlDocument();
                            docTemp.Load(_strXslFile);
                            XmlNodeReader nrTemp = new XmlNodeReader(docTemp);
                            try
                            {
                                _output.WriteLine("Loading style sheet as XmlNodeReader " + _strXslFile);
                                //xslt.Load(nrTemp, xr, e); Evidence is not supported in V2 XSLT Load
                                xslt.Load(nrTemp, XsltSettings.TrustedXslt, xr);
                            }
                            catch (Exception ex)
                            {
                                throw (ex);
                            }
                            finally
                            {
                                if (nrTemp != null)
                                    nrTemp.Dispose();
                            }
                            break;

                        case ReaderType.XmlValidatingReader:
                        default:
                            XmlReaderSettings xrs = new XmlReaderSettings();
#pragma warning disable 0618
                            xrs.ProhibitDtd = false;
#pragma warning restore 0618
                            XmlReader vrTemp = null;
                            try
                            {
                                vrTemp = XmlReader.Create(_strXslFile, xrs);
                                _output.WriteLine("Loading style sheet as XmlValidatingReader " + _strXslFile);
                                //xslt.Load(vrTemp, xr, e); Evidence is not supported in V2 XSLT Load
                                xslt.Load(vrTemp, XsltSettings.TrustedXslt, xr);
                            }
                            catch (Exception ex)
                            {
                                throw (ex);
                            }
                            finally
                            {
                                if (vrTemp != null)
                                    vrTemp.Dispose();
                            }
                            break;
                    }
                    break;

                case XslInputType.Navigator:
                    XmlReader xrLoad = XmlReader.Create(_strXslFile);
                    XPathDocument xdTemp = new XPathDocument(xrLoad, XmlSpace.Preserve);
                    xrLoad.Dispose();
                    _output.WriteLine("Loading style sheet as Navigator " + _strXslFile);
                    xslt.Load(xdTemp.CreateNavigator(), XsltSettings.TrustedXslt, xr);
                    break;
            }
            return 1;
        }*/

        //VerifyResult
        public void VerifyResult(string expectedValue)
        {
            XmlDiff.XmlDiff xmldiff = new XmlDiff.XmlDiff();
            xmldiff.Option = XmlDiffOption.InfosetComparison | XmlDiffOption.IgnoreEmptyElement;

            StreamReader sr = new StreamReader(new FileStream("out.xml", FileMode.Open, FileAccess.Read));
            string actualValue = sr.ReadToEnd();
            sr.Dispose();
//.........这里部分代码省略.........
开发者ID:geoffkizer,项目名称:corefx,代码行数:101,代码来源:XsltApiV2.cs

示例6: LoadXSL_Resolver

        // --------------------------------------------------------------------------------------------------------------
        //  LoadXSL_Resolver
        //  -------------------------------------------------------------------------------------------------------------
        public int LoadXSL_Resolver(String _strXslFile, XmlResolver xr)
        {
            _strXslFile = FullFilePath(_strXslFile);
            xslt = new XslCompiledTransform();
            XmlReaderSettings xrs = null;
            switch (_nInputXsl)
            {
                case XslInputType.URI:
                    _output.WriteLine("Loading style sheet as URI " + _strXslFile);
                    xslt.Load(_strXslFile, XsltSettings.TrustedXslt, xr);
                    break;

                case XslInputType.Reader:
                    switch (_readerType)
                    {
                        case ReaderType.XmlTextReader:
                            XmlTextReader trTemp = new XmlTextReader(_strXslFile);
                            try
                            {
                                _output.WriteLine("Loading style sheet as XmlTextReader " + _strXslFile);
                                xslt.Load(trTemp, XsltSettings.TrustedXslt, xr);
                            }
                            catch (Exception ex)
                            {
                                throw (ex);
                            }
                            finally
                            {
                                if (trTemp != null)
                                    trTemp.Dispose();
                            }
                            break;

                        case ReaderType.XmlNodeReader:
                            XmlDocument docTemp = new XmlDocument();
                            docTemp.Load(_strXslFile);
                            XmlNodeReader nrTemp = new XmlNodeReader(docTemp);
                            try
                            {
                                _output.WriteLine("Loading style sheet as XmlNodeReader " + _strXslFile);
                                xslt.Load(nrTemp, XsltSettings.TrustedXslt, xr);
                            }
                            catch (Exception ex)
                            {
                                throw (ex);
                            }
                            finally
                            {
                                if (nrTemp != null)
                                    nrTemp.Dispose();
                            }
                            break;

                        case ReaderType.XmlValidatingReader:
                        default:
                            xrs = new XmlReaderSettings();
#pragma warning disable 0618
                            xrs.ProhibitDtd = false;
#pragma warning restore 0618
                            XmlReader vrTemp = XmlReader.Create(_strXslFile, xrs);
                            try
                            {
                                _output.WriteLine("Loading style sheet as XmlValidatingReader " + _strXslFile);
                                xslt.Load(vrTemp, XsltSettings.TrustedXslt, xr);
                            }
                            catch (Exception ex)
                            {
                                throw (ex);
                            }
                            finally
                            {
                                if (vrTemp != null)
                                    vrTemp.Dispose();
                            }
                            break;
                    }
                    break;

                case XslInputType.Navigator:
                    xrs = new XmlReaderSettings();
#pragma warning disable 0618
                    xrs.ProhibitDtd = false;
#pragma warning restore 0618
                    XmlReader xrLoad = XmlReader.Create(_strXslFile, xrs);

                    XPathDocument xdTemp = new XPathDocument(xrLoad, XmlSpace.Preserve);
                    xrLoad.Dispose();
                    _output.WriteLine("Loading style sheet as Navigator " + _strXslFile);
                    xslt.Load(xdTemp, XsltSettings.TrustedXslt, xr);
                    break;
            }
            return 1;
        }
开发者ID:geoffkizer,项目名称:corefx,代码行数:96,代码来源:XsltApiV2.cs

示例7: GetSavedVersion

 // TODO : ADDED FOR PS5
 /// <summary>
 /// Returns the version information of the spreadsheet saved in the named file.
 /// If there are any problems opening, reading, or closing the file, the method
 /// should throw a SpreadsheetReadWriteException with an explanatory message.
 /// </summary>
 public override string GetSavedVersion(string filename)
 {
     string vers = "";
     XmlTextReader xmlReader = null;
     try
     {
         xmlReader = new XmlTextReader(filename);
     }
     catch (Exception)
     {
         xmlReader.Dispose();
         throw new SpreadsheetReadWriteException("File could not be opened using XmlTextReader");
     }
     // Attempts to read the spreadsheet version from the XML file.
     if (!xmlReader.ReadToFollowing("spreadsheet") || !xmlReader.MoveToFirstAttribute())
         throw new SpreadsheetReadWriteException("Spreadsheet version could not be found");
     vers = xmlReader.Value;
     // Attemtps to close the XML reader.
     try
     {
         xmlReader.Close();
     }
     catch (Exception)
     {
         xmlReader.Dispose();
         throw new SpreadsheetReadWriteException("File could not be closed.");
     }
     return vers;
 }
开发者ID:drewmacmac,项目名称:old_class,代码行数:35,代码来源:Spreadsheet.cs

示例8: Spreadsheet

        /// <summary>
        /// Provides a four argument constructor for a spreadsheet.
        /// This constructor will use the provided Validator and Normalizer, and will set the version to be the provided version string.
        /// This constructor will also construct cells based on an XMl spreadsheet representation of a spreadsheet.
        /// If the version passed into the constructor does not match the version in the XML file, an exception is thrown.
        /// </summary>
        public Spreadsheet(string filePath, Func<string, bool> isValid, Func<string, string> normalize, string version)
            : base(isValid, normalize, version)
        {
            cells = new Dictionary<string, Cell>();
            dependencies = new DependencyGraph();
            if (GetSavedVersion(filePath) != version)
                throw new SpreadsheetReadWriteException("The saved version of the XML file does not match the version provided to the constructor.");

            // Constructs an XML reader object.
            XmlTextReader xmlReader = null;
            try
            {
                xmlReader = new XmlTextReader(filePath);
            }
            catch (Exception)
            {
                xmlReader.Dispose();
                throw new SpreadsheetReadWriteException("File could not be opened using XmlTextReader");
            }
            // Reads cells from XML spreadsheet.
            while (xmlReader.Read())
            {
                string name = "";
                string contents = "";
                if (xmlReader.ReadToFollowing("name"))
                {
                    name = xmlReader.ReadElementContentAsString();
                    if (!xmlReader.ReadToFollowing("contents"))
                        throw new SpreadsheetReadWriteException("No contents found associated with name: " + name);
                    contents = xmlReader.ReadElementContentAsString();

                    this.SetContentsOfCell(name, contents);
                }
            }
            IsValid = isValid;
            Normalize = normalize;
            hasChanged = false;
        }
开发者ID:drewmacmac,项目名称:old_class,代码行数:44,代码来源:Spreadsheet.cs

示例9: LoadXSL_Resolver

        // --------------------------------------------------------------------------------------------------------------
        //  LoadXSL_Resolver
        //  -------------------------------------------------------------------------------------------------------------
        public int LoadXSL_Resolver(String _strXslFile, XmlResolver xr)
        {
            _strXslFile = FullFilePath(_strXslFile);
#pragma warning disable 0618
            xslt = new XslTransform();
#pragma warning restore 0618

            switch (_nInput)
            {
                case InputType.URI:
                    _output.WriteLine("Loading style sheet as URI {0}", _strXslFile);
                    xslt.Load(_strXslFile, xr);
                    break;

                case InputType.Reader:
                    switch (_readerType)
                    {
                        case ReaderType.XmlTextReader:
                            XmlTextReader trTemp = new XmlTextReader(_strXslFile);
                            try
                            {
                                _output.WriteLine("Loading style sheet as XmlTextReader {0}", _strXslFile);
                                xslt.Load(trTemp, xr);
                            }
                            catch (Exception ex)
                            {
                                throw (ex);
                            }
                            finally
                            {
                                if (trTemp != null)
                                    trTemp.Dispose();
                            }
                            break;

                        case ReaderType.XmlNodeReader:
                            XmlDocument docTemp = new XmlDocument();
                            docTemp.Load(_strXslFile);
                            XmlNodeReader nrTemp = new XmlNodeReader(docTemp);
                            try
                            {
                                _output.WriteLine("Loading style sheet as XmlNodeReader {0}", _strXslFile);
                                xslt.Load(nrTemp, xr);
                            }
                            catch (Exception ex)
                            {
                                throw (ex);
                            }
                            finally
                            {
                                if (nrTemp != null)
                                    nrTemp.Dispose();
                            }
                            break;

                        case ReaderType.XmlValidatingReader:
                        default:
#pragma warning disable 0618
                            XmlValidatingReader vrTemp = new XmlValidatingReader(new XmlTextReader(_strXslFile));
#pragma warning restore 0618
                            vrTemp.ValidationType = ValidationType.None;
                            vrTemp.EntityHandling = EntityHandling.ExpandEntities;
                            try
                            {
                                _output.WriteLine("Loading style sheet as XmlValidatingReader {0}", _strXslFile);
                                xslt.Load(vrTemp, xr);
                            }
                            catch (Exception ex)
                            {
                                throw (ex);
                            }
                            finally
                            {
                                if (vrTemp != null)
                                    vrTemp.Dispose();
                            }
                            break;
                    }
                    break;

                case InputType.Navigator:
#pragma warning disable 0618
                    XmlValidatingReader xrLoad = new XmlValidatingReader(new XmlTextReader(_strXslFile));
#pragma warning restore 0618
                    XPathDocument xdTemp = new XPathDocument(xrLoad, XmlSpace.Preserve);
                    xrLoad.Dispose();
                    _output.WriteLine("Loading style sheet as Navigator {0}", _strXslFile);
                    xslt.Load(xdTemp, xr);
                    break;
            }
            return 1;
        }
开发者ID:shmao,项目名称:corefx,代码行数:95,代码来源:XSLTransform.cs

示例10: TransformStrStrResolver1

 public void TransformStrStrResolver1()
 {
     String szFullFilename = FullFilePath("fruits.xml");
     try
     {
         if (LoadXSL("xmlResolver_main.xsl", new XmlUrlResolver()) == 1)
         {
             XmlTextReader xr = new XmlTextReader(szFullFilename);
             XmlTextWriter xw = new XmlTextWriter("out.xml", Encoding.Unicode);
             xslt.Transform(xr, null, xw, null);
             xr.Dispose();
             xw.Dispose();
             if (CheckResult(403.7784431795) == 1)
                 return;
             else
                 Assert.True(false);
         }
     }
     catch (Exception e)
     {
         _output.WriteLine(e.ToString());
         Assert.True(false);
     }
     Assert.True(false);
 }
开发者ID:shmao,项目名称:corefx,代码行数:25,代码来源:XslCompiledTransform.cs

示例11: TransformStrStrResolver1

        public void TransformStrStrResolver1()
        {
            String szFullFilename = FullFilePath("fruits.xml");
            string expected = @"<result>
  <fruit>Apple</fruit>
  <fruit>orange</fruit>
</result>";

            if (LoadXSL("XmlResolver_Main.xsl", new XmlUrlResolver()) == 1)
            {
                XmlTextReader xr = new XmlTextReader(szFullFilename);
                XmlTextWriter xw = new XmlTextWriter("out.xml", Encoding.Unicode);
                xslt.Transform(xr, null, xw, null);
                xr.Dispose();
                xw.Dispose();
                VerifyResult(expected);
                return;
            }
            Assert.True(false);
        }
开发者ID:JonHanna,项目名称:corefx,代码行数:20,代码来源:XslCompiledTransform.cs

示例12: ProcessClientBigRequest

        public static void ProcessClientBigRequest(string ConnString, Stream requestStream, Stream responseStream, bool dispose, FlushDelegate flushDelegate, TaskLoggingHelper log)
        {
            XmlTextReader xr = new XmlTextReader(requestStream);

            XmlTextWriter xw = new XmlTextWriter(responseStream, Encoding.UTF8);

            xw.WriteStartDocument();
            xw.WriteStartElement("table");

            bool first = true;

            //using (xr)
            //{
                xr.Read();
                xr.Read();
                xr.ReadStartElement("request");
                while (xr.Name == "id")
                {
                    int serviceTableID = Convert.ToInt32(xr.ReadElementString("id"));
                    ServiceTable st = DAO.GetServiceTable(ConnString, serviceTableID);
                    if (first)
                    {
                        if (log != null)
                            log.LogMessage("Processing ID " + serviceTableID.ToString() + " response " + st.ServiceTableID.ToString());
                        first = false;
                    }

                    xw.WriteStartElement("record");
                    xw.WriteElementString("ServiceTableID", st.ServiceTableID.ToString());
                    xw.WriteElementString("DescServiceTable", st.DescServiceTable);
                    xw.WriteElementString("Value", st.Value.ToString("0.00"));
                    xw.WriteElementString("CreationDate", st.CreationDate.ToString("dd/MM/yyyy hh:mm:ss"));
                    xw.WriteElementString("StringField1", st.StringField1);
                    xw.WriteElementString("StringField2", st.StringField2);
                    xw.WriteEndElement();
                    if (flushDelegate != null)
                        flushDelegate();
                }
                xr.ReadEndElement();

            //}
                xr.Dispose();
            xw.WriteEndElement();
            xw.Flush();

            if (dispose)
                xw.Close();
        }
开发者ID:ericlemes,项目名称:IntegrationTests,代码行数:48,代码来源:StreamUtil.cs

示例13: ProcessWspFile


//.........这里部分代码省略.........
                                            XmlNodeList xmlFieldRefList = fieldRefs.ChildNodes;

                                            for (int j = 0; j < xmlFieldRefList.Count; j++)
                                            {
                                                try
                                                {
                                                    string fieldRefId = xmlFieldRefList[j].Attributes["ID"].Value;
                                                    if (lstCustomFieldIDs.Where(c => fieldRefId.Equals(c)).Any())
                                                    {
                                                        isCustomSiteColumn = true;
                                                        Logger.LogInfoMessage("[DownloadAndModifySiteTemplate: ProcessWspFile] Customized Site Column associated with Content Type Found for: " + objSiteCustOutput.SiteTemplateName, true);
                                                        break;
                                                    }
                                                }
                                                catch (Exception ex)
                                                {
                                                    Logger.LogErrorMessage("[DownloadAndModifySiteTemplate: ProcessWspFile]. Exception Message: " + ex.Message + ", Exception Comments: Exception while reading Site Columns tag in content types", true);
                                                    ExceptionCsv.WriteException(objSiteCustOutput.WebApplication, objSiteCustOutput.SiteCollection, Constants.NotApplicable, "SiteTemplate", ex.Message, ex.ToString(),
                                                        "ProcessWspFile", ex.GetType().ToString(), "Exception while reading Site Columns tag in content types. SolutionName: " + solFileName + ", FileName: " + contentTypesXml);
                                                }
                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        Logger.LogErrorMessage("[DownloadAndModifySiteTemplate: ProcessWspFile]. Exception Message: " + ex.Message + ", Exception Comments: Exception while reading Site Columns tag in content types", true);
                                        ExceptionCsv.WriteException(objSiteCustOutput.WebApplication, objSiteCustOutput.SiteCollection, Constants.NotApplicable, "SiteTemplate", ex.Message, ex.ToString(),
                                            "ProcessWspFile", ex.GetType().ToString(), "Exception while reading Site Columns tag in content types. SolutionName: " + solFileName + ", FileName: " + contentTypesXml);
                                    }
                                }
                            }
                            #endregion

                            reader.Dispose();
                        }
                        //Reading ElementContentTypes.xml for Searching Custom Fields
                        if (list.ElementAt(0).EndsWith(@"\"))
                            customFieldsTypesXml = list.ElementAt(0) + "ElementsFields.xml";
                        else
                            customFieldsTypesXml = list.ElementAt(0) + @"\" + "ElementsFields.xml";

                        if (!isCustomSiteColumn && System.IO.File.Exists(customFieldsTypesXml) && !isCustomSiteColumn)
                        {
                            Logger.LogInfoMessage("[DownloadAndModifySiteTemplate: ProcessWspFile] Searching for customized Site Columns in List in: " + customFieldsTypesXml, true);
                            var reader = new XmlTextReader(customFieldsTypesXml);

                            reader.Namespaces = false;
                            reader.Read();
                            XmlDocument doc3 = new XmlDocument();
                            doc3.Load(reader);
                            XmlNodeList xmlFields = doc3.SelectNodes("/Elements/Field");

                            #region Custom Fields
                            if (lstCustomFieldIDs != null && lstCustomFieldIDs.Count > 0)
                            {
                                for (int i = 0; i < xmlFields.Count; i++)
                                {
                                    try
                                    {
                                        var fieldList = xmlFields[i].Attributes["ID"].Value;

                                        //Remove contenttype tag if ContentTypeId present in custom ContentTypes file ContentTypes.csv
                                        if (lstCustomFieldIDs.Where(c => fieldList.Equals(c)).Any())
                                        {
                                            isCustomSiteColumn = true;
                                            Logger.LogInfoMessage("[DownloadAndModifySiteTemplate: ProcessWspFile] Customized Site Column Found for: " + objSiteCustOutput.SiteTemplateName, true);
开发者ID:OfficeDev,项目名称:PnP-Transformation,代码行数:67,代码来源:DownloadAndModifySiteTemplate.cs

示例14: CheckCustomEventReceiver

        public static void CheckCustomEventReceiver(string xmlFilePath, string erNodePath, ref bool isCustomEventReceiver, string siteTemplateName)
        {
            string xml;

            if (System.IO.File.Exists(xmlFilePath))
            {
                Logger.LogInfoMessage("[DownloadAndModifySiteTemplate: ProcessWspFile] Searching for customized Web/Site Event Receivers in: " + xmlFilePath, true);
                var reader = new XmlTextReader(xmlFilePath);
                try
                {
                    using (TextReader txtreader = new StreamReader(xmlFilePath))
                    {
                        xml = txtreader.ReadToEnd();
                    }

                    xml = CommonUtility.SanitizeXmlString(xml);
                    reader.Namespaces = false;
                    reader.Read();

                    XmlDocument doc = new XmlDocument();

                    try
                    {
                        doc = CommonUtility.GetXmlDocumentFromString(xml);
                    }
                    catch (Exception ex)
                    {
                        Logger.LogErrorMessage("[DownloadAndModifySiteTemplate: CheckCustomEventReceiver]. Exception Message: " + ex.Message
                            + ", Exception Comments: Exception while loading the XML File. XML File Path: " + xmlFilePath + ". SiteTemplateName: " + siteTemplateName, true);
                        ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, Constants.NotApplicable, "SiteTemplate", ex.Message, ex.ToString(), "CheckCustomEventReceiver",
                            ex.GetType().ToString(), "Exception while loading the XML File. XML File Path: " + xmlFilePath + ". SiteTemplateName: " + siteTemplateName);
                    }

                    //reader.Namespaces = false;
                    //reader.Read();
                    //XmlDocument doc = new XmlDocument();
                    //doc.Load(reader);

                    //Initiallizing all the nodes required to check
                    XmlNodeList receiverNodes = doc.SelectNodes(erNodePath);

                    //Chcecking for Custom Event Receivers
                    if (receiverNodes != null && receiverNodes.Count > 0)
                    {
                        for (int i = 0; i < receiverNodes.Count; i++)
                        {
                            XmlNodeList receiverChilds = receiverNodes[i].ChildNodes;
                            for (int j = 0; j < receiverChilds.Count; j++)
                            {
                                try
                                {
                                    if (receiverChilds[j].HasChildNodes)
                                    {
                                        string assemblyValue = receiverChilds[j]["Assembly"].InnerText;
                                        if (lstCustomErs.Where(c => assemblyValue.Equals(c, StringComparison.CurrentCultureIgnoreCase)).Any())
                                        {
                                            isCustomEventReceiver = true;
                                            Logger.LogInfoMessage("[DownloadAndModifySiteTemplate: CheckCustomEventReceiver] Customized Web/Site/List Event Receiver Found for: " + siteTemplateName, true);
                                            break;
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Logger.LogErrorMessage("[DownloadAndModifySiteTemplate: CheckCustomEventReceiver]. Exception Message: " + ex.Message + ", Exception Comments: Exception while reading Web/Site Receivers tag", true);
                                    ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, Constants.NotApplicable, "SiteTemplate", ex.Message, ex.ToString(),
                                        "CheckCustomEventReceiver", ex.GetType().ToString(), "Exception while reading Web/Site Receivers tag");
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogErrorMessage("[DownloadAndModifySiteTemplate: CheckCustomEventReceiver]. Exception Message: " + ex.Message + ", Exception Comments: Exception while reading Features tag", true);
                    ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, Constants.NotApplicable, "SiteTemplate", ex.Message, ex.ToString(),
                                        "CheckCustomEventReceiver", ex.GetType().ToString(), "Exception while reading Web/Site Receivers tag");
                }
                finally
                {
                    reader.Dispose();
                }
            }
        }
开发者ID:OfficeDev,项目名称:PnP-Transformation,代码行数:84,代码来源:DownloadAndModifySiteTemplate.cs

示例15: CheckCustomFeature

        public static void CheckCustomFeature(string xmlFilePath, string featureNodePath, ref bool isCustomFeature, string siteTemplateName)
        {
            string featureID = string.Empty;
            string xml;

            if (System.IO.File.Exists(xmlFilePath))
            {
                var reader = new XmlTextReader(xmlFilePath);
                try
                {
                    using (TextReader txtreader = new StreamReader(xmlFilePath))
                    {
                        xml = txtreader.ReadToEnd();
                    }

                    xml = CommonUtility.SanitizeXmlString(xml);
                    reader.Namespaces = false;
                    reader.Read();

                    XmlDocument doc = new XmlDocument();

                    try
                    {
                        doc = CommonUtility.GetXmlDocumentFromString(xml);
                    }
                    catch (Exception ex)
                    {
                        Logger.LogErrorMessage("[DownloadAndModifySiteTemplate: CheckCustomFeature]. Exception Message: " + ex.Message
                            + ", Exception Comments: Exception while loading the XML File. XML File Path: " + xmlFilePath + ". SiteTemplateName: " + siteTemplateName, true);
                        ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, Constants.NotApplicable, "SiteTemplate", ex.Message, ex.ToString(), "CheckCustomFeature",
                            ex.GetType().ToString(), "Exception while loading the XML File. XML File Path: " + xmlFilePath + ". SiteTemplateName: " + siteTemplateName);
                    }
                    //reader.Namespaces = false;
                    //reader.Read();
                    //XmlDocument doc = new XmlDocument();
                    ////doc.Load(reader);

                    //Initiallizing all the nodes required to check
                    XmlNodeList siteFeatureNodes = doc.SelectNodes(featureNodePath);

                    for (int j = 0; j < siteFeatureNodes.Count; j++)
                    {
                        try
                        {
                            try
                            {
                                featureID = siteFeatureNodes[j].Attributes["ID"].Value;
                            }
                            catch { }

                            if (string.IsNullOrEmpty(featureID))
                            {
                                featureID = siteFeatureNodes[j].Attributes["Id"].Value;
                            }

                            if (featureID.StartsWith("{"))
                            {
                                featureID = featureID.TrimStart('{');
                                featureID = featureID.TrimEnd('}');
                            }
                            if (lstCustomFeatureIDs.Where(c => c.Contains(featureID.ToLower())).Any())
                            {
                                isCustomFeature = true;
                                Logger.LogInfoMessage("[DownloadAndModifySiteTemplate: CheckCustomFeature] Customized Feature Found for: " + siteTemplateName, true);
                                break;
                            }
                        }
                        catch (Exception ex)
                        {
                            Logger.LogErrorMessage("[DownloadAndModifySiteTemplate: CheckCustomFeature]. Exception Message: " + ex.Message + ", Exception Comments: Exception while reading Features tag", true);
                            ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, Constants.NotApplicable, "SiteTemplate", ex.Message, ex.ToString(),
                                "CheckCustomFeature", ex.GetType().ToString(), "Exception while reading Features tag");
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogErrorMessage("[DownloadAndModifySiteTemplate: CheckCustomFeature]. Exception Message: " + ex.Message + ", Exception Comments: Exception while reading Features tag", true);
                    ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, Constants.NotApplicable, "SiteTemplate", ex.Message, ex.ToString(),
                        "CheckCustomFeature", ex.GetType().ToString(), "Exception while reading Features tag");
                }
                finally
                {
                    reader.Dispose();
                }
            }
        }
开发者ID:OfficeDev,项目名称:PnP-Transformation,代码行数:87,代码来源:DownloadAndModifySiteTemplate.cs


注:本文中的System.Xml.XmlTextReader.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。