/*
Kooboo is a content management system based on ASP.NET MVC framework. Copyright 2009 Yardi Technology Limited.
This program is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License version 3 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program.
If not, see http://www.kooboo.com/gpl3/.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Everest.Library.ExtensionMethod;
namespace Everest.CmsServices.Models{
public class UniqueName
{
const string Style = "{0}.{1}";
public UniqueName()
{
}
public UniqueName(string uniqueName)
{
Parse(uniqueName);
}
private void Parse(string uniqueName)
{
int dotIndex = uniqueName.IndexOf('.');
if (dotIndex == -1)
{
ApplicationName = string.Empty;
ItemName = uniqueName;
}
else
{
ApplicationName = uniqueName.Substring(0, dotIndex);
ItemName = uniqueName.Substring(dotIndex + 1);
}
}
public UniqueName(string appName, string itemName)
{
ApplicationName = appName;
ItemName = itemName;
}
/// <summary>
/// Gets or sets the name of the application.
/// The application cannot contains '.'
/// </summary>
/// <value>The name of the application.</value>
public string ApplicationName { get; set; }
/// <summary>
/// Gets or sets the name of the item.
/// </summary>
/// <value>The name of the item.</value>
public string ItemName { get; set; }
public override string ToString()
{
if (StringExtensions.IsNullOrEmptyTrim(ApplicationName) && StringExtensions.IsNullOrEmptyTrim(ItemName))
{
return "";
}
return string.Format(Style, ApplicationName, ItemName);
}
}
}
|