A useful article to any SharePoint developer

http://madhurahuja.blogspot.com/2008/01/reveal-unknown-error-on-sharepoint-2007.html

finally find out what the actaul error is!!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

a number of articles by a development team whom implemented a web site using Sharp Architecture

Bill's link

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

I fnd it fun to look at Architecture, as when it comes to building web applications you do not want to re invent the wheel every time. before recently there where not many designs for using .Net in a n-tier approach which did not contain DataSets. If you are like me and come from a OO back ground you may see DataSets to be DataCentric and not easy to apply domain rules to the data (neatly).

With the Alt.Net movement promoting a clean OO approch there has been a nice shift from the DataSet designs to Domain Driven technques. The first publised example framework was Patterns in Action. This is quite nice in the sence it promotes the Gang of Four patterns along with some of Martin Fowlers Pattern of Enterprise Application Architecture (PEAA, one of my faviourte books). I have the .Net 2.0 copy (there is a .Net 3.5 one now), which i would reconmned just so you can see how things fit together.

However, there has been another Architecture I have been following, its S#arp Architecture. This is where all my friends woudl know go, "he mentioning it again", at the same time they will think "but he is right this is worth a look". the SA has just released its version 1 RTM release, of which im partictually found of the WCF addition. If you have not been keeping an eye on this I would reconmend downloading the RC2 (just for the word document) and the RTM (for the updated code). I found this Architcture to be extremely impressive. Its easy to understand and its easer to extend. The best thing is the price tag (its FREE). 

Before you consider looking at an architecture in .Net I would highly reconmend reading the Foundations of Programming, then looking at S#arp Architecture. you will note between these 2 you will have knowlegde of some extremely good tools and patterns.

thats it for my rant,,, go look at the new S#arp Arhicture now!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Some Links for AOP

Published 3/11/2009 by Dave in alt.net | dotNet

AOP is a great way to clean code, well if used correctly. lots of examples will only show the logging example, when an exception is thrown (I should know here is one I wrote: hello world of AOP). Well thats ok, you can see it in action and step through it, however that for me was not enough. So here are a few more really helpful links

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

 This is just to demo a way which could be implemented to reset all the properties to the default values. consider the following:

Test test = new Test();
test.Age = 26;
test.Name = "dave";
test.Test1 = 2222;

//do some work with the object

simple enough, you have created a Test obejct and now you may want to reset the properties back to default, or at least some. Here is a function which will take an object and a skip list, the object is the one which you want to reset, and the skip list contains all the property names which you want to keep. 

/// <summary>
/// this will try to blank all the properties in an object
/// </summary>
/// <param name="o">The object to blank</param>
/// <param name="skipItems">the items to skip</param>
private static void SetDefaults(object o, IList<string> skipItems)
{
 Type t = o.GetType();
 PropertyInfo[] ps = t.GetProperties();

 //done for spped
 if (skipItems == null)
  skipItems = new List<string>();

 foreach (PropertyInfo field in ps)
 {
  Type propType = field.PropertyType;

  //only interested in something that could be a genric container.
  if (!propType.IsValueType && (propType.Name != typeof(string).Name))
   continue;

  if (skipItems.Contains(field.Name))
   continue;

  //get the actual type of the property.
  Type getType = (propType.IsGenericType && propType.GetGenericTypeDefinition() == typeof(Nullable<>)) ?
   Nullable.GetUnderlyingType(propType) : propType;
  //get the default value and set this to the object
  object value = (getType.IsValueType) ? Activator.CreateInstance(getType) : "";
  t.GetProperty(field.Name).SetValue(o, value, null);
 }
}

 

Note, this takes into account of Nullable value types, and sets these to the underlying value type default. second note this will only reset value types and strings (but its easy to change for what you may want).

Taking the example object above and appending some code we can demo reseting the properties

Test test = new Test();
test.Age = 26;
test.Name = "dave";
test.Test1 = 2222;

Console.WriteLine("Before");
Console.WriteLine(PrintAll(test));


List<string> leave = new List<string>();
leave.Add("Name");


SetDefaults(test, leave);
Console.WriteLine("After");
Console.WriteLine(PrintAll(test));

Console.ReadLine();

Out come

if you were wondering what is the PrintAll function, here it is

