DO NOT DOWNLOAD. DOWNLOAD LATEST STABLE FROM RELEASE TAB
Accepting patches Tweaking linq to umbraco for some funky stuff [TFS Changeset #61318]
This commit is contained in:
@@ -22,9 +22,9 @@ namespace umbraco.Linq.Core
|
||||
private string _versionId;
|
||||
private int _templateId;
|
||||
private int _parentId;
|
||||
private int _writerID;
|
||||
private int writerID;
|
||||
private User _writer;
|
||||
private int _creatorID;
|
||||
private int creatorID;
|
||||
private User _creator;
|
||||
private IEnumerable<DocTypeBase> _ancestors;
|
||||
private AssociationTree<DocTypeBase> _children;
|
||||
@@ -38,46 +38,11 @@ namespace umbraco.Linq.Core
|
||||
this.IsDirty = true;
|
||||
}
|
||||
|
||||
internal void LoadFromXml(XElement xml)
|
||||
{
|
||||
if (xml.Name != "node")
|
||||
{
|
||||
throw new ArgumentException("Xml provided is not valid");
|
||||
}
|
||||
|
||||
if (!ReflectionAssistance.CompareByAlias(this.GetType(), xml))
|
||||
{
|
||||
throw new DocTypeMissMatchException((string)xml.Attribute("nodeTypeAlias"), ReflectionAssistance.GetumbracoInfoAttribute(this.GetType()).Alias);
|
||||
}
|
||||
|
||||
this.Id = (int)xml.Attribute("id");
|
||||
this.ParentNodeId = (int)xml.Attribute("parentID");
|
||||
this.Name = (string)xml.Attribute("nodeName");
|
||||
this.Version = (string)xml.Attribute("version");
|
||||
this.CreateDate = (DateTime)xml.Attribute("createDate");
|
||||
this.SortOrder = (int)xml.Attribute("sortOrder");
|
||||
this.UpdateDate = (DateTime)xml.Attribute("updateDate");
|
||||
this._creatorID = (int)xml.Attribute("creatorID");
|
||||
this._writerID = (int)xml.Attribute("writerID");
|
||||
this.Level = (int)xml.Attribute("level");
|
||||
this.TemplateId = (int)xml.Attribute("template");
|
||||
|
||||
var properties = this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(p => p.GetCustomAttributes(typeof(PropertyAttribute), true).Count() > 0);
|
||||
foreach (var p in properties)
|
||||
{
|
||||
var attr = ReflectionAssistance.GetumbracoInfoAttribute(p);
|
||||
|
||||
var data = xml.Elements("data").Single(x => (string)x.Attribute("alias") == attr.Alias).Value;
|
||||
if (p.PropertyType == typeof(int) && string.IsNullOrEmpty(data))
|
||||
{
|
||||
data = "-1";
|
||||
}
|
||||
// TODO: Address how Convert.ChangeType works in globalisation
|
||||
p.SetValue(this, Convert.ChangeType(data, p.PropertyType), null);
|
||||
}
|
||||
}
|
||||
|
||||
internal UmbracoDataProvider Provider { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the provider.
|
||||
/// </summary>
|
||||
/// <value>The provider.</value>
|
||||
protected internal UmbracoDataProvider Provider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this instance has been modified since it was first loaded
|
||||
@@ -98,7 +63,7 @@ namespace umbraco.Linq.Core
|
||||
{
|
||||
return this._Id;
|
||||
}
|
||||
protected set
|
||||
protected internal set
|
||||
{
|
||||
if (this._Id != value)
|
||||
{
|
||||
@@ -169,7 +134,7 @@ namespace umbraco.Linq.Core
|
||||
{
|
||||
return this._versionId;
|
||||
}
|
||||
protected set
|
||||
protected internal set
|
||||
{
|
||||
if (this._versionId != value)
|
||||
{
|
||||
@@ -232,7 +197,7 @@ namespace umbraco.Linq.Core
|
||||
/// </summary>
|
||||
/// <value>The level.</value>
|
||||
[Field]
|
||||
[UmbracoInfo("level", DisplayName="Level"), DataMember(Name="Level")]
|
||||
[UmbracoInfo("level", DisplayName = "Level"), DataMember(Name = "Level")]
|
||||
public virtual int Level { get; set; }
|
||||
#endregion
|
||||
|
||||
@@ -315,9 +280,24 @@ namespace umbraco.Linq.Core
|
||||
}
|
||||
|
||||
return this._ancestors.Where(a => a is TDocType).Cast<TDocType>().FirstOrDefault(func);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the creator ID.
|
||||
/// </summary>
|
||||
/// <value>The creator ID.</value>
|
||||
public int CreatorID
|
||||
{
|
||||
get
|
||||
{
|
||||
return creatorID;
|
||||
}
|
||||
internal set
|
||||
{
|
||||
this.creatorID = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the umbraco user who created the item
|
||||
/// </summary>
|
||||
@@ -328,13 +308,27 @@ namespace umbraco.Linq.Core
|
||||
{
|
||||
if (this._creator == null)
|
||||
{
|
||||
this._creator = new User(this._creatorID);
|
||||
this._creator = new User(this.CreatorID);
|
||||
}
|
||||
|
||||
return this._creator;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ID of the user who last edited the item
|
||||
/// </summary>
|
||||
public int WriterID
|
||||
{
|
||||
get
|
||||
{
|
||||
return writerID;
|
||||
}
|
||||
internal set
|
||||
{
|
||||
this.writerID = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the umbraco user who last edited the instance
|
||||
/// </summary>
|
||||
@@ -345,7 +339,7 @@ namespace umbraco.Linq.Core
|
||||
{
|
||||
if (this._writer == null)
|
||||
{
|
||||
this._writer = new User(this._writerID);
|
||||
this._writer = new User(this.WriterID);
|
||||
}
|
||||
|
||||
return this._writer;
|
||||
|
||||
@@ -237,7 +237,7 @@ namespace umbraco.Linq.Core.Node
|
||||
}
|
||||
|
||||
var parent = new TDocType();
|
||||
parent.LoadFromXml(parentXml);
|
||||
this.LoadFromXml(parentXml, parent);
|
||||
|
||||
return parent;
|
||||
}
|
||||
@@ -306,7 +306,7 @@ namespace umbraco.Linq.Core.Node
|
||||
var alias = (string)ancestor.Attribute("nodeTypeAlias");
|
||||
var t = KnownTypes[alias];
|
||||
var instaceOfT = (DocTypeBase)Activator.CreateInstance(t); //create an instance of the type and down-cast so we can use it
|
||||
instaceOfT.LoadFromXml(ancestor);
|
||||
this.LoadFromXml(ancestor, instaceOfT);
|
||||
instaceOfT.Provider = this;
|
||||
ancestors.Add(instaceOfT);
|
||||
yield return instaceOfT;
|
||||
@@ -357,5 +357,50 @@ namespace umbraco.Linq.Core.Node
|
||||
this._xml = null;
|
||||
this._trees.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads from XML.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="xml">The XML.</param>
|
||||
/// <param name="node">The node.</param>
|
||||
public void LoadFromXml<T>(XElement xml, T node) where T : DocTypeBase
|
||||
{
|
||||
if (xml.Name != "node")
|
||||
{
|
||||
throw new ArgumentException("Xml provided is not valid");
|
||||
}
|
||||
|
||||
if (!ReflectionAssistance.CompareByAlias(node.GetType(), xml))
|
||||
{
|
||||
throw new DocTypeMissMatchException((string)xml.Attribute("nodeTypeAlias"), ReflectionAssistance.GetumbracoInfoAttribute(node.GetType()).Alias);
|
||||
}
|
||||
|
||||
node.Id = (int)xml.Attribute("id");
|
||||
node.ParentNodeId = (int)xml.Attribute("parentID");
|
||||
node.Name = (string)xml.Attribute("nodeName");
|
||||
node.Version = (string)xml.Attribute("version");
|
||||
node.CreateDate = (DateTime)xml.Attribute("createDate");
|
||||
node.SortOrder = (int)xml.Attribute("sortOrder");
|
||||
node.UpdateDate = (DateTime)xml.Attribute("updateDate");
|
||||
node.CreatorID = (int)xml.Attribute("creatorID");
|
||||
node.WriterID = (int)xml.Attribute("writerID");
|
||||
node.Level = (int)xml.Attribute("level");
|
||||
node.TemplateId = (int)xml.Attribute("template");
|
||||
|
||||
var properties = node.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(p => p.GetCustomAttributes(typeof(PropertyAttribute), true).Count() > 0);
|
||||
foreach (var p in properties)
|
||||
{
|
||||
var attr = ReflectionAssistance.GetumbracoInfoAttribute(p);
|
||||
|
||||
var data = xml.Elements("data").Single(x => (string)x.Attribute("alias") == attr.Alias).Value;
|
||||
if (p.PropertyType == typeof(int) && string.IsNullOrEmpty(data))
|
||||
{
|
||||
data = "-1";
|
||||
}
|
||||
// TODO: Address how Convert.ChangeType works in globalisation
|
||||
p.SetValue(node, Convert.ChangeType(data, p.PropertyType), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace umbraco.Linq.Core.Node
|
||||
foreach (XElement n in rawNodes)
|
||||
{
|
||||
var dt = new TDocTypeBase();
|
||||
dt.LoadFromXml(n);
|
||||
this._provider.LoadFromXml(n, dt);
|
||||
|
||||
dt.IsDirty = false;
|
||||
dt.Provider = this._provider;
|
||||
|
||||
@@ -8,7 +8,7 @@ using umbraco.Linq.Core.Node;
|
||||
namespace umbraco.Linq.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// The umbracoDataContext which handles the interaction with an <see cref="umbracoDataProvider"/>
|
||||
/// The umbracoDataContext which handles the interaction with an <see cref="umbraco.Linq.Core.UmbracoDataProvider"/>
|
||||
/// </summary>
|
||||
public abstract class UmbracoDataContext : IDisposable
|
||||
{
|
||||
@@ -41,6 +41,9 @@ namespace umbraco.Linq.Core
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Submits the changes within the UmbracoDataContext through the <see cref="umbraco.Linq.Core.UmbracoDataProvider"/>
|
||||
/// </summary>
|
||||
public void SubmitChanges()
|
||||
{
|
||||
this.CheckDisposed();
|
||||
@@ -51,14 +54,14 @@ namespace umbraco.Linq.Core
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="umbracoDataContext"/> class, using a <see cref="umbraco.Linq.Core.Node.NodeDataProvider"/> data provider with the connection string from the umbraco config
|
||||
/// Initializes a new instance of the <see cref="umbraco.Linq.Core.UmbracoDataProvider"/> class, using a <see cref="umbraco.Linq.Core.Node.NodeDataProvider"/> data provider with the connection string from the umbraco config
|
||||
/// </summary>
|
||||
protected UmbracoDataContext() : this(new NodeDataProvider())
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="umbracoDataContext"/> class.
|
||||
/// Initializes a new instance of the <see cref="umbraco.Linq.Core.UmbracoDataProvider"/> class.
|
||||
/// </summary>
|
||||
/// <param name="dataProvider">The data provider to use within the DataContext.</param>
|
||||
protected UmbracoDataContext(UmbracoDataProvider dataProvider)
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body onload="this.focus()" style="overflow: hidden; padding: 0px; margin: 0px;">
|
||||
<body onload="this.focus()" style="overflow: auto; padding: 0px; margin: 0px;">
|
||||
<script type="text/javascript" language="javascript">
|
||||
function dialogHandler(id) {
|
||||
<%
|
||||
@@ -79,7 +79,7 @@
|
||||
<div id="umbModal">
|
||||
<div id="header">
|
||||
<div id="caption">Pick a node</div>
|
||||
<a id="close" onclick="closeWindow(); return false;" title="Close window" href="#"><span>×</span></a>
|
||||
<a id="close" onclick="closeWindow(); return false;" title="Close window" href="#" style="margin-right:15px"><span>×</span></a>
|
||||
</div>
|
||||
<div id="body">
|
||||
<iframe src="<%=TreeInitUrl %>" frameborder="0" style="overflow: auto; width: 291px; position: relative; height: 370px; background: white"></iframe>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.3053
|
||||
// Runtime Version:2.0.50727.3082
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.3053
|
||||
// Runtime Version:2.0.50727.3082
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="/configuration/appSettings/add[@key='umbracoConfigurationStatus']/@value">
|
||||
<xsl:attribute name="value">4.1.0.alpha</xsl:attribute>
|
||||
<xsl:attribute name="value">4.1.0.beta</xsl:attribute>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Default templates to match anything else -->
|
||||
|
||||
Reference in New Issue
Block a user