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


C# DataManager.ResolvePath方法代码示例

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


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

示例1: Save

		internal void Save(DataManager data)
		{
			string fullPath = data.ResolvePath(FileName);

			// We use the internal list to circumvent ignoring 
			// items where IsPublic is set to false.
			if ( Entries.Count == 0 )
			{
				if ( File.Exists( fullPath ) )
				{
					File.Delete( fullPath );
				}
			}
			else
			{
				System.Security.Principal.WindowsImpersonationContext wi = Impersonation.Impersonate();

				FileStream fileStream = FileUtils.OpenForWrite(fullPath);

				if ( fileStream != null )
				{
					try
					{
						XmlSerializer ser = new XmlSerializer(typeof(DayEntry),Data.NamespaceURI);
						using (StreamWriter writer = new StreamWriter(fileStream))
						{
							ser.Serialize(writer, this);
						}
					}
					catch(Exception e)
					{
						ErrorTrace.Trace(System.Diagnostics.TraceLevel.Error,e);
					}
					finally
					{
						fileStream.Close();
					}
				}

				wi.Undo();
			}
		}
开发者ID:plntxt,项目名称:dasblog,代码行数:42,代码来源:DayEntry.cs

示例2: Save

        internal void Save(DataManager data)
        {
            FileStream fileStream = FileUtils.OpenForWrite(data.ResolvePath(FileName));
            if (fileStream != null)
            {
                WindowsImpersonationContext wi = Impersonation.Impersonate();

                try
                {
                    XmlSerializer ser = new XmlSerializer(typeof (DayExtra), Data.NamespaceURI);
                    using (StreamWriter writer = new StreamWriter(fileStream))
                    {
                        ser.Serialize(writer, this);
                    }
                }
                catch (Exception e)
                {
                    ErrorTrace.Trace(TraceLevel.Error, e);
                    // truncate the file if this fails
                    fileStream.SetLength(0);
                }
                finally
                {
                    fileStream.Close();
                }

                wi.Undo();
            }
        }
开发者ID:AArnott,项目名称:dasblog,代码行数:29,代码来源:DayExtra.cs

示例3: Load

		internal void Load(DataManager data)
		{
			if ( Loaded ) 
			{
				return;
			}

			lock(entriesLock)
			{
				if ( Loaded ) //SDH: standard thread-safe double check
				{
					return;
				}
				
				string fullPath = data.ResolvePath(FileName);
				FileStream fileStream = FileUtils.OpenForRead(fullPath);
				if ( fileStream != null )
				{
					try
					{
						XmlSerializer ser = new XmlSerializer(typeof(DayEntry),Data.NamespaceURI);
						using (StreamReader reader = new StreamReader(fileStream))
						{
							//XmlNamespaceUpgradeReader upg = new XmlNamespaceUpgradeReader( reader, "", Data.NamespaceURI );
                            DayEntry e = (DayEntry)ser.Deserialize(reader);
							Entries = e.Entries;
						}
					}
					catch(Exception e)
					{
						ErrorTrace.Trace(System.Diagnostics.TraceLevel.Error,e);
					}
					finally
					{
						fileStream.Close();
					}
				}

				Entries.Sort((left,right) => right.CreatedUtc.CompareTo(left.CreatedUtc));
			
				Loaded = true;
			}
		}
开发者ID:plntxt,项目名称:dasblog,代码行数:43,代码来源:DayEntry.cs

示例4: Load

        internal void Load(DataManager data)
        {
            if (_loaded)
            {
                return;
            }

            if (data.Resolver != null)
            {
                string fullPath = data.ResolvePath(FileName);
                string oldPath = data.ResolvePath(DateLocalTime.ToString("yyyy-MM-dd") + ".dayextra.xml");

                if (UpgradeFilesToUtc && File.Exists(oldPath))
                {
                    LoadDayExtra(oldPath);

                    // backup the old file
                    try
                    {
                        DirectoryInfo backup = new DirectoryInfo(Path.Combine(data.ResolvePath(""), "backup"));

                        if (!backup.Exists)
                        {
                            backup.Create();
                        }

                        FileInfo f = new FileInfo(oldPath);
                        f.MoveTo(Path.Combine(backup.FullName, f.Name));
                    }
                    catch (Exception e)
                    {
                        ErrorTrace.Trace(TraceLevel.Error, e);
                    }

                    // now write the new file
                    this.Save(data);
                }
                else if (File.Exists(fullPath))
                {
                    LoadDayExtra(fullPath);
                }

            }

            _loaded = true;
        }
开发者ID:AArnott,项目名称:dasblog,代码行数:46,代码来源:DayExtra.cs


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