/// <summary>
/// Gets all the properties, and places the vlaues into a string, ready to be
/// printed out to a cmd prompt
/// </summary>
/// <param name="o">the object to get the values of</param>
/// <returns>a string of all the property values</returns>
public static string PrintAll(object o)
{
 StringBuilder str = new StringBuilder();

 Type t = o.GetType();
 PropertyInfo[] ps = t.GetProperties();

 foreach (PropertyInfo field in ps)
 {
  Type propType = field.PropertyType;
  //only interested in something that could be a genric container.
  if (!propType.IsValueType && (propType.Name != typeof(string).Name))
   continue;

  object value = t.GetProperty(field.Name).GetValue(o, null);
  string msg = (value == null) ? "" : value.ToString();

  msg = string.Format("Property: {0}, value: {1}", field.Name, msg);
  str.AppendLine(msg);
 }
 return str.ToString();
}

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Here are 3 quick lessons to get you started using  the DotDiff Library.

Attached Project (vs 2008) Tutorial_DotDiff1.zip (67.29 kb)

Lessons

  1. simple compare and merge
  2. Generate a Diff Gram
  3. Advanced Compare and Merge

Common Setup

Before we start any of the lessons lets go over the common set up  steps, which are as follows:

//Step 1, create an instance of the compare engine.
XmlCompare xmlCompare = new XmlCompare();

//step2, load in the documents
xmlCompare.LoadOldDocXml(File.ReadAllText("Old Xml file"));
xmlCompare.LoadNewDocXml(File.ReadAllText("New Xml file"));

//Step 3, run the compare Engine.
xmlCompare.Compare(); //yep you have just compared these documents.

From this point forward you can now:

  • Look at the Differences and merge them back into the OldXml (Lesson 1) 
  • Generate a Diff Gram AKA a Difference Graph (Lesson 2)
  • Re-Compare and other changes.

Lesson 1 

Lesson 1, is to simply compare 2 Xml files and merge a single change. start of by following the common setup, and then you can do the following:

//now lets copy of only one of the changes
DiffInstance diffInstance = xmlCompare.Differences[0];

Console.WriteLine("About to merge the following chnage: {0}, which is {1}",
    diffInstance.XPath, diffInstance.Difference.ToString());

xmlCompare.MergeNode(diffInstance); //Merge the selected change back into the oldXml doc
xmlCompare.UpdateDifferences(); //cleans up the Differences collection.

The above code, just merged the first difference into the OldXml document. That seemed simple enough

Lesson 2

Lesson 2 looks at creating a Diff Gram, you may ask what is a diff gram? Well its the Xml which only holds what is different between the New and Old Documents, it will not contain any information which both contain. making it nice and compact (helpful for updates). As with Lesson 1, follow the common setup steps and proceed with:

//Now we can Generate the Diff Gram
XmlDocument DiffDoc = xmlCompare.GenerateDifferenceGraph(); //Simple Enough

thats it, you have just created the Diff Gram, now that was not too hard :D

Lesson 3

Lesson 3 uses the advanced feature of the "IdNode", consider the following XML

<book >
  <Id>1</Id>
  <title lang="eng">Harry Potter</title>
  <price>29.99</price>
</book>

note the child node called "Id", this as you can guess is the Identifier node of the Book object. If you try and compare normally with DotDiff, it cannot tell the difference between book 1 and book 2, unless you do the following.

//Step 1, create an instance of the compare engine.
XmlCompare xmlCompare = new XmlCompare();
xmlCompare.IdNode = "Id"; //Set the name of the Id Node

This small alteration to step 1 in the setup will notify DotDiff you have child nodes with the name of "Id" as the Identifiers. You can now compare as you did before (Lesson 1) and generate Diff grams as in lesson 2

I hope this sheds some light on the use of this Library.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

I have written code for open source before, but this is my first full (small) project which I have released.

