Thursday, March 29, 2012
Friday, March 23, 2012
Adding SharePoint library to page in subsite
Adding SharePoint library to page in subsite. Found simple solution here.
Thursday, March 22, 2012
ContentTypeRef or ContentType in schema.xml
Couldn't figure out why my schema.xml adapted from a downloaded site template .stp file was not a Contact type (ServerTemplate was not 105). The following quote explains why:
http://www.rnowik.com/SharePoint-Content-Type-IDs.aspx
This article seems to favor using the copy-a-ContentType into your list definition: http://rnowik.com/MOSS-WSS-3-0-Creating-a-custom-list-feature.aspx
This article seem to indicate ContentType is disfavored and ContentTypeRef is preferred: http://withinsharepoint.com/archives/115
It is noteworthy in this article that Visual Studio appears to have imported the ContentType.
The problem with using ContentTypeRef is that I see no way to override the DisplayName of title as shown in dispform.aspx and EditForm.aspx, which continues to show the Last Name of the referenced ContentType.
It is worth noting that you can specify a new content type in a schema.xml file of a list feature (aka list definition), however inheritance from the parent class is not preserved if specified there (bizarrely).
http://www.rnowik.com/SharePoint-Content-Type-IDs.aspx
This article seems to favor using the copy-a-ContentType into your list definition: http://rnowik.com/MOSS-WSS-3-0-Creating-a-custom-list-feature.aspx
This article seem to indicate ContentType is disfavored and ContentTypeRef is preferred: http://withinsharepoint.com/archives/115
It is noteworthy in this article that Visual Studio appears to have imported the ContentType.
The problem with using ContentTypeRef is that I see no way to override the DisplayName of title as shown in dispform.aspx and EditForm.aspx, which continues to show the Last Name of the referenced ContentType.
On choosing ServerTemplate/type in ListTemplate
See my comment (by "AWG") at http://karinebosch.wordpress.com/walkthroughs/create-custom-list-templates-in-caml/
Note, I think from MSDN settles the question of whether the type ID from one of the base lists can be used in your custom list template: "This identifier must be unique within the feature, but need not be unique across all feature definitiohttp://www.blogger.com/img/blank.gifns or site definitions."
Note, I think from MSDN settles the question of whether the type ID from one of the base lists can be used in your custom list template: "This identifier must be unique within the feature, but need not be unique across all feature definitiohttp://www.blogger.com/img/blank.gifns or site definitions."
Monday, March 19, 2012
Reuse Logic with Expression Trees
Here the reused logic is in the variable predicateBody:
ref: http://msdn.microsoft.com/en-us/library/bb882637.aspx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string[] companies = { "Consolidated Messenger", "Alpine Ski House", "Southridge Video", "City Power & Light",
"Coho Winery", "Wide World Importers", "Graphic Design Institute", "Adventure Works",
"Humongous Insurance", "Woodgrove Bank", "Margie's Travel", "Northwind Traders",
"Blue Yonder Airlines", "Trey Research", "The Phone Company",
"Wingtip Toys", "Lucerne Publishing", "Fourth Coffee" };
// The IQueryable data to query.
IQueryable<String> queryableData = companies.AsQueryable<string>();
// Compose the expression tree that represents the parameter to the predicate.
ParameterExpression pe = Expression.Parameter(typeof(string), "company");
// ***** Where(company => (company.ToLower() == "coho winery" || company.Length > 16)) *****
// Create an expression tree that represents the expression 'company.ToLower() == "coho winery"'.
Expression left = Expression.Call(pe, typeof(string).GetMethod("ToLower", System.Type.EmptyTypes));
Expression right = Expression.Constant("coho winery");
Expression e1 = Expression.Equal(left, right);
// Create an expression tree that represents the expression 'company.Length > 16'.
left = Expression.Property(pe, typeof(string).GetProperty("Length"));
right = Expression.Constant(16, typeof(int));
Expression e2 = Expression.GreaterThan(left, right);
// Combine the expression trees to create an expression tree that represents the
// expression '(company.ToLower() == "coho winery" || company.Length > 16)'.
Expression predicateBody = Expression.OrElse(e1, e2);
// Create an expression tree that represents the expression
// 'queryableData.Where(company => (company.ToLower() == "coho winery" || company.Length > 16))'
MethodCallExpression whereCallExpression = Expression.Call(
typeof(Queryable),
"Where",
new Type[] { queryableData.ElementType },
queryableData.Expression,
Expression.Lambda<Func<string, bool>>(predicateBody, new ParameterExpression[] { pe }));
// ***** End Where *****
// ***** OrderBy(company => company) *****
// Create an expression tree that represents the expression
// 'whereCallExpression.OrderBy(company => company)'
MethodCallExpression orderByCallExpression = Expression.Call(
typeof(Queryable),
"OrderBy",
new Type[] { queryableData.ElementType, queryableData.ElementType },
whereCallExpression,
Expression.Lambda<Func<string, string>>(pe, new ParameterExpression[] { pe }));
// ***** End OrderBy *****
Console.WriteLine("orderByCallExpression: " + orderByCallExpression.ToString());
// Create an executable query from the expression tree.
IQueryable<string> results = queryableData.Provider.CreateQuery<string>(whereCallExpression);
// Enumerate the results.
foreach (string company in results)
Console.WriteLine(company);
/* This code produces the following output:
Blue Yonder Airlines
City Power & Light
Coho Winery
Consolidated Messenger
Graphic Design Institute
Humongous Insurance
Lucerne Publishing
Northwind Traders
The Phone Company
Wide World Importers
*/
Console.WriteLine("\n\n");
string[] companies2 = { "Consolidateds Messenger", "Alpines Ski House", "Southridges Video", "City Power & Light",
"Coho Winery", "Wides World Importers", "Graphics Design Institute", "Adventure Works",
"Humongouss Insurance", "Woodgroves Bank", "Margie'ss Travel", "Northwind Traders",
"Blues Yonder Airlines", "Treys Research", "Thes Phone Company",
"Wingtips Toys", "Lucerne Publishing", "Fourth Coffee" };
Console.WriteLine("predicateBody: " + predicateBody.ToString());
IQueryable<string> iqueryable2 = companies2.AsQueryable<string>();
Console.WriteLine("iqueryable2: " + iqueryable2.ToString());
MethodCallExpression whereCallExpression2 = Expression.Call(
typeof(Queryable),
"Where",
new Type[] { iqueryable2.ElementType },
iqueryable2.Expression,
Expression.Lambda<Func<string, bool>>(predicateBody, new ParameterExpression[] { pe }));
Console.WriteLine("whereCallExpression2: " + whereCallExpression2.ToString());
IQueryable<string> results2 = iqueryable2.Provider.CreateQuery<string>(whereCallExpression2);
foreach (string compan in results2)
Console.WriteLine(compan);http://www.blogger.com/img/blank.gif
Console.ReadLine();
}
}
}
ref: http://msdn.microsoft.com/en-us/library/bb882637.aspx
Sunday, March 11, 2012
An Investigation of the Laws of Thought, by George Boole
Causally Given vs Derived
http://www.gutenberg.org/files/15114/15114-pdf.pdf
As concerns the data, they are either causally given,—as when the probability of a particular throw of a die is deduced from a knowledge of the constitution of the piece,—or they are derived from observation of repeated instances of the success or failure of events. In the latter case the probability of an event may be defined as the limit toward which the ratio of the favourable to the whole number of observed cases approaches (the uniformity of nature being presupposed) as the observations are indefinitely continued.
http://www.gutenberg.org/files/15114/15114-pdf.pdf
Thursday, March 8, 2012
Covariant, Contravariant
Covariant - may assign derived to a base; i.e. polymorphism
Contravariant - may assign base to derived; used with delegate generic type parameters, i.e. the parameters of the function when executed may be derived
http://msdn.microsoft.com/en-us/library/dd799517.aspx
Contravariant - may assign base to derived; used with delegate generic type parameters, i.e. the parameters of the function when executed may be derived
http://msdn.microsoft.com/en-us/library/dd799517.aspx
Subscribe to:
Posts (Atom)