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


C# IClassMap.GetDocRoot方法代码示例

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


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

示例1: LoadObjectNodeFromDomainFile

        protected virtual XmlNode LoadObjectNodeFromDomainFile(object obj, IClassMap classMap)
        {
            string fileName = GetFileNamePerDomain(classMap);
            LogMessage message = new LogMessage("Saving object to file", "File: {0}, Object Type: {1}" , fileName , obj.GetType());
            this.Context.LogManager.Debug(this, message); // do not localize

            XmlDocument xmlDoc;
            if (File.Exists(fileName))
                xmlDoc = GetXmlDocument(fileName);
            else
                if (HasXmlDocument(fileName))
                    xmlDoc = GetXmlDocument(fileName);
                else
                    xmlDoc = CreateDomainXmlDocument(classMap, fileName);

            XmlNode xmlRoot = xmlDoc.SelectSingleNode(classMap.GetDocSourceMap().GetDocRoot() );
            XmlNode xmlClass = GetNode(xmlRoot, classMap.GetDocRoot() );
            XmlNode xmlObject = GetNodeForObject(xmlClass, obj, classMap );

            return xmlObject;
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:21,代码来源:DocumentPersistenceEngine.cs

示例2: LoadObjectNodeFromClassFile

        protected virtual XmlNode LoadObjectNodeFromClassFile(object obj, IClassMap classMap)
        {
            string fileName = GetFileNamePerClass(classMap);
            LogMessage message = new LogMessage("Removing object from file");
            LogMessage verbose = new LogMessage("File: {0}, Object Type: {1}",fileName , obj.GetType());
            this.Context.LogManager.Debug(this, message,verbose); // do not localize
            //
            //			if (!(File.Exists(fileName)))
            //				throw new NPersistException("The file '" + fileName + "' could not be found!"); // do not localize

            XmlDocument xmlDoc;
            if (File.Exists(fileName))
                xmlDoc = GetXmlDocument(fileName);
            else
                if (HasXmlDocument(fileName))
                xmlDoc = GetXmlDocument(fileName);
            else
                xmlDoc = CreateClassXmlDocument(classMap, fileName);

            XmlNode xmlRoot = xmlDoc.SelectSingleNode(classMap.GetDocRoot() );
            XmlNode xmlObject = GetNodeForObject(xmlRoot, obj, classMap );

            return xmlObject;
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:24,代码来源:DocumentPersistenceEngine.cs

示例3: DeserializeDomain

 protected virtual void DeserializeDomain(ref object obj, IClassMap classMap, string xml)
 {
     XmlDocument xmlDoc = new XmlDocument();
     xmlDoc.LoadXml(xml);
     XmlNode xmlRoot = xmlDoc.SelectSingleNode(classMap.GetDocSourceMap().GetDocRoot());
     XmlNode xmlClass = xmlRoot.SelectSingleNode(classMap.GetDocRoot());
     XmlNode xmlObject = FindNodeForObject(xmlClass, obj, classMap);
     if (xmlObject == null)
         obj = null;
     else
         DeserializeObject(obj, classMap, xmlObject);
 }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:12,代码来源:DocumentPersistenceEngine.cs

示例4: CreateClassXmlDocument

        protected virtual XmlDocument CreateClassXmlDocument(IClassMap classMap, string fileName)
        {
            ISourceMap sourceMap = classMap.GetDocSourceMap();

            MemoryStream ms = new MemoryStream() ;
            XmlTextWriter xmlWriter = new XmlTextWriter(
                ms,
                Encoding.GetEncoding( sourceMap.GetDocEncoding() ));

            xmlWriter.Formatting = Formatting.Indented;

            xmlWriter.WriteStartDocument(false);

            xmlWriter.WriteDocType("ObjectList",null,null,null);
            xmlWriter.WriteComment("Serialized object list"); // do not localize

            xmlWriter.WriteStartElement(classMap.GetDocRoot() , null);

            xmlWriter.WriteEndElement();
            xmlWriter.WriteEndDocument();

            //Write the XML to file and close the writer
            xmlWriter.Flush();
            string xml = Encoding.GetEncoding( "utf-8" ).GetString(ms.ToArray(),0,(int)ms.Length);
            xmlWriter.Close();

            //Obs fulhack!! Jag får ett konstigt skräptecken i början!!
            xml = xml.Substring(1);

            XmlDocument xmlDocument = new XmlDocument() ;
            xmlDocument.LoadXml(xml);

            CachedXmlDocument cachedXmlDocument = new CachedXmlDocument(xmlDocument, fileName) ;
            cachedXmlDocuments[fileName] = cachedXmlDocument;

            return xmlDocument;
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:37,代码来源:DocumentPersistenceEngine.cs


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