mirror of
https://github.com/ckaczor/FeedCenter.git
synced 2026-02-17 02:51:37 -05:00
Update to EF6
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
using System;
|
using Common.Debug;
|
||||||
using System.Diagnostics;
|
|
||||||
using Common.Debug;
|
|
||||||
using Common.Internet;
|
using Common.Internet;
|
||||||
using FeedCenter.Properties;
|
using FeedCenter.Properties;
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace FeedCenter
|
namespace FeedCenter
|
||||||
{
|
{
|
||||||
|
|||||||
27
Category.cs
Normal file
27
Category.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated from a template.
|
||||||
|
//
|
||||||
|
// Manual changes to this file may cause unexpected behavior in your application.
|
||||||
|
// Manual changes to this file will be overwritten if the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace FeedCenter
|
||||||
|
{
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
public partial class Category
|
||||||
|
{
|
||||||
|
public Category()
|
||||||
|
{
|
||||||
|
this.Feeds = new HashSet<Feed>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public System.Guid ID { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public virtual ICollection<Feed> Feeds { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +1,11 @@
|
|||||||
using System;
|
using Common.Debug;
|
||||||
|
using FeedCenter.Properties;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Data.SqlServerCe;
|
using System.Data.SqlServerCe;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
using Common.Debug;
|
|
||||||
|
|
||||||
using FeedCenter.Properties;
|
|
||||||
|
|
||||||
namespace FeedCenter.Data
|
namespace FeedCenter.Data
|
||||||
{
|
{
|
||||||
public static class Database
|
public static class Database
|
||||||
@@ -45,10 +43,10 @@ namespace FeedCenter.Data
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Open the database file
|
// Open the database file
|
||||||
using (FileStream stream = new FileStream(databasePath, FileMode.Open, FileAccess.Read))
|
using (var stream = new FileStream(databasePath, FileMode.Open, FileAccess.Read))
|
||||||
{
|
{
|
||||||
// Read the file using the binary reader
|
// Read the file using the binary reader
|
||||||
BinaryReader reader = new BinaryReader(stream);
|
var reader = new BinaryReader(stream);
|
||||||
|
|
||||||
// Seek to the version signature
|
// Seek to the version signature
|
||||||
stream.Seek(16, SeekOrigin.Begin);
|
stream.Seek(16, SeekOrigin.Begin);
|
||||||
@@ -81,7 +79,7 @@ namespace FeedCenter.Data
|
|||||||
Tracer.WriteLine("Creating database engine");
|
Tracer.WriteLine("Creating database engine");
|
||||||
|
|
||||||
// Create the database engine
|
// Create the database engine
|
||||||
using (SqlCeEngine engine = new SqlCeEngine(string.Format("Data Source={0}", DatabasePath)))
|
using (var engine = new SqlCeEngine(string.Format("Data Source={0}", DatabasePath)))
|
||||||
{
|
{
|
||||||
Tracer.WriteLine("Creating database");
|
Tracer.WriteLine("Creating database");
|
||||||
|
|
||||||
@@ -95,20 +93,20 @@ namespace FeedCenter.Data
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getVersion(SqlCeConnection connection)
|
private static int GetVersion(SqlCeConnection connection)
|
||||||
{
|
{
|
||||||
string versionString = string.Empty;
|
string versionString;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Check the database version table
|
// Check the database version table
|
||||||
using (SqlCeCommand command = new SqlCeCommand("SELECT Value FROM DatabaseVersion", connection))
|
using (var command = new SqlCeCommand("SELECT Value FROM DatabaseVersion", connection))
|
||||||
versionString = command.ExecuteScalar().ToString();
|
versionString = command.ExecuteScalar().ToString();
|
||||||
}
|
}
|
||||||
catch (SqlCeException)
|
catch (SqlCeException)
|
||||||
{
|
{
|
||||||
// Check the setting table for the version
|
// Check the setting table for the version
|
||||||
using (SqlCeCommand command = new SqlCeCommand("SELECT Value FROM Setting WHERE Name = 'DatabaseVersion'", connection))
|
using (var command = new SqlCeCommand("SELECT Value FROM Setting WHERE Name = 'DatabaseVersion'", connection))
|
||||||
versionString = command.ExecuteScalar().ToString();
|
versionString = command.ExecuteScalar().ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,7 +123,7 @@ namespace FeedCenter.Data
|
|||||||
Tracer.WriteLine("Getting database file version");
|
Tracer.WriteLine("Getting database file version");
|
||||||
|
|
||||||
// Get the database file version
|
// Get the database file version
|
||||||
SqlServerCeFileVersion fileVersion = GetFileVersion(DatabasePath);
|
var fileVersion = GetFileVersion(DatabasePath);
|
||||||
|
|
||||||
Tracer.WriteLine("Database file version: {0}", fileVersion);
|
Tracer.WriteLine("Database file version: {0}", fileVersion);
|
||||||
|
|
||||||
@@ -135,7 +133,7 @@ namespace FeedCenter.Data
|
|||||||
Tracer.WriteLine("Creating database engine");
|
Tracer.WriteLine("Creating database engine");
|
||||||
|
|
||||||
// Create the database engine
|
// Create the database engine
|
||||||
using (SqlCeEngine engine = new SqlCeEngine(string.Format("Data Source={0}", DatabasePath)))
|
using (var engine = new SqlCeEngine(string.Format("Data Source={0}", DatabasePath)))
|
||||||
{
|
{
|
||||||
Tracer.WriteLine("Upgrading database");
|
Tracer.WriteLine("Upgrading database");
|
||||||
|
|
||||||
@@ -147,13 +145,13 @@ namespace FeedCenter.Data
|
|||||||
Tracer.WriteLine("Getting database version");
|
Tracer.WriteLine("Getting database version");
|
||||||
|
|
||||||
// Create a database connection
|
// Create a database connection
|
||||||
using (SqlCeConnection connection = new SqlCeConnection(string.Format("Data Source={0}", DatabasePath)))
|
using (var connection = new SqlCeConnection(string.Format("Data Source={0}", DatabasePath)))
|
||||||
{
|
{
|
||||||
// Open the connection
|
// Open the connection
|
||||||
connection.Open();
|
connection.Open();
|
||||||
|
|
||||||
// Get the database version
|
// Get the database version
|
||||||
int databaseVersion = getVersion(connection);
|
var databaseVersion = GetVersion(connection);
|
||||||
|
|
||||||
// Create a dictionary of database upgrade scripts and their version numbers
|
// Create a dictionary of database upgrade scripts and their version numbers
|
||||||
var scriptList = new Dictionary<int, string>();
|
var scriptList = new Dictionary<int, string>();
|
||||||
@@ -162,10 +160,10 @@ namespace FeedCenter.Data
|
|||||||
foreach (var property in typeof(Resources).GetProperties().Where(property => property.Name.StartsWith("DatabaseUpdate")))
|
foreach (var property in typeof(Resources).GetProperties().Where(property => property.Name.StartsWith("DatabaseUpdate")))
|
||||||
{
|
{
|
||||||
// Get the name of the property
|
// Get the name of the property
|
||||||
string propertyName = property.Name;
|
var propertyName = property.Name;
|
||||||
|
|
||||||
// Extract the version from the name
|
// Extract the version from the name
|
||||||
int version = int.Parse(propertyName.Substring(propertyName.IndexOf("_", StringComparison.Ordinal) + 1));
|
var version = int.Parse(propertyName.Substring(propertyName.IndexOf("_", StringComparison.Ordinal) + 1));
|
||||||
|
|
||||||
// Add to the script list
|
// Add to the script list
|
||||||
scriptList[version] = propertyName;
|
scriptList[version] = propertyName;
|
||||||
@@ -178,7 +176,7 @@ namespace FeedCenter.Data
|
|||||||
if (databaseVersion <= pair.Key)
|
if (databaseVersion <= pair.Key)
|
||||||
{
|
{
|
||||||
// Get the script text
|
// Get the script text
|
||||||
string scriptText = Resources.ResourceManager.GetString(pair.Value);
|
var scriptText = Resources.ResourceManager.GetString(pair.Value);
|
||||||
|
|
||||||
// Run the script
|
// Run the script
|
||||||
ExecuteScript(scriptText);
|
ExecuteScript(scriptText);
|
||||||
@@ -192,7 +190,7 @@ namespace FeedCenter.Data
|
|||||||
Tracer.WriteLine("Creating database engine");
|
Tracer.WriteLine("Creating database engine");
|
||||||
|
|
||||||
// Create the database engine
|
// Create the database engine
|
||||||
using (SqlCeEngine engine = new SqlCeEngine(string.Format("Data Source={0}", DatabasePath)))
|
using (var engine = new SqlCeEngine(string.Format("Data Source={0}", DatabasePath)))
|
||||||
{
|
{
|
||||||
Tracer.WriteLine("Shrinking database");
|
Tracer.WriteLine("Shrinking database");
|
||||||
|
|
||||||
@@ -204,22 +202,22 @@ namespace FeedCenter.Data
|
|||||||
private static void ExecuteScript(string scriptText)
|
private static void ExecuteScript(string scriptText)
|
||||||
{
|
{
|
||||||
// Create a database connection
|
// Create a database connection
|
||||||
using (SqlCeConnection connection = new SqlCeConnection(string.Format("Data Source={0}", DatabasePath)))
|
using (var connection = new SqlCeConnection(string.Format("Data Source={0}", DatabasePath)))
|
||||||
{
|
{
|
||||||
// Open the connection
|
// Open the connection
|
||||||
connection.Open();
|
connection.Open();
|
||||||
|
|
||||||
// Setup the delimiters
|
// Setup the delimiters
|
||||||
string[] delimiters = new[] { "\r\nGO\r\n" };
|
var delimiters = new[] { "\r\nGO\r\n" };
|
||||||
|
|
||||||
// Split the script at the delimiters
|
// Split the script at the delimiters
|
||||||
string[] statements = scriptText.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
|
var statements = scriptText.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
// Loop over each statement in the script
|
// Loop over each statement in the script
|
||||||
foreach (string statement in statements)
|
foreach (var statement in statements)
|
||||||
{
|
{
|
||||||
// Execute the statement
|
// Execute the statement
|
||||||
using (SqlCeCommand command = new SqlCeCommand(statement, connection))
|
using (var command = new SqlCeCommand(statement, connection))
|
||||||
command.ExecuteNonQuery();
|
command.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace FeedCenter.Data
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
// Get the first table
|
// Get the first table
|
||||||
DataTable firstTable = dataSet.Tables[0];
|
var firstTable = dataSet.Tables[0];
|
||||||
|
|
||||||
// If the table has no rows then return nothing
|
// If the table has no rows then return nothing
|
||||||
if (firstTable.Rows.Count == 0)
|
if (firstTable.Rows.Count == 0)
|
||||||
@@ -43,13 +43,13 @@ namespace FeedCenter.Data
|
|||||||
public static void SetStatement(this SqlCeCommand command, string statement, params object[] parameters)
|
public static void SetStatement(this SqlCeCommand command, string statement, params object[] parameters)
|
||||||
{
|
{
|
||||||
// Create a new array to hold the updated parameters
|
// Create a new array to hold the updated parameters
|
||||||
object[] formattedParameters = new object[parameters.Length];
|
var formattedParameters = new object[parameters.Length];
|
||||||
|
|
||||||
// Initialize our position
|
// Initialize our position
|
||||||
int position = 0;
|
var position = 0;
|
||||||
|
|
||||||
// Loop over each parameter
|
// Loop over each parameter
|
||||||
foreach (object parameter in parameters)
|
foreach (var parameter in parameters)
|
||||||
{
|
{
|
||||||
// If the parameter is a DateTime then we need to reformat
|
// If the parameter is a DateTime then we need to reformat
|
||||||
if (parameter == null)
|
if (parameter == null)
|
||||||
@@ -60,10 +60,10 @@ namespace FeedCenter.Data
|
|||||||
else if (parameter is DateTime)
|
else if (parameter is DateTime)
|
||||||
{
|
{
|
||||||
// Cast the parameter back to a DateTime
|
// Cast the parameter back to a DateTime
|
||||||
DateTime dateTime = (DateTime) parameter;
|
var dateTime = (DateTime) parameter;
|
||||||
|
|
||||||
// Convert the DateTime to sortable format
|
// Convert the DateTime to sortable format
|
||||||
string formatted = dateTime.ToString("s");
|
var formatted = dateTime.ToString("s");
|
||||||
|
|
||||||
// Set into the formatted array
|
// Set into the formatted array
|
||||||
formattedParameters[position++] = formatted;
|
formattedParameters[position++] = formatted;
|
||||||
@@ -101,7 +101,7 @@ namespace FeedCenter.Data
|
|||||||
public static void ExecuteNonQuery(this SqlCeConnection connection, string query, params object[] parameters)
|
public static void ExecuteNonQuery(this SqlCeConnection connection, string query, params object[] parameters)
|
||||||
{
|
{
|
||||||
// Create the command object
|
// Create the command object
|
||||||
SqlCeCommand command = connection.CreateCommand();
|
var command = connection.CreateCommand();
|
||||||
|
|
||||||
// Set the statement based on the query and parameters
|
// Set the statement based on the query and parameters
|
||||||
command.SetStatement(query, parameters);
|
command.SetStatement(query, parameters);
|
||||||
@@ -115,16 +115,16 @@ namespace FeedCenter.Data
|
|||||||
public static DataSet ExecuteDataSet(this SqlCeConnection connection, string query, params object[] parameters)
|
public static DataSet ExecuteDataSet(this SqlCeConnection connection, string query, params object[] parameters)
|
||||||
{
|
{
|
||||||
// Create the command object
|
// Create the command object
|
||||||
SqlCeCommand command = connection.CreateCommand();
|
var command = connection.CreateCommand();
|
||||||
|
|
||||||
// Set the statement based on the query and parameters
|
// Set the statement based on the query and parameters
|
||||||
command.SetStatement(query, parameters);
|
command.SetStatement(query, parameters);
|
||||||
|
|
||||||
// Create a new data adapter
|
// Create a new data adapter
|
||||||
using (SqlCeDataAdapter adapter = new SqlCeDataAdapter(command))
|
using (var adapter = new SqlCeDataAdapter(command))
|
||||||
{
|
{
|
||||||
// Create the new data set
|
// Create the new data set
|
||||||
using (DataSet dataSet = new DataSet())
|
using (var dataSet = new DataSet())
|
||||||
{
|
{
|
||||||
//Tracer.WriteLine("Executing SQL query: {0}", command.CommandText);
|
//Tracer.WriteLine("Executing SQL query: {0}", command.CommandText);
|
||||||
|
|
||||||
@@ -139,7 +139,7 @@ namespace FeedCenter.Data
|
|||||||
public static object ExecuteScalar(this SqlCeConnection connection, string query, params object[] parameters)
|
public static object ExecuteScalar(this SqlCeConnection connection, string query, params object[] parameters)
|
||||||
{
|
{
|
||||||
// Create the command object
|
// Create the command object
|
||||||
SqlCeCommand command = connection.CreateCommand();
|
var command = connection.CreateCommand();
|
||||||
|
|
||||||
// Set the statement based on the query and parameters
|
// Set the statement based on the query and parameters
|
||||||
command.SetStatement(query, parameters);
|
command.SetStatement(query, parameters);
|
||||||
|
|||||||
18
Entities.cs
18
Entities.cs
@@ -1,5 +1,6 @@
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Data.Entity.Infrastructure;
|
||||||
|
|
||||||
namespace FeedCenter
|
namespace FeedCenter
|
||||||
{
|
{
|
||||||
@@ -11,7 +12,8 @@ namespace FeedCenter
|
|||||||
{
|
{
|
||||||
if (disposing)
|
if (disposing)
|
||||||
{
|
{
|
||||||
ObjectStateManager.ObjectStateManagerChanged -= HandleObjectStateManagerObjectStateManagerChanged;
|
var manager = ((IObjectContextAdapter) this).ObjectContext.ObjectStateManager;
|
||||||
|
manager.ObjectStateManagerChanged -= HandleObjectStateManagerObjectStateManagerChanged;
|
||||||
_hookedStateManager = false;
|
_hookedStateManager = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,7 +38,8 @@ namespace FeedCenter
|
|||||||
|
|
||||||
if (!_hookedStateManager)
|
if (!_hookedStateManager)
|
||||||
{
|
{
|
||||||
ObjectStateManager.ObjectStateManagerChanged += HandleObjectStateManagerObjectStateManagerChanged;
|
var manager = ((IObjectContextAdapter) this).ObjectContext.ObjectStateManager;
|
||||||
|
manager.ObjectStateManagerChanged += HandleObjectStateManagerObjectStateManagerChanged;
|
||||||
_hookedStateManager = true;
|
_hookedStateManager = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,7 +64,8 @@ namespace FeedCenter
|
|||||||
|
|
||||||
if (!_hookedStateManager)
|
if (!_hookedStateManager)
|
||||||
{
|
{
|
||||||
ObjectStateManager.ObjectStateManagerChanged += HandleObjectStateManagerObjectStateManagerChanged;
|
var manager = ((IObjectContextAdapter) this).ObjectContext.ObjectStateManager;
|
||||||
|
manager.ObjectStateManagerChanged += HandleObjectStateManagerObjectStateManagerChanged;
|
||||||
_hookedStateManager = true;
|
_hookedStateManager = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,7 +85,7 @@ namespace FeedCenter
|
|||||||
if (_allCategories == null)
|
if (_allCategories == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Category category = e.Element as Category;
|
var category = e.Element as Category;
|
||||||
|
|
||||||
switch (e.Action)
|
switch (e.Action)
|
||||||
{
|
{
|
||||||
@@ -93,7 +97,7 @@ namespace FeedCenter
|
|||||||
break;
|
break;
|
||||||
case CollectionChangeAction.Refresh:
|
case CollectionChangeAction.Refresh:
|
||||||
_allCategories.Clear();
|
_allCategories.Clear();
|
||||||
foreach (Category loopCategory in Categories)
|
foreach (var loopCategory in Categories)
|
||||||
_allCategories.Add(loopCategory);
|
_allCategories.Add(loopCategory);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -103,7 +107,7 @@ namespace FeedCenter
|
|||||||
if (_allFeeds == null)
|
if (_allFeeds == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Feed feed = e.Element as Feed;
|
var feed = e.Element as Feed;
|
||||||
|
|
||||||
switch (e.Action)
|
switch (e.Action)
|
||||||
{
|
{
|
||||||
@@ -115,7 +119,7 @@ namespace FeedCenter
|
|||||||
break;
|
break;
|
||||||
case CollectionChangeAction.Refresh:
|
case CollectionChangeAction.Refresh:
|
||||||
_allFeeds.Clear();
|
_allFeeds.Clear();
|
||||||
foreach (Feed loopfeed in Feeds)
|
foreach (var loopfeed in Feeds)
|
||||||
_allFeeds.Add(loopfeed);
|
_allFeeds.Add(loopfeed);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
59
Feed.cs
Normal file
59
Feed.cs
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated from a template.
|
||||||
|
//
|
||||||
|
// Manual changes to this file may cause unexpected behavior in your application.
|
||||||
|
// Manual changes to this file will be overwritten if the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace FeedCenter
|
||||||
|
{
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
public partial class Feed
|
||||||
|
{
|
||||||
|
public Feed()
|
||||||
|
{
|
||||||
|
this.Name = "";
|
||||||
|
this.Title = "";
|
||||||
|
this.Source = "";
|
||||||
|
this.Link = "";
|
||||||
|
this.Description = "";
|
||||||
|
this.LastChecked = new DateTime(599266080000000000, DateTimeKind.Unspecified);
|
||||||
|
this.CheckInterval = 60;
|
||||||
|
this.Enabled = true;
|
||||||
|
this.Authenticate = false;
|
||||||
|
this.Username = "";
|
||||||
|
this.Password = "";
|
||||||
|
this.Domain = "";
|
||||||
|
this.LastUpdated = new DateTime(599266080000000000, DateTimeKind.Unspecified);
|
||||||
|
this.Actions = new HashSet<FeedAction>();
|
||||||
|
this.Items = new HashSet<FeedItem>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public System.Guid ID { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
public string Source { get; set; }
|
||||||
|
public string Link { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
|
public System.DateTime LastChecked { get; set; }
|
||||||
|
public int CheckInterval { get; set; }
|
||||||
|
public bool Enabled { get; set; }
|
||||||
|
public bool Authenticate { get; set; }
|
||||||
|
public string Username { get; set; }
|
||||||
|
public string Password { get; set; }
|
||||||
|
public string Domain { get; set; }
|
||||||
|
public FeedCenter.FeedReadResult LastReadResult { get; set; }
|
||||||
|
public System.DateTime LastUpdated { get; set; }
|
||||||
|
public FeedCenter.FeedItemComparison ItemComparison { get; set; }
|
||||||
|
public System.Guid CategoryID { get; set; }
|
||||||
|
public FeedCenter.MultipleOpenAction MultipleOpenAction { get; set; }
|
||||||
|
|
||||||
|
public virtual Category Category { get; set; }
|
||||||
|
public virtual ICollection<FeedAction> Actions { get; set; }
|
||||||
|
public virtual ICollection<FeedItem> Items { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
26
FeedAction.cs
Normal file
26
FeedAction.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated from a template.
|
||||||
|
//
|
||||||
|
// Manual changes to this file may cause unexpected behavior in your application.
|
||||||
|
// Manual changes to this file will be overwritten if the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace FeedCenter
|
||||||
|
{
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
public partial class FeedAction
|
||||||
|
{
|
||||||
|
public System.Guid ID { get; set; }
|
||||||
|
public System.Guid FeedID { get; set; }
|
||||||
|
public int Field { get; set; }
|
||||||
|
public string Search { get; set; }
|
||||||
|
public string Replace { get; set; }
|
||||||
|
public int Sequence { get; set; }
|
||||||
|
|
||||||
|
public virtual Feed Feed { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -132,17 +132,26 @@
|
|||||||
<Reference Include="Common.Wpf.MarkupExtensions">
|
<Reference Include="Common.Wpf.MarkupExtensions">
|
||||||
<HintPath>..\Common.Wpf.MarkupExtensions\bin\Release\Common.Wpf.MarkupExtensions.dll</HintPath>
|
<HintPath>..\Common.Wpf.MarkupExtensions\bin\Release\Common.Wpf.MarkupExtensions.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="EntityFramework">
|
||||||
|
<HintPath>packages\EntityFramework.6.1.1\lib\net45\EntityFramework.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="EntityFramework.SqlServer">
|
||||||
|
<HintPath>packages\EntityFramework.6.1.1\lib\net45\EntityFramework.SqlServer.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="EntityFramework.SqlServerCompact">
|
||||||
|
<HintPath>packages\EntityFramework.SqlServerCompact.6.1.1\lib\net45\EntityFramework.SqlServerCompact.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||||
<Reference Include="System.configuration" />
|
<Reference Include="System.configuration" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Data.Entity" />
|
<Reference Include="System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
|
||||||
<Reference Include="System.Data.SqlServerCe, Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
|
<Private>True</Private>
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<HintPath>packages\Microsoft.SqlServer.Compact.4.0.8854.1\lib\net40\System.Data.SqlServerCe.dll</HintPath>
|
||||||
<HintPath>bin\Debug\System.Data.SqlServerCe.dll</HintPath>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Data.SqlServerCe.Entity, Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
|
<Reference Include="System.Data.SqlServerCe.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<Private>True</Private>
|
||||||
<HintPath>bin\Debug\System.Data.SqlServerCe.Entity.dll</HintPath>
|
<HintPath>packages\Microsoft.SqlServer.Compact.4.0.8854.1\lib\net40\System.Data.SqlServerCe.Entity.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Deployment" />
|
<Reference Include="System.Deployment" />
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
@@ -168,12 +177,34 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</Page>
|
</Page>
|
||||||
<Compile Include="BrowserCommon.cs" />
|
<Compile Include="BrowserCommon.cs" />
|
||||||
|
<Compile Include="Category.cs">
|
||||||
|
<DependentUpon>Model.tt</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Data\Extensions.cs" />
|
<Compile Include="Data\Extensions.cs" />
|
||||||
<Compile Include="Entities.cs" />
|
<Compile Include="Entities.cs" />
|
||||||
|
<Compile Include="Feed.cs">
|
||||||
|
<DependentUpon>Model.tt</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="FeedAction.cs">
|
||||||
|
<DependentUpon>Model.tt</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="FeedErrorWindow.xaml.cs">
|
<Compile Include="FeedErrorWindow.xaml.cs">
|
||||||
<DependentUpon>FeedErrorWindow.xaml</DependentUpon>
|
<DependentUpon>FeedErrorWindow.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="FeedItem.cs">
|
||||||
|
<DependentUpon>Model.tt</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Feeds\Category.cs" />
|
<Compile Include="Feeds\Category.cs" />
|
||||||
|
<Compile Include="Model.Context.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<DependentUpon>Model.Context.tt</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Model.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<DependentUpon>Model.tt</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Model.Designer.cs">
|
<Compile Include="Model.Designer.cs">
|
||||||
<AutoGen>True</AutoGen>
|
<AutoGen>True</AutoGen>
|
||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
@@ -212,6 +243,9 @@
|
|||||||
<Compile Include="Options\UpdateOptionsPanel.xaml.cs">
|
<Compile Include="Options\UpdateOptionsPanel.xaml.cs">
|
||||||
<DependentUpon>UpdateOptionsPanel.xaml</DependentUpon>
|
<DependentUpon>UpdateOptionsPanel.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Setting.cs">
|
||||||
|
<DependentUpon>Model.tt</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="SettingsStore.cs" />
|
<Compile Include="SettingsStore.cs" />
|
||||||
<Compile Include="SplashWindow.xaml.cs">
|
<Compile Include="SplashWindow.xaml.cs">
|
||||||
<DependentUpon>SplashWindow.xaml</DependentUpon>
|
<DependentUpon>SplashWindow.xaml</DependentUpon>
|
||||||
@@ -326,6 +360,16 @@
|
|||||||
</EntityDeploy>
|
</EntityDeploy>
|
||||||
<None Include="FeedCenter_1_TemporaryKey.pfx" />
|
<None Include="FeedCenter_1_TemporaryKey.pfx" />
|
||||||
<None Include="FeedCenter_TemporaryKey.pfx" />
|
<None Include="FeedCenter_TemporaryKey.pfx" />
|
||||||
|
<None Include="Model.Context.tt">
|
||||||
|
<Generator>TextTemplatingFileGenerator</Generator>
|
||||||
|
<LastGenOutput>Model.Context.cs</LastGenOutput>
|
||||||
|
<DependentUpon>Model.edmx</DependentUpon>
|
||||||
|
</None>
|
||||||
|
<None Include="Model.tt">
|
||||||
|
<Generator>TextTemplatingFileGenerator</Generator>
|
||||||
|
<LastGenOutput>Model.cs</LastGenOutput>
|
||||||
|
<DependentUpon>Model.edmx</DependentUpon>
|
||||||
|
</None>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
<None Include="Properties\app.manifest" />
|
<None Include="Properties\app.manifest" />
|
||||||
<None Include="Properties\Settings.settings">
|
<None Include="Properties\Settings.settings">
|
||||||
@@ -455,12 +499,17 @@
|
|||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<Import Project="packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
|
<PropertyGroup>
|
||||||
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
|
<PostBuildEvent>
|
||||||
<Error Condition="!Exists('packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
|
if not exist "$(TargetDir)x86" md "$(TargetDir)x86"
|
||||||
<Error Condition="Exists('packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
|
xcopy /s /y "$(SolutionDir)packages\Microsoft.SqlServer.Compact.4.0.8854.1\NativeBinaries\x86\*.*" "$(TargetDir)x86"
|
||||||
</Target>
|
if not exist "$(TargetDir)amd64" md "$(TargetDir)amd64"
|
||||||
|
xcopy /s /y "$(SolutionDir)packages\Microsoft.SqlServer.Compact.4.0.8854.1\NativeBinaries\amd64\*.*" "$(TargetDir)amd64"</PostBuildEvent>
|
||||||
|
</PropertyGroup>
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
<Target Name="BeforeBuild">
|
<Target Name="BeforeBuild">
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
using System.ComponentModel;
|
using FeedCenter.Options;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Data;
|
using System.Windows.Data;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using FeedCenter.Options;
|
|
||||||
|
|
||||||
namespace FeedCenter
|
namespace FeedCenter
|
||||||
{
|
{
|
||||||
@@ -38,9 +38,9 @@ namespace FeedCenter
|
|||||||
|
|
||||||
private void HandleCollectionViewSourceFilter(object sender, FilterEventArgs e)
|
private void HandleCollectionViewSourceFilter(object sender, FilterEventArgs e)
|
||||||
{
|
{
|
||||||
Feed feed = (Feed) e.Item;
|
var feed = (Feed) e.Item;
|
||||||
|
|
||||||
e.Accepted = (feed.LastReadResult != (int) FeedReadResult.Success);
|
e.Accepted = (feed.LastReadResult != FeedReadResult.Success);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleEditFeedButtonClick(object sender, RoutedEventArgs e)
|
private void HandleEditFeedButtonClick(object sender, RoutedEventArgs e)
|
||||||
@@ -58,18 +58,18 @@ namespace FeedCenter
|
|||||||
if (feedDataGrid.SelectedItem == null)
|
if (feedDataGrid.SelectedItem == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Feed feed = (Feed) feedDataGrid.SelectedItem;
|
var feed = (Feed) feedDataGrid.SelectedItem;
|
||||||
|
|
||||||
FeedWindow feedWindow = new FeedWindow();
|
var feedWindow = new FeedWindow();
|
||||||
|
|
||||||
feedWindow.Display(_database, feed, GetWindow(this));
|
feedWindow.Display(_database, feed, GetWindow(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeleteSelectedFeed()
|
private void DeleteSelectedFeed()
|
||||||
{
|
{
|
||||||
Feed feed = (Feed) feedDataGrid.SelectedItem;
|
var feed = (Feed) feedDataGrid.SelectedItem;
|
||||||
|
|
||||||
_database.Feeds.DeleteObject(feed);
|
_database.Feeds.Remove(feed);
|
||||||
|
|
||||||
SetFeedButtonStates();
|
SetFeedButtonStates();
|
||||||
}
|
}
|
||||||
@@ -85,13 +85,13 @@ namespace FeedCenter
|
|||||||
|
|
||||||
private void HandleOpenPageButtonClick(object sender, RoutedEventArgs e)
|
private void HandleOpenPageButtonClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Feed feed = (Feed) feedDataGrid.SelectedItem;
|
var feed = (Feed) feedDataGrid.SelectedItem;
|
||||||
BrowserCommon.OpenLink(feed.Link);
|
BrowserCommon.OpenLink(feed.Link);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleOpenFeedButtonClick(object sender, RoutedEventArgs e)
|
private void HandleOpenFeedButtonClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Feed feed = (Feed) feedDataGrid.SelectedItem;
|
var feed = (Feed) feedDataGrid.SelectedItem;
|
||||||
BrowserCommon.OpenLink(feed.Source);
|
BrowserCommon.OpenLink(feed.Source);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ namespace FeedCenter
|
|||||||
{
|
{
|
||||||
Mouse.OverrideCursor = Cursors.Wait;
|
Mouse.OverrideCursor = Cursors.Wait;
|
||||||
|
|
||||||
Feed feed = (Feed) feedDataGrid.SelectedItem;
|
var feed = (Feed) feedDataGrid.SelectedItem;
|
||||||
feed.Read(_database, true);
|
feed.Read(_database, true);
|
||||||
|
|
||||||
_collectionViewSource.View.Refresh();
|
_collectionViewSource.View.Refresh();
|
||||||
|
|||||||
38
FeedItem.cs
Normal file
38
FeedItem.cs
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated from a template.
|
||||||
|
//
|
||||||
|
// Manual changes to this file may cause unexpected behavior in your application.
|
||||||
|
// Manual changes to this file will be overwritten if the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace FeedCenter
|
||||||
|
{
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
public partial class FeedItem
|
||||||
|
{
|
||||||
|
public FeedItem()
|
||||||
|
{
|
||||||
|
this.Title = "";
|
||||||
|
this.Link = "";
|
||||||
|
this.Description = "";
|
||||||
|
this.LastFound = new DateTime(599266080000000000, DateTimeKind.Unspecified);
|
||||||
|
}
|
||||||
|
|
||||||
|
public System.Guid ID { get; set; }
|
||||||
|
public System.Guid FeedID { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
public string Link { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
|
public bool BeenRead { get; set; }
|
||||||
|
public System.DateTime LastFound { get; set; }
|
||||||
|
public bool New { get; set; }
|
||||||
|
public string Guid { get; set; }
|
||||||
|
public int Sequence { get; set; }
|
||||||
|
|
||||||
|
public virtual Feed Feed { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
using System.Xml;
|
using Common.Debug;
|
||||||
|
|
||||||
using Common.Debug;
|
|
||||||
using Common.Xml;
|
using Common.Xml;
|
||||||
|
using System.Xml;
|
||||||
|
|
||||||
namespace FeedCenter.FeedParsers
|
namespace FeedCenter.FeedParsers
|
||||||
{
|
{
|
||||||
@@ -14,13 +13,13 @@ namespace FeedCenter.FeedParsers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Create the XML document
|
// Create the XML document
|
||||||
XmlDocument document = new XmlDocument { XmlResolver = null };
|
var document = new XmlDocument { XmlResolver = null };
|
||||||
|
|
||||||
// Load the XML document from the text
|
// Load the XML document from the text
|
||||||
document.LoadXml(feedText);
|
document.LoadXml(feedText);
|
||||||
|
|
||||||
// Create the namespace manager
|
// Create the namespace manager
|
||||||
XmlNamespaceManager namespaceManager = document.GetAllNamespaces();
|
var namespaceManager = document.GetAllNamespaces();
|
||||||
|
|
||||||
// Get the root node
|
// Get the root node
|
||||||
XmlNode rootNode = document.DocumentElement;
|
XmlNode rootNode = document.DocumentElement;
|
||||||
@@ -30,7 +29,7 @@ namespace FeedCenter.FeedParsers
|
|||||||
return FeedReadResult.UnknownError;
|
return FeedReadResult.UnknownError;
|
||||||
|
|
||||||
// Initialize the sequence number for items
|
// Initialize the sequence number for items
|
||||||
int sequence = 0;
|
var sequence = 0;
|
||||||
|
|
||||||
// Loop over all nodes in the root node
|
// Loop over all nodes in the root node
|
||||||
foreach (XmlNode node in rootNode.ChildNodes)
|
foreach (XmlNode node in rootNode.ChildNodes)
|
||||||
@@ -81,7 +80,7 @@ namespace FeedCenter.FeedParsers
|
|||||||
protected override FeedItem ParseFeedItem(XmlNamespaceManager namespaceManager, XmlNode node)
|
protected override FeedItem ParseFeedItem(XmlNamespaceManager namespaceManager, XmlNode node)
|
||||||
{
|
{
|
||||||
// Create a new feed item
|
// Create a new feed item
|
||||||
FeedItem feedItem = new FeedItem();
|
var feedItem = FeedItem.Create();
|
||||||
|
|
||||||
// Loop over all nodes in the feed node
|
// Loop over all nodes in the feed node
|
||||||
foreach (XmlNode childNode in node.ChildNodes)
|
foreach (XmlNode childNode in node.ChildNodes)
|
||||||
@@ -114,7 +113,7 @@ namespace FeedCenter.FeedParsers
|
|||||||
|
|
||||||
if (string.IsNullOrEmpty(rel) || rel == "alternate")
|
if (string.IsNullOrEmpty(rel) || rel == "alternate")
|
||||||
{
|
{
|
||||||
string link = childNode.Attributes["href"].InnerText;
|
var link = childNode.Attributes["href"].InnerText;
|
||||||
|
|
||||||
if (link.StartsWith("/"))
|
if (link.StartsWith("/"))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
using System;
|
using Common.Debug;
|
||||||
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
using Common.Debug;
|
|
||||||
|
|
||||||
namespace FeedCenter.FeedParsers
|
namespace FeedCenter.FeedParsers
|
||||||
{
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
internal class InvalidFeedFormatException : ApplicationException
|
internal class InvalidFeedFormatException : ApplicationException
|
||||||
{
|
{
|
||||||
internal InvalidFeedFormatException(Exception exception) : base(string.Empty, exception)
|
internal InvalidFeedFormatException(Exception exception)
|
||||||
|
: base(string.Empty, exception)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,7 +124,7 @@ namespace FeedCenter.FeedParsers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Create the XML document
|
// Create the XML document
|
||||||
XmlDocument document = new XmlDocument { XmlResolver = null };
|
var document = new XmlDocument { XmlResolver = null };
|
||||||
|
|
||||||
// Load the XML document from the text
|
// Load the XML document from the text
|
||||||
document.LoadXml(feedText);
|
document.LoadXml(feedText);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using System.Xml;
|
using Common.Debug;
|
||||||
|
|
||||||
using Common.Debug;
|
|
||||||
using Common.Xml;
|
using Common.Xml;
|
||||||
|
using System.Xml;
|
||||||
|
|
||||||
namespace FeedCenter.FeedParsers
|
namespace FeedCenter.FeedParsers
|
||||||
{
|
{
|
||||||
@@ -14,7 +13,7 @@ namespace FeedCenter.FeedParsers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Create the XML document
|
// Create the XML document
|
||||||
XmlDocument document = new XmlDocument { XmlResolver = null };
|
var document = new XmlDocument { XmlResolver = null };
|
||||||
|
|
||||||
// Load the XML document from the text
|
// Load the XML document from the text
|
||||||
document.LoadXml(feedText);
|
document.LoadXml(feedText);
|
||||||
@@ -83,7 +82,7 @@ namespace FeedCenter.FeedParsers
|
|||||||
protected override FeedItem ParseFeedItem(XmlNamespaceManager namespaceManager, XmlNode node)
|
protected override FeedItem ParseFeedItem(XmlNamespaceManager namespaceManager, XmlNode node)
|
||||||
{
|
{
|
||||||
// Create a new feed item
|
// Create a new feed item
|
||||||
FeedItem feedItem = new FeedItem();
|
FeedItem feedItem = FeedItem.Create();
|
||||||
|
|
||||||
// Loop over all nodes in the feed node
|
// Loop over all nodes in the feed node
|
||||||
foreach (XmlNode childNode in node.ChildNodes)
|
foreach (XmlNode childNode in node.ChildNodes)
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using System.Xml;
|
using Common.Debug;
|
||||||
|
|
||||||
using Common.Debug;
|
|
||||||
using Common.Xml;
|
using Common.Xml;
|
||||||
|
using System.Xml;
|
||||||
|
|
||||||
namespace FeedCenter.FeedParsers
|
namespace FeedCenter.FeedParsers
|
||||||
{
|
{
|
||||||
@@ -14,7 +13,7 @@ namespace FeedCenter.FeedParsers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Create the XML document
|
// Create the XML document
|
||||||
XmlDocument document = new XmlDocument { XmlResolver = null };
|
var document = new XmlDocument { XmlResolver = null };
|
||||||
|
|
||||||
// Load the XML document from the text
|
// Load the XML document from the text
|
||||||
document.LoadXml(feedText);
|
document.LoadXml(feedText);
|
||||||
@@ -75,7 +74,7 @@ namespace FeedCenter.FeedParsers
|
|||||||
protected override FeedItem ParseFeedItem(XmlNamespaceManager namespaceManager, XmlNode node)
|
protected override FeedItem ParseFeedItem(XmlNamespaceManager namespaceManager, XmlNode node)
|
||||||
{
|
{
|
||||||
// Create a new feed item
|
// Create a new feed item
|
||||||
FeedItem feedItem = new FeedItem();
|
FeedItem feedItem = FeedItem.Create();
|
||||||
|
|
||||||
// Loop over all nodes in the feed node
|
// Loop over all nodes in the feed node
|
||||||
foreach (XmlNode childNode in node.ChildNodes)
|
foreach (XmlNode childNode in node.ChildNodes)
|
||||||
|
|||||||
@@ -4,15 +4,11 @@ namespace FeedCenter
|
|||||||
{
|
{
|
||||||
public partial class Category
|
public partial class Category
|
||||||
{
|
{
|
||||||
#region Constructor
|
public static Category Create()
|
||||||
|
|
||||||
public Category()
|
|
||||||
{
|
{
|
||||||
ID = Guid.NewGuid();
|
return new Category { ID = Guid.NewGuid() };
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
public bool IsDefault
|
public bool IsDefault
|
||||||
{
|
{
|
||||||
get { return Name == "< default >"; }
|
get { return Name == "< default >"; }
|
||||||
|
|||||||
@@ -3,15 +3,23 @@ using Common.Xml;
|
|||||||
using FeedCenter.FeedParsers;
|
using FeedCenter.FeedParsers;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Windows.Data;
|
||||||
|
|
||||||
namespace FeedCenter
|
namespace FeedCenter
|
||||||
{
|
{
|
||||||
#region Enumerations
|
#region Enumerations
|
||||||
|
|
||||||
|
public enum MultipleOpenAction
|
||||||
|
{
|
||||||
|
IndividualPages,
|
||||||
|
SinglePage
|
||||||
|
}
|
||||||
|
|
||||||
public enum FeedType
|
public enum FeedType
|
||||||
{
|
{
|
||||||
Unknown,
|
Unknown,
|
||||||
@@ -20,7 +28,7 @@ namespace FeedCenter
|
|||||||
Atom
|
Atom
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum FeedItemComparison
|
public enum FeedItemComparison : byte
|
||||||
{
|
{
|
||||||
Default,
|
Default,
|
||||||
Title
|
Title
|
||||||
@@ -44,16 +52,26 @@ namespace FeedCenter
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public partial class Feed
|
[ValueConversion(typeof(int), typeof(MultipleOpenAction))]
|
||||||
|
public class MultipleOpenActionConverter : IValueConverter
|
||||||
{
|
{
|
||||||
#region Constructor
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
|
||||||
public Feed()
|
|
||||||
{
|
{
|
||||||
ID = Guid.NewGuid();
|
return (MultipleOpenAction) value;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
return (int) value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public partial class Feed
|
||||||
|
{
|
||||||
|
public static Feed Create()
|
||||||
|
{
|
||||||
|
return new Feed { ID = Guid.NewGuid() };
|
||||||
|
}
|
||||||
|
|
||||||
#region Event delegates
|
#region Event delegates
|
||||||
|
|
||||||
@@ -81,7 +99,7 @@ namespace FeedCenter
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
// Save as last result
|
// Save as last result
|
||||||
LastReadResult = (int) result;
|
LastReadResult = result;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -268,7 +286,7 @@ namespace FeedCenter
|
|||||||
foreach (var itemToRemove in removedItems)
|
foreach (var itemToRemove in removedItems)
|
||||||
{
|
{
|
||||||
// Delete the item from the database
|
// Delete the item from the database
|
||||||
database.FeedItems.DeleteObject(itemToRemove);
|
database.FeedItems.Remove(itemToRemove);
|
||||||
|
|
||||||
// Remove the item from the list
|
// Remove the item from the list
|
||||||
Items.Remove(itemToRemove);
|
Items.Remove(itemToRemove);
|
||||||
@@ -315,7 +333,7 @@ namespace FeedCenter
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
// Cast the last read result to the proper enum
|
// Cast the last read result to the proper enum
|
||||||
var lastReadResult = (FeedReadResult) LastReadResult;
|
var lastReadResult = LastReadResult;
|
||||||
|
|
||||||
// Build the name of the resource using the enum name and the value
|
// Build the name of the resource using the enum name and the value
|
||||||
var resourceName = string.Format("{0}_{1}", typeof(FeedReadResult).Name, lastReadResult);
|
var resourceName = string.Format("{0}_{1}", typeof(FeedReadResult).Name, lastReadResult);
|
||||||
|
|||||||
@@ -6,15 +6,11 @@ namespace FeedCenter
|
|||||||
{
|
{
|
||||||
public partial class FeedItem
|
public partial class FeedItem
|
||||||
{
|
{
|
||||||
#region Constructor
|
public static FeedItem Create()
|
||||||
|
|
||||||
public FeedItem()
|
|
||||||
{
|
{
|
||||||
ID = System.Guid.NewGuid();
|
return new FeedItem { ID = System.Guid.NewGuid() };
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
|
|||||||
@@ -1,24 +1,22 @@
|
|||||||
using System;
|
using Common.Debug;
|
||||||
|
using Common.Helpers;
|
||||||
|
using Common.IO;
|
||||||
|
using Common.Wpf.Extensions;
|
||||||
|
using FeedCenter.Options;
|
||||||
|
using FeedCenter.Properties;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Deployment.Application;
|
using System.Deployment.Application;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
using System.Web.UI;
|
using System.Web.UI;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Interop;
|
using System.Windows.Interop;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
using Common.Debug;
|
|
||||||
using Common.Helpers;
|
|
||||||
using Common.IO;
|
|
||||||
using Common.Internet;
|
|
||||||
using Common.Wpf.Extensions;
|
|
||||||
using FeedCenter.Options;
|
|
||||||
using FeedCenter.Properties;
|
|
||||||
|
|
||||||
namespace FeedCenter
|
namespace FeedCenter
|
||||||
{
|
{
|
||||||
@@ -180,14 +178,14 @@ namespace FeedCenter
|
|||||||
private void LoadWindowSettings()
|
private void LoadWindowSettings()
|
||||||
{
|
{
|
||||||
// Get the last window location
|
// Get the last window location
|
||||||
Point windowLocation = Settings.Default.WindowLocation;
|
var windowLocation = Settings.Default.WindowLocation;
|
||||||
|
|
||||||
// Set the window into position
|
// Set the window into position
|
||||||
Left = windowLocation.X;
|
Left = windowLocation.X;
|
||||||
Top = windowLocation.Y;
|
Top = windowLocation.Y;
|
||||||
|
|
||||||
// Get the last window size
|
// Get the last window size
|
||||||
Size windowSize = Settings.Default.WindowSize;
|
var windowSize = Settings.Default.WindowSize;
|
||||||
|
|
||||||
// Set the window into the previous size if it is valid
|
// Set the window into the previous size if it is valid
|
||||||
if (!windowSize.Width.Equals(0) && !windowSize.Height.Equals(0))
|
if (!windowSize.Width.Equals(0) && !windowSize.Height.Equals(0))
|
||||||
@@ -315,7 +313,7 @@ namespace FeedCenter
|
|||||||
private void InitializeFeed()
|
private void InitializeFeed()
|
||||||
{
|
{
|
||||||
// Cache the feed count to save (a little) time
|
// Cache the feed count to save (a little) time
|
||||||
int feedCount = _database.Feeds.Count();
|
var feedCount = _database.Feeds.Count();
|
||||||
|
|
||||||
// Set button states
|
// Set button states
|
||||||
previousToolbarButton.IsEnabled = (feedCount > 1);
|
previousToolbarButton.IsEnabled = (feedCount > 1);
|
||||||
@@ -343,7 +341,7 @@ namespace FeedCenter
|
|||||||
|
|
||||||
private void NextFeed()
|
private void NextFeed()
|
||||||
{
|
{
|
||||||
int feedCount = _database.Feeds.Count();
|
var feedCount = _database.Feeds.Count();
|
||||||
|
|
||||||
if (feedCount == 0)
|
if (feedCount == 0)
|
||||||
return;
|
return;
|
||||||
@@ -359,10 +357,10 @@ namespace FeedCenter
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Keep track if we found something
|
// Keep track if we found something
|
||||||
bool found = false;
|
var found = false;
|
||||||
|
|
||||||
// Remember our starting position
|
// Remember our starting position
|
||||||
int startIndex = (_feedIndex == -1 ? 0 : _feedIndex);
|
var startIndex = (_feedIndex == -1 ? 0 : _feedIndex);
|
||||||
|
|
||||||
// Increment the index and adjust if we've gone around the end
|
// Increment the index and adjust if we've gone around the end
|
||||||
_feedIndex = (_feedIndex + 1) % feedCount;
|
_feedIndex = (_feedIndex + 1) % feedCount;
|
||||||
@@ -402,7 +400,7 @@ namespace FeedCenter
|
|||||||
|
|
||||||
private void PreviousFeed()
|
private void PreviousFeed()
|
||||||
{
|
{
|
||||||
int feedCount = _database.Feeds.Count();
|
var feedCount = _database.Feeds.Count();
|
||||||
|
|
||||||
if (feedCount == 0)
|
if (feedCount == 0)
|
||||||
return;
|
return;
|
||||||
@@ -422,10 +420,10 @@ namespace FeedCenter
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Keep track if we found something
|
// Keep track if we found something
|
||||||
bool found = false;
|
var found = false;
|
||||||
|
|
||||||
// Remember our starting position
|
// Remember our starting position
|
||||||
int startIndex = (_feedIndex == -1 ? 0 : _feedIndex);
|
var startIndex = (_feedIndex == -1 ? 0 : _feedIndex);
|
||||||
|
|
||||||
// Decrement the feed index
|
// Decrement the feed index
|
||||||
_feedIndex--;
|
_feedIndex--;
|
||||||
@@ -473,7 +471,7 @@ namespace FeedCenter
|
|||||||
|
|
||||||
private void UpdateOpenAllButton()
|
private void UpdateOpenAllButton()
|
||||||
{
|
{
|
||||||
var multipleOpenAction = (MultipleOpenAction) _currentFeed.MultipleOpenAction;
|
var multipleOpenAction = _currentFeed.MultipleOpenAction;
|
||||||
|
|
||||||
switch (multipleOpenAction)
|
switch (multipleOpenAction)
|
||||||
{
|
{
|
||||||
@@ -509,7 +507,7 @@ namespace FeedCenter
|
|||||||
var sortedItems = _currentFeed.Items.Where(item => !item.BeenRead).OrderBy(item => item.Sequence);
|
var sortedItems = _currentFeed.Items.Where(item => !item.BeenRead).OrderBy(item => item.Sequence);
|
||||||
|
|
||||||
// Loop over all items in the current feed
|
// Loop over all items in the current feed
|
||||||
foreach (FeedItem feedItem in sortedItems)
|
foreach (var feedItem in sortedItems)
|
||||||
{
|
{
|
||||||
// Add the list item
|
// Add the list item
|
||||||
linkTextList.Items.Add(feedItem);
|
linkTextList.Items.Add(feedItem);
|
||||||
@@ -575,7 +573,7 @@ namespace FeedCenter
|
|||||||
SetProgressMode(true, 1);
|
SetProgressMode(true, 1);
|
||||||
|
|
||||||
// Create the input class
|
// Create the input class
|
||||||
FeedReadWorkerInput workerInput = new FeedReadWorkerInput { ForceRead = forceRead, Feed = _currentFeed };
|
var workerInput = new FeedReadWorkerInput { ForceRead = forceRead, Feed = _currentFeed };
|
||||||
|
|
||||||
// Start the worker
|
// Start the worker
|
||||||
_feedReadWorker.RunWorkerAsync(workerInput);
|
_feedReadWorker.RunWorkerAsync(workerInput);
|
||||||
@@ -595,7 +593,7 @@ namespace FeedCenter
|
|||||||
SetProgressMode(true, _database.Feeds.Count());
|
SetProgressMode(true, _database.Feeds.Count());
|
||||||
|
|
||||||
// Create the input class
|
// Create the input class
|
||||||
FeedReadWorkerInput workerInput = new FeedReadWorkerInput { ForceRead = forceRead, Feed = null };
|
var workerInput = new FeedReadWorkerInput { ForceRead = forceRead, Feed = null };
|
||||||
|
|
||||||
// Start the worker
|
// Start the worker
|
||||||
_feedReadWorker.RunWorkerAsync(workerInput);
|
_feedReadWorker.RunWorkerAsync(workerInput);
|
||||||
@@ -610,7 +608,7 @@ namespace FeedCenter
|
|||||||
private void HandleFeedReadWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
|
private void HandleFeedReadWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
|
||||||
{
|
{
|
||||||
// Get the state info
|
// Get the state info
|
||||||
FeedReadWorkerOutput workerOutput = (FeedReadWorkerOutput) e.Result;
|
var workerOutput = (FeedReadWorkerOutput) e.Result;
|
||||||
|
|
||||||
// Reset the database to current settings
|
// Reset the database to current settings
|
||||||
ResetDatabase();
|
ResetDatabase();
|
||||||
@@ -628,7 +626,7 @@ namespace FeedCenter
|
|||||||
SetProgressMode(false, 0);
|
SetProgressMode(false, 0);
|
||||||
|
|
||||||
// Check for update information
|
// Check for update information
|
||||||
UpdateCheckInfo updateCheckInfo = workerOutput.UpdateResult;
|
var updateCheckInfo = workerOutput.UpdateResult;
|
||||||
|
|
||||||
if (updateCheckInfo != null && updateCheckInfo.UpdateAvailable)
|
if (updateCheckInfo != null && updateCheckInfo.UpdateAvailable)
|
||||||
newVersionLink.Visibility = Visibility.Visible;
|
newVersionLink.Visibility = Visibility.Visible;
|
||||||
@@ -638,7 +636,7 @@ namespace FeedCenter
|
|||||||
|
|
||||||
private void UpdateErrorLink()
|
private void UpdateErrorLink()
|
||||||
{
|
{
|
||||||
var feedErrorCount = _database.Feeds.Count(f => f.LastReadResult != (int) FeedReadResult.Success);
|
var feedErrorCount = _database.Feeds.Count(f => f.LastReadResult != FeedReadResult.Success);
|
||||||
|
|
||||||
// Set the visibility of the error link
|
// Set the visibility of the error link
|
||||||
feedErrorsLink.Visibility = feedErrorCount == 0 ? Visibility.Collapsed : Visibility.Visible;
|
feedErrorsLink.Visibility = feedErrorCount == 0 ? Visibility.Collapsed : Visibility.Visible;
|
||||||
@@ -652,22 +650,22 @@ namespace FeedCenter
|
|||||||
private static void HandleFeedReadWorkerStart(object sender, DoWorkEventArgs e)
|
private static void HandleFeedReadWorkerStart(object sender, DoWorkEventArgs e)
|
||||||
{
|
{
|
||||||
// Create a new database instance for just this thread
|
// Create a new database instance for just this thread
|
||||||
FeedCenterEntities database = new FeedCenterEntities();
|
var database = new FeedCenterEntities();
|
||||||
|
|
||||||
// Get the worker
|
// Get the worker
|
||||||
BackgroundWorker worker = (BackgroundWorker) sender;
|
var worker = (BackgroundWorker) sender;
|
||||||
|
|
||||||
// Get the input information
|
// Get the input information
|
||||||
FeedReadWorkerInput workerInput = (FeedReadWorkerInput) e.Argument;
|
var workerInput = (FeedReadWorkerInput) e.Argument;
|
||||||
|
|
||||||
// Create the output
|
// Create the output
|
||||||
FeedReadWorkerOutput workerOutput = new FeedReadWorkerOutput();
|
var workerOutput = new FeedReadWorkerOutput();
|
||||||
|
|
||||||
// Setup for progress
|
// Setup for progress
|
||||||
int currentProgress = 0;
|
var currentProgress = 0;
|
||||||
|
|
||||||
// Create the list of feeds to read
|
// Create the list of feeds to read
|
||||||
List<Feed> feedsToRead = new List<Feed>();
|
var feedsToRead = new List<Feed>();
|
||||||
|
|
||||||
// If we have a single feed then add it to the list - otherwise add them all
|
// If we have a single feed then add it to the list - otherwise add them all
|
||||||
if (workerInput.Feed != null)
|
if (workerInput.Feed != null)
|
||||||
@@ -676,7 +674,7 @@ namespace FeedCenter
|
|||||||
feedsToRead.AddRange(database.Feeds);
|
feedsToRead.AddRange(database.Feeds);
|
||||||
|
|
||||||
// Loop over each feed and read it
|
// Loop over each feed and read it
|
||||||
foreach (Feed feed in feedsToRead)
|
foreach (var feed in feedsToRead)
|
||||||
{
|
{
|
||||||
// Read the feed
|
// Read the feed
|
||||||
feed.Read(database, workerInput.ForceRead);
|
feed.Read(database, workerInput.ForceRead);
|
||||||
@@ -743,10 +741,10 @@ namespace FeedCenter
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Pad the command line with a trailing space just to be lazy in parsing
|
// Pad the command line with a trailing space just to be lazy in parsing
|
||||||
string commandLine = e.Message + " ";
|
var commandLine = e.Message + " ";
|
||||||
|
|
||||||
// Look for the feed URL in the command line
|
// Look for the feed URL in the command line
|
||||||
int startPosition = commandLine.IndexOf("feed://", StringComparison.Ordinal);
|
var startPosition = commandLine.IndexOf("feed://", StringComparison.Ordinal);
|
||||||
|
|
||||||
// If we found one then we should extract and process it
|
// If we found one then we should extract and process it
|
||||||
if (startPosition > 0)
|
if (startPosition > 0)
|
||||||
@@ -755,10 +753,10 @@ namespace FeedCenter
|
|||||||
startPosition += 7;
|
startPosition += 7;
|
||||||
|
|
||||||
// Starting at the URL position look for the next space
|
// Starting at the URL position look for the next space
|
||||||
int endPosition = commandLine.IndexOf(" ", startPosition, StringComparison.Ordinal);
|
var endPosition = commandLine.IndexOf(" ", startPosition, StringComparison.Ordinal);
|
||||||
|
|
||||||
// Extract the feed URL
|
// Extract the feed URL
|
||||||
string feedUrl = commandLine.Substring(startPosition, endPosition - startPosition);
|
var feedUrl = commandLine.Substring(startPosition, endPosition - startPosition);
|
||||||
|
|
||||||
// Add the HTTP protocol by default
|
// Add the HTTP protocol by default
|
||||||
feedUrl = "http://" + feedUrl;
|
feedUrl = "http://" + feedUrl;
|
||||||
@@ -772,14 +770,12 @@ namespace FeedCenter
|
|||||||
private void HandleNewFeed(string feedUrl)
|
private void HandleNewFeed(string feedUrl)
|
||||||
{
|
{
|
||||||
// Create and configure the new feed
|
// Create and configure the new feed
|
||||||
Feed feed = new Feed
|
var feed = Feed.Create();
|
||||||
{
|
feed.Source = feedUrl;
|
||||||
Source = feedUrl,
|
feed.Category = _database.Categories.ToList().First(category => category.IsDefault);
|
||||||
Category = _database.Categories.ToList().First(category => category.IsDefault),
|
|
||||||
};
|
|
||||||
|
|
||||||
// Read the feed for the first time
|
// Read the feed for the first time
|
||||||
FeedReadResult feedReadResult = feed.Read(_database);
|
var feedReadResult = feed.Read(_database);
|
||||||
|
|
||||||
// See if we read the feed okay
|
// See if we read the feed okay
|
||||||
if (feedReadResult == FeedReadResult.Success)
|
if (feedReadResult == FeedReadResult.Success)
|
||||||
@@ -788,7 +784,7 @@ namespace FeedCenter
|
|||||||
feed.Name = feed.Title;
|
feed.Name = feed.Title;
|
||||||
|
|
||||||
// Add the feed to the feed table
|
// Add the feed to the feed table
|
||||||
_database.Feeds.AddObject(feed);
|
_database.Feeds.Add(feed);
|
||||||
|
|
||||||
// Save the changes
|
// Save the changes
|
||||||
_database.SaveChanges();
|
_database.SaveChanges();
|
||||||
@@ -802,15 +798,15 @@ namespace FeedCenter
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Feed read failed - ceate a new feed window
|
// Feed read failed - ceate a new feed window
|
||||||
FeedWindow feedForm = new FeedWindow();
|
var feedForm = new FeedWindow();
|
||||||
|
|
||||||
bool? dialogResult = feedForm.Display(_database, feed, this);
|
var dialogResult = feedForm.Display(_database, feed, this);
|
||||||
|
|
||||||
// Display the new feed form
|
// Display the new feed form
|
||||||
if (dialogResult.HasValue && dialogResult.Value)
|
if (dialogResult.HasValue && dialogResult.Value)
|
||||||
{
|
{
|
||||||
// Add the feed to the feed table
|
// Add the feed to the feed table
|
||||||
_database.Feeds.AddObject(feed);
|
_database.Feeds.Add(feed);
|
||||||
|
|
||||||
// Save the changes
|
// Save the changes
|
||||||
_database.SaveChanges();
|
_database.SaveChanges();
|
||||||
@@ -828,7 +824,7 @@ namespace FeedCenter
|
|||||||
private void ResetDatabase()
|
private void ResetDatabase()
|
||||||
{
|
{
|
||||||
// Get the ID of the current feed
|
// Get the ID of the current feed
|
||||||
Guid currentId = _currentFeed.ID;
|
var currentId = _currentFeed.ID;
|
||||||
|
|
||||||
// Create a new database object
|
// Create a new database object
|
||||||
_database = new FeedCenterEntities();
|
_database = new FeedCenterEntities();
|
||||||
@@ -872,7 +868,7 @@ namespace FeedCenter
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Get the data as a string
|
// Get the data as a string
|
||||||
string data = (string) e.Data.GetData(DataFormats.Text);
|
var data = (string) e.Data.GetData(DataFormats.Text);
|
||||||
|
|
||||||
// If the data doesn't look like a URI then it is not allowed
|
// If the data doesn't look like a URI then it is not allowed
|
||||||
if (!Uri.IsWellFormedUriString(data, UriKind.Absolute))
|
if (!Uri.IsWellFormedUriString(data, UriKind.Absolute))
|
||||||
@@ -885,7 +881,7 @@ namespace FeedCenter
|
|||||||
private void HandleDragDrop(object sender, DragEventArgs e)
|
private void HandleDragDrop(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
// Get the data as a string
|
// Get the data as a string
|
||||||
string data = (string) e.Data.GetData(DataFormats.Text);
|
var data = (string) e.Data.GetData(DataFormats.Text);
|
||||||
|
|
||||||
// Handle the new feed but allow the drag/drop to complete
|
// Handle the new feed but allow the drag/drop to complete
|
||||||
Dispatcher.BeginInvoke(new NewFeedDelegate(HandleNewFeed), data);
|
Dispatcher.BeginInvoke(new NewFeedDelegate(HandleNewFeed), data);
|
||||||
@@ -918,7 +914,7 @@ namespace FeedCenter
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Get the feed item
|
// Get the feed item
|
||||||
FeedItem feedItem = (FeedItem) ((ListBoxItem) sender).DataContext;
|
var feedItem = (FeedItem) ((ListBoxItem) sender).DataContext;
|
||||||
|
|
||||||
// The feed item has been read and is no longer new
|
// The feed item has been read and is no longer new
|
||||||
feedItem.BeenRead = true;
|
feedItem.BeenRead = true;
|
||||||
@@ -935,7 +931,7 @@ namespace FeedCenter
|
|||||||
private void HandleLinkTextListListItemMouseDoubleClick(object sender, MouseButtonEventArgs e)
|
private void HandleLinkTextListListItemMouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
// Get the feed item
|
// Get the feed item
|
||||||
FeedItem feedItem = (FeedItem) ((ListBoxItem) sender).DataContext;
|
var feedItem = (FeedItem) ((ListBoxItem) sender).DataContext;
|
||||||
|
|
||||||
// Open the item link
|
// Open the item link
|
||||||
if (BrowserCommon.OpenLink(feedItem.Link))
|
if (BrowserCommon.OpenLink(feedItem.Link))
|
||||||
@@ -959,16 +955,16 @@ namespace FeedCenter
|
|||||||
private void HandleFeedButtonClick(object sender, RoutedEventArgs e)
|
private void HandleFeedButtonClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
// Create a new context menu
|
// Create a new context menu
|
||||||
ContextMenu contextMenu = new ContextMenu();
|
var contextMenu = new ContextMenu();
|
||||||
|
|
||||||
// Loop over each feed
|
// Loop over each feed
|
||||||
foreach (Feed feed in _database.Feeds.OrderBy(feed => feed.Name))
|
foreach (var feed in _database.Feeds.OrderBy(feed => feed.Name))
|
||||||
{
|
{
|
||||||
// Build a string to display the feed name and the unread count
|
// Build a string to display the feed name and the unread count
|
||||||
string display = string.Format("{0} ({1:d})", feed.Name, feed.Items.Count(item => !item.BeenRead));
|
var display = string.Format("{0} ({1:d})", feed.Name, feed.Items.Count(item => !item.BeenRead));
|
||||||
|
|
||||||
// Create a menu item
|
// Create a menu item
|
||||||
MenuItem menuItem = new MenuItem
|
var menuItem = new MenuItem
|
||||||
{
|
{
|
||||||
Header = display,
|
Header = display,
|
||||||
Tag = feed,
|
Tag = feed,
|
||||||
@@ -995,14 +991,14 @@ namespace FeedCenter
|
|||||||
private void HandleFeedMenuItemClick(object sender, RoutedEventArgs e)
|
private void HandleFeedMenuItemClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
// Get the menu item clicked
|
// Get the menu item clicked
|
||||||
MenuItem menuItem = (MenuItem) sender;
|
var menuItem = (MenuItem) sender;
|
||||||
|
|
||||||
// Get the feed from the menu item tab
|
// Get the feed from the menu item tab
|
||||||
Feed feed = (Feed) menuItem.Tag;
|
var feed = (Feed) menuItem.Tag;
|
||||||
|
|
||||||
// Loop over all feeds and look for the index of the new one
|
// Loop over all feeds and look for the index of the new one
|
||||||
int feedIndex = 0;
|
var feedIndex = 0;
|
||||||
foreach (Feed loopFeed in _database.Feeds.OrderBy(loopFeed => loopFeed.Name))
|
foreach (var loopFeed in _database.Feeds.OrderBy(loopFeed => loopFeed.Name))
|
||||||
{
|
{
|
||||||
if (loopFeed == feed)
|
if (loopFeed == feed)
|
||||||
{
|
{
|
||||||
@@ -1029,11 +1025,11 @@ namespace FeedCenter
|
|||||||
|
|
||||||
private void UpdateBorder()
|
private void UpdateBorder()
|
||||||
{
|
{
|
||||||
WindowInteropHelper windowInteropHelper = new WindowInteropHelper(this);
|
var windowInteropHelper = new WindowInteropHelper(this);
|
||||||
|
|
||||||
System.Windows.Forms.Screen screen = System.Windows.Forms.Screen.FromHandle(windowInteropHelper.Handle);
|
var screen = System.Windows.Forms.Screen.FromHandle(windowInteropHelper.Handle);
|
||||||
|
|
||||||
System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle
|
var rectangle = new System.Drawing.Rectangle
|
||||||
{
|
{
|
||||||
X = (int) Left,
|
X = (int) Left,
|
||||||
Y = (int) Top,
|
Y = (int) Top,
|
||||||
@@ -1041,7 +1037,7 @@ namespace FeedCenter
|
|||||||
Height = (int) Height
|
Height = (int) Height
|
||||||
};
|
};
|
||||||
|
|
||||||
Thickness borderThickness = new Thickness();
|
var borderThickness = new Thickness();
|
||||||
|
|
||||||
if (rectangle.Right != screen.WorkingArea.Right)
|
if (rectangle.Right != screen.WorkingArea.Right)
|
||||||
borderThickness.Right = 1;
|
borderThickness.Right = 1;
|
||||||
@@ -1116,16 +1112,16 @@ namespace FeedCenter
|
|||||||
var feedItems = (from FeedItem feedItem in linkTextList.Items select feedItem).ToList();
|
var feedItems = (from FeedItem feedItem in linkTextList.Items select feedItem).ToList();
|
||||||
|
|
||||||
// Get the browser
|
// Get the browser
|
||||||
Browser browser = BrowserCommon.FindBrowser(Settings.Default.Browser);
|
var browser = BrowserCommon.FindBrowser(Settings.Default.Browser);
|
||||||
|
|
||||||
// Cache the settings object
|
// Cache the settings object
|
||||||
var settings = Settings.Default;
|
var settings = Settings.Default;
|
||||||
|
|
||||||
// Start with a longer sleep interval to give time for the browser to come up
|
// Start with a longer sleep interval to give time for the browser to come up
|
||||||
int sleepInterval = settings.OpenAllSleepIntervalFirst;
|
var sleepInterval = settings.OpenAllSleepIntervalFirst;
|
||||||
|
|
||||||
// Loop over all items
|
// Loop over all items
|
||||||
foreach (FeedItem feedItem in feedItems)
|
foreach (var feedItem in feedItems)
|
||||||
{
|
{
|
||||||
// Try to open the link
|
// Try to open the link
|
||||||
if (BrowserCommon.OpenLink(browser, feedItem.Link))
|
if (BrowserCommon.OpenLink(browser, feedItem.Link))
|
||||||
@@ -1151,10 +1147,10 @@ namespace FeedCenter
|
|||||||
private void HandleOptionsToolbarButtonClick(object sender, RoutedEventArgs e)
|
private void HandleOptionsToolbarButtonClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
// Create the options form
|
// Create the options form
|
||||||
OptionsWindow optionsWindow = new OptionsWindow { Owner = this };
|
var optionsWindow = new OptionsWindow { Owner = this };
|
||||||
|
|
||||||
// Show the options form and get the result
|
// Show the options form and get the result
|
||||||
bool? result = optionsWindow.ShowDialog();
|
var result = optionsWindow.ShowDialog();
|
||||||
|
|
||||||
// If okay was selected
|
// If okay was selected
|
||||||
if (result.HasValue && result.Value)
|
if (result.HasValue && result.Value)
|
||||||
@@ -1175,10 +1171,10 @@ namespace FeedCenter
|
|||||||
private void HandleShowErrorsButtonClick(object sender, RoutedEventArgs e)
|
private void HandleShowErrorsButtonClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
// Create the feed error window
|
// Create the feed error window
|
||||||
FeedErrorWindow feedErrorWindow = new FeedErrorWindow();
|
var feedErrorWindow = new FeedErrorWindow();
|
||||||
|
|
||||||
// Display the window
|
// Display the window
|
||||||
bool? result = feedErrorWindow.Display(this);
|
var result = feedErrorWindow.Display(this);
|
||||||
|
|
||||||
// If okay was selected
|
// If okay was selected
|
||||||
if (result.GetValueOrDefault())
|
if (result.GetValueOrDefault())
|
||||||
@@ -1195,11 +1191,11 @@ namespace FeedCenter
|
|||||||
|
|
||||||
private void HandleRefreshMenuItemClick(object sender, RoutedEventArgs e)
|
private void HandleRefreshMenuItemClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
MenuItem menuItem = (MenuItem) e.Source;
|
var menuItem = (MenuItem) e.Source;
|
||||||
|
|
||||||
if (menuItem == menuRefresh)
|
if (Equals(menuItem, menuRefresh))
|
||||||
ReadCurrentFeed(true);
|
ReadCurrentFeed(true);
|
||||||
else if (menuItem == menuRefreshAll)
|
else if (Equals(menuItem, menuRefreshAll))
|
||||||
ReadFeeds(true);
|
ReadFeeds(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1210,11 +1206,11 @@ namespace FeedCenter
|
|||||||
|
|
||||||
private void HandleOpenAllMenuItemClick(object sender, RoutedEventArgs e)
|
private void HandleOpenAllMenuItemClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
MenuItem menuItem = (MenuItem) e.Source;
|
var menuItem = (MenuItem) e.Source;
|
||||||
|
|
||||||
if (menuItem == menuOpenAllSinglePage)
|
if (Equals(menuItem, menuOpenAllSinglePage))
|
||||||
OpenAllFeedItemsOnSinglePage();
|
OpenAllFeedItemsOnSinglePage();
|
||||||
else if (menuItem == menuOpenAllMultiplePages)
|
else if (Equals(menuItem, menuOpenAllMultiplePages))
|
||||||
OpenAllFeedItemsIndividually();
|
OpenAllFeedItemsIndividually();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1236,10 +1232,10 @@ namespace FeedCenter
|
|||||||
private void HandleEditCurrentFeedMenuItemClick(object sender, RoutedEventArgs e)
|
private void HandleEditCurrentFeedMenuItemClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
// Create a new feed window
|
// Create a new feed window
|
||||||
FeedWindow feedWindow = new FeedWindow();
|
var feedWindow = new FeedWindow();
|
||||||
|
|
||||||
// Display the feed window and get the result
|
// Display the feed window and get the result
|
||||||
bool? result = feedWindow.Display(_database, _currentFeed, this);
|
var result = feedWindow.Display(_database, _currentFeed, this);
|
||||||
|
|
||||||
// If OK was clicked...
|
// If OK was clicked...
|
||||||
if (result.HasValue && result.Value)
|
if (result.HasValue && result.Value)
|
||||||
@@ -1259,17 +1255,17 @@ namespace FeedCenter
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Get the current feed
|
// Get the current feed
|
||||||
Feed feedToDelete = _currentFeed;
|
var feedToDelete = _currentFeed;
|
||||||
|
|
||||||
// Move to the next feed
|
// Move to the next feed
|
||||||
NextFeed();
|
NextFeed();
|
||||||
|
|
||||||
// Delete all items
|
// Delete all items
|
||||||
foreach (var item in feedToDelete.Items.ToList())
|
foreach (var item in feedToDelete.Items.ToList())
|
||||||
_database.FeedItems.DeleteObject(item);
|
_database.FeedItems.Remove(item);
|
||||||
|
|
||||||
// Delete the feed
|
// Delete the feed
|
||||||
_database.Feeds.DeleteObject(feedToDelete);
|
_database.Feeds.Remove(feedToDelete);
|
||||||
|
|
||||||
// Save
|
// Save
|
||||||
_database.SaveChanges();
|
_database.SaveChanges();
|
||||||
@@ -1281,10 +1277,10 @@ namespace FeedCenter
|
|||||||
|
|
||||||
private void OpenAllFeedItemsOnSinglePage()
|
private void OpenAllFeedItemsOnSinglePage()
|
||||||
{
|
{
|
||||||
string fileName = Path.GetTempFileName() + ".html";
|
var fileName = Path.GetTempFileName() + ".html";
|
||||||
TextWriter textWriter = new StreamWriter(fileName);
|
TextWriter textWriter = new StreamWriter(fileName);
|
||||||
|
|
||||||
using (HtmlTextWriter htmlTextWriter = new HtmlTextWriter(textWriter))
|
using (var htmlTextWriter = new HtmlTextWriter(textWriter))
|
||||||
{
|
{
|
||||||
htmlTextWriter.RenderBeginTag(HtmlTextWriterTag.Html);
|
htmlTextWriter.RenderBeginTag(HtmlTextWriterTag.Html);
|
||||||
|
|
||||||
@@ -1305,7 +1301,7 @@ namespace FeedCenter
|
|||||||
|
|
||||||
var sortedItems = from item in _currentFeed.Items where !item.BeenRead orderby item.Sequence ascending select item;
|
var sortedItems = from item in _currentFeed.Items where !item.BeenRead orderby item.Sequence ascending select item;
|
||||||
|
|
||||||
bool firstItem = true;
|
var firstItem = true;
|
||||||
|
|
||||||
foreach (var item in sortedItems)
|
foreach (var item in sortedItems)
|
||||||
{
|
{
|
||||||
@@ -1351,28 +1347,5 @@ namespace FeedCenter
|
|||||||
// Display update information
|
// Display update information
|
||||||
VersionCheck.DisplayUpdateInformation(true);
|
VersionCheck.DisplayUpdateInformation(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Hover selection events
|
|
||||||
|
|
||||||
private void HandleListItemMouseEnter(object sender, MouseEventArgs e)
|
|
||||||
{
|
|
||||||
// Get the list box item
|
|
||||||
ListBoxItem listBoxItem = (ListBoxItem) sender;
|
|
||||||
|
|
||||||
// Select the data context
|
|
||||||
linkTextList.SelectedItem = listBoxItem.DataContext;
|
|
||||||
|
|
||||||
// Set the cursor
|
|
||||||
listBoxItem.Cursor = Cursors.Hand;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void HandleListItemMouseLeave(object sender, MouseEventArgs e)
|
|
||||||
{
|
|
||||||
// Clear selection
|
|
||||||
linkTextList.SelectedItem = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
34
Model.Context.cs
Normal file
34
Model.Context.cs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated from a template.
|
||||||
|
//
|
||||||
|
// Manual changes to this file may cause unexpected behavior in your application.
|
||||||
|
// Manual changes to this file will be overwritten if the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace FeedCenter
|
||||||
|
{
|
||||||
|
using System;
|
||||||
|
using System.Data.Entity;
|
||||||
|
using System.Data.Entity.Infrastructure;
|
||||||
|
|
||||||
|
public partial class FeedCenterEntities : DbContext
|
||||||
|
{
|
||||||
|
public FeedCenterEntities()
|
||||||
|
: base("name=FeedCenterEntities")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnModelCreating(DbModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
throw new UnintentionalCodeFirstException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual DbSet<Category> Categories { get; set; }
|
||||||
|
public virtual DbSet<Feed> Feeds { get; set; }
|
||||||
|
public virtual DbSet<FeedAction> FeedActions { get; set; }
|
||||||
|
public virtual DbSet<FeedItem> FeedItems { get; set; }
|
||||||
|
public virtual DbSet<Setting> Settings { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
636
Model.Context.tt
Normal file
636
Model.Context.tt
Normal file
@@ -0,0 +1,636 @@
|
|||||||
|
<#@ template language="C#" debug="false" hostspecific="true"#>
|
||||||
|
<#@ include file="EF6.Utility.CS.ttinclude"#><#@
|
||||||
|
output extension=".cs"#><#
|
||||||
|
|
||||||
|
const string inputFile = @"Model.edmx";
|
||||||
|
var textTransform = DynamicTextTransformation.Create(this);
|
||||||
|
var code = new CodeGenerationTools(this);
|
||||||
|
var ef = new MetadataTools(this);
|
||||||
|
var typeMapper = new TypeMapper(code, ef, textTransform.Errors);
|
||||||
|
var loader = new EdmMetadataLoader(textTransform.Host, textTransform.Errors);
|
||||||
|
var itemCollection = loader.CreateEdmItemCollection(inputFile);
|
||||||
|
var modelNamespace = loader.GetModelNamespace(inputFile);
|
||||||
|
var codeStringGenerator = new CodeStringGenerator(code, typeMapper, ef);
|
||||||
|
|
||||||
|
var container = itemCollection.OfType<EntityContainer>().FirstOrDefault();
|
||||||
|
if (container == null)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1")#>
|
||||||
|
//
|
||||||
|
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2")#>
|
||||||
|
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3")#>
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
<#
|
||||||
|
|
||||||
|
var codeNamespace = code.VsNamespaceSuggestion();
|
||||||
|
if (!String.IsNullOrEmpty(codeNamespace))
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
namespace <#=code.EscapeNamespace(codeNamespace)#>
|
||||||
|
{
|
||||||
|
<#
|
||||||
|
PushIndent(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
#>
|
||||||
|
using System;
|
||||||
|
using System.Data.Entity;
|
||||||
|
using System.Data.Entity.Infrastructure;
|
||||||
|
<#
|
||||||
|
if (container.FunctionImports.Any())
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
using System.Data.Entity.Core.Objects;
|
||||||
|
using System.Linq;
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
|
||||||
|
<#=Accessibility.ForType(container)#> partial class <#=code.Escape(container)#> : DbContext
|
||||||
|
{
|
||||||
|
public <#=code.Escape(container)#>()
|
||||||
|
: base("name=<#=container.Name#>")
|
||||||
|
{
|
||||||
|
<#
|
||||||
|
if (!loader.IsLazyLoadingEnabled(container))
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
this.Configuration.LazyLoadingEnabled = false;
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var entitySet in container.BaseEntitySets.OfType<EntitySet>())
|
||||||
|
{
|
||||||
|
// Note: the DbSet members are defined below such that the getter and
|
||||||
|
// setter always have the same accessibility as the DbSet definition
|
||||||
|
if (Accessibility.ForReadOnlyProperty(entitySet) != "public")
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
<#=codeStringGenerator.DbSetInitializer(entitySet)#>
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnModelCreating(DbModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
throw new UnintentionalCodeFirstException();
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
foreach (var entitySet in container.BaseEntitySets.OfType<EntitySet>())
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
<#=codeStringGenerator.DbSet(entitySet)#>
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var edmFunction in container.FunctionImports)
|
||||||
|
{
|
||||||
|
WriteFunctionImport(typeMapper, codeStringGenerator, edmFunction, modelNamespace, includeMergeOption: false);
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
}
|
||||||
|
<#
|
||||||
|
|
||||||
|
if (!String.IsNullOrEmpty(codeNamespace))
|
||||||
|
{
|
||||||
|
PopIndent();
|
||||||
|
#>
|
||||||
|
}
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
<#+
|
||||||
|
|
||||||
|
private void WriteFunctionImport(TypeMapper typeMapper, CodeStringGenerator codeStringGenerator, EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||||
|
{
|
||||||
|
if (typeMapper.IsComposable(edmFunction))
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
|
||||||
|
[DbFunction("<#=edmFunction.NamespaceName#>", "<#=edmFunction.Name#>")]
|
||||||
|
<#=codeStringGenerator.ComposableFunctionMethod(edmFunction, modelNamespace)#>
|
||||||
|
{
|
||||||
|
<#+
|
||||||
|
codeStringGenerator.WriteFunctionParameters(edmFunction, WriteFunctionParameter);
|
||||||
|
#>
|
||||||
|
<#=codeStringGenerator.ComposableCreateQuery(edmFunction, modelNamespace)#>
|
||||||
|
}
|
||||||
|
<#+
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
|
||||||
|
<#=codeStringGenerator.FunctionMethod(edmFunction, modelNamespace, includeMergeOption)#>
|
||||||
|
{
|
||||||
|
<#+
|
||||||
|
codeStringGenerator.WriteFunctionParameters(edmFunction, WriteFunctionParameter);
|
||||||
|
#>
|
||||||
|
<#=codeStringGenerator.ExecuteFunction(edmFunction, modelNamespace, includeMergeOption)#>
|
||||||
|
}
|
||||||
|
<#+
|
||||||
|
if (typeMapper.GenerateMergeOptionFunction(edmFunction, includeMergeOption))
|
||||||
|
{
|
||||||
|
WriteFunctionImport(typeMapper, codeStringGenerator, edmFunction, modelNamespace, includeMergeOption: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void WriteFunctionParameter(string name, string isNotNull, string notNullInit, string nullInit)
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
var <#=name#> = <#=isNotNull#> ?
|
||||||
|
<#=notNullInit#> :
|
||||||
|
<#=nullInit#>;
|
||||||
|
|
||||||
|
<#+
|
||||||
|
}
|
||||||
|
|
||||||
|
public const string TemplateId = "CSharp_DbContext_Context_EF6";
|
||||||
|
|
||||||
|
public class CodeStringGenerator
|
||||||
|
{
|
||||||
|
private readonly CodeGenerationTools _code;
|
||||||
|
private readonly TypeMapper _typeMapper;
|
||||||
|
private readonly MetadataTools _ef;
|
||||||
|
|
||||||
|
public CodeStringGenerator(CodeGenerationTools code, TypeMapper typeMapper, MetadataTools ef)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(code, "code");
|
||||||
|
ArgumentNotNull(typeMapper, "typeMapper");
|
||||||
|
ArgumentNotNull(ef, "ef");
|
||||||
|
|
||||||
|
_code = code;
|
||||||
|
_typeMapper = typeMapper;
|
||||||
|
_ef = ef;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Property(EdmProperty edmProperty)
|
||||||
|
{
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} {1} {2} {{ {3}get; {4}set; }}",
|
||||||
|
Accessibility.ForProperty(edmProperty),
|
||||||
|
_typeMapper.GetTypeName(edmProperty.TypeUsage),
|
||||||
|
_code.Escape(edmProperty),
|
||||||
|
_code.SpaceAfter(Accessibility.ForGetter(edmProperty)),
|
||||||
|
_code.SpaceAfter(Accessibility.ForSetter(edmProperty)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string NavigationProperty(NavigationProperty navProp)
|
||||||
|
{
|
||||||
|
var endType = _typeMapper.GetTypeName(navProp.ToEndMember.GetEntityType());
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} {1} {2} {{ {3}get; {4}set; }}",
|
||||||
|
AccessibilityAndVirtual(Accessibility.ForNavigationProperty(navProp)),
|
||||||
|
navProp.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType,
|
||||||
|
_code.Escape(navProp),
|
||||||
|
_code.SpaceAfter(Accessibility.ForGetter(navProp)),
|
||||||
|
_code.SpaceAfter(Accessibility.ForSetter(navProp)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string AccessibilityAndVirtual(string accessibility)
|
||||||
|
{
|
||||||
|
return accessibility + (accessibility != "private" ? " virtual" : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public string EntityClassOpening(EntityType entity)
|
||||||
|
{
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} {1}partial class {2}{3}",
|
||||||
|
Accessibility.ForType(entity),
|
||||||
|
_code.SpaceAfter(_code.AbstractOption(entity)),
|
||||||
|
_code.Escape(entity),
|
||||||
|
_code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string EnumOpening(SimpleType enumType)
|
||||||
|
{
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} enum {1} : {2}",
|
||||||
|
Accessibility.ForType(enumType),
|
||||||
|
_code.Escape(enumType),
|
||||||
|
_code.Escape(_typeMapper.UnderlyingClrType(enumType)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void WriteFunctionParameters(EdmFunction edmFunction, Action<string, string, string, string> writeParameter)
|
||||||
|
{
|
||||||
|
var parameters = FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
|
||||||
|
foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable))
|
||||||
|
{
|
||||||
|
var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null";
|
||||||
|
var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")";
|
||||||
|
var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + TypeMapper.FixNamespaces(parameter.RawClrTypeName) + "))";
|
||||||
|
writeParameter(parameter.LocalVariableName, isNotNull, notNullInit, nullInit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ComposableFunctionMethod(EdmFunction edmFunction, string modelNamespace)
|
||||||
|
{
|
||||||
|
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||||
|
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} IQueryable<{1}> {2}({3})",
|
||||||
|
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
|
||||||
|
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
|
||||||
|
_code.Escape(edmFunction),
|
||||||
|
string.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ComposableCreateQuery(EdmFunction edmFunction, string modelNamespace)
|
||||||
|
{
|
||||||
|
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||||
|
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<{0}>(\"[{1}].[{2}]({3})\"{4});",
|
||||||
|
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
|
||||||
|
edmFunction.NamespaceName,
|
||||||
|
edmFunction.Name,
|
||||||
|
string.Join(", ", parameters.Select(p => "@" + p.EsqlParameterName).ToArray()),
|
||||||
|
_code.StringBefore(", ", string.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray())));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string FunctionMethod(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||||
|
{
|
||||||
|
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||||
|
var returnType = _typeMapper.GetReturnType(edmFunction);
|
||||||
|
|
||||||
|
var paramList = String.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray());
|
||||||
|
if (includeMergeOption)
|
||||||
|
{
|
||||||
|
paramList = _code.StringAfter(paramList, ", ") + "MergeOption mergeOption";
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} {1} {2}({3})",
|
||||||
|
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
|
||||||
|
returnType == null ? "int" : "ObjectResult<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
|
||||||
|
_code.Escape(edmFunction),
|
||||||
|
paramList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||||
|
{
|
||||||
|
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||||
|
var returnType = _typeMapper.GetReturnType(edmFunction);
|
||||||
|
|
||||||
|
var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()));
|
||||||
|
if (includeMergeOption)
|
||||||
|
{
|
||||||
|
callParams = ", mergeOption" + callParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});",
|
||||||
|
returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
|
||||||
|
edmFunction.Name,
|
||||||
|
callParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string DbSet(EntitySet entitySet)
|
||||||
|
{
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} virtual DbSet<{1}> {2} {{ get; set; }}",
|
||||||
|
Accessibility.ForReadOnlyProperty(entitySet),
|
||||||
|
_typeMapper.GetTypeName(entitySet.ElementType),
|
||||||
|
_code.Escape(entitySet));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string DbSetInitializer(EntitySet entitySet)
|
||||||
|
{
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} = Set<{1}>();",
|
||||||
|
_code.Escape(entitySet),
|
||||||
|
_typeMapper.GetTypeName(entitySet.ElementType));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string UsingDirectives(bool inHeader, bool includeCollections = true)
|
||||||
|
{
|
||||||
|
return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion())
|
||||||
|
? string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0}using System;{1}" +
|
||||||
|
"{2}",
|
||||||
|
inHeader ? Environment.NewLine : "",
|
||||||
|
includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "",
|
||||||
|
inHeader ? "" : Environment.NewLine)
|
||||||
|
: "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TypeMapper
|
||||||
|
{
|
||||||
|
private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName";
|
||||||
|
|
||||||
|
private readonly System.Collections.IList _errors;
|
||||||
|
private readonly CodeGenerationTools _code;
|
||||||
|
private readonly MetadataTools _ef;
|
||||||
|
|
||||||
|
public static string FixNamespaces(string typeName)
|
||||||
|
{
|
||||||
|
return typeName.Replace("System.Data.Spatial.", "System.Data.Entity.Spatial.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public TypeMapper(CodeGenerationTools code, MetadataTools ef, System.Collections.IList errors)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(code, "code");
|
||||||
|
ArgumentNotNull(ef, "ef");
|
||||||
|
ArgumentNotNull(errors, "errors");
|
||||||
|
|
||||||
|
_code = code;
|
||||||
|
_ef = ef;
|
||||||
|
_errors = errors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetTypeName(TypeUsage typeUsage)
|
||||||
|
{
|
||||||
|
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetTypeName(EdmType edmType)
|
||||||
|
{
|
||||||
|
return GetTypeName(edmType, isNullable: null, modelNamespace: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetTypeName(TypeUsage typeUsage, string modelNamespace)
|
||||||
|
{
|
||||||
|
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetTypeName(EdmType edmType, string modelNamespace)
|
||||||
|
{
|
||||||
|
return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace)
|
||||||
|
{
|
||||||
|
if (edmType == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var collectionType = edmType as CollectionType;
|
||||||
|
if (collectionType != null)
|
||||||
|
{
|
||||||
|
return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace));
|
||||||
|
}
|
||||||
|
|
||||||
|
var typeName = _code.Escape(edmType.MetadataProperties
|
||||||
|
.Where(p => p.Name == ExternalTypeNameAttributeName)
|
||||||
|
.Select(p => (string)p.Value)
|
||||||
|
.FirstOrDefault())
|
||||||
|
?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ?
|
||||||
|
_code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) :
|
||||||
|
_code.Escape(edmType));
|
||||||
|
|
||||||
|
if (edmType is StructuralType)
|
||||||
|
{
|
||||||
|
return typeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (edmType is SimpleType)
|
||||||
|
{
|
||||||
|
var clrType = UnderlyingClrType(edmType);
|
||||||
|
if (!IsEnumType(edmType))
|
||||||
|
{
|
||||||
|
typeName = _code.Escape(clrType);
|
||||||
|
}
|
||||||
|
|
||||||
|
typeName = FixNamespaces(typeName);
|
||||||
|
|
||||||
|
return clrType.IsValueType && isNullable == true ?
|
||||||
|
String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) :
|
||||||
|
typeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ArgumentException("edmType");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type UnderlyingClrType(EdmType edmType)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(edmType, "edmType");
|
||||||
|
|
||||||
|
var primitiveType = edmType as PrimitiveType;
|
||||||
|
if (primitiveType != null)
|
||||||
|
{
|
||||||
|
return primitiveType.ClrEquivalentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsEnumType(edmType))
|
||||||
|
{
|
||||||
|
return GetEnumUnderlyingType(edmType).ClrEquivalentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
return typeof(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
public object GetEnumMemberValue(MetadataItem enumMember)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(enumMember, "enumMember");
|
||||||
|
|
||||||
|
var valueProperty = enumMember.GetType().GetProperty("Value");
|
||||||
|
return valueProperty == null ? null : valueProperty.GetValue(enumMember, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetEnumMemberName(MetadataItem enumMember)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(enumMember, "enumMember");
|
||||||
|
|
||||||
|
var nameProperty = enumMember.GetType().GetProperty("Name");
|
||||||
|
return nameProperty == null ? null : (string)nameProperty.GetValue(enumMember, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public System.Collections.IEnumerable GetEnumMembers(EdmType enumType)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(enumType, "enumType");
|
||||||
|
|
||||||
|
var membersProperty = enumType.GetType().GetProperty("Members");
|
||||||
|
return membersProperty != null
|
||||||
|
? (System.Collections.IEnumerable)membersProperty.GetValue(enumType, null)
|
||||||
|
: Enumerable.Empty<MetadataItem>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool EnumIsFlags(EdmType enumType)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(enumType, "enumType");
|
||||||
|
|
||||||
|
var isFlagsProperty = enumType.GetType().GetProperty("IsFlags");
|
||||||
|
return isFlagsProperty != null && (bool)isFlagsProperty.GetValue(enumType, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsEnumType(GlobalItem edmType)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(edmType, "edmType");
|
||||||
|
|
||||||
|
return edmType.GetType().Name == "EnumType";
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrimitiveType GetEnumUnderlyingType(EdmType enumType)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(enumType, "enumType");
|
||||||
|
|
||||||
|
return (PrimitiveType)enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string CreateLiteral(object value)
|
||||||
|
{
|
||||||
|
if (value == null || value.GetType() != typeof(TimeSpan))
|
||||||
|
{
|
||||||
|
return _code.CreateLiteral(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan)value).Ticks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable<string> types, string sourceFile)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(types, "types");
|
||||||
|
ArgumentNotNull(sourceFile, "sourceFile");
|
||||||
|
|
||||||
|
var hash = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
|
||||||
|
if (types.Any(item => !hash.Add(item)))
|
||||||
|
{
|
||||||
|
_errors.Add(
|
||||||
|
new CompilerError(sourceFile, -1, -1, "6023",
|
||||||
|
String.Format(CultureInfo.CurrentCulture, CodeGenerationTools.GetResourceString("Template_CaseInsensitiveTypeConflict"))));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<SimpleType> GetEnumItemsToGenerate(IEnumerable<GlobalItem> itemCollection)
|
||||||
|
{
|
||||||
|
return GetItemsToGenerate<SimpleType>(itemCollection)
|
||||||
|
.Where(e => IsEnumType(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<T> GetItemsToGenerate<T>(IEnumerable<GlobalItem> itemCollection) where T: EdmType
|
||||||
|
{
|
||||||
|
return itemCollection
|
||||||
|
.OfType<T>()
|
||||||
|
.Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName))
|
||||||
|
.OrderBy(i => i.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<string> GetAllGlobalItems(IEnumerable<GlobalItem> itemCollection)
|
||||||
|
{
|
||||||
|
return itemCollection
|
||||||
|
.Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i))
|
||||||
|
.Select(g => GetGlobalItemName(g));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetGlobalItemName(GlobalItem item)
|
||||||
|
{
|
||||||
|
if (item is EdmType)
|
||||||
|
{
|
||||||
|
return ((EdmType)item).Name;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ((EntityContainer)item).Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<EdmProperty> GetSimpleProperties(EntityType type)
|
||||||
|
{
|
||||||
|
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<EdmProperty> GetSimpleProperties(ComplexType type)
|
||||||
|
{
|
||||||
|
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<EdmProperty> GetComplexProperties(EntityType type)
|
||||||
|
{
|
||||||
|
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<EdmProperty> GetComplexProperties(ComplexType type)
|
||||||
|
{
|
||||||
|
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(EntityType type)
|
||||||
|
{
|
||||||
|
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(ComplexType type)
|
||||||
|
{
|
||||||
|
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<NavigationProperty> GetNavigationProperties(EntityType type)
|
||||||
|
{
|
||||||
|
return type.NavigationProperties.Where(np => np.DeclaringType == type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<NavigationProperty> GetCollectionNavigationProperties(EntityType type)
|
||||||
|
{
|
||||||
|
return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FunctionParameter GetReturnParameter(EdmFunction edmFunction)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(edmFunction, "edmFunction");
|
||||||
|
|
||||||
|
var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters");
|
||||||
|
return returnParamsProperty == null
|
||||||
|
? edmFunction.ReturnParameter
|
||||||
|
: ((IEnumerable<FunctionParameter>)returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsComposable(EdmFunction edmFunction)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(edmFunction, "edmFunction");
|
||||||
|
|
||||||
|
var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute");
|
||||||
|
return isComposableProperty != null && (bool)isComposableProperty.GetValue(edmFunction, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<FunctionImportParameter> GetParameters(EdmFunction edmFunction)
|
||||||
|
{
|
||||||
|
return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TypeUsage GetReturnType(EdmFunction edmFunction)
|
||||||
|
{
|
||||||
|
var returnParam = GetReturnParameter(edmFunction);
|
||||||
|
return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption)
|
||||||
|
{
|
||||||
|
var returnType = GetReturnType(edmFunction);
|
||||||
|
return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ArgumentNotNull<T>(T arg, string name) where T : class
|
||||||
|
{
|
||||||
|
if (arg == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#>
|
||||||
1545
Model.Designer.cs
generated
1545
Model.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
9
Model.cs
Normal file
9
Model.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated from a template.
|
||||||
|
//
|
||||||
|
// Manual changes to this file may cause unexpected behavior in your application.
|
||||||
|
// Manual changes to this file will be overwritten if the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
99
Model.edmx
99
Model.edmx
@@ -4,50 +4,31 @@
|
|||||||
<edmx:Runtime>
|
<edmx:Runtime>
|
||||||
<!-- SSDL content -->
|
<!-- SSDL content -->
|
||||||
<edmx:StorageModels>
|
<edmx:StorageModels>
|
||||||
<Schema Namespace="FeedCenterModel.Store" Alias="Self" Provider="System.Data.SqlServerCe.4.0" ProviderManifestToken="4.0" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
|
<Schema Namespace="FeedCenterModel.Store" Provider="System.Data.SqlServerCe.4.0" ProviderManifestToken="4.0" Alias="Self" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
|
||||||
<EntityContainer Name="FeedCenterModelStoreContainer">
|
|
||||||
<EntitySet Name="Category" EntityType="FeedCenterModel.Store.Category" store:Type="Tables" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" />
|
|
||||||
<EntitySet Name="Feed" EntityType="FeedCenterModel.Store.Feed" store:Type="Tables" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" />
|
|
||||||
<EntitySet Name="FeedAction" EntityType="FeedCenterModel.Store.FeedAction" store:Type="Tables" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" />
|
|
||||||
<EntitySet Name="FeedItem" EntityType="FeedCenterModel.Store.FeedItem" store:Type="Tables" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" />
|
|
||||||
<EntitySet Name="Setting" EntityType="FeedCenterModel.Store.Setting" store:Type="Tables" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" />
|
|
||||||
<AssociationSet Name="FK_Feed_Category" Association="FeedCenterModel.Store.FK_Feed_Category">
|
|
||||||
<End Role="Category" EntitySet="Category" />
|
|
||||||
<End Role="Feed" EntitySet="Feed" />
|
|
||||||
</AssociationSet>
|
|
||||||
<AssociationSet Name="FK_FeedAction_Feed" Association="FeedCenterModel.Store.FK_FeedAction_Feed">
|
|
||||||
<End Role="Feed" EntitySet="Feed" />
|
|
||||||
<End Role="FeedAction" EntitySet="FeedAction" />
|
|
||||||
</AssociationSet>
|
|
||||||
<AssociationSet Name="FK_FeedItem_Feed" Association="FeedCenterModel.Store.FK_FeedItem_Feed">
|
|
||||||
<End Role="Feed" EntitySet="Feed" />
|
|
||||||
<End Role="FeedItem" EntitySet="FeedItem" />
|
|
||||||
</AssociationSet>
|
|
||||||
</EntityContainer>
|
|
||||||
<EntityType Name="Category">
|
<EntityType Name="Category">
|
||||||
<Key>
|
<Key>
|
||||||
<PropertyRef Name="ID" />
|
<PropertyRef Name="ID" />
|
||||||
</Key>
|
</Key>
|
||||||
<Property Name="ID" Type="uniqueidentifier" Nullable="false" />
|
<Property Name="ID" Type="uniqueidentifier" Nullable="false" />
|
||||||
<Property Name="Name" Type="nvarchar" Nullable="false" MaxLength="1000" />
|
<Property Name="Name" Type="nvarchar" MaxLength="1000" Nullable="false" />
|
||||||
</EntityType>
|
</EntityType>
|
||||||
<EntityType Name="Feed">
|
<EntityType Name="Feed">
|
||||||
<Key>
|
<Key>
|
||||||
<PropertyRef Name="ID" />
|
<PropertyRef Name="ID" />
|
||||||
</Key>
|
</Key>
|
||||||
<Property Name="ID" Type="uniqueidentifier" Nullable="false" />
|
<Property Name="ID" Type="uniqueidentifier" Nullable="false" />
|
||||||
<Property Name="Name" Type="nvarchar" Nullable="false" MaxLength="1000" />
|
<Property Name="Name" Type="nvarchar" MaxLength="1000" Nullable="false" />
|
||||||
<Property Name="Title" Type="nvarchar" Nullable="false" MaxLength="1000" />
|
<Property Name="Title" Type="nvarchar" MaxLength="1000" Nullable="false" />
|
||||||
<Property Name="Source" Type="nvarchar" Nullable="false" MaxLength="1000" />
|
<Property Name="Source" Type="nvarchar" MaxLength="1000" Nullable="false" />
|
||||||
<Property Name="Link" Type="nvarchar" Nullable="false" MaxLength="1000" />
|
<Property Name="Link" Type="nvarchar" MaxLength="1000" Nullable="false" />
|
||||||
<Property Name="Description" Type="ntext" Nullable="false" />
|
<Property Name="Description" Type="ntext" Nullable="false" />
|
||||||
<Property Name="LastChecked" Type="datetime" Nullable="false" />
|
<Property Name="LastChecked" Type="datetime" Nullable="false" />
|
||||||
<Property Name="CheckInterval" Type="int" Nullable="false" />
|
<Property Name="CheckInterval" Type="int" Nullable="false" />
|
||||||
<Property Name="Enabled" Type="bit" Nullable="false" />
|
<Property Name="Enabled" Type="bit" Nullable="false" />
|
||||||
<Property Name="Authenticate" Type="bit" Nullable="false" />
|
<Property Name="Authenticate" Type="bit" Nullable="false" />
|
||||||
<Property Name="Username" Type="nvarchar" Nullable="false" MaxLength="1000" />
|
<Property Name="Username" Type="nvarchar" MaxLength="1000" Nullable="false" />
|
||||||
<Property Name="Password" Type="nvarchar" Nullable="false" MaxLength="1000" />
|
<Property Name="Password" Type="nvarchar" MaxLength="1000" Nullable="false" />
|
||||||
<Property Name="Domain" Type="nvarchar" Nullable="false" MaxLength="1000" />
|
<Property Name="Domain" Type="nvarchar" MaxLength="1000" Nullable="false" />
|
||||||
<Property Name="LastReadResult" Type="int" Nullable="false" />
|
<Property Name="LastReadResult" Type="int" Nullable="false" />
|
||||||
<Property Name="LastUpdated" Type="datetime" Nullable="false" />
|
<Property Name="LastUpdated" Type="datetime" Nullable="false" />
|
||||||
<Property Name="ItemComparison" Type="tinyint" Nullable="false" />
|
<Property Name="ItemComparison" Type="tinyint" Nullable="false" />
|
||||||
@@ -61,8 +42,8 @@
|
|||||||
<Property Name="ID" Type="uniqueidentifier" Nullable="false" />
|
<Property Name="ID" Type="uniqueidentifier" Nullable="false" />
|
||||||
<Property Name="FeedID" Type="uniqueidentifier" Nullable="false" />
|
<Property Name="FeedID" Type="uniqueidentifier" Nullable="false" />
|
||||||
<Property Name="Field" Type="int" Nullable="false" />
|
<Property Name="Field" Type="int" Nullable="false" />
|
||||||
<Property Name="Search" Type="nvarchar" Nullable="false" MaxLength="1000" />
|
<Property Name="Search" Type="nvarchar" MaxLength="1000" Nullable="false" />
|
||||||
<Property Name="Replace" Type="nvarchar" Nullable="false" MaxLength="1000" />
|
<Property Name="Replace" Type="nvarchar" MaxLength="1000" Nullable="false" />
|
||||||
<Property Name="Sequence" Type="int" Nullable="false" />
|
<Property Name="Sequence" Type="int" Nullable="false" />
|
||||||
</EntityType>
|
</EntityType>
|
||||||
<EntityType Name="FeedItem">
|
<EntityType Name="FeedItem">
|
||||||
@@ -72,26 +53,26 @@
|
|||||||
<Property Name="ID" Type="uniqueidentifier" Nullable="false" />
|
<Property Name="ID" Type="uniqueidentifier" Nullable="false" />
|
||||||
<Property Name="FeedID" Type="uniqueidentifier" Nullable="false" />
|
<Property Name="FeedID" Type="uniqueidentifier" Nullable="false" />
|
||||||
<Property Name="Title" Type="ntext" Nullable="false" />
|
<Property Name="Title" Type="ntext" Nullable="false" />
|
||||||
<Property Name="Link" Type="nvarchar" Nullable="false" MaxLength="1000" />
|
<Property Name="Link" Type="nvarchar" MaxLength="1000" Nullable="false" />
|
||||||
<Property Name="Description" Type="ntext" Nullable="false" />
|
<Property Name="Description" Type="ntext" Nullable="false" />
|
||||||
<Property Name="BeenRead" Type="bit" Nullable="false" />
|
<Property Name="BeenRead" Type="bit" Nullable="false" />
|
||||||
<Property Name="LastFound" Type="datetime" Nullable="false" />
|
<Property Name="LastFound" Type="datetime" Nullable="false" />
|
||||||
<Property Name="New" Type="bit" Nullable="false" />
|
<Property Name="New" Type="bit" Nullable="false" />
|
||||||
<Property Name="Sequence" Type="int" Nullable="false" />
|
<Property Name="Sequence" Type="int" Nullable="false" />
|
||||||
<Property Name="Guid" Type="nvarchar" Nullable="false" MaxLength="1000" />
|
<Property Name="Guid" Type="nvarchar" MaxLength="1000" Nullable="false" />
|
||||||
</EntityType>
|
</EntityType>
|
||||||
<EntityType Name="Setting">
|
<EntityType Name="Setting">
|
||||||
<Key>
|
<Key>
|
||||||
<PropertyRef Name="Name" />
|
<PropertyRef Name="Name" />
|
||||||
<PropertyRef Name="Version" />
|
<PropertyRef Name="Version" />
|
||||||
</Key>
|
</Key>
|
||||||
<Property Name="Name" Type="nvarchar" Nullable="false" MaxLength="500" />
|
<Property Name="Name" Type="nvarchar" MaxLength="500" Nullable="false" />
|
||||||
<Property Name="Value" Type="nvarchar" Nullable="false" MaxLength="3500" />
|
<Property Name="Value" Type="nvarchar" MaxLength="3500" Nullable="false" />
|
||||||
<Property Name="Version" Type="nvarchar" Nullable="false" MaxLength="50" />
|
<Property Name="Version" Type="nvarchar" MaxLength="50" Nullable="false" />
|
||||||
</EntityType>
|
</EntityType>
|
||||||
<Association Name="FK_Feed_Category">
|
<Association Name="FK_Feed_Category">
|
||||||
<End Role="Category" Type="FeedCenterModel.Store.Category" Multiplicity="1" />
|
<End Role="Category" Type="Self.Category" Multiplicity="1" />
|
||||||
<End Role="Feed" Type="FeedCenterModel.Store.Feed" Multiplicity="*" />
|
<End Role="Feed" Type="Self.Feed" Multiplicity="*" />
|
||||||
<ReferentialConstraint>
|
<ReferentialConstraint>
|
||||||
<Principal Role="Category">
|
<Principal Role="Category">
|
||||||
<PropertyRef Name="ID" />
|
<PropertyRef Name="ID" />
|
||||||
@@ -102,10 +83,10 @@
|
|||||||
</ReferentialConstraint>
|
</ReferentialConstraint>
|
||||||
</Association>
|
</Association>
|
||||||
<Association Name="FK_FeedAction_Feed">
|
<Association Name="FK_FeedAction_Feed">
|
||||||
<End Role="Feed" Type="FeedCenterModel.Store.Feed" Multiplicity="1">
|
<End Role="Feed" Type="Self.Feed" Multiplicity="1">
|
||||||
<OnDelete Action="Cascade" />
|
<OnDelete Action="Cascade" />
|
||||||
</End>
|
</End>
|
||||||
<End Role="FeedAction" Type="FeedCenterModel.Store.FeedAction" Multiplicity="*" />
|
<End Role="FeedAction" Type="Self.FeedAction" Multiplicity="*" />
|
||||||
<ReferentialConstraint>
|
<ReferentialConstraint>
|
||||||
<Principal Role="Feed">
|
<Principal Role="Feed">
|
||||||
<PropertyRef Name="ID" />
|
<PropertyRef Name="ID" />
|
||||||
@@ -116,10 +97,10 @@
|
|||||||
</ReferentialConstraint>
|
</ReferentialConstraint>
|
||||||
</Association>
|
</Association>
|
||||||
<Association Name="FK_FeedItem_Feed">
|
<Association Name="FK_FeedItem_Feed">
|
||||||
<End Role="Feed" Type="FeedCenterModel.Store.Feed" Multiplicity="1">
|
<End Role="Feed" Type="Self.Feed" Multiplicity="1">
|
||||||
<OnDelete Action="Cascade" />
|
<OnDelete Action="Cascade" />
|
||||||
</End>
|
</End>
|
||||||
<End Role="FeedItem" Type="FeedCenterModel.Store.FeedItem" Multiplicity="*" />
|
<End Role="FeedItem" Type="Self.FeedItem" Multiplicity="*" />
|
||||||
<ReferentialConstraint>
|
<ReferentialConstraint>
|
||||||
<Principal Role="Feed">
|
<Principal Role="Feed">
|
||||||
<PropertyRef Name="ID" />
|
<PropertyRef Name="ID" />
|
||||||
@@ -129,6 +110,25 @@
|
|||||||
</Dependent>
|
</Dependent>
|
||||||
</ReferentialConstraint>
|
</ReferentialConstraint>
|
||||||
</Association>
|
</Association>
|
||||||
|
<EntityContainer Name="FeedCenterModelStoreContainer">
|
||||||
|
<EntitySet Name="Category" EntityType="Self.Category" store:Type="Tables" />
|
||||||
|
<EntitySet Name="Feed" EntityType="Self.Feed" store:Type="Tables" />
|
||||||
|
<EntitySet Name="FeedAction" EntityType="Self.FeedAction" store:Type="Tables" />
|
||||||
|
<EntitySet Name="FeedItem" EntityType="Self.FeedItem" store:Type="Tables" />
|
||||||
|
<EntitySet Name="Setting" EntityType="Self.Setting" store:Type="Tables" />
|
||||||
|
<AssociationSet Name="FK_Feed_Category" Association="Self.FK_Feed_Category">
|
||||||
|
<End Role="Category" EntitySet="Category" />
|
||||||
|
<End Role="Feed" EntitySet="Feed" />
|
||||||
|
</AssociationSet>
|
||||||
|
<AssociationSet Name="FK_FeedAction_Feed" Association="Self.FK_FeedAction_Feed">
|
||||||
|
<End Role="Feed" EntitySet="Feed" />
|
||||||
|
<End Role="FeedAction" EntitySet="FeedAction" />
|
||||||
|
</AssociationSet>
|
||||||
|
<AssociationSet Name="FK_FeedItem_Feed" Association="Self.FK_FeedItem_Feed">
|
||||||
|
<End Role="Feed" EntitySet="Feed" />
|
||||||
|
<End Role="FeedItem" EntitySet="FeedItem" />
|
||||||
|
</AssociationSet>
|
||||||
|
</EntityContainer>
|
||||||
</Schema></edmx:StorageModels>
|
</Schema></edmx:StorageModels>
|
||||||
<!-- CSDL content -->
|
<!-- CSDL content -->
|
||||||
<edmx:ConceptualModels>
|
<edmx:ConceptualModels>
|
||||||
@@ -170,21 +170,21 @@
|
|||||||
<Property Type="String" Name="Source" Nullable="false" MaxLength="1000" FixedLength="false" Unicode="true" DefaultValue="" />
|
<Property Type="String" Name="Source" Nullable="false" MaxLength="1000" FixedLength="false" Unicode="true" DefaultValue="" />
|
||||||
<Property Type="String" Name="Link" Nullable="false" MaxLength="1000" FixedLength="false" Unicode="true" DefaultValue="" />
|
<Property Type="String" Name="Link" Nullable="false" MaxLength="1000" FixedLength="false" Unicode="true" DefaultValue="" />
|
||||||
<Property Type="String" Name="Description" Nullable="false" MaxLength="Max" FixedLength="false" Unicode="true" DefaultValue="" />
|
<Property Type="String" Name="Description" Nullable="false" MaxLength="Max" FixedLength="false" Unicode="true" DefaultValue="" />
|
||||||
<Property Type="DateTime" Name="LastChecked" Nullable="false" DefaultValue="1900-01-01 00:00:00.000Z" />
|
<Property Type="DateTime" Name="LastChecked" Nullable="false" DefaultValue="1900-01-01 00:00:00.000Z" Precision="3" />
|
||||||
<Property Type="Int32" Name="CheckInterval" Nullable="false" DefaultValue="60" />
|
<Property Type="Int32" Name="CheckInterval" Nullable="false" DefaultValue="60" />
|
||||||
<Property Type="Boolean" Name="Enabled" Nullable="false" DefaultValue="True" />
|
<Property Type="Boolean" Name="Enabled" Nullable="false" DefaultValue="True" />
|
||||||
<Property Type="Boolean" Name="Authenticate" Nullable="false" DefaultValue="False" />
|
<Property Type="Boolean" Name="Authenticate" Nullable="false" DefaultValue="False" />
|
||||||
<Property Type="String" Name="Username" Nullable="false" MaxLength="1000" FixedLength="false" Unicode="true" DefaultValue="" />
|
<Property Type="String" Name="Username" Nullable="false" MaxLength="1000" FixedLength="false" Unicode="true" DefaultValue="" />
|
||||||
<Property Type="String" Name="Password" Nullable="false" MaxLength="1000" FixedLength="false" Unicode="true" DefaultValue="" />
|
<Property Type="String" Name="Password" Nullable="false" MaxLength="1000" FixedLength="false" Unicode="true" DefaultValue="" />
|
||||||
<Property Type="String" Name="Domain" Nullable="false" MaxLength="1000" FixedLength="false" Unicode="true" DefaultValue="" />
|
<Property Type="String" Name="Domain" Nullable="false" MaxLength="1000" FixedLength="false" Unicode="true" DefaultValue="" />
|
||||||
<Property Type="Int32" Name="LastReadResult" Nullable="false" />
|
<Property Type="FeedCenterModel.FeedReadResult" Name="LastReadResult" Nullable="false" />
|
||||||
<Property Type="DateTime" Name="LastUpdated" Nullable="false" DefaultValue="1900-01-01 00:00:00.000Z" />
|
<Property Type="DateTime" Name="LastUpdated" Nullable="false" DefaultValue="1900-01-01 00:00:00.000Z" Precision="3" />
|
||||||
<Property Type="Byte" Name="ItemComparison" Nullable="false" DefaultValue="0" />
|
<Property Type="FeedCenterModel.FeedItemComparison" Name="ItemComparison" Nullable="false" />
|
||||||
<Property Type="Guid" Name="CategoryID" Nullable="false" />
|
<Property Type="Guid" Name="CategoryID" Nullable="false" />
|
||||||
<NavigationProperty Name="Category" Relationship="FeedCenterModel.FK_Feed_Category" FromRole="Feed" ToRole="Category" />
|
<NavigationProperty Name="Category" Relationship="FeedCenterModel.FK_Feed_Category" FromRole="Feed" ToRole="Category" />
|
||||||
<NavigationProperty Name="Actions" Relationship="FeedCenterModel.FK_FeedAction_Feed" FromRole="Feed" ToRole="FeedAction" />
|
<NavigationProperty Name="Actions" Relationship="FeedCenterModel.FK_FeedAction_Feed" FromRole="Feed" ToRole="FeedAction" />
|
||||||
<NavigationProperty Name="Items" Relationship="FeedCenterModel.FK_FeedItem_Feed" FromRole="Feed" ToRole="FeedItem" />
|
<NavigationProperty Name="Items" Relationship="FeedCenterModel.FK_FeedItem_Feed" FromRole="Feed" ToRole="FeedItem" />
|
||||||
<Property Type="Int32" Name="MultipleOpenAction" Nullable="false" DefaultValue="0" />
|
<Property Type="FeedCenterModel.MultipleOpenAction" Name="MultipleOpenAction" Nullable="false" />
|
||||||
</EntityType>
|
</EntityType>
|
||||||
<EntityType Name="FeedAction">
|
<EntityType Name="FeedAction">
|
||||||
<Key>
|
<Key>
|
||||||
@@ -208,7 +208,7 @@
|
|||||||
<Property Type="String" Name="Link" Nullable="false" MaxLength="1000" FixedLength="false" Unicode="true" DefaultValue="" />
|
<Property Type="String" Name="Link" Nullable="false" MaxLength="1000" FixedLength="false" Unicode="true" DefaultValue="" />
|
||||||
<Property Type="String" Name="Description" Nullable="false" MaxLength="Max" FixedLength="false" Unicode="true" DefaultValue="" />
|
<Property Type="String" Name="Description" Nullable="false" MaxLength="Max" FixedLength="false" Unicode="true" DefaultValue="" />
|
||||||
<Property Type="Boolean" Name="BeenRead" Nullable="false" />
|
<Property Type="Boolean" Name="BeenRead" Nullable="false" />
|
||||||
<Property Type="DateTime" Name="LastFound" Nullable="false" DefaultValue="1900-01-01 00:00:00.000Z" />
|
<Property Type="DateTime" Name="LastFound" Nullable="false" DefaultValue="1900-01-01 00:00:00.000Z" Precision="3" />
|
||||||
<Property Type="Boolean" Name="New" Nullable="false" />
|
<Property Type="Boolean" Name="New" Nullable="false" />
|
||||||
<NavigationProperty Name="Feed" Relationship="FeedCenterModel.FK_FeedItem_Feed" FromRole="FeedItem" ToRole="Feed" />
|
<NavigationProperty Name="Feed" Relationship="FeedCenterModel.FK_FeedItem_Feed" FromRole="FeedItem" ToRole="Feed" />
|
||||||
<Property Type="String" Name="Guid" Nullable="false" MaxLength="1000" FixedLength="false" Unicode="true" />
|
<Property Type="String" Name="Guid" Nullable="false" MaxLength="1000" FixedLength="false" Unicode="true" />
|
||||||
@@ -259,6 +259,9 @@
|
|||||||
</Dependent>
|
</Dependent>
|
||||||
</ReferentialConstraint>
|
</ReferentialConstraint>
|
||||||
</Association>
|
</Association>
|
||||||
|
<EnumType Name="FeedReadResult" a:ExternalTypeName="FeedCenter.FeedReadResult" xmlns:a="http://schemas.microsoft.com/ado/2006/04/codegeneration" />
|
||||||
|
<EnumType Name="FeedItemComparison" UnderlyingType="Byte" a:ExternalTypeName="FeedCenter.FeedItemComparison" xmlns:a="http://schemas.microsoft.com/ado/2006/04/codegeneration" />
|
||||||
|
<EnumType Name="MultipleOpenAction" a:ExternalTypeName="FeedCenter.MultipleOpenAction" xmlns:a="http://schemas.microsoft.com/ado/2006/04/codegeneration" />
|
||||||
</Schema>
|
</Schema>
|
||||||
</edmx:ConceptualModels>
|
</edmx:ConceptualModels>
|
||||||
<!-- C-S mapping content -->
|
<!-- C-S mapping content -->
|
||||||
@@ -350,6 +353,8 @@
|
|||||||
<DesignerProperty Name="ValidateOnBuild" Value="true" />
|
<DesignerProperty Name="ValidateOnBuild" Value="true" />
|
||||||
<DesignerProperty Name="EnablePluralization" Value="True" />
|
<DesignerProperty Name="EnablePluralization" Value="True" />
|
||||||
<DesignerProperty Name="IncludeForeignKeysInModel" Value="True" />
|
<DesignerProperty Name="IncludeForeignKeysInModel" Value="True" />
|
||||||
|
<DesignerProperty Name="CodeGenerationStrategy" Value="None" />
|
||||||
|
<DesignerProperty Name="UseLegacyProvider" Value="False" />
|
||||||
</DesignerInfoPropertySet>
|
</DesignerInfoPropertySet>
|
||||||
</Options>
|
</Options>
|
||||||
<!-- Diagram content (shape and connector positions) -->
|
<!-- Diagram content (shape and connector positions) -->
|
||||||
|
|||||||
726
Model.tt
Normal file
726
Model.tt
Normal file
@@ -0,0 +1,726 @@
|
|||||||
|
<#@ template language="C#" debug="false" hostspecific="true"#>
|
||||||
|
<#@ include file="EF6.Utility.CS.ttinclude"#><#@
|
||||||
|
output extension=".cs"#><#
|
||||||
|
|
||||||
|
const string inputFile = @"Model.edmx";
|
||||||
|
var textTransform = DynamicTextTransformation.Create(this);
|
||||||
|
var code = new CodeGenerationTools(this);
|
||||||
|
var ef = new MetadataTools(this);
|
||||||
|
var typeMapper = new TypeMapper(code, ef, textTransform.Errors);
|
||||||
|
var fileManager = EntityFrameworkTemplateFileManager.Create(this);
|
||||||
|
var itemCollection = new EdmMetadataLoader(textTransform.Host, textTransform.Errors).CreateEdmItemCollection(inputFile);
|
||||||
|
var codeStringGenerator = new CodeStringGenerator(code, typeMapper, ef);
|
||||||
|
|
||||||
|
if (!typeMapper.VerifyCaseInsensitiveTypeUniqueness(typeMapper.GetAllGlobalItems(itemCollection), inputFile))
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
WriteHeader(codeStringGenerator, fileManager);
|
||||||
|
|
||||||
|
foreach (var entity in typeMapper.GetItemsToGenerate<EntityType>(itemCollection))
|
||||||
|
{
|
||||||
|
fileManager.StartNewFile(entity.Name + ".cs");
|
||||||
|
BeginNamespace(code);
|
||||||
|
#>
|
||||||
|
<#=codeStringGenerator.UsingDirectives(inHeader: false)#>
|
||||||
|
<#=codeStringGenerator.EntityClassOpening(entity)#>
|
||||||
|
{
|
||||||
|
<#
|
||||||
|
var propertiesWithDefaultValues = typeMapper.GetPropertiesWithDefaultValues(entity);
|
||||||
|
var collectionNavigationProperties = typeMapper.GetCollectionNavigationProperties(entity);
|
||||||
|
var complexProperties = typeMapper.GetComplexProperties(entity);
|
||||||
|
|
||||||
|
if (propertiesWithDefaultValues.Any() || collectionNavigationProperties.Any() || complexProperties.Any())
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
public <#=code.Escape(entity)#>()
|
||||||
|
{
|
||||||
|
<#
|
||||||
|
foreach (var edmProperty in propertiesWithDefaultValues)
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
this.<#=code.Escape(edmProperty)#> = <#=typeMapper.CreateLiteral(edmProperty.DefaultValue)#>;
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var navigationProperty in collectionNavigationProperties)
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
this.<#=code.Escape(navigationProperty)#> = new HashSet<<#=typeMapper.GetTypeName(navigationProperty.ToEndMember.GetEntityType())#>>();
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var complexProperty in complexProperties)
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
this.<#=code.Escape(complexProperty)#> = new <#=typeMapper.GetTypeName(complexProperty.TypeUsage)#>();
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
|
||||||
|
var simpleProperties = typeMapper.GetSimpleProperties(entity);
|
||||||
|
if (simpleProperties.Any())
|
||||||
|
{
|
||||||
|
foreach (var edmProperty in simpleProperties)
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
<#=codeStringGenerator.Property(edmProperty)#>
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (complexProperties.Any())
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
|
||||||
|
<#
|
||||||
|
foreach(var complexProperty in complexProperties)
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
<#=codeStringGenerator.Property(complexProperty)#>
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var navigationProperties = typeMapper.GetNavigationProperties(entity);
|
||||||
|
if (navigationProperties.Any())
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
|
||||||
|
<#
|
||||||
|
foreach (var navigationProperty in navigationProperties)
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
<#=codeStringGenerator.NavigationProperty(navigationProperty)#>
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
}
|
||||||
|
<#
|
||||||
|
EndNamespace(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var complex in typeMapper.GetItemsToGenerate<ComplexType>(itemCollection))
|
||||||
|
{
|
||||||
|
fileManager.StartNewFile(complex.Name + ".cs");
|
||||||
|
BeginNamespace(code);
|
||||||
|
#>
|
||||||
|
<#=codeStringGenerator.UsingDirectives(inHeader: false, includeCollections: false)#>
|
||||||
|
<#=Accessibility.ForType(complex)#> partial class <#=code.Escape(complex)#>
|
||||||
|
{
|
||||||
|
<#
|
||||||
|
var complexProperties = typeMapper.GetComplexProperties(complex);
|
||||||
|
var propertiesWithDefaultValues = typeMapper.GetPropertiesWithDefaultValues(complex);
|
||||||
|
|
||||||
|
if (propertiesWithDefaultValues.Any() || complexProperties.Any())
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
public <#=code.Escape(complex)#>()
|
||||||
|
{
|
||||||
|
<#
|
||||||
|
foreach (var edmProperty in propertiesWithDefaultValues)
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
this.<#=code.Escape(edmProperty)#> = <#=typeMapper.CreateLiteral(edmProperty.DefaultValue)#>;
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var complexProperty in complexProperties)
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
this.<#=code.Escape(complexProperty)#> = new <#=typeMapper.GetTypeName(complexProperty.TypeUsage)#>();
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
|
||||||
|
var simpleProperties = typeMapper.GetSimpleProperties(complex);
|
||||||
|
if (simpleProperties.Any())
|
||||||
|
{
|
||||||
|
foreach(var edmProperty in simpleProperties)
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
<#=codeStringGenerator.Property(edmProperty)#>
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (complexProperties.Any())
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
|
||||||
|
<#
|
||||||
|
foreach(var edmProperty in complexProperties)
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
<#=codeStringGenerator.Property(edmProperty)#>
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
}
|
||||||
|
<#
|
||||||
|
EndNamespace(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var enumType in typeMapper.GetEnumItemsToGenerate(itemCollection))
|
||||||
|
{
|
||||||
|
fileManager.StartNewFile(enumType.Name + ".cs");
|
||||||
|
BeginNamespace(code);
|
||||||
|
#>
|
||||||
|
<#=codeStringGenerator.UsingDirectives(inHeader: false, includeCollections: false)#>
|
||||||
|
<#
|
||||||
|
if (typeMapper.EnumIsFlags(enumType))
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
[Flags]
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
<#=codeStringGenerator.EnumOpening(enumType)#>
|
||||||
|
{
|
||||||
|
<#
|
||||||
|
var foundOne = false;
|
||||||
|
|
||||||
|
foreach (MetadataItem member in typeMapper.GetEnumMembers(enumType))
|
||||||
|
{
|
||||||
|
foundOne = true;
|
||||||
|
#>
|
||||||
|
<#=code.Escape(typeMapper.GetEnumMemberName(member))#> = <#=typeMapper.GetEnumMemberValue(member)#>,
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
|
||||||
|
if (foundOne)
|
||||||
|
{
|
||||||
|
this.GenerationEnvironment.Remove(this.GenerationEnvironment.Length - 3, 1);
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
}
|
||||||
|
<#
|
||||||
|
EndNamespace(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
fileManager.Process();
|
||||||
|
|
||||||
|
#>
|
||||||
|
<#+
|
||||||
|
|
||||||
|
public void WriteHeader(CodeStringGenerator codeStringGenerator, EntityFrameworkTemplateFileManager fileManager)
|
||||||
|
{
|
||||||
|
fileManager.StartHeader();
|
||||||
|
#>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1")#>
|
||||||
|
//
|
||||||
|
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2")#>
|
||||||
|
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3")#>
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
<#=codeStringGenerator.UsingDirectives(inHeader: true)#>
|
||||||
|
<#+
|
||||||
|
fileManager.EndBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BeginNamespace(CodeGenerationTools code)
|
||||||
|
{
|
||||||
|
var codeNamespace = code.VsNamespaceSuggestion();
|
||||||
|
if (!String.IsNullOrEmpty(codeNamespace))
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
namespace <#=code.EscapeNamespace(codeNamespace)#>
|
||||||
|
{
|
||||||
|
<#+
|
||||||
|
PushIndent(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EndNamespace(CodeGenerationTools code)
|
||||||
|
{
|
||||||
|
if (!String.IsNullOrEmpty(code.VsNamespaceSuggestion()))
|
||||||
|
{
|
||||||
|
PopIndent();
|
||||||
|
#>
|
||||||
|
}
|
||||||
|
<#+
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public const string TemplateId = "CSharp_DbContext_Types_EF6";
|
||||||
|
|
||||||
|
public class CodeStringGenerator
|
||||||
|
{
|
||||||
|
private readonly CodeGenerationTools _code;
|
||||||
|
private readonly TypeMapper _typeMapper;
|
||||||
|
private readonly MetadataTools _ef;
|
||||||
|
|
||||||
|
public CodeStringGenerator(CodeGenerationTools code, TypeMapper typeMapper, MetadataTools ef)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(code, "code");
|
||||||
|
ArgumentNotNull(typeMapper, "typeMapper");
|
||||||
|
ArgumentNotNull(ef, "ef");
|
||||||
|
|
||||||
|
_code = code;
|
||||||
|
_typeMapper = typeMapper;
|
||||||
|
_ef = ef;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Property(EdmProperty edmProperty)
|
||||||
|
{
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} {1} {2} {{ {3}get; {4}set; }}",
|
||||||
|
Accessibility.ForProperty(edmProperty),
|
||||||
|
_typeMapper.GetTypeName(edmProperty.TypeUsage),
|
||||||
|
_code.Escape(edmProperty),
|
||||||
|
_code.SpaceAfter(Accessibility.ForGetter(edmProperty)),
|
||||||
|
_code.SpaceAfter(Accessibility.ForSetter(edmProperty)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string NavigationProperty(NavigationProperty navProp)
|
||||||
|
{
|
||||||
|
var endType = _typeMapper.GetTypeName(navProp.ToEndMember.GetEntityType());
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} {1} {2} {{ {3}get; {4}set; }}",
|
||||||
|
AccessibilityAndVirtual(Accessibility.ForNavigationProperty(navProp)),
|
||||||
|
navProp.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType,
|
||||||
|
_code.Escape(navProp),
|
||||||
|
_code.SpaceAfter(Accessibility.ForGetter(navProp)),
|
||||||
|
_code.SpaceAfter(Accessibility.ForSetter(navProp)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string AccessibilityAndVirtual(string accessibility)
|
||||||
|
{
|
||||||
|
return accessibility + (accessibility != "private" ? " virtual" : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public string EntityClassOpening(EntityType entity)
|
||||||
|
{
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} {1}partial class {2}{3}",
|
||||||
|
Accessibility.ForType(entity),
|
||||||
|
_code.SpaceAfter(_code.AbstractOption(entity)),
|
||||||
|
_code.Escape(entity),
|
||||||
|
_code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string EnumOpening(SimpleType enumType)
|
||||||
|
{
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} enum {1} : {2}",
|
||||||
|
Accessibility.ForType(enumType),
|
||||||
|
_code.Escape(enumType),
|
||||||
|
_code.Escape(_typeMapper.UnderlyingClrType(enumType)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void WriteFunctionParameters(EdmFunction edmFunction, Action<string, string, string, string> writeParameter)
|
||||||
|
{
|
||||||
|
var parameters = FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
|
||||||
|
foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable))
|
||||||
|
{
|
||||||
|
var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null";
|
||||||
|
var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")";
|
||||||
|
var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + TypeMapper.FixNamespaces(parameter.RawClrTypeName) + "))";
|
||||||
|
writeParameter(parameter.LocalVariableName, isNotNull, notNullInit, nullInit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ComposableFunctionMethod(EdmFunction edmFunction, string modelNamespace)
|
||||||
|
{
|
||||||
|
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||||
|
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} IQueryable<{1}> {2}({3})",
|
||||||
|
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
|
||||||
|
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
|
||||||
|
_code.Escape(edmFunction),
|
||||||
|
string.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ComposableCreateQuery(EdmFunction edmFunction, string modelNamespace)
|
||||||
|
{
|
||||||
|
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||||
|
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<{0}>(\"[{1}].[{2}]({3})\"{4});",
|
||||||
|
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
|
||||||
|
edmFunction.NamespaceName,
|
||||||
|
edmFunction.Name,
|
||||||
|
string.Join(", ", parameters.Select(p => "@" + p.EsqlParameterName).ToArray()),
|
||||||
|
_code.StringBefore(", ", string.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray())));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string FunctionMethod(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||||
|
{
|
||||||
|
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||||
|
var returnType = _typeMapper.GetReturnType(edmFunction);
|
||||||
|
|
||||||
|
var paramList = String.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray());
|
||||||
|
if (includeMergeOption)
|
||||||
|
{
|
||||||
|
paramList = _code.StringAfter(paramList, ", ") + "MergeOption mergeOption";
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} {1} {2}({3})",
|
||||||
|
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
|
||||||
|
returnType == null ? "int" : "ObjectResult<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
|
||||||
|
_code.Escape(edmFunction),
|
||||||
|
paramList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||||
|
{
|
||||||
|
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||||
|
var returnType = _typeMapper.GetReturnType(edmFunction);
|
||||||
|
|
||||||
|
var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()));
|
||||||
|
if (includeMergeOption)
|
||||||
|
{
|
||||||
|
callParams = ", mergeOption" + callParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});",
|
||||||
|
returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
|
||||||
|
edmFunction.Name,
|
||||||
|
callParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string DbSet(EntitySet entitySet)
|
||||||
|
{
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} virtual DbSet<{1}> {2} {{ get; set; }}",
|
||||||
|
Accessibility.ForReadOnlyProperty(entitySet),
|
||||||
|
_typeMapper.GetTypeName(entitySet.ElementType),
|
||||||
|
_code.Escape(entitySet));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string UsingDirectives(bool inHeader, bool includeCollections = true)
|
||||||
|
{
|
||||||
|
return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion())
|
||||||
|
? string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0}using System;{1}" +
|
||||||
|
"{2}",
|
||||||
|
inHeader ? Environment.NewLine : "",
|
||||||
|
includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "",
|
||||||
|
inHeader ? "" : Environment.NewLine)
|
||||||
|
: "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TypeMapper
|
||||||
|
{
|
||||||
|
private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName";
|
||||||
|
|
||||||
|
private readonly System.Collections.IList _errors;
|
||||||
|
private readonly CodeGenerationTools _code;
|
||||||
|
private readonly MetadataTools _ef;
|
||||||
|
|
||||||
|
public TypeMapper(CodeGenerationTools code, MetadataTools ef, System.Collections.IList errors)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(code, "code");
|
||||||
|
ArgumentNotNull(ef, "ef");
|
||||||
|
ArgumentNotNull(errors, "errors");
|
||||||
|
|
||||||
|
_code = code;
|
||||||
|
_ef = ef;
|
||||||
|
_errors = errors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string FixNamespaces(string typeName)
|
||||||
|
{
|
||||||
|
return typeName.Replace("System.Data.Spatial.", "System.Data.Entity.Spatial.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetTypeName(TypeUsage typeUsage)
|
||||||
|
{
|
||||||
|
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetTypeName(EdmType edmType)
|
||||||
|
{
|
||||||
|
return GetTypeName(edmType, isNullable: null, modelNamespace: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetTypeName(TypeUsage typeUsage, string modelNamespace)
|
||||||
|
{
|
||||||
|
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetTypeName(EdmType edmType, string modelNamespace)
|
||||||
|
{
|
||||||
|
return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace)
|
||||||
|
{
|
||||||
|
if (edmType == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var collectionType = edmType as CollectionType;
|
||||||
|
if (collectionType != null)
|
||||||
|
{
|
||||||
|
return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace));
|
||||||
|
}
|
||||||
|
|
||||||
|
var typeName = _code.Escape(edmType.MetadataProperties
|
||||||
|
.Where(p => p.Name == ExternalTypeNameAttributeName)
|
||||||
|
.Select(p => (string)p.Value)
|
||||||
|
.FirstOrDefault())
|
||||||
|
?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ?
|
||||||
|
_code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) :
|
||||||
|
_code.Escape(edmType));
|
||||||
|
|
||||||
|
if (edmType is StructuralType)
|
||||||
|
{
|
||||||
|
return typeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (edmType is SimpleType)
|
||||||
|
{
|
||||||
|
var clrType = UnderlyingClrType(edmType);
|
||||||
|
if (!IsEnumType(edmType))
|
||||||
|
{
|
||||||
|
typeName = _code.Escape(clrType);
|
||||||
|
}
|
||||||
|
|
||||||
|
typeName = FixNamespaces(typeName);
|
||||||
|
|
||||||
|
return clrType.IsValueType && isNullable == true ?
|
||||||
|
String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) :
|
||||||
|
typeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ArgumentException("edmType");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type UnderlyingClrType(EdmType edmType)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(edmType, "edmType");
|
||||||
|
|
||||||
|
var primitiveType = edmType as PrimitiveType;
|
||||||
|
if (primitiveType != null)
|
||||||
|
{
|
||||||
|
return primitiveType.ClrEquivalentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsEnumType(edmType))
|
||||||
|
{
|
||||||
|
return GetEnumUnderlyingType(edmType).ClrEquivalentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
return typeof(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
public object GetEnumMemberValue(MetadataItem enumMember)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(enumMember, "enumMember");
|
||||||
|
|
||||||
|
var valueProperty = enumMember.GetType().GetProperty("Value");
|
||||||
|
return valueProperty == null ? null : valueProperty.GetValue(enumMember, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetEnumMemberName(MetadataItem enumMember)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(enumMember, "enumMember");
|
||||||
|
|
||||||
|
var nameProperty = enumMember.GetType().GetProperty("Name");
|
||||||
|
return nameProperty == null ? null : (string)nameProperty.GetValue(enumMember, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public System.Collections.IEnumerable GetEnumMembers(EdmType enumType)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(enumType, "enumType");
|
||||||
|
|
||||||
|
var membersProperty = enumType.GetType().GetProperty("Members");
|
||||||
|
return membersProperty != null
|
||||||
|
? (System.Collections.IEnumerable)membersProperty.GetValue(enumType, null)
|
||||||
|
: Enumerable.Empty<MetadataItem>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool EnumIsFlags(EdmType enumType)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(enumType, "enumType");
|
||||||
|
|
||||||
|
var isFlagsProperty = enumType.GetType().GetProperty("IsFlags");
|
||||||
|
return isFlagsProperty != null && (bool)isFlagsProperty.GetValue(enumType, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsEnumType(GlobalItem edmType)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(edmType, "edmType");
|
||||||
|
|
||||||
|
return edmType.GetType().Name == "EnumType";
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrimitiveType GetEnumUnderlyingType(EdmType enumType)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(enumType, "enumType");
|
||||||
|
|
||||||
|
return (PrimitiveType)enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string CreateLiteral(object value)
|
||||||
|
{
|
||||||
|
if (value == null || value.GetType() != typeof(TimeSpan))
|
||||||
|
{
|
||||||
|
return _code.CreateLiteral(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan)value).Ticks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable<string> types, string sourceFile)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(types, "types");
|
||||||
|
ArgumentNotNull(sourceFile, "sourceFile");
|
||||||
|
|
||||||
|
var hash = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
|
||||||
|
if (types.Any(item => !hash.Add(item)))
|
||||||
|
{
|
||||||
|
_errors.Add(
|
||||||
|
new CompilerError(sourceFile, -1, -1, "6023",
|
||||||
|
String.Format(CultureInfo.CurrentCulture, CodeGenerationTools.GetResourceString("Template_CaseInsensitiveTypeConflict"))));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<SimpleType> GetEnumItemsToGenerate(IEnumerable<GlobalItem> itemCollection)
|
||||||
|
{
|
||||||
|
return GetItemsToGenerate<SimpleType>(itemCollection)
|
||||||
|
.Where(e => IsEnumType(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<T> GetItemsToGenerate<T>(IEnumerable<GlobalItem> itemCollection) where T: EdmType
|
||||||
|
{
|
||||||
|
return itemCollection
|
||||||
|
.OfType<T>()
|
||||||
|
.Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName))
|
||||||
|
.OrderBy(i => i.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<string> GetAllGlobalItems(IEnumerable<GlobalItem> itemCollection)
|
||||||
|
{
|
||||||
|
return itemCollection
|
||||||
|
.Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i))
|
||||||
|
.Select(g => GetGlobalItemName(g));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetGlobalItemName(GlobalItem item)
|
||||||
|
{
|
||||||
|
if (item is EdmType)
|
||||||
|
{
|
||||||
|
return ((EdmType)item).Name;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ((EntityContainer)item).Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<EdmProperty> GetSimpleProperties(EntityType type)
|
||||||
|
{
|
||||||
|
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<EdmProperty> GetSimpleProperties(ComplexType type)
|
||||||
|
{
|
||||||
|
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<EdmProperty> GetComplexProperties(EntityType type)
|
||||||
|
{
|
||||||
|
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<EdmProperty> GetComplexProperties(ComplexType type)
|
||||||
|
{
|
||||||
|
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(EntityType type)
|
||||||
|
{
|
||||||
|
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(ComplexType type)
|
||||||
|
{
|
||||||
|
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<NavigationProperty> GetNavigationProperties(EntityType type)
|
||||||
|
{
|
||||||
|
return type.NavigationProperties.Where(np => np.DeclaringType == type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<NavigationProperty> GetCollectionNavigationProperties(EntityType type)
|
||||||
|
{
|
||||||
|
return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FunctionParameter GetReturnParameter(EdmFunction edmFunction)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(edmFunction, "edmFunction");
|
||||||
|
|
||||||
|
var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters");
|
||||||
|
return returnParamsProperty == null
|
||||||
|
? edmFunction.ReturnParameter
|
||||||
|
: ((IEnumerable<FunctionParameter>)returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsComposable(EdmFunction edmFunction)
|
||||||
|
{
|
||||||
|
ArgumentNotNull(edmFunction, "edmFunction");
|
||||||
|
|
||||||
|
var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute");
|
||||||
|
return isComposableProperty != null && (bool)isComposableProperty.GetValue(edmFunction, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<FunctionImportParameter> GetParameters(EdmFunction edmFunction)
|
||||||
|
{
|
||||||
|
return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TypeUsage GetReturnType(EdmFunction edmFunction)
|
||||||
|
{
|
||||||
|
var returnParam = GetReturnParameter(edmFunction);
|
||||||
|
return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption)
|
||||||
|
{
|
||||||
|
var returnType = GetReturnType(edmFunction);
|
||||||
|
return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ArgumentNotNull<T>(T arg, string name) where T : class
|
||||||
|
{
|
||||||
|
if (arg == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#>
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
using System.Windows.Forms;
|
using FeedCenter.Properties;
|
||||||
|
using System.Windows.Forms;
|
||||||
using FeedCenter.Properties;
|
|
||||||
|
|
||||||
namespace FeedCenter
|
namespace FeedCenter
|
||||||
{
|
{
|
||||||
@@ -19,9 +18,9 @@ namespace FeedCenter
|
|||||||
_notificationIcon.DoubleClick += HandleNotificationIconDoubleClick;
|
_notificationIcon.DoubleClick += HandleNotificationIconDoubleClick;
|
||||||
|
|
||||||
// Setup the menu
|
// Setup the menu
|
||||||
ContextMenuStrip contextMenuStrip = new ContextMenuStrip();
|
var contextMenuStrip = new ContextMenuStrip();
|
||||||
|
|
||||||
ToolStripMenuItem toolStripMenuItem = new ToolStripMenuItem(Resources.NotificationIconContextMenuLocked, null, HandleLockWindowClicked)
|
var toolStripMenuItem = new ToolStripMenuItem(Resources.NotificationIconContextMenuLocked, null, HandleLockWindowClicked)
|
||||||
{
|
{
|
||||||
Checked = Settings.Default.WindowLocked
|
Checked = Settings.Default.WindowLocked
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
xmlns:my="clr-namespace:FeedCenter.Properties"
|
xmlns:my="clr-namespace:FeedCenter.Properties"
|
||||||
xmlns:Options="clr-namespace:FeedCenter.Options"
|
xmlns:Options="clr-namespace:FeedCenter.Options"
|
||||||
xmlns:LinkControl="clr-namespace:Common.Wpf.LinkControl;assembly=Common.Wpf"
|
xmlns:LinkControl="clr-namespace:Common.Wpf.LinkControl;assembly=Common.Wpf"
|
||||||
|
xmlns:feedCenter="clr-namespace:FeedCenter"
|
||||||
WindowStartupLocation="CenterOwner"
|
WindowStartupLocation="CenterOwner"
|
||||||
Icon="/FeedCenter;component/Resources/Application.ico"
|
Icon="/FeedCenter;component/Resources/Application.ico"
|
||||||
FocusManager.FocusedElement="{Binding ElementName=feedLinkFilterText}">
|
FocusManager.FocusedElement="{Binding ElementName=feedLinkFilterText}">
|
||||||
@@ -97,9 +98,9 @@
|
|||||||
ToolTip="{x:Static my:Resources.DisableHint}"
|
ToolTip="{x:Static my:Resources.DisableHint}"
|
||||||
IsEnabled="False">
|
IsEnabled="False">
|
||||||
<ComboBoxItem Content="{x:Static my:Resources.openAllMultipleToolbarButton}"
|
<ComboBoxItem Content="{x:Static my:Resources.openAllMultipleToolbarButton}"
|
||||||
Tag="{x:Static Options:MultipleOpenAction.IndividualPages}" />
|
Tag="{x:Static feedCenter:MultipleOpenAction.IndividualPages}" />
|
||||||
<ComboBoxItem Content="{x:Static my:Resources.openAllSingleToolbarButton}"
|
<ComboBoxItem Content="{x:Static my:Resources.openAllSingleToolbarButton}"
|
||||||
Tag="{x:Static Options:MultipleOpenAction.SinglePage}" />
|
Tag="{x:Static feedCenter:MultipleOpenAction.SinglePage}" />
|
||||||
</ComboBox>
|
</ComboBox>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Button Content="{x:Static my:Resources.OkayButton}"
|
<Button Content="{x:Static my:Resources.OkayButton}"
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
using System.Collections.Generic;
|
using Common.Wpf;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Data;
|
using System.Windows.Data;
|
||||||
|
|
||||||
using Common.Wpf;
|
|
||||||
|
|
||||||
namespace FeedCenter.Options
|
namespace FeedCenter.Options
|
||||||
{
|
{
|
||||||
public partial class BulkFeedWindow
|
public partial class BulkFeedWindow
|
||||||
@@ -39,9 +38,9 @@ namespace FeedCenter.Options
|
|||||||
|
|
||||||
void HandleCollectionViewSourceFilter(object sender, FilterEventArgs e)
|
void HandleCollectionViewSourceFilter(object sender, FilterEventArgs e)
|
||||||
{
|
{
|
||||||
CheckedListItem<Feed> checkedListBoxItem = (CheckedListItem<Feed>) e.Item;
|
var checkedListBoxItem = (CheckedListItem<Feed>) e.Item;
|
||||||
|
|
||||||
Feed feed = checkedListBoxItem.Item;
|
var feed = checkedListBoxItem.Item;
|
||||||
|
|
||||||
e.Accepted = feed.Link.Contains(feedLinkFilterText.Text);
|
e.Accepted = feed.Link.Contains(feedLinkFilterText.Text);
|
||||||
}
|
}
|
||||||
@@ -56,7 +55,7 @@ namespace FeedCenter.Options
|
|||||||
foreach (var item in _checkedListBoxItems.Where(i => i.IsChecked))
|
foreach (var item in _checkedListBoxItems.Where(i => i.IsChecked))
|
||||||
{
|
{
|
||||||
if (openComboBox.IsEnabled)
|
if (openComboBox.IsEnabled)
|
||||||
item.Item.MultipleOpenAction = (int) ((ComboBoxItem) openComboBox.SelectedItem).Tag;
|
item.Item.MultipleOpenAction = (MultipleOpenAction) ((ComboBoxItem) openComboBox.SelectedItem).Tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogResult = true;
|
DialogResult = true;
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
using System.Linq;
|
using FeedCenter.Properties;
|
||||||
|
using System.Linq;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
|
||||||
using FeedCenter.Properties;
|
|
||||||
|
|
||||||
namespace FeedCenter.Options
|
namespace FeedCenter.Options
|
||||||
{
|
{
|
||||||
public partial class DisplayOptionsPanel
|
public partial class DisplayOptionsPanel
|
||||||
@@ -35,12 +34,10 @@ namespace FeedCenter.Options
|
|||||||
if (displayEmptyFeedsCheckBox.IsChecked.HasValue && Settings.Default.DisplayEmptyFeeds != displayEmptyFeedsCheckBox.IsChecked.Value)
|
if (displayEmptyFeedsCheckBox.IsChecked.HasValue && Settings.Default.DisplayEmptyFeeds != displayEmptyFeedsCheckBox.IsChecked.Value)
|
||||||
Settings.Default.DisplayEmptyFeeds = displayEmptyFeedsCheckBox.IsChecked.Value;
|
Settings.Default.DisplayEmptyFeeds = displayEmptyFeedsCheckBox.IsChecked.Value;
|
||||||
|
|
||||||
Dock dock = (Dock) ((ComboBoxItem) toolbarLocationComboBox.SelectedItem).Tag;
|
var dock = (Dock) ((ComboBoxItem) toolbarLocationComboBox.SelectedItem).Tag;
|
||||||
if (Settings.Default.ToolbarLocation != dock)
|
|
||||||
Settings.Default.ToolbarLocation = dock;
|
Settings.Default.ToolbarLocation = dock;
|
||||||
|
|
||||||
MultipleLineDisplay multipleLineDisplay = (MultipleLineDisplay) ((ComboBoxItem) multipleLineDisplayComboBox.SelectedItem).Tag;
|
var multipleLineDisplay = (MultipleLineDisplay) ((ComboBoxItem) multipleLineDisplayComboBox.SelectedItem).Tag;
|
||||||
if (Settings.Default.MultipleLineDisplay != multipleLineDisplay)
|
|
||||||
Settings.Default.MultipleLineDisplay = multipleLineDisplay;
|
Settings.Default.MultipleLineDisplay = multipleLineDisplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:Properties="clr-namespace:FeedCenter.Properties"
|
xmlns:Properties="clr-namespace:FeedCenter.Properties"
|
||||||
xmlns:Options="clr-namespace:FeedCenter.Options"
|
xmlns:feedCenter="clr-namespace:FeedCenter"
|
||||||
Title="FeedWindow"
|
Title="FeedWindow"
|
||||||
Height="300"
|
Height="300"
|
||||||
Width="450"
|
Width="450"
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
Icon="/FeedCenter;component/Resources/Application.ico"
|
Icon="/FeedCenter;component/Resources/Application.ico"
|
||||||
FocusManager.FocusedElement="{Binding ElementName=urlTextBox}">
|
FocusManager.FocusedElement="{Binding ElementName=urlTextBox}">
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
<Options:MultipleOpenActionConverter x:Key="multipleOpenActionConverter" />
|
<feedCenter:MultipleOpenActionConverter x:Key="multipleOpenActionConverter" />
|
||||||
</Window.Resources>
|
</Window.Resources>
|
||||||
<Grid Name="mainGrid">
|
<Grid Name="mainGrid">
|
||||||
<TabControl Name="optionsTabControl"
|
<TabControl Name="optionsTabControl"
|
||||||
@@ -116,9 +116,9 @@
|
|||||||
Margin="6">
|
Margin="6">
|
||||||
|
|
||||||
<ComboBoxItem Content="{x:Static Properties:Resources.openAllSingleToolbarButton}"
|
<ComboBoxItem Content="{x:Static Properties:Resources.openAllSingleToolbarButton}"
|
||||||
Tag="{x:Static Options:MultipleOpenAction.SinglePage}" />
|
Tag="{x:Static feedCenter:MultipleOpenAction.SinglePage}" />
|
||||||
<ComboBoxItem Content="{x:Static Properties:Resources.openAllMultipleToolbarButton}"
|
<ComboBoxItem Content="{x:Static Properties:Resources.openAllMultipleToolbarButton}"
|
||||||
Tag="{x:Static Options:MultipleOpenAction.IndividualPages}" />
|
Tag="{x:Static feedCenter:MultipleOpenAction.IndividualPages}" />
|
||||||
</ComboBox>
|
</ComboBox>
|
||||||
</Grid>
|
</Grid>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using Microsoft.Win32;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
@@ -6,7 +7,6 @@ using System.Windows.Controls;
|
|||||||
using System.Windows.Data;
|
using System.Windows.Data;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using Microsoft.Win32;
|
|
||||||
|
|
||||||
namespace FeedCenter.Options
|
namespace FeedCenter.Options
|
||||||
{
|
{
|
||||||
@@ -27,7 +27,7 @@ namespace FeedCenter.Options
|
|||||||
{
|
{
|
||||||
base.LoadPanel(database);
|
base.LoadPanel(database);
|
||||||
|
|
||||||
CollectionViewSource collectionViewSource = new CollectionViewSource { Source = Database.AllCategories };
|
var collectionViewSource = new CollectionViewSource { Source = Database.AllCategories };
|
||||||
collectionViewSource.SortDescriptions.Add(new SortDescription("SortKey", ListSortDirection.Ascending));
|
collectionViewSource.SortDescriptions.Add(new SortDescription("SortKey", ListSortDirection.Ascending));
|
||||||
collectionViewSource.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
|
collectionViewSource.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
|
||||||
|
|
||||||
@@ -61,15 +61,15 @@ namespace FeedCenter.Options
|
|||||||
|
|
||||||
private void AddFeed()
|
private void AddFeed()
|
||||||
{
|
{
|
||||||
Feed feed = new Feed();
|
var feed = Feed.Create();
|
||||||
|
|
||||||
FeedWindow feedWindow = new FeedWindow();
|
var feedWindow = new FeedWindow();
|
||||||
|
|
||||||
bool? result = feedWindow.Display(Database, feed, Window.GetWindow(this));
|
var result = feedWindow.Display(Database, feed, Window.GetWindow(this));
|
||||||
|
|
||||||
if (result.HasValue && result.Value)
|
if (result.HasValue && result.Value)
|
||||||
{
|
{
|
||||||
Database.Feeds.AddObject(feed);
|
Database.Feeds.Add(feed);
|
||||||
|
|
||||||
feedListBox.SelectedItem = feed;
|
feedListBox.SelectedItem = feed;
|
||||||
|
|
||||||
@@ -82,18 +82,18 @@ namespace FeedCenter.Options
|
|||||||
if (feedListBox.SelectedItem == null)
|
if (feedListBox.SelectedItem == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Feed feed = (Feed) feedListBox.SelectedItem;
|
var feed = (Feed) feedListBox.SelectedItem;
|
||||||
|
|
||||||
FeedWindow feedWindow = new FeedWindow();
|
var feedWindow = new FeedWindow();
|
||||||
|
|
||||||
feedWindow.Display(Database, feed, Window.GetWindow(this));
|
feedWindow.Display(Database, feed, Window.GetWindow(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeleteSelectedFeed()
|
private void DeleteSelectedFeed()
|
||||||
{
|
{
|
||||||
Feed feed = (Feed) feedListBox.SelectedItem;
|
var feed = (Feed) feedListBox.SelectedItem;
|
||||||
|
|
||||||
Database.Feeds.DeleteObject(feed);
|
Database.Feeds.Remove(feed);
|
||||||
|
|
||||||
SetFeedButtonStates();
|
SetFeedButtonStates();
|
||||||
}
|
}
|
||||||
@@ -134,20 +134,20 @@ namespace FeedCenter.Options
|
|||||||
private void ExportFeeds()
|
private void ExportFeeds()
|
||||||
{
|
{
|
||||||
// Setup the save file dialog
|
// Setup the save file dialog
|
||||||
SaveFileDialog saveFileDialog = new SaveFileDialog
|
var saveFileDialog = new SaveFileDialog
|
||||||
{
|
{
|
||||||
Filter = Properties.Resources.ImportExportFilter,
|
Filter = Properties.Resources.ImportExportFilter,
|
||||||
FilterIndex = 0,
|
FilterIndex = 0,
|
||||||
OverwritePrompt = true
|
OverwritePrompt = true
|
||||||
};
|
};
|
||||||
|
|
||||||
bool? result = saveFileDialog.ShowDialog();
|
var result = saveFileDialog.ShowDialog();
|
||||||
|
|
||||||
if (!result.Value)
|
if (!result.GetValueOrDefault(false))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Setup the writer settings
|
// Setup the writer settings
|
||||||
XmlWriterSettings writerSettings = new XmlWriterSettings
|
var writerSettings = new XmlWriterSettings
|
||||||
{
|
{
|
||||||
Indent = true,
|
Indent = true,
|
||||||
CheckCharacters = true,
|
CheckCharacters = true,
|
||||||
@@ -155,7 +155,7 @@ namespace FeedCenter.Options
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Create an XML writer for the file chosen
|
// Create an XML writer for the file chosen
|
||||||
XmlWriter xmlWriter = XmlWriter.Create(saveFileDialog.FileName, writerSettings);
|
var xmlWriter = XmlWriter.Create(saveFileDialog.FileName, writerSettings);
|
||||||
|
|
||||||
// Start the opml element
|
// Start the opml element
|
||||||
xmlWriter.WriteStartElement("opml");
|
xmlWriter.WriteStartElement("opml");
|
||||||
@@ -164,7 +164,7 @@ namespace FeedCenter.Options
|
|||||||
xmlWriter.WriteStartElement("body");
|
xmlWriter.WriteStartElement("body");
|
||||||
|
|
||||||
// Loop over each feed
|
// Loop over each feed
|
||||||
foreach (Feed feed in Database.Feeds.OrderBy(feed => feed.Name))
|
foreach (var feed in Database.Feeds.OrderBy(feed => feed.Name))
|
||||||
{
|
{
|
||||||
// Start the outline element
|
// Start the outline element
|
||||||
xmlWriter.WriteStartElement("outline");
|
xmlWriter.WriteStartElement("outline");
|
||||||
@@ -196,22 +196,22 @@ namespace FeedCenter.Options
|
|||||||
private void ImportFeeds()
|
private void ImportFeeds()
|
||||||
{
|
{
|
||||||
// Setup the open file dialog
|
// Setup the open file dialog
|
||||||
OpenFileDialog openFileDialog = new OpenFileDialog
|
var openFileDialog = new OpenFileDialog
|
||||||
{
|
{
|
||||||
Filter = Properties.Resources.ImportExportFilter,
|
Filter = Properties.Resources.ImportExportFilter,
|
||||||
FilterIndex = 0
|
FilterIndex = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
bool? result = openFileDialog.ShowDialog();
|
var result = openFileDialog.ShowDialog();
|
||||||
|
|
||||||
if (!result.Value)
|
if (!result.GetValueOrDefault(false))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Setup the reader settings
|
// Setup the reader settings
|
||||||
XmlReaderSettings xmlReaderSettings = new XmlReaderSettings { IgnoreWhitespace = true };
|
var xmlReaderSettings = new XmlReaderSettings { IgnoreWhitespace = true };
|
||||||
|
|
||||||
// Create an XML reader for the file chosen
|
// Create an XML reader for the file chosen
|
||||||
XmlReader xmlReader = XmlReader.Create(openFileDialog.FileName, xmlReaderSettings);
|
var xmlReader = XmlReader.Create(openFileDialog.FileName, xmlReaderSettings);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -228,7 +228,8 @@ namespace FeedCenter.Options
|
|||||||
while (xmlReader.NodeType != XmlNodeType.EndElement)
|
while (xmlReader.NodeType != XmlNodeType.EndElement)
|
||||||
{
|
{
|
||||||
// Create a new feed
|
// Create a new feed
|
||||||
Feed feed = new Feed { Category = Database.Categories.ToList().First(c => c.IsDefault) };
|
var feed = Feed.Create();
|
||||||
|
feed.Category = Database.Categories.ToList().First(c => c.IsDefault);
|
||||||
|
|
||||||
// Loop over all attributes
|
// Loop over all attributes
|
||||||
while (xmlReader.MoveToNextAttribute())
|
while (xmlReader.MoveToNextAttribute())
|
||||||
@@ -259,7 +260,7 @@ namespace FeedCenter.Options
|
|||||||
feed.Name = feed.Title;
|
feed.Name = feed.Title;
|
||||||
|
|
||||||
// Add the feed to the main list
|
// Add the feed to the main list
|
||||||
Database.Feeds.AddObject(feed);
|
Database.Feeds.Add(feed);
|
||||||
|
|
||||||
// Move back to the element node
|
// Move back to the element node
|
||||||
xmlReader.MoveToElement();
|
xmlReader.MoveToElement();
|
||||||
@@ -293,15 +294,15 @@ namespace FeedCenter.Options
|
|||||||
|
|
||||||
private void AddCategory()
|
private void AddCategory()
|
||||||
{
|
{
|
||||||
Category category = new Category();
|
var category = Category.Create();
|
||||||
|
|
||||||
CategoryWindow categoryWindow = new CategoryWindow();
|
var categoryWindow = new CategoryWindow();
|
||||||
|
|
||||||
bool? result = categoryWindow.Display(category, Window.GetWindow(this));
|
var result = categoryWindow.Display(category, Window.GetWindow(this));
|
||||||
|
|
||||||
if (result.HasValue && result.Value)
|
if (result.HasValue && result.Value)
|
||||||
{
|
{
|
||||||
Database.Categories.AddObject(category);
|
Database.Categories.Add(category);
|
||||||
|
|
||||||
categoryListBox.SelectedItem = category;
|
categoryListBox.SelectedItem = category;
|
||||||
|
|
||||||
@@ -314,18 +315,18 @@ namespace FeedCenter.Options
|
|||||||
if (categoryListBox.SelectedItem == null)
|
if (categoryListBox.SelectedItem == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Category category = (Category) categoryListBox.SelectedItem;
|
var category = (Category) categoryListBox.SelectedItem;
|
||||||
|
|
||||||
CategoryWindow categoryWindow = new CategoryWindow();
|
var categoryWindow = new CategoryWindow();
|
||||||
|
|
||||||
categoryWindow.Display(category, Window.GetWindow(this));
|
categoryWindow.Display(category, Window.GetWindow(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeleteSelectedCategory()
|
private void DeleteSelectedCategory()
|
||||||
{
|
{
|
||||||
Category category = (Category) categoryListBox.SelectedItem;
|
var category = (Category) categoryListBox.SelectedItem;
|
||||||
|
|
||||||
Database.Categories.DeleteObject(category);
|
Database.Categories.Remove(category);
|
||||||
|
|
||||||
SetCategoryButtonStates();
|
SetCategoryButtonStates();
|
||||||
}
|
}
|
||||||
@@ -357,7 +358,7 @@ namespace FeedCenter.Options
|
|||||||
{
|
{
|
||||||
if (_collectionViewSource == null)
|
if (_collectionViewSource == null)
|
||||||
{
|
{
|
||||||
_collectionViewSource = new CollectionViewSource {Source = Database.AllFeeds};
|
_collectionViewSource = new CollectionViewSource { Source = Database.AllFeeds };
|
||||||
_collectionViewSource.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
|
_collectionViewSource.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
|
||||||
_collectionViewSource.Filter += HandleCollectionViewSourceFilter;
|
_collectionViewSource.Filter += HandleCollectionViewSourceFilter;
|
||||||
|
|
||||||
@@ -374,20 +375,20 @@ namespace FeedCenter.Options
|
|||||||
|
|
||||||
private void HandleCollectionViewSourceFilter(object sender, FilterEventArgs e)
|
private void HandleCollectionViewSourceFilter(object sender, FilterEventArgs e)
|
||||||
{
|
{
|
||||||
Category selectedCategory = (Category) categoryListBox.SelectedItem;
|
var selectedCategory = (Category) categoryListBox.SelectedItem;
|
||||||
|
|
||||||
Feed feed = (Feed) e.Item;
|
var feed = (Feed) e.Item;
|
||||||
|
|
||||||
e.Accepted = (feed.Category == selectedCategory);
|
e.Accepted = (feed.Category == selectedCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleTextBlockDrop(object sender, DragEventArgs e)
|
private void HandleTextBlockDrop(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
List<Feed> feedList = (List<Feed>) e.Data.GetData(typeof(List<Feed>));
|
var feedList = (List<Feed>) e.Data.GetData(typeof(List<Feed>));
|
||||||
|
|
||||||
Category category = (Category) ((DataGridRow) sender).Item;
|
var category = (Category) ((DataGridRow) sender).Item;
|
||||||
|
|
||||||
foreach (Feed feed in feedList)
|
foreach (var feed in feedList)
|
||||||
feed.Category = category;
|
feed.Category = category;
|
||||||
|
|
||||||
_collectionViewSource.View.Refresh();
|
_collectionViewSource.View.Refresh();
|
||||||
@@ -399,7 +400,7 @@ namespace FeedCenter.Options
|
|||||||
{
|
{
|
||||||
if (e.LeftButton == MouseButtonState.Pressed)
|
if (e.LeftButton == MouseButtonState.Pressed)
|
||||||
{
|
{
|
||||||
List<Feed> selectedItems = feedListBox.SelectedItems.Cast<Feed>().ToList();
|
var selectedItems = feedListBox.SelectedItems.Cast<Feed>().ToList();
|
||||||
|
|
||||||
DragDrop.DoDragDrop(feedListBox, selectedItems, DragDropEffects.Move);
|
DragDrop.DoDragDrop(feedListBox, selectedItems, DragDropEffects.Move);
|
||||||
}
|
}
|
||||||
@@ -407,14 +408,14 @@ namespace FeedCenter.Options
|
|||||||
|
|
||||||
private void HandleTextBlockDragEnter(object sender, DragEventArgs e)
|
private void HandleTextBlockDragEnter(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
DataGridRow dataGridRow = (DataGridRow) sender;
|
var dataGridRow = (DataGridRow) sender;
|
||||||
|
|
||||||
dataGridRow.FontWeight = FontWeights.Bold;
|
dataGridRow.FontWeight = FontWeights.Bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleTextBlockDragLeave(object sender, DragEventArgs e)
|
private void HandleTextBlockDragLeave(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
DataGridRow dataGridRow = (DataGridRow) sender;
|
var dataGridRow = (DataGridRow) sender;
|
||||||
|
|
||||||
dataGridRow.FontWeight = FontWeights.Normal;
|
dataGridRow.FontWeight = FontWeights.Normal;
|
||||||
}
|
}
|
||||||
@@ -426,7 +427,7 @@ namespace FeedCenter.Options
|
|||||||
|
|
||||||
private void HandleMultipleEditClick(object sender, RoutedEventArgs e)
|
private void HandleMultipleEditClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
BulkFeedWindow bulkFeedWindow = new BulkFeedWindow();
|
var bulkFeedWindow = new BulkFeedWindow();
|
||||||
bulkFeedWindow.Display(Window.GetWindow(this), Database);
|
bulkFeedWindow.Display(Window.GetWindow(this), Database);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
using System;
|
namespace FeedCenter.Options
|
||||||
using System.Globalization;
|
|
||||||
using System.Windows.Data;
|
|
||||||
|
|
||||||
namespace FeedCenter.Options
|
|
||||||
{
|
{
|
||||||
public enum MultipleLineDisplay
|
public enum MultipleLineDisplay
|
||||||
{
|
{
|
||||||
@@ -10,24 +6,4 @@ namespace FeedCenter.Options
|
|||||||
SingleLine,
|
SingleLine,
|
||||||
FirstLine
|
FirstLine
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum MultipleOpenAction
|
|
||||||
{
|
|
||||||
IndividualPages,
|
|
||||||
SinglePage
|
|
||||||
}
|
|
||||||
|
|
||||||
[ValueConversion(typeof(int), typeof(MultipleOpenAction))]
|
|
||||||
public class MultipleOpenActionConverter : IValueConverter
|
|
||||||
{
|
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
||||||
{
|
|
||||||
return (MultipleOpenAction) value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
||||||
{
|
|
||||||
return (int) value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
21
Setting.cs
Normal file
21
Setting.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated from a template.
|
||||||
|
//
|
||||||
|
// Manual changes to this file may cause unexpected behavior in your application.
|
||||||
|
// Manual changes to this file will be overwritten if the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace FeedCenter
|
||||||
|
{
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
public partial class Setting
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Value { get; set; }
|
||||||
|
public string Version { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,14 +7,14 @@ namespace FeedCenter
|
|||||||
{
|
{
|
||||||
public static object OpenDataStore()
|
public static object OpenDataStore()
|
||||||
{
|
{
|
||||||
FeedCenterEntities entities = new FeedCenterEntities();
|
var entities = new FeedCenterEntities();
|
||||||
|
|
||||||
return entities.DatabaseExists() ? entities : null;
|
return entities.Database.Exists() ? entities : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void CloseDataStore(object dataStore)
|
public static void CloseDataStore(object dataStore)
|
||||||
{
|
{
|
||||||
FeedCenterEntities entities = (FeedCenterEntities) dataStore;
|
var entities = (FeedCenterEntities) dataStore;
|
||||||
|
|
||||||
if (entities == null)
|
if (entities == null)
|
||||||
return;
|
return;
|
||||||
@@ -26,25 +26,25 @@ namespace FeedCenter
|
|||||||
|
|
||||||
public static string GetSettingValue(object dataStore, string name, string version)
|
public static string GetSettingValue(object dataStore, string name, string version)
|
||||||
{
|
{
|
||||||
FeedCenterEntities entities = (FeedCenterEntities) dataStore;
|
var entities = (FeedCenterEntities) dataStore;
|
||||||
|
|
||||||
if (entities == null)
|
if (entities == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
Setting setting = entities.Settings.FirstOrDefault(s => s.Name == name && s.Version == version);
|
var setting = entities.Settings.FirstOrDefault(s => s.Name == name && s.Version == version);
|
||||||
|
|
||||||
return setting == null ? null : setting.Value;
|
return setting == null ? null : setting.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetSettingValue(object dataStore, string name, string version, string value)
|
public static void SetSettingValue(object dataStore, string name, string version, string value)
|
||||||
{
|
{
|
||||||
FeedCenterEntities entities = (FeedCenterEntities) dataStore;
|
var entities = (FeedCenterEntities) dataStore;
|
||||||
|
|
||||||
if (entities == null)
|
if (entities == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Try to get the setting from the database that matches the name and version
|
// Try to get the setting from the database that matches the name and version
|
||||||
Setting setting = entities.Settings.FirstOrDefault(s => s.Name == name && s.Version == version);
|
var setting = entities.Settings.FirstOrDefault(s => s.Name == name && s.Version == version);
|
||||||
|
|
||||||
// If there was no setting we need to create it
|
// If there was no setting we need to create it
|
||||||
if (setting == null)
|
if (setting == null)
|
||||||
@@ -53,7 +53,7 @@ namespace FeedCenter
|
|||||||
setting = new Setting { Name = name, Version = version };
|
setting = new Setting { Name = name, Version = version };
|
||||||
|
|
||||||
// Add the setting to the database
|
// Add the setting to the database
|
||||||
entities.Settings.AddObject(setting);
|
entities.Settings.Add(setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the value into the setting
|
// Set the value into the setting
|
||||||
@@ -62,7 +62,7 @@ namespace FeedCenter
|
|||||||
|
|
||||||
public static List<string> GetVersionList(object dataStore)
|
public static List<string> GetVersionList(object dataStore)
|
||||||
{
|
{
|
||||||
FeedCenterEntities entities = (FeedCenterEntities) dataStore;
|
var entities = (FeedCenterEntities) dataStore;
|
||||||
|
|
||||||
if (entities == null)
|
if (entities == null)
|
||||||
return null;
|
return null;
|
||||||
@@ -73,7 +73,7 @@ namespace FeedCenter
|
|||||||
|
|
||||||
public static void DeleteSettingsForVersion(object dataStore, string version)
|
public static void DeleteSettingsForVersion(object dataStore, string version)
|
||||||
{
|
{
|
||||||
FeedCenterEntities entities = (FeedCenterEntities) dataStore;
|
var entities = (FeedCenterEntities) dataStore;
|
||||||
|
|
||||||
if (entities == null)
|
if (entities == null)
|
||||||
return;
|
return;
|
||||||
@@ -82,8 +82,8 @@ namespace FeedCenter
|
|||||||
var settings = entities.Settings.Where(setting => setting.Version == version);
|
var settings = entities.Settings.Where(setting => setting.Version == version);
|
||||||
|
|
||||||
// Delete each setting
|
// Delete each setting
|
||||||
foreach (Setting setting in settings)
|
foreach (var setting in settings)
|
||||||
entities.Settings.DeleteObject(setting);
|
entities.Settings.Remove(setting);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
using System;
|
using Common.Debug;
|
||||||
|
using FeedCenter.Data;
|
||||||
|
using FeedCenter.Properties;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Deployment.Application;
|
using System.Deployment.Application;
|
||||||
@@ -6,10 +9,6 @@ using System.Threading;
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
|
|
||||||
using Common.Debug;
|
|
||||||
using FeedCenter.Data;
|
|
||||||
using FeedCenter.Properties;
|
|
||||||
|
|
||||||
namespace FeedCenter
|
namespace FeedCenter
|
||||||
{
|
{
|
||||||
public partial class SplashWindow
|
public partial class SplashWindow
|
||||||
@@ -103,7 +102,7 @@ namespace FeedCenter
|
|||||||
progressBar.Value += e.ProgressPercentage;
|
progressBar.Value += e.ProgressPercentage;
|
||||||
|
|
||||||
// Get the message
|
// Get the message
|
||||||
string message = (string) e.UserState;
|
var message = (string) e.UserState;
|
||||||
|
|
||||||
// Update the status label if one was supplied
|
// Update the status label if one was supplied
|
||||||
if (!string.IsNullOrEmpty(message))
|
if (!string.IsNullOrEmpty(message))
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
using System;
|
using Common.Debug;
|
||||||
|
using FeedCenter.Properties;
|
||||||
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Deployment.Application;
|
using System.Deployment.Application;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
using Common.Debug;
|
|
||||||
|
|
||||||
using FeedCenter.Properties;
|
|
||||||
using Application = System.Windows.Forms.Application;
|
using Application = System.Windows.Forms.Application;
|
||||||
|
|
||||||
namespace FeedCenter
|
namespace FeedCenter
|
||||||
|
|||||||
34
app.config
34
app.config
@@ -1,12 +1,15 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<configSections>
|
<configSections>
|
||||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<section name="FeedCenter.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
|
<section name="FeedCenter.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||||
</sectionGroup>
|
</sectionGroup>
|
||||||
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<section name="FeedCenter.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
|
<section name="FeedCenter.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||||
</sectionGroup>
|
</sectionGroup>
|
||||||
|
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
|
||||||
|
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||||
|
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
|
||||||
</configSections>
|
</configSections>
|
||||||
<userSettings>
|
<userSettings>
|
||||||
<FeedCenter.Properties.Settings>
|
<FeedCenter.Properties.Settings>
|
||||||
@@ -32,7 +35,7 @@
|
|||||||
<value>True</value>
|
<value>True</value>
|
||||||
</setting>
|
</setting>
|
||||||
<setting name="LastVersionCheck" serializeAs="String">
|
<setting name="LastVersionCheck" serializeAs="String">
|
||||||
<value/>
|
<value />
|
||||||
</setting>
|
</setting>
|
||||||
<setting name="StartWithWindows" serializeAs="String">
|
<setting name="StartWithWindows" serializeAs="String">
|
||||||
<value>False</value>
|
<value>False</value>
|
||||||
@@ -50,7 +53,7 @@
|
|||||||
<value>False</value>
|
<value>False</value>
|
||||||
</setting>
|
</setting>
|
||||||
<setting name="Browser" serializeAs="String">
|
<setting name="Browser" serializeAs="String">
|
||||||
<value/>
|
<value />
|
||||||
</setting>
|
</setting>
|
||||||
<setting name="OpenAllSleepIntervalFirst" serializeAs="String">
|
<setting name="OpenAllSleepIntervalFirst" serializeAs="String">
|
||||||
<value>1500</value>
|
<value>1500</value>
|
||||||
@@ -80,7 +83,7 @@
|
|||||||
</FeedCenter.Properties.Settings>
|
</FeedCenter.Properties.Settings>
|
||||||
</applicationSettings>
|
</applicationSettings>
|
||||||
<startup>
|
<startup>
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1"/>
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
|
||||||
</startup>
|
</startup>
|
||||||
<!--<system.data>
|
<!--<system.data>
|
||||||
<DbProviderFactories>
|
<DbProviderFactories>
|
||||||
@@ -89,6 +92,23 @@
|
|||||||
</DbProviderFactories>
|
</DbProviderFactories>
|
||||||
</system.data>-->
|
</system.data>-->
|
||||||
<connectionStrings>
|
<connectionStrings>
|
||||||
<add name="FeedCenterEntities" connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlServerCe.4.0;provider connection string="Data Source=|DataDirectory|\FeedCenter.sdf"" providerName="System.Data.EntityClient"/>
|
<add name="FeedCenterEntities" connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlServerCe.4.0;provider connection string="Data Source=|DataDirectory|\FeedCenter.sdf"" providerName="System.Data.EntityClient" />
|
||||||
</connectionStrings>
|
</connectionStrings>
|
||||||
|
<entityFramework>
|
||||||
|
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
|
||||||
|
<parameters>
|
||||||
|
<parameter value="System.Data.SqlServerCe.4.0" />
|
||||||
|
</parameters>
|
||||||
|
</defaultConnectionFactory>
|
||||||
|
<providers>
|
||||||
|
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
|
||||||
|
<provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" />
|
||||||
|
</providers>
|
||||||
|
</entityFramework>
|
||||||
|
<system.data>
|
||||||
|
<DbProviderFactories>
|
||||||
|
<remove invariant="System.Data.SqlServerCe.4.0" />
|
||||||
|
<add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
|
||||||
|
</DbProviderFactories>
|
||||||
|
</system.data>
|
||||||
</configuration>
|
</configuration>
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="Microsoft.Bcl" version="1.1.8" targetFramework="net45" />
|
<package id="EntityFramework" version="6.1.1" targetFramework="net451" />
|
||||||
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net45" />
|
<package id="EntityFramework.SqlServerCompact" version="6.1.1" targetFramework="net451" />
|
||||||
|
<package id="Microsoft.SqlServer.Compact" version="4.0.8854.1" targetFramework="net451" />
|
||||||
</packages>
|
</packages>
|
||||||
Reference in New Issue
Block a user