|
/*
*
* iFinity Smart Business Solutions - http://www.ifinity.com.au
* Copyright (c) 2006
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), the rights to use, copy, modify, merge, publish, distribute, sublicense
* copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
* following conditions:
* 1. The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
* 2. The software may not be claimed as the original work and may not be sold as a stand alone product
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
namespace iFinity.DNN.Modules.GoogleSiteMap
{
public class SitePage
{
string _loc;
DateTime _lastMod;
ChangeFrequencies _changeFreq;
double _priority;
public SitePage()
{
}
public SitePage(string loc, DateTime lastMod, ChangeFrequencies changeFreq, double priority)
{
_loc = loc;
_lastMod = lastMod;
_changeFreq = changeFreq;
_priority = priority;
}
public string Loc
{
get { return _loc; }
set { _loc = value; }
}
public DateTime LastMod
{
get
{
return _lastMod;
}
set
{
_lastMod = value;
}
}
public void SetLastMod(string value)
{
_lastMod = DateTime.Parse(value);
}
public ChangeFrequencies ChangeFreq
{
get
{
return _changeFreq;
}
set
{
_changeFreq = value;
}
}
public double Priority
{
get { return _priority; }
set { _priority = value; }
}
/// <summary>
/// This date should be in ISO 8601 format.
/// This format allows you to omit the time portion, use YYYY-MM-DD.
/// </summary>
/// <param name="dateValue">string date value</param>
/// <returns>ISO 8601 date format</returns>
internal static string FormatISODate(string dateValue)
{
return FormatISODate(DateTime.Parse(dateValue));
}
/// <summary>
/// This date should be in ISO 8601 format.
/// This format allows you to omit the time portion, use YYYY-MM-DD.
/// </summary>
/// <param name="dateValue">datetime date value</param>
/// <returns>ISO 8601 date format</returns>
internal static string FormatISODate(DateTime date)
{
StringBuilder sb = new StringBuilder();
sb.Append(date.Year);
sb.Append("-");
if (date.Month < 10)
{
sb.Append("0");
}
sb.Append(date.Month);
sb.Append("-");
if (date.Day < 10)
{
sb.Append("0");
}
sb.Append(date.Day);
return sb.ToString();
}
internal static string ConvertChangeFrequencyToString(ChangeFrequencies changeFreq)
{
string retVal="";
switch (changeFreq)
{
case ChangeFrequencies.always:
retVal = "always";
break;
case ChangeFrequencies.daily:
retVal = "daily";
break;
case ChangeFrequencies.hourly:
retVal = "hourly";
break;
case ChangeFrequencies.monthly:
retVal = "monthly";
break;
case ChangeFrequencies.never:
retVal = "never";
break;
case ChangeFrequencies.weekly:
retVal = "weekly";
break;
case ChangeFrequencies.yearly:
retVal = "yearly";
break;
}
return retVal;
}
internal static ChangeFrequencies ConvertChangeFrequencyToEnum(string changeFreq)
{
ChangeFrequencies retVal = ChangeFrequencies.daily;
switch (changeFreq)
{
case "always":
retVal = ChangeFrequencies.always;
break;
case "daily":
retVal = ChangeFrequencies.daily;
break;
case "hourly":
retVal = ChangeFrequencies.hourly;
break;
case "monthly":
retVal = ChangeFrequencies.monthly;
break;
case "never":
retVal = ChangeFrequencies.never;
break;
case "weekly":
retVal = ChangeFrequencies.weekly;
break;
case "yearly":
retVal = ChangeFrequencies.yearly;
break;
}
return retVal;
}
}
public enum ChangeFrequencies
{
always,
hourly,
daily,
weekly,
monthly,
yearly,
never
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.