Presenting, Pause for effect, DotDiff, (first day see's 12 downloads!)

If you remember the sandbox compare tool I wrote way back last year, I have neaten some of the code up added in a Diff Gram feature and released the code on codeplex. Feel free to download it today.

Please Tell me what you think of it. Laughing, yes i know about the lack of documentation, but i have included a sample interface and comments on the code.

Hope you like it.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Snippy

Published 12/21/2008 by Dave in dotNet

I recently joined stackoverflow (which is awesome, and yes i know i should have done it sooner). however a recent post asked about a way to quickly test snippets of code, with out the need to open visual studio and create a full project. One answer mentioned Snippy.

its pretty simply, a small IDE, which allows developers to tests snippets of their code, quickly. its in a alpha release.

comes with

  • intellisence
  • code highlighting
  • supports .net (2 verions, 1.1 and a 2.0/3.5)

 

Now you have no excuses to help out in forums Laughing

Download your copy today - Snippy

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Looking into templating.

Published 11/23/2008 by Dave in dotNet

Work in progress - published to preview

On a side project Im looking into a means of templating some output files.

I have found 2 main ways so far (with out the need of other tools such as CodeSmith) key focus is free.

  1. NVelocity (Noticed Castle Project had updated the Open Source project)
  2. TemplateMaschine (another free one, closer to T4's/ASP.NET way)

I have not included Microsoft T4 ToolBox as this seems to be for code generation, where a file will be exported to a folder.

Test

A simple road test is in order, lets look into creating the following output (consider this the HelloWorld, where the Name "Dave" can be injected as an arguement)

1. The Template File

The template file to produce this required outcome, (syntax is important, consider the people whom will write the templates, will they be coders?)

Nvolicity

Hello $Name


this is a test

TemplateMaschine

<%@ Argument Name="name" Type="string" %>
Hello <%=name%>


this is a test

First observation, the TemplateMaschine requires the varibles to be declared, this could be useful (again, it depends on what you want to do.)

2. The Code

the code samples will try to use the default settings. the template file will be located in the same folder as the created Exe.

NVolicity

With NVolicity you can set up properties on the engine, as this was more of an advance option i have left it alone.

//following the CastleProject instructions.
VelocityEngine velocity = new VelocityEngine();
ExtendedProperties props = new ExtendedProperties();
velocity.Init(props);

//get the template file.
string fileName = "<a href="file://templatefile.txt/">\\templateFile.txt</a>";
Template template = velocity.GetTemplate(fileName);

//create arguements. the context
VelocityContext context = new VelocityContext();
context.Put("Name", "Dave");

//get the output and display
StringWriter writer = new StringWriter();
template.Merge(context, writer);
Console.WriteLine(writer.GetStringBuilder().ToString());

Console.ReadLine();

TemplateMaschine

//get the execution folder.
string location =Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);


// Load a template from file 'Sample2.template' and compile it
string fileName = location + "<a href="file://template.txt/">\\template.txt</a>";
Template myTemplate = new Template(fileName);

//setup the input args
Dictionary<string,object> inputArgs = new Dictionary<string, object>();
inputArgs.Add("name", "Dave");

//get the output
string output = myTemplate.Generate(inputArgs);
Console.WriteLine(output);

Console.ReadLine();

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

FREE Tools for the .Net Developer!

Published 11/2/2008 by Dave in dotNet
Tags:

Co in siding with the new release of CodeRush Xpress for C#, (give it a go today!) here is a list of FREE tools, which I think, are a must have:

.Net Visual Studio Tools

Code Rush Xpress, C# & VS2008 only- helps you code faster

IntelliSpell Community - correct you bad spelling, in your XML comments, strings etc

Ghost Doc - helps you on your XML comments

Source Out liner - provides a tree view of your source code's types and members and lets you quickly navigate to them with filtering inside the editor.

Source Control (SVN) - great article with links for plugins

.Net Tools

Reflector - Look into the compiled .Net Dll's, Awesome tool, now owned by Red-Gate

Reflector add ins - loads of plugins. worth your time to have a look.

SandBox Compare - compares the .dbproj file to the .dbproj.user, highlights the differences and allows you to merge them. (developed by your truly :D)

Web Tools

Fiddler - HTTP packet sniffer, this is a proxy tool, it lets you see the traffic between the browser and the web server.

FireFox, with Firebug

Other Utils

WinMerge - Compare 2 files/folders, highlights the Differences and merges the difference.

Expresso - allows you to test your Regex expressions, like an IDE for regex, really cool.

Agent Ransack - file search tool, it will find the file and tell you the line number of where the text appears, also has its own expression engine, and its fast.

 

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5