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


C# FlexWiki.LocalTopicName类代码示例

本文整理汇总了C#中FlexWiki.LocalTopicName的典型用法代码示例。如果您正苦于以下问题:C# LocalTopicName类的具体用法?C# LocalTopicName怎么用?C# LocalTopicName使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: MakeTopicName

		static string MakeTopicName(LocalTopicName name)
		{
			if (name.Version == null || name.Version.Length == 0)
				return name.Name;
			else
				return name.Name + "(" + name.Version + ")";
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:7,代码来源:SqlStore.cs

示例2: IsExistingTopicWritable

		/// <summary>
		/// Answer whether a topic exists and is writable
		/// </summary>
		/// <param name="topic">The topic (must directly be in this content base)</param>
		/// <returns>true if the topic exists AND is writable by the current user; else false</returns>
		public abstract bool IsExistingTopicWritable(LocalTopicName topic);
开发者ID:nuxleus,项目名称:flexwiki,代码行数:6,代码来源:ContentBase.cs

示例3: WriteTopic

		/// <summary>
		/// Write a new version of the topic (doesn't write a new version).  Generate all needed federation update changes via the supplied generator.
		/// </summary>
		/// <param name="topic">Topic to write</param>
		/// <param name="content">New content</param>
		/// <param name="sink">Object to recieve change info about the topic</param>
		override protected void WriteTopic(LocalTopicName topic, string content, FederationUpdateGenerator gen)
		{
			string root = Root;
			string fullpath = MakePath(root, topic);
			bool isNew = !(File.Exists(fullpath));

			// Get old topic so we can analyze it for properties to compare with the new one
			string oldText = null;
			Hashtable oldProperties = null;
			if (!isNew)
			{
				using (StreamReader sr = new StreamReader(new FileStream(fullpath, FileMode.Open, FileAccess.Read, FileShare.Read)))
				{
					oldText = sr.ReadToEnd();
				}
				oldProperties = ExtractExplicitFieldsFromTopicBody(oldText);	
			}

			// Change it
			using (StreamWriter sw = new StreamWriter(fullpath))
			{
				sw.Write(content);
			}

			// Quick check to see if we're about to let somebody write the DefinitionTopic for this ContentBase.  
			// If so, we reset our Info object to reread
			string pathToDefinitionTopic = MakePath(Root, DefinitionTopicName.LocalName);
			if (fullpath == pathToDefinitionTopic)
				this.Federation.InvalidateNamespace(Namespace);

			// Record changes
			try
			{
				AbsoluteTopicName absTopic = topic.AsAbsoluteTopicName(Namespace);

				gen.Push();

				// Record the topic-level change
				if (isNew)
					gen.RecordCreatedTopic(absTopic);
				else
					gen.RecordUpdatedTopic(absTopic);

				//	Now process the properties
				Hashtable newProperties = ExtractExplicitFieldsFromTopicBody(content);
				if (isNew)
				{
					foreach (string pName in newProperties.Keys)
						gen.RecordPropertyChange(absTopic, pName, FederationUpdate.PropertyChangeType.PropertyAdd);
					gen.RecordPropertyChange(absTopic, "_Body", FederationUpdate.PropertyChangeType.PropertyAdd);
					gen.RecordPropertyChange(absTopic, "_TopicName", FederationUpdate.PropertyChangeType.PropertyAdd);
					gen.RecordPropertyChange(absTopic, "_TopicFullName", FederationUpdate.PropertyChangeType.PropertyAdd);
					gen.RecordPropertyChange(absTopic, "_LastModifiedBy", FederationUpdate.PropertyChangeType.PropertyAdd);
					gen.RecordPropertyChange(absTopic, "_CreationTime", FederationUpdate.PropertyChangeType.PropertyAdd);
					gen.RecordPropertyChange(absTopic, "_ModificationTime", FederationUpdate.PropertyChangeType.PropertyAdd);
				}
				else
				{
					if (content != oldText)
					{
						FillFederationUpdateByComparingPropertyHashes(gen, absTopic, oldProperties, newProperties);
						gen.RecordPropertyChange(absTopic, "_Body", FederationUpdate.PropertyChangeType.PropertyUpdate);
					}
					gen.RecordPropertyChange(absTopic, "_ModificationTime", FederationUpdate.PropertyChangeType.PropertyUpdate);				
				}
			}
			finally
			{
				gen.Pop();
			}
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:77,代码来源:FileSystemStore.cs

示例4: FileInfosForTopic

		/// <summary>
		/// All of the FileInfos for the historical versions of a given topic
		/// </summary>
		/// <param name="topic"></param>
		/// <returns>FileInfos</returns>
		FileInfo[] FileInfosForTopic(LocalTopicName topic)
		{
			FileInfo [] answer = {};

			// If the topic does not exist, we ignore any historical versions (the result of a delete)
			if (!TipFileExists(topic.Name))
				return answer;

			try
			{
				answer = new DirectoryInfo(Root).GetFiles(topic.Name + "(*).awiki");
			}
			catch (DirectoryNotFoundException e)
			{
				System.Diagnostics.Debug.WriteLine(e.ToString()); 
			}
			return answer;
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:23,代码来源:FileSystemStore.cs

示例5: AllVersionsForTopic

		/// <summary>
		/// Answer all of the versions for a given topic
		/// </summary>
		/// <remarks>
		/// TODO: Change this to return TopicChanges instead of the TopicNames
		/// </remarks>
		/// <param name="topic">A topic</param>
		/// <returns>Enumeration of the topic names (with non-null versions in them) </returns>
		override public IEnumerable AllVersionsForTopic(LocalTopicName topic)
		{
			ArrayList answer = new ArrayList();
			FileInfo[] infos = FileInfosForTopic(topic);
			ArrayList sortable = new ArrayList();
			foreach (FileInfo each in infos)
				sortable.Add(new FileInfoTopicData(each, Namespace));
			BackingTopic back = GetBackingTopicNamed(topic);
			if (back != null)
				sortable.Add(new BackingTopicTopicData(back));
			sortable.Sort(new TimeSort());
			foreach (TopicData each in sortable)
			{
				AbsoluteTopicName name = topic.AsAbsoluteTopicName(Namespace);
				name.Version = each.Version;
				answer.Add(name);
			}
			return answer;
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:27,代码来源:FileSystemStore.cs

示例6: TextReaderForTopic

		/// <summary>
		/// Answer a TextReader for the given topic
		/// </summary>
		/// <param name="topic"></param>
		/// <exception cref="TopicNotFoundException">Thrown when the topic doesn't exist</exception>
		/// <returns>TextReader</returns>
		override public TextReader TextReaderForTopic(LocalTopicName topic)
		{
			string topicFile = TopicPath(topic);
			if (topicFile == null || !File.Exists(topicFile))
			{
				BackingTopic back = GetBackingTopicNamed(topic);
				if (back != null)
					return new StringReader(back.Body);
				throw TopicNotFoundException.ForTopic(topic, Namespace);
			}
			return new StreamReader(new FileStream(topicFile, FileMode.Open, FileAccess.Read, FileShare.Read));
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:18,代码来源:FileSystemStore.cs

示例7: GetTopicCreationTime

		/// <summary>
		/// Answer when a topic was created
		/// </summary>
		/// <param name="topic">The topic</param>
		/// <returns></returns>
		override public DateTime GetTopicCreationTime(LocalTopicName topic)
		{
			string path = TopicPath(topic);
			if (File.Exists(path))
				return File.GetCreationTime(path);
			BackingTopic back = GetBackingTopicNamed(topic);
			if (back != null)
				return back.CreationTime;
			throw TopicNotFoundException.ForTopic(topic, Namespace);			
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:15,代码来源:FileSystemStore.cs

示例8: TopicExistsLocally

		/// <summary>
		/// Answer true if a topic exists in this ContentBase
		/// </summary>
		/// <param name="name">Name of the topic</param>
		/// <returns>true if it exists</returns>
		override public bool TopicExistsLocally(LocalTopicName name)
		{
			if (BackingTopics.ContainsKey(name.Name))
				return true;
			return File.Exists(MakePath(Root, name));
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:11,代码来源:FileSystemStore.cs

示例9: DeleteTopic

		/// <summary>
		/// Delete a topic
		/// </summary>
		/// <param name="topic"></param>
		public abstract void DeleteTopic(LocalTopicName topic);
开发者ID:nuxleus,项目名称:flexwiki,代码行数:5,代码来源:ContentBase.cs

示例10: TextReaderForTopic

		/// <summary>
		/// Answer a TextReader for the given topic
		/// </summary>
		/// <param name="topic"></param>
		/// <exception cref="TopicNotFoundException">Thrown when the topic doesn't exist</exception>
		/// <returns>TextReader</returns>
		public abstract TextReader TextReaderForTopic(LocalTopicName topic);
开发者ID:nuxleus,项目名称:flexwiki,代码行数:7,代码来源:ContentBase.cs

示例11: SetFieldValue

		/// <summary>
		/// Change the value of a property (aka field) in a a topic.  If the topic doesn't exist, it will be created.
		/// </summary>
		/// <param name="topic">The topic whose property is to be changed</param>
		/// <param name="field">The name of the property to change</param>
		/// <param name="rep">The new value for the field</param>
		public void SetFieldValue(LocalTopicName topic, string field, string rep, bool writeNewVersion)
		{
			if (!TopicExistsLocally(topic))
			{
				WriteTopic(topic, "");
			}

			string original = Read(topic);

			// Multiline values need to end a complete line
			string repWithLineEnd = rep;
			if (!repWithLineEnd.EndsWith("\n"))
				repWithLineEnd = repWithLineEnd + "\n";
			bool newValueIsMultiline = rep.IndexOf("\n") > 0;

			string simpleField = "(?<name>(" + field + ")):(?<val>[^\\[].*)";
			string multiLineField = "(?<name>(" + field + ")):\\[(?<val>[^\\[]*\\])";

			string update = original;
			if (new Regex(simpleField).IsMatch(original))
			{
				if (newValueIsMultiline)
					update = Regex.Replace (original, simpleField, "${name}:[ " + repWithLineEnd + "]");
				else
					update = Regex.Replace (original, simpleField, "${name}: " + rep);
			}
			else if (new Regex(multiLineField).IsMatch(original))
			{
				if (newValueIsMultiline)
					update = Regex.Replace (original, multiLineField, "${name}:[ " + repWithLineEnd + "]");
				else
					update = Regex.Replace (original, multiLineField, "${name}: " + rep);
			}
			else
			{
				if (!update.EndsWith("\n"))
					update = update + "\n";
				if (rep.IndexOf("\n") == -1)
					update += field + ": " + repWithLineEnd;
				else
					update += field + ":[ " + repWithLineEnd + "]\n";
			}
			if (writeNewVersion)
				WriteTopicAndNewVersion(topic, update);
			else
				WriteTopic(topic, update);
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:53,代码来源:ContentBase.cs

示例12: GetFieldsForTopic

		/// <summary>
		/// Reach and answer all the properties (aka fields) for the given topic.  This includes both the 
		/// properties defined in the topic plus the extra properties that every topic has (e.g., _TopicName, _TopicFullName, _LastModifiedBy, etc.)
		/// </summary>
		/// <param name="topic"></param>
		/// <returns>Hashtable (keys = string property names, values = values [as strings]);  or null if the topic doesn't exist</returns>
		public Hashtable GetFieldsForTopic(LocalTopicName topic)
		{
			if (!TopicExistsLocally(topic))
				return null;

			string allLines = Read(topic);
			Hashtable answer = ExtractExplicitFieldsFromTopicBody(allLines);	
			Federation.AddImplicitPropertiesToHash(answer, topic.AsAbsoluteTopicName(Namespace), GetTopicLastAuthor(topic), GetTopicCreationTime(topic), GetTopicLastWriteTime(topic), allLines);
			return answer;
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:16,代码来源:ContentBase.cs

示例13: Read

		/// <summary>
		/// Answer the contents of a given topic
		/// </summary>
		/// <param name="topic">The topic</param>
		/// <returns>The contents of the topic or null if it can't be read (e.g., doesn't exist)</returns>
		public string Read(LocalTopicName topic)
		{
			using (TextReader st = TextReaderForTopic(topic))
			{
				if (st == null)
					return null;
				return st.ReadToEnd();
			}
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:14,代码来源:ContentBase.cs

示例14: GetTopicLastAuthor

		/// <summary>
		/// Answer the identify of the author who last modified a given topic
		/// </summary>
		/// <param name="topic"></param>
		/// <returns>a user name</returns>
		public abstract string GetTopicLastAuthor(LocalTopicName topic);
开发者ID:nuxleus,项目名称:flexwiki,代码行数:6,代码来源:ContentBase.cs

示例15: GetTopicCreationTime

		/// <summary>
		/// Answer when a topic was created
		/// </summary>
		/// <param name="topic">The topic</param>
		/// <returns></returns>
		public abstract DateTime GetTopicCreationTime(LocalTopicName topic);
开发者ID:nuxleus,项目名称:flexwiki,代码行数:6,代码来源:ContentBase.cs


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