text:
Hey NHibernate, Don't Mess With My Enums!Posted: April 16, 2011 Filed under: C#, DataBase, Mono.NET | Tags: .NET, C#, DataBase, Enum, Fluent NHibernate, Mono, NHibernate, ORM 2 Comments
So I've been using Fluent NHibernate for a short while now. Initially I had to overcome some minor challenges, but since I got those out of the way it's been pretty smooth sailing. One thing that stands out, which required more tinkering and timeshare than I would've liked is the way NHibernate handles the .NET enum type. Natively NHibernate allows you to save your enum's value as a string or number property/column in the referencing object's table. In other words, by default it doesn't allow you to map your enum to its own separate table, and then let your objects refer to it through an association/foreign key. For NHibernate enums are primitive values, and not "entity objects" (logically speaking – ignoring the technical internal mechanics of .NET's enum). I would argue that enums can be both a primitive string or number, or a more complex entity. Under certain circumstances an enum can be viewed as a simple "object" that consists of two properties:
- An Id, represented by the enum member's number value
- And a name, represented by the enum member's string name.
I've found that it's very convenient to use the "entity object" version of enums for very simple, slow changing look-up data with a fair amount of business logic attached to it. For instance in a credit application app, you might only support 3 or 4 types of loans, but you know that over time app's life, the company won't add more than 2 or 3 new types of loans. Adding a loan type requires some additional work, and isn't merely a matter of just inserting a new loan type into a look-up table. The reason is that a fair amount of the app's business logic, mainly in the form of conditional logic statements, must also be adapted to accommodate the new loan type. From a coding perspective it's very convenient to use enum types in these cases, because you can refer to the various options through DRY strong typed members, with a simultaneous string and number representation. So instead of
var loan = loanRepository.FindById(234); var loanType = loanTypeRepository.FindById(123); // ... if (loan.Type == "PersonalLoan") { // ... }
rather do
var loan = loanRepository.FindById(234); if (loan.Type == LoanType.Personal) { //... }
Okay, schweet, you get the point. Next logical question: How do you get NHibernate to treat your enums as objects with their own table, and not primitive values? To do this you have to create a generic class that can wrap your enum types, and then create a mapping for this enum wrapper class. I call this class Reference:
public class Reference<TEnum> { private TEnum enm; public Reference(TEnum enm) { this.enm = enm; } public Reference() {} public virtual int Id { get { return Convert.ToInt32(enm); } set { enm = (TEnum)Enum.Parse(typeof(TEnum), value.ToString(), true); } } public virtual string Name { get { return enm.ToString(); } set { enm = (TEnum)Enum.Parse(typeof(TEnum), value, true); } } public virtual TEnum Value { get { return enm; } set { enm = value; } } }
The Reference class is pretty straight forward. All it does is translate the contained enum into an object with three properties:
- Id – the integer value of the enum member.
- Name – the string name of the enum member.
- Value – the contained enum member.
You might wonder why I didn't bother to restrict the allowed generic Types to enums. Well, it so happens that .NET generics doesn't allow you to restrict generic type declarations to enums. It allows you to restrict generic types to structs, and all sort of other things, but not to enums. So you will never be able to get an exact generic restriction for the Reference class. So I thought, aag what the hell, if I can't get an exact restriction, then what's the point anyways? I'll have to trust that whoever is using the code, knows what he's doing.
Now, for example, instead of directly using the LoanTypes enum, the Loan class's Type property will be a Reference object, with its generic type set to the LoanTypes enum:
public class Loan { // ... public Reference<LoanType> Type { get; set; } // ... }
This is not completely tidy, because to a degree the limitations of the data access infrastructure, i.e. NHibernate, force us to adopt a compromise solution that's not necessary if we changed to something else. In other words things from the data infrastructure layers spills into the domain.
What's left to do is (1) create a mapping for Reference<LoanType>, and (2) get NHibernate to use the right table name, i.e. LoanType, instead of Reference[LoanType]. Here the Fluent NHibernate mapping for Reference<LoanType>:
public class LoanTypeMap: ClassMap<Reference<LoanType>> { public LoanTypeMap() { Table(typeof(LoanType).Name); Id(loanType => loanType.Id).GeneratedBy.Assigned(); Map(loanType => loanType.Name); } }
The above Fluent NHibernate mapping tells NHibernate to use whatever value property Id has for the primary key, and not generate one for it. You also have to explicitly specify the table's name you'd like NHibernate to use, because you want to ignore "Reference" as part of the table name, and only use the enum type name.
And that's it. You will now have a separate table called LoanType, with the foreign keys of other classes' tables referencing the LoanType enum's table. Just keep in mind that this solution might not always be feasible. For example it might not work too well when you write a multilingual application. Also should you want to get a pretty description for each enum's member, for example "Personal Loan", instead of "PersonalLoan" you'll have to throw in some intelligent text parsing that split's a text string before each uppercase character. Hopefully this post gave you another option to map your enum types with NHibernate.
REST Web Services with ServiceStackPosted: March 21, 2011 Filed under: C#, InfoTech, Mono.NET | Tags: .NET, Alt.Net, Apache, C#, HTTP, IIS, JavaScript, JSON, mod_mono, Mono, Open Source, REST, ServiceStack, WCF, Web Services 12 Comments
Over the past month I ventured deep into the alternative side of the .NET web world. I took quite a few web frameworks for a test drive, including OpenRasta, Nancy, Kayak and ServiceStack. All of the aforementioned supports Mono, except OpenRasta, that has it on its road-map. While kicking the tires of each framework, some harder than others, I saw the extent of just how far .NET has grown beyond its Microsoft roots, and how spoiled .NET developers have become with a long list of viable alternative .NET solutions from the valley of open source.
ServiceStack really impressed me, with its solid mix of components that speak to the heart of any modern C# web application. From Redis NOSQL and lightweight relational database libraries, right through to an extremely simple REST and SOAP web service framework. As the name suggests, it is indeed a complete stack.
Anyways, enough with the marketing fluff, let's pop the bonnet and get our hands dirty. What I'm going to show you isn't anything advanced. Just a few basic steps to help you to get to like the ServiceStack web framework as much as I do. You can learn the same things I'll be explaining here by investigating the very complete ServiceStack example applications, but I thought some extra tidbits I picked up working through some of them should make life even easier for you.
Some Background Info On REST
I'm going to show you how to build a REpresentation State Transfer (REST) web service with ServiceStack. RESTful web services declare resources that have a URI and can be accessed through HTTP methods, or verbs (GET, PUT, POST and DELETE), to our domain services and entities. This is different from SOAP web services that require you to expose methods RPC style, that are ignorant of the underlying HTTP methods and headers. To implement a REST resource and its HTTP-methods in ServiceStack requires the use of two classes, RestService and RestServiceAttribute.
Another feature of REST is that data resources are encoded in either XML or JSON. However, the latest trend is to encode objects in JSON for its brevity and smaller size, rather than its more clunky counterpart, XML. We will therefore follow suit and do the same. Okay, I think you're ready now to write your first line of ServiceStack code.
Create a Web Service Host with AppHostBase
The first thing you have to do is specify how you'd like ServiceStack to run your web services. You can choose to either run your web services from Internet Information Services (IIS) or Apache, or from the embedded HTTP listener based web server. Both of these approaches require you to declare a class that inherits from AppHostBase:
public class AppHost: AppHostBase { public AppHost() : base("Robots Web Service: It's alive!", typeof(RobotRestResource).Assembly) {} public override void Configure(Container container) { SetConfig(new EndpointHostConfig { GlobalResponseHeaders = { { "Access-Control-Allow-Origin", "*" }, { "Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS" }, }, }); } }
Class AppHost's default constructor makes a call to AppHostBase's constructor that takes 2 arguments. This first argument is the name of the web app, and the second argument tells ServiceStack to scan the Assembly where class RobotRestResource is defined, for REST web services and resources.
Now all that's left to do is to initialize your custom web service host in Global.asax's Application_Start method:
public class Global : System.Web.HttpApplication { protected void Application_Start(object sender, EventArgs e) { new AppHost().Init(); } }
The last thing you might be wondering about, before we move on, is the web.config of your ServiceStack web service. For reasons of brevity I'm not going to cover this, but please download ServiceStack's examples and use one of their web.configs. The setup require to run ServiceStack from IIS is really minimal, and very easy to configure.
Define REST Resources with RestService
Now that we've created a host for our services, we're ready to create some REST resources. In a very basic sense you could say a REST resource is like a Data Transfer Object (DTO) that provides a suitable external representation of your domain. Let's create a resource that represents a robot:
using System.Collections.Generic; using System.Runtime.Serialization; [RestService("/robot", "GET,POST,PUT,OPTIONS")] [DataContract] public class RobotRestResource { [DataMember] public string Name { get; set; } [DataMember] public double IntelligenceRating { get; set; } [DataMember] public bool IsATerminator { get; set; } [DataMember] public IList<string> Predecessors { get; set; } public IList<Thought> Thoughts { get; set; } }
The minimum requirement for a class to be recognized as a REST resource by ServiceStack, is that it must
inherit from IRestResource, and have a RestServiceAttribute with a URL template, and that's it. ServiceStack doesn't force you to use the DataContractAttribute or DataMemberAttribute. The only reason I used it for the example is to demonstrate how to exclude a member from being serialized to JSON when it's sent to the client. The Thoughts member will not be serialized and the web client will never know the value of this object. I had a situation where I wanted to have a member on my resource for internal use in my application, but I didn't want to send it to clients over the web service. In this situation you have to apply the DataContractAttribute to your resource's class definition, and the DataMemberAttribute to each property you want to expose. And that's it, nothing else is required to declare a REST resource ffor ServiceStack.
Provide a Service for Each Resource with RestServiceBase
Each resource you declare requires a corresponding service that implements the supported HTTP verb-methods:
public class RobotRestService: RestServiceBase<RobotRestResource> { public override object OnPut(RobotRestResource robotRestResource) { // Do something here & return a // new RobotRestResource here, // or any other serializable // object, if you like. } public override object OnGet(RobotRestResource robotRestResource) { // Do some things here ... // Return the list of RobotRestResources // here, or any other serializable // object, if you like. return new [] { new RobotRestResource(), new RobotRestResource() }; } }
In order for ServiceStack to assign a class as a service for a resource, you have to inherit from RestServiceBase, specifying the resource class as the generic type. RestServiceBase provides virtual methods for each REST approved HTTP-verb: OnGet for GET, OnPut for PUT, OnPost for POST and OnDelete for DELETE. You can selectively override each one that your resource supports.
Each HTTP-verb method may return one of the following results:
- Your IRestResource DTO object. This will send the object to the client in the specified format JSON, or XML.
- ServiceStack.Common.Web.HtmlResult, when you want to render the page on the server and send that to the client.
- ServiceStack.Common.Web.HttpResult, when you want to send a HTTP status to the client, for instance to redirect the client:
var httpResult = new HttpResult(new object(), null, HttpStatusCode.Redirect); httpResult.Headers[HttpHeaders.Location] = "http://openlandscape.wordpress.com"; return httpResult;
And that's it. Launch your web site, and call the OnGet methof at /robot?format=json, or if you prefer XML /robot?format=xml. To debug your RESTful service API I can highly recommend the Poster Firefox plug-in. Poster allows you to manually construct HTTP commands and send them to the server.
You might be wondering what the purpose is of RobotRestResource that gets passed to each HTTP-verb method. Well, that is basically an aggregation of the posted form parameters and URL query string parameters. In other words if the submitted form has a corresponding field name to one of RobotRestResource's properties, ServiceStack will automatically assign the parameter's value to the supplied RobotRestResource. The same applies for query strings, the query strings ?Name="TheTerminator"&IsATerminator=true: robotRestResource's Name will be assigned the value of "TheTerminator" and IsATerminator will be true.
Using ServiceStack's Built-In Web Service as a Service Host
The above discussion assumed that you'll be hosting your ServiceStack service in IIS or with mod_mono in Apache. However, ServiceStack has another pretty cool option available, self hosting. That's right, services can be independently hosted on their own and embedded in your application. This might be useful in scenarios where you don't want to be dependent on IIS. I imagine something like a Windows service, or similar, that also serves as small web server to expose a web service API to clients, without the need for lengthy and complicated IIS setup procedures.
var appHost = new AppHost(); appHost.Init(); appHost.Start("http://localhost:82/");
To start the self hosted ServiceStack you configure your host as usual, and then call Start(…), passing the URL (with free port) where the web server will be accessed.
Why Use ServiceStack
For me one of the big reasons for choosing ServiceStack is that it has a solid library to build web services running on Mono. However, after using if for a while I found its easy setup and simple conventions very refreshing from the often confusing and cumbersome configuration of Windows Communication Foundation (WCF) web services.ServiceStack also does a much better job of RESTful services, than WCF's current implementation. I know future versions of WCF will enable a more mature RESTful architecture, but for now it's pretty much RPC hacked into REST. Another bonus was the complete set of example apps that were a great help to quickly get things working. So if you're tired of WCF's heavy configuration and you're looking for something to quickly implement mature RESTful web services, then definitely give ServiceStack a try.
Fluent NHibernate on PostgreSQLPosted: November 23, 2010 Filed under: C#, DataBase, Mono.NET | Tags: C#, Fluent NHibernate, Mono, NHibernate, Object Relational Mapper, ORM, Postgres, PostgreSQL 7 Comments
When you write your first Fluent NHibernate application with Mono/.NET based on the Getting started tutorial, you eventually discover that you require a few extra assembly-dll references not mentioned. For my Postgres (PostgreSQL) project my references are:
I won't go into the detail of the matter, other than to say that many of these don't give you a very clear indication as to what exactly is missing.
To configure Fluent NHibernate to work with Postgres you will need the following:
var connectionStr = "Server=127.0.0.1;Port=5432;Database=the_db;User Id=user_name;Password=password;" ISessionFactory sessionFactory = Fluently .Configure() .Database(PostgreSQLConfiguration.Standard.ConnectionString(connectionStr)) .Mappings(m => m.FluentMappings.AddFromAssemblyOf<TypeOfFluentNHibernateMapping>()) .ExposeConfiguration(BuildSchema) .BuildSessionFactory(); private static void BuildSchema(Configuration config) { // This NHibernate tool takes a configuration (with mapping info in) // and exports a database schema from it. var dbSchemaExport = new SchemaExport(config); //dbSchemaExport.Drop(false, true); dbSchemaExport.Create(false, true); }
TypeOfFluentNHibernateMapping is a class that inherits from FluentNHibernate.Mapping.ClassMap<T>. This tells Fluent to load all ClassMappings from the assembly where this type is defined.
BuildSchema(…) creates the database's schema based on the specified mapping configuration and recreates the tables and the rest of it in the database specified by the connection string. I included the call to the schema export's drop method, because the code originates from my unit tests, where I drop & recreate the database on each test run.
So far I like Fluent NHibernate, and the only complaint I have so far is the way NHibernate (not Fluent) handles enums. It assumes you want to use the enum member's string name. The way I like to store my enums, are to have a separate table for them.
Sexy Transactions In Spring.NETPosted: July 28, 2010 Filed under: C#, DataBase, Mono.NET | Tags: .NET 4, ADO.NET, Enterprise Services, Entity Framework, NHibernate, POCO, Spring.NET, SQL Server, System.Transactions, Transaction Management 2 Comments
Spring.NET really has tons of handy features you can put to work in your application. One of them is its transaction management, that provides an implementation agnostic abstraction for your application. The first question you're probably asking yourself is, why do you need to abstract away your transaction technology? The short answer is there are various ways of using transactions and different transaction technologies: ADO.NET, Enterprise Services, System.Transactions, and the different transaction implementations for other database technologies like ORMs (NHibernate). I won't go into the detail of these, suffice to say that choosing, using and changing a transaction technology can become a complicated affair, and that Spring.NET protects your application from these ugly details. I encourage you to take a deep dive into the official Spring.NET documentation, should you want to know more about the details behind this.
What I did was, write a helper class that makes it a little easier and cleaner to use Spring.NET's transaction management:
/// <summary> /// Manages database transactions by wrapping executed /// methods in a transaction. /// </summary> public static class Transaction { /// <summary> /// Executes the specified method in a transaction. /// </summary> public static void Execute(Action method, bool commitChanges = true) { // Create a new transaction Instantiate.New<ITransactionOperations>().Execute(delegate(ITransactionStatus transaction) { // If changes should not be committed, make // sure we roll back once done if (!commitChanges) transaction.SetRollbackOnly(); method(); return null; }); } } /// <summary> /// Instantiates objects based on their name. /// </summary> public static class Instantiate { #region Fields private static IApplicationContext context; #endregion #region Get objects from ApplicationContext /// <summary> /// Retrieves the object with the specified name. /// </summary> /// <typeparam name="T">The type of object to return. /// <param name="name">The name of the object.</param> /// <returns>A newly created object with the type specified by the name, or a singleton object if so configured.</returns> public static T New<T>(string name) { return (T)Context.GetObject(name); } /// <summary> /// Retrieves the object of the specified type. /// </summary> public static T New<T>() { return (from obj in Context.GetObjectsOfType(typeof(T)).Values.Cast().ToList() select obj).FirstOrDefault(); } /// <summary> /// Retrieves the object with the specified name, and constructor arguments. /// </summary> public static T New<T>(string name, object[] arguments) { return (T)Context.GetObject(name, arguments); } #endregion #region Private methods /// <summary> /// Gets the context. /// </summary> /// <value>The context.</value> private static IApplicationContext Context { get { if (context == null) { context = ContextRegistry.GetContext(); } return context; } } #endregion }
Class Instantiate
The Instantiate class is a wrapper for Spring.NET's IApplicationContext, with a few helper methods. It provides three overloads of the method New<T>, that instantiates new objects from the ApplicationContext configuration. The most important method is New<T> without any arguments. This method simply grabs the first instance of the requested Type it finds in the ApplicationContext. The other two variations allow you to instantiate a new object with a specific id.
With the help of the Instantiate class the Transaction class will obtain the specified transaction management from Spring's ApplicationContext.
Class Transaction
This is where all the action really happens as far as database transactions go. The Transaction class has a single Execute method, that transparently wraps any block of code in a transaction. There are a small number of things you have to do to use Spring's transaction management:
1. First get an instance of your chosen transaction implementation.
2. Call Execute with a delegate with an ITransactionStatus argument.
3. When you're done, you have to return something, even if it's null.
My goal is to remove the above 3 requirements, so I can just pass a block of code through to get it wrapped in a transaction. This is exactly what Execute achieves:
Transaction.Execute(() => { // Get a FileTypeRepository var fileTypeRepository = Instantiate.New(); // Add an object fileTypeRepository.Add(fileType); // Save the changes to the database fileTypeRepository.SaveChanges(); });
Spring.NET provides 4 transaction implementations:
- Spring.Data.Core.AdoPlatformTransactionManager - local ADO.NET based transactions
- Spring.Data.Core.ServiceDomainPlatformTransactionManager - distributed transaction manager from Enterprise Services
- Spring.Data.Core.TxScopeTransactionManager - local/distributed transaction manager from System.Transactions.
- Spring.Data.NHibernate.HibernateTransactionManager - local transaction manager for use with NHibernate or mixed ADO.NET/NHibernate data access operations.
To configure your transaction manager for the ApplicationContext you need:
<objects xmlns="http://www.springframework.net"> <object id="transactionManager" type="Spring.Data.Core.TxScopeTransactionManager, Spring.Data" /> <object id="transactionTemplate" type="Spring.Transaction.Support.TransactionTemplate, Spring.Data" autowire="constructor" /> </objects>
Spring.NET' provides a TransactionTemplate that handles all the necessary transaction logic and resources like commits, rollbacks, and errors. It frees you from getting involved with low level transaction management details, and provides all transaction management out of the box. If you desire you can directly access a transaction manager, through an IPlatformTransactionManager interface, to manage the details of your transaction process.
TransactionTemplate implements the ITransactionOperations interface. It has a constructor that requires a IPlatformTransactionManager instance. All transaction managers implement the IPlatformTransactionManager interface. This means TransactionTemplate contains the specified transaction manager. The required transaction manager is provided to the TransactionTemplate through autowiring of the constructor's parameters. The autowiring searches through the objects and returns the first configured object that implements the IPlatformTransactionManager interface, which is transactionManager in our case.
Object transactionManager is an instance of TxScopeTransactionManager, that is in turn based on System.Transactions.
Transaction.Execute has a second optional parameter, commitChanges. The commitChanges argument defaults to true, so the transaction manager will always attempt to commit changes. I use it when I test my application, and I want all test data to be rolled back.
Based on the fact that it commitChanges is an optional parameter, you've probably figured out by now that I recompiled Spring.NET to run on .NET 4.
The example IFileTypeRepository is actually based on Entity Framework 4 with Plain Old CLR/C# Objects (POCO). Just in case you were wondering if Spring.NET's transaction management works with Entity Framework.
An Impersonation Aspect With Spring.NET AOPPosted: December 10, 2008 Filed under: C#, Mono.NET | Tags: AOP, Aspect Oriented Programming, C#, Impersonation, Mono.NET, Spring.NET, Spring.NET AOP, Spring.NET Aspect Oriented Programming, WindowsIdentity 1 Comment
One of the most useful features of Spring.NET is its Aspect Oriented Programming (AOP). Object Orientation (OO) decomposes an application into a hierarchy of entities linked through references. AOP on the other hand, decomposes an application into 'service layers' (referred to as aspects or cross cutting concerns in AOP lingo). This allows us to transfer infrastructure code out of our core business logic and entities. AOP has some really confusing jargon, like advice, weaving, crosscutting concern, joinpoint, pointcut, etc. To get a grip of these basic building blocks of AOP I refer you to Spring's excellent documentation that will get you started in no time.
This post is for those of you that covered the basic concepts and terms of AOP, and Spring.NET AOP in particular, but are still struggling a bit to put it all together. I'll give an overview of how all the different parts of AOP come together, and then follow it up with a working example.
Transparently Wrapping Infrastructure Around Objects
Even after going over the fundamentals of AOP can one still be confused. So let's start of with two very simplified diagrams that contrast OO against AOP. These diagrams are not ment to be technically accurate, just demonstrate the very high level concept of AOP.
Figure 1
The frist diagram of figure 1 shows how all of OO's operating logic is contained within an object's methods. In OO the object (or class) is the main construct that distills data (properties) and tasks (methods) into a type of entity. Each class has several methods, and in turn each method consists of business and infrastructure logic. Before we move on, I'd just like to mention that it's not a case of AOP vs OO, and which one is the better than the other. AOP complements OO, and improves the quality and adaptability of OO.
OO works wonderfully when we only consider data, methods, and statements directly related to the bigger concept they collectively represent. But when we take things like logging, caching, security, and transactions into concideration we get this uneasy feeling that we are adding code that do not have any direct relation to the logical entity. Traditionally we would combine this infrastructure code with our business logic. This results in dirty business logic code, that becomes more complex, confusing, and less maintainable as we increase its coupling with infrastructure code. Not only this, but let's say you quickly wanted to cache the results of several methods, without modifying each object's method? You would have to go and manually duplicate the same code in each method were you want to perform the caching. That's a lot of hard coding labor, and even harder maintenance should you want to change the way you do things.
Along comes AOP that allow you to move the infrastructure code out of our object's methods into aspects that has specific roles with tasks. So you'll have an aspect that provides security around methods, and another logging method execution. Our object's business logic does not have to know anything about the infrastructure code in which it's embedded. The infrastructure code is dynamically injected before or after a method executes. That is what the second diagram of figure 2 demonstrates: We have our object, and dynamically we specify when, and how infrastructure aspects intercept incoming and outgoing method calls. The result is that we are left with pure business logic code in the object's methods, which are themselves transparently wrapped in the necessary infrastructure code.
Interfaces And Proxies
Spring.NET's AOP framework uses proxies and interfaces to transparently wrap objects in aspects. An AOP proxy is an object that intercepts calls to, and results from, our actual business entity objects. The proxy has the exact same public members as our business entity object. When we request an object that we want to wrap in aspects, we actually request its proxy. In our configuration we will tell the proxy which object provides the actual implementation:
<objects xmlns="http://www.springframework.net"> <object id="crmService" type="Spring.Aop.Framework.ProxyFactoryObject, Spring.Aop"> <property name="proxyInterfaces" value="Shinobido.GhostBlade.Customers.ICRMService" /> <property name="target"> <object type="Shinobido.GhostBlade.Customers.CRMService, Shinobido.GhostBlade"> <property name="Url" value="http://localhost:2491/CRMService.asmx" /> <property name="UseDefaultCredentials" value="true" /> </object> </property> <property name="interceptorNames"> <list> <value>impersonationAspect</value> </list> </property> </object> <!-- Interception AOP Begin --> <object id="impersonationAspect" type="Spring.Aop.Support.DefaultPointcutAdvisor, Spring.Aop"> <property name="Pointcut"> <object id="regexPointcut" type="Spring.Aop.Support.SdkRegularExpressionMethodPointcut, Spring.Aop"> <property name="patterns"> <list> <value>.*</value> </list> </property> </object> </property> <property name="Advice" ref="impersonationAdvice" /> </object> <object id="impersonationAdvice" type="Shinobido.GhostBlade.Security.ImpersonationAdvice, Shinobido.GhostBlade" /> <object id="Shinobido.GhostBlade.Security.IIdentityProvider" type="Shinobido.GhostBlade.Security.HttpContextIdentityProvider, Shinobido.GhostBlade" /> </objects>
public interface ICRMService { CustomerInformation GetCustomerById( int id ) ; } public class CRMService: System.Web.Services.Protocols.SoapHttpClientProtocol, ICRMService { public CustomerInformation GetCustomerById( int id ) { object[] results = this.Invoke( "GetCustomerById", new object[] { id } ); return ( CustomerInformation )results[0]; } }
Figure 2
From the above example we can infer a number of things:
- ProxyFactoryObject is going to intercept calls to our target object, CRMService. In Spring.NET there are several proxying strategies to choose from like inheritance or composition (interface) based, autoproxies, and so forth. Here we're using a GUID-based composition ProxyFactoryObject. When you instantiate this proxy through Spring.NET's object factory, you'll notice that the object's type is actually a runtime generated object of a type like "CompositionAopProxy_4f054a8f2cd349479fe1673d4427aca3″ that implements ICRMService.
- ProxyInterfaces expose the members that will be visible to client code and intercepted by the proxy through interface ICRMService. In other words aspects will only be applied to members specified by this interface. Any members specified by this interface will automatically receive advice based on their pointcuts.
- Target specifies the business entity object that we're going to wrap.
- InterceptorNames specify that the aspect impersonationAspect must be applied to method requests and outputs.
- impersonationAspect's Pointcut uses a regualr expression that selects all members of the given class to receive impersonationAdvice.
In point 1 I mentioned composition vs inheritance based AOP proxies. We are using a composition based proxy, because the proxy never inherits from our target object, CRMService. A composition based proxy has a private field called m_targetSourceWrapper of type Spring.Aop.Framework.StaticTargetSourceWrapper that stores the actual business entity class we're redirecting to. An inheritance based proxy inherits from the target object.
Writing A Custom Impersonation MethodInterceptor
Spring.NET provides a number of out-of-the-box aspects for caching, logging, transactions, and exceptions. What we're going to do is write custom 'around advice', called a MethodInterceptor. Remember, Advice are objects that perform the actual work. So logging advice will actually write to the log file. Pointcuts tell the proxy when to pass control to the specified advice. You get four types of advice:
- Before a target method executes.
- After a target method executes.
- Before and after (around) a method executes.
- When a target method throws an unhandled exception.
The AOP advice we're going to write, will impersonate the current thread with a WindowsIdentity obtained from an identity provider. This is used when an application runs under a Windows service account, but selected methods need to be called with the current user's identity, instead of the service account's. The IIdentityProvider is dynamically injected, and retrieves the WindowsIdentity from the applicable context. For instance when you're impersonating the current thread in a web application, you need to implement a HTTP IIdentityProvider, that gets the current user's WindowsIdentity from the HttpContext.
In our specific scenario we are applying impersonationAdvice to all methods (.*) of the ICRMService, implemented by CRMService. In a nutshell, we are impersonating all our calls to CRMService.
Control is passed to an IMethodInterceptor before a target method is entered, and after it returns:
public class ImpersonationAdvice : IMethodInterceptor { #region IMethodInterceptor Members public object Invoke( IMethodInvocation invocation ) { using ( IdentityImpersonator.Begin( ObjectManager.New<IIdentityProvider>().Provide() ) ) { return invocation.Proceed(); } } #endregion }
ImpersonationAdvice implements IMethodInterceptor. You can almost say that Invoke will replace the target method it's wrapping. To execute the actual target method, you need to call Proceed() on the supplied IMethodInvocation argument.
Here's the code for our implementation of IIdentityProvider, IdentityImpersonator, and ObjectManager:
internal class HttpContextIdentityProvider : IIdentityProvider { #region IIdentityProvider Members /// <summary> /// Provides the identity of the current user. /// </summary> /// <returns></returns> public WindowsIdentity Provide() { return (WindowsIdentity) HttpContext.Current.User.Identity; } #endregion } public sealed class IdentityImpersonator : IDisposable { #region Globals private WindowsImpersonationContext ctx; private bool disposed; #endregion #region Construction /// <summary> /// Initializes a new instance of the <see cref="IdentityImpersonator"/> class. /// </summary> private IdentityImpersonator() { // Static Construction in Begin(). } #endregion #region Public Members /// <summary> /// Begins this instance. /// </summary> /// <returns></returns> public static IdentityImpersonator Begin(WindowsIdentity identity) { var impersonator = new IdentityImpersonator {ctx = identity.Impersonate()}; return impersonator; } /// <summary> /// Undoes this instance. /// </summary> public void Undo() { if (ctx != null) { ctx.Undo(); } } #endregion #region IDisposable Members /// <summary> /// Releases unmanaged and - optionally - managed resources /// </summary> public void Dispose() { if (!disposed) { Undo(); GC.SuppressFinalize(this); disposed = true; } } #endregion } /// <summary> /// Instantiates objects based on their name, and provides /// a standard set of configured utility objects. /// </summary> public static class ObjectManager { private static IApplicationContext context; /// <summary> /// Instantiates a default object with an id/name /// that is the same as the class's full name. /// </summary> public static T New<T>() { return New<T>(typeof(T).FullName); } /// <summary> /// Instantiates the object with the specified name. /// </summary> /// <typeparam name="T">The type of object to return.</typeparam> ///<param name="name">The name of the object.</param> /// <returns>A newly created object with the type specified by the name, or a singleton object if so configured. /// </returns> public static T New<T>(string name) { return (T)Context.GetObject(name); } /// <summary> /// Instantiates the object with the specified name, and constructor arguments. /// </summary> public static T New<T>(string name, object[] arguments) { return (T)Context.GetObject( name, arguments); } /// <summary> /// Gets the context. /// </summary> /// <value>The context.</value> internal static IApplicationContext Context { get { if (context == null) { lock ( ContextRegistry.SyncRoot ) { context = ContextRegistry.GetContext(); } } return context; } } }
ObjectManager serves as the object factory that wraps Spring.NET's ApplicationContext with some additional functionality. Specifically in this scenario, ObjectManager instantiates our proxied objects.
The important tasks are performed by IdentityImpersonator. HttpContextIdentityProvider supplies IdentityImpersonator.Begin(…) with the current user's WindowsIdentity from HttpContext.Current.User, which in turn calls WindowsIdentity.Impersonate(). To stop impersonating the current thread, you need to call WindowsIdentity.Undo(). The Dispose method stops the impersonation, so that you need to put code that you want to impersonate, in a using {…} clause. GC.SuppressFinalize(…) tells the garbage collector to ignore IdentityImpersonator's finalize method, since we already cleaned up the object when it was Disposed.
Usage and Conclusion
So, to impersonate a call to CRMService becomes a completely transparent process. You don't need to duplicate IdentityImpersonator.Begin() every time you want to impersonate the current thread. The methods that need impersonation is dynamically selected from one place, impersonationAspect's Pointcut, and the impersonation work is also performed from one place, in ImpersonationAdvice:
var crmService = ObjectManager.New<ICRMService>( "crmService" ); crmService.GetCustomerById( 1 );<
This should clearly demonstrate the power of AOP: Injecting all that functionality into GetCustomerById(…), without adding a single line of code to it, and we can change it all without making any code changes!
Integrating The Spring.NET Validation Framework And ASP .NET MVCPosted: December 2, 2008 Filed under: C#, Mono.NET | Tags: ASP .NET, ASP .NET MVC, ASP MVC, C#, MVC, Spring.NET, Spring.NET Validation Framework, Validation Framework 13 Comments
I recently completed a very successful project for a client using ASP .NET MVC, Spring.NET and jQuery. One of the technical requirements of the solution was that we wanted to have an advanced validation mechanism that would allow us to move all our validation rules out of theUI layer, and business logic, and into a dynamically configurable rule engine. Spring.NET's validation framework is ideally suited for this challenging task.
Spring.NET's validation framework is based on a hierarchy of validation groups, conditions, and actions. I refer those unfimiliiar with Spring.NET's validation framework, to their well composed documentation.
What I'll propose here is a way to integrate Spring.NET's validation with ASP MVC, and some issues you might encounter alng the way.
Spring.NET Validation Is From Mars, and ASP MVC Is From Venus
Okay, so you've covered the validation framework's documentation. You can create new validation rules, pass through an object (in the MVC space this would be the model), and get back a boolean result to tell you whether the object passed (true) or failed (false). As I've mentioned this process is made very clear in the help documentation of the validation framework, so I'm going to jump straight into the juicy complexities.
Spring.NET's validation rules apply themselves directly to a POCO's (Plain Old C# Object) schema. For instance, say I've got a class Customer that I pass through as the validationContext, and I wanted to validate his CellPhone ContactNumber (Customer.ContactNumbers.CellPhone), the validation rule might look something like this:
<v:regex when="ContactNumbers.CellPhone != null and ContactNumbers.CellPhone != ''" test="ContactNumbers.CellPhone">
When we're talking about MVC, our Customer will serve as the model sent to a ViewPage by a Controller action.
ASP's Controller all have a ViewData.ModelState.AddModelError(…), that takes in a key, and an error message. To get MVC to highlight the input element, the key must match its name. To get MVC to automatically bind the HTML control to a model property, the name of the control in turn should be the same as the path to the Property that provides its value. For example, say I want ASP MVC to automatically display his CellPhone number, then I'd use "Customer.ContactNumbers.CellPhone" as the input control's name. To flag this control as an error source, I'll use a key with the exact same name.
<%= Html.TextBox( "Customer.ContactNumbers.HomeDialCode" )%> - <%= Html.TextBox( "Customer.ContactNumbers.HomePhone" )%> <%= Html.ValidationMessage( "Customer.ContactNumbers.HomeDialCode" )%> <%= Html.ValidationMessage( "Customer.ContactNumbers.HomePhone" )%>
The important point is that the naming convention of the ViewPage's HTML controls, is based on the model's schema or graph, and so are the validation rules. The trick is then to relate a Spring.NET validation error (and specifically the error message) to the current node in the schema to which it's being applied.
Spring.NET's message or ErrorMessageAction has the concept of "providers". A provider is just a fancy name for an IDictionary<string,IList> of key-values, where the provider name serves as the key, and the list is a list of ErrorMessages. The idea is that each provider name relates to a Spring validation web server control, that will display it's error. For ASP MVC we'd rather like to generate the correct ModelError key, so MVC can automatically take care of displaying the error message in its own way.
So at this point we have 3 tasks that we need to complete to successfully integrate ASP MVC and Spring.NET Validation:
1. Tell each Spring.NET validation rule where in the object graph it's currently executing.
2. Generate the correct error key from the validation rule's location or context.
3. Convert the validation error to a ModelError and add it to the Controller's ModelState.
Validation Rules: "I Know What I'm Doing, But Not Where I'm Doing It!"
One of the problems of Spring.NET's validation rules are that they do not know where in the schema they're executing. Put a another way, they do not know the path that lead to the current rule being executed – henceforth being referred to as their context. Why is this important? It is important because, as explained previously, the MVC's input field names and error keys are based on the full path of underlying model-object property.
The most straightforward way to provide this contextual information for a validation rule is to embed it directly inside its definition, probably using a custom IValidationAction:
<v:regex id="homeDialCodeValidator" when="HomeDialCode != null and HomeDialCode != ''" test="HomeDialCode"> <v:property name="Expression" value="[0-9]{3}"/> <v:action type="Shinobido.GhostBlade.Validation.ModelValidationAction, Shinobido.GhostBlade.Core"> <v:property name="CurrentError"> <object id="homeDialCodeError" type="Shinobido.GhostBlade.Validation.ModelError, Shinobido.GhostBlade"> <property name="Key" value="Customer.ContactNumbers.HomeDialCode" /> <property name="Message" value="3 numbers expected." /> </object> </v:property> </v:action> </v:regex>
The problem with the aforementioned approach is that it reduces the re-usability of validation rules. For instance, lets say we have the following classes:
public class ContactNumbers { public string HomeDialCode { get; set; } public string HomePhone { get; set; } } public class Customer { public string Name { get; set; } public ContactNumbers ContactNumbers { get; set; } public Spouse Spouse { get; set; } public NextOfKin NextOfKin { get; set; } } public class Spouse { public ContactNumbers ContactNumbers { get; set; } } public class NextOfKin { public ContactNumbers ContactNumbers { get; set; } }
Ideally we want to create one contactNumbersValidator rule-group, that can be referenced from other validators, wherever ContactNumbers need to be validated:
<v:ref name="contactNumbersValidator" context="Spouse.ContactNumbers" />
The problem with specifying the context information or error key, in the rule, as that it only caters for a single context. For instance, in the above example we would like to validate ContactNumbers from three different contexts: Customer.ContactNumbers, Customer.Spouse.ContactNumbers, and Customer.NextOfKin.ContactNumbers. All three will use the same validation rule, but from different contexts or schema paths. If we specify a context of Customer.ContactNumbers.HomeDialCode, then we are unable to accommodate any other path, such as those for NextOfKin and Spouse.
What we can infer from this exercise is that we need to specify a rule's context outside of the rule, in a parent group or rule. A validation rule itself cannot contain the context, because it does not know from where it's referenced. So how do we set the rule's current context, from its parent?
One of the ValidatorGroup's overloads for the Validate(…) method, has an input argument called contextParams of type IDictionary. The significance of this argument is that we can write and read values to it – programmatically and from the config file. This allows us to make variables available to validation groups, validators or actions.
So how do we set a variable from the rule configuration? For this we use the "#variableName" syntax of Spring.NET's expression language. When Spring.NET encounters the following command "#SomeVariable='SomeValue'" a new entry is made in the contextParams dictionary with a key name of "SomeVariable" and value of "SomeValue".
What we're going to do is write a magic little custom class that allow us to navigate up and down the object graph, as validation rules are evaluated:
public class ObjectContext { private IList<string> contextPath = new List<string>(); private string finalContext; private readonly StringBuilder pathBuilder = new StringBuilder(); public bool StepIn( params string[] path ) { for ( var i = 0; path != null && i < path.Length; ++i ) { contextPath.Add( path[i] ); } return true; } public bool FinalStepIn( params string[] path ) { for ( var i = 0; path != null && i < path.Length; ++i ) { if ( i == path.Length - 1 ) { finalContext = path[i]; } else { contextPath.Add( path[i] ); } } return true; } public bool StepOut( params string[] path ) { // Reverse list so we can start deleting from index 0 var reversedContextPath = contextPath.Reverse().ToList(); for ( var i = 0; i < reversedContextPath.Count(); ++i ) { // Just remove the same number of items in "path" // from "contextPath" reversedContextPath.RemoveRange( 0, path.Length ); } // Revert back to original order and assign back to "contextPath" reversedContextPath.Reverse(); contextPath = reversedContextPath; return true; } public string ContextPath { get { if ( pathBuilder.Length > 0 ) pathBuilder.Remove( 0, pathBuilder.Length ); for ( var i = 0; i < contextPath.Count; ++i ) { pathBuilder.Append( contextPath[i] ); // If don't have a leaf node, and this is the last // intermediate/branch node, then do not add a "." if ( string.IsNullOrEmpty( finalContext ) && i == contextPath.Count - 1 ) { continue; } pathBuilder.Append( "." ); } pathBuilder.Append( finalContext ); return pathBuilder.ToString(); } } }
Let's first explain some of the logic behind ObjectContext. When it comes to object schemas or graphs we can distinguish between three types of contexts: the root context, several intermediate sub contexts, and a final leaf context (containing the "test" expression). The root context serves as the starting point for the evaluation path, and is similar to MVC's concept of a binding prefix. Sub contexts refer to those that navigate from the root down to a final leaf context. A leaf context is a validation rule end-point, that does not have any children, and contains the actual "test" expression.
ObjectContext has three methods StepIn, FinalStepIn, and StepOut. StepIn allows us to step into a child context, like when we move from Customer into Spouse. FinalStepIn is used when we move from a parent context into a final leaf context, like we'd do if we moved from ContactNumbers to HomePhone. Lastly we have StepOut, that takes us from a child context back up to a parent one, such as when we move back from Spouse to Customer.
All we need to do now, is add a new instance of ObjectContext to contextParams and call the relevant methods as we move through the object graph's nodes. I wrote a ValidatorGroup extension method to automatically add a new ObjectContext instance to contextParams:
public static class ValidatorGroupExtensions { public static bool Validate( this ValidatorGroup validatorGroup, object validationContext, IValidationErrors errors, bool hasContext ) { var contextParams = hasContext ? new Dictionary<string,object> { { "ObjectContext", new ObjectContext() } } : new Dictionary<string,object>(); return validatorGroup.Validate( validationContext, contextParams, errors ); } }
At this point it should be clear how to add a new instance of ObjectContext to contextParams. What we haven't discussed is how we're going to retrieve our ObjectContext instance from contextParams, and invoke one of its methods in the validation configuration. The answer to this question lies in the fact that Spring.NET's IExpression interface allows multiple independent commands to be executed in the same expression. What's also important is that we realize that the validation configuration schema's "when" and "test" attributes are actually IExpression properties. Therefore we can use any of the validation framework's attributes/properties that is an IExpression to use variables from contextParams:
<v:group id="customerValidator" when="#ObjectContext.StepIn( 'Customer' )"> <v:condition when="#ObjectContext.FinalStepIn( 'Name' )" test="Name != null and Name != ''" /> <v:group when="( #ObjectContext.StepIn( 'Spouse', 'ContactNumbers' ); Employer != null )"> <v:ref name="contactNumbersValidator" context="Spouse.ContactNumbers" /> </v:group> <v:group when="( #ObjectContext.StepOut( 'Spouse', 'ContactNumbers' ); #ObjectContext.StepIn( 'ContactNumbers' ) )"> <v:ref name="contactNumbersValidator" context="ContactNumbers" /> </v:group> </v:group> <!-- contactNumbersValidator --> <v:group id="contactNumbersValidator"> <!-- CellPhone validator --> <v:regex when="( #ObjectContext.FinalStepIn( 'CellPhone' ); CellPhone != null and CellPhone != '' )" test="CellPhone"> <v:property name="Expression" value="[0-9]{10}"/> <v:action type="Shinobido.GhostBlade.ErrorMessageContextAction, Shinobido.GhostBlade"> <v:property name="Message" value="Unexpected format for cellphone number." /> </v:action> </v:regex> </v:group>
The first "when" validation statement on the group element tells Spring.NET to fetch the value of the DictionaryEntry with key "ObjectContext". To execute multiple commands in a single IExpression we place the entire expression in brackets, and separate the each sub-expression with a semi-colon. When multiple statements are specified like this, Spring.NET always returns the last statement's value. This is why our navigation methods all return true: So that the groups are executed by default, relieving us from the burden to add a last additional expression that returns true.
The next step is to create a custom IValidationAction that inherits from BaseValidationAction, that will store our validation rule's error message, and build the current context's full path info:
public class ErrorMessageContextAction: BaseValidationAction { /// <summary> /// Gets or sets the error message. /// </summary> public string Message { get; set; } protected override void OnInvalid( object validationContext, IDictionary contextParams, IValidationErrors errors ) { var objContext = contextParams["ObjectContext"] as ObjectContext; if ( objContext == null ) return; var error = new ErrorMessage( null, Message ); errors.AddError( objContext.ContextPath, error ); } }
BaseValidationAction provides two virtual methods OnInvalid and OnValid, that are called when a rule fails or passes. ErrorMessageContextAction has one property called Message, that is set to the actual error message we wish to display. Our override of OnInvalid uses ObjectContext.ContextPath to build the full path of the current context. This full path will be used as our 'provider'. ASP MVC's built-in error message handling magic fulfills the role of validation errors renderer using this 'provider'.
The last piece of the puzzle is a custom IValidationErrors implementation that will add validation errors to a MVC Controller's ViewData.ModelState:
public class ModelStateErrors: IValidationErrors { ModelStateDictionary modelState; public ModelStateErrors( ModelStateDictionary modelState ) { this.modelState = modelState; } public void AddError( string provider, ErrorMessage message ) { if ( message != null && message.Parameters != null && message.Parameters.Length > 0 && message.Parameters[0] != null && message.Parameters[0] is string ) { modelState.AddModelError( provider, message.Parameters[0].ToString() ); } } public void MergeErrors( ValidationErrors errorsToMerge ) { throw new System.NotImplementedException(); } public IList GetErrors( string provider ) { var modelStateDict = modelState[provider]; return modelStateDict == null ? null : modelStateDict.Errors; } public IList GetResolvedErrors(string provider, IMessageSource messageSource) { throw new System.NotImplementedException(); } public bool IsEmpty { get { return modelState.Count == 0; } } public IList Providers { get { return modelState.Keys.ToList(); } } }
Class ModelStateErrors internally wraps a ViewData's ModelStateDictionary, and automatically adds Spring.NET validation errors to it. The provider name is used as the key for AddModelError, because this is the 'bucket' that we'd like to sink the message to. The ErrorMessage's first parameter is expected to be the message text.
Usage and Conclusion
An important point to remember when specifying the context in Spring's validation configuration, is to always provide a complete path from the current node to a final leaf node. It is important to StepIn and StepOut of contexts in-sync with the validation rules. If a context is skipped, our we don't StepOut of a previous one, we will not get the correct path. When you get the wrong context, check that you've SteppedOut as many times as you've SteppedIn, to bring you back to the current node or level. Also check that you've specified the correct context names when you StepInto a context.
All we need to do is make sure our context navigation correctly follows our validation rules. Apart from this we don't really need to do anything else to get Spring.NET to add its validation errors and messages to ViewData's ModelState:
1. Import the namespace where the ValidatorGroupExtensions is defined:
using Shinobido.GhostBlade.Extensions;
2. Get the desired ValidatorGroup from Spring.NET's objects configuration.
3. Call ValidatorGroup.Validate with ModelStateErrors as the IValidationErrors implementation, and hasContext as true.
Just obtain the desired ValidatorGroup from the objects configuration, ModelStateErrors as the IValidationErrors implementation in a Controller's Action method:
public partial class CustomerController: Controller { public ActionResult EditPersonalAssessment( int id ) { var customer = ObjectManager.New<ICustomer>(); customer.ContactNumbers = new ContactNumbers { CellPhone = "djsk" }; customer.Spouse = new Spouse { ContactNumbers = new ContactNumbers { CellPhone = "kasjd" } }; var validator = ObjectManager.New<ValidatorGroup>( "customerValidator" ); var result = validator.Validate( sampleObj, new ModelStateErrors( ViewData.ModelState ), true ); } }
From the final usage we observe that it's a pretty neat way of integrating Spring.NET's Validation Framework with ASP .NET MVC's ModelState and error handling magic. The only part that's a bit weird is the way we specify the context in Spring.NET's validation configuration. It abuses the IExpression attributes a little in a way that they weren't originally designed for. But I believe this is a small price to pay to gain the huge benefit of automatic integration of Spring.NET's Validation Framework and ASP MVC's validation and error handling and display.
In the next Spring.NET post I'll be covering how to use Spring.NET's Aspect Oriented Programming (AOP) to create an impersonation aspect. Happy Springing until then!
The Only C# .NET Singleton You'll Ever NeedPosted: September 2, 2008 Filed under: C#, Mono.NET | Tags: C#, Code Snippet, Mono.NET, Singleton 4 Comments
My colleague, Riaan Hanekom from NGenerics fame, showed me his perfect code for a singleton in C# .NET (version 2 and later). This generic class can create a singleton for any non-static class that has a default constructor.
Copyright 2008 The NGenerics Team
(http://www.codeplex.com/NGenerics/Wiki/View.aspx?title=Team)This program is licensed under the Microsoft Permissive License (Ms-PL). You should
have received a copy of the license along with the source code. If not, an online copy
of the license can be found at http://www.codeplex.com/NGenerics/Project/License.aspx.
*/public static class Singleton<T> where T:new()
What Is Your Code Saying?Posted: August 9, 2008 Filed under: C#, Mono.NET, SoftwareDevelopment | Tags: Best Practices, Programming, Software Development 2 Comments
Developers often talk of "self describing code". This term is a favorite answer when a developer's poor use of comments comes into question. Often the answer: "I don't need to write thorough comments, because my code is self describing." Ignoring the commenting part of the example, lets dwell further on the "self describing code" claim. So my question is how well does your code reveal it's purpose?
Let's take the following example into consideration. Let's say I need to determine whether data was binded to a control. The control has a property called Description, that will have a value after data was binded to it. So in order for me to determine whether the data binding operation completed successfully I could write the following code:
if ( string.IsNullOrEmpty( controlInstance.Description ) ) { … }
So what does this say about the purpose of the code? Does this line of code clearly tell you that I am actually checking whether the control was data binded? No. That knowledge is hidden away, deep inside my head. Anyone looking at this line of code will immediately be confused as to why I am doing this check. So now I am faced with two choices; I can either put a comment next to the statement, or encapsulate the logic in a property or method that will reveal the meaning of the operation (preferably we should do both). The latter option will make the code self describing, and reveal it's intrinsic meaning:
/// <summary>
/// Checks if a data source was binded to the control.
/// </summary>
public bool DataBinded
return !string.IsNullOrEmpty( this.Description );
Our original line of code then becomes: if ( controlInstance.DataBinded ) { … }
Looking at this code, there is no confusion at what I was trying to achieve. We now also have one place where we define the rules that determine whether the control was data binded, so that if it needs to change, we only need to do it in one place.
The point is that there are a lot of things that need to be taken into consideration when writing and structuring source code, such as performance, coupling, inheritance hierarchy, abstraction, patterns and so forth. A very important one that I believe is too often neglected, or forgotten all together, is how well the source code communicates its meaning. In fact, personally I would say this aspect should be of the highest priority. I believe the team paying attention to this aspect of coding, will really reap the rewards once they have to start maintaining the product, especially as the original developers leave, and new ones join the team. Considering that the maintenance of existing software can account for over 60% of all development effort, and that 70% of the cost of software is devoted to maintenance, I believe that any technique that can help with easing this task is of great importance, especially if it's something as simple as packaging and naming your code in a clear and concise manner!
C# Source Analysis And Client .NETPosted: May 28, 2008 Filed under: C#, Mono.NET | Tags: C#, Microsoft, Mono.NET, Software Development Leave a comment
Microsoft Source Analysis for C#
If you code in C#, you definitely would want to have a look at this. It's been used by Microsoft internally for as long as I know. Previously called Stylecop. Get it here.
Microsoft .NET Client Profile Assemblies
Because we mainly work in .NET and we have to keep lugging a large .NET framework around to install at clients (if they don't have it). Microsoft has released a .NET Framework client profile that's about 26mb and that is optimized for client .NET applications. Get it here.
Free E-Book: Introducing Microsoft LINQPosted: February 15, 2008 Filed under: C#, DataBase, Mono.NET | Tags: C#, LanguageIntegratedQuery, LINQ, Mono.NET, ObjectRelationalMapping, ORM Leave a comment
The complete book "Introducing Microsoft LINQ", is available as a free e-book/pdf download. Thank you very much Microsoft! Some chapters from "Introducing Microsoft ASP.NET AJAX", and "Introducing Microsoft Silverlight 1.0″ can also be downloaded.


text:
Hm, I thought I might start this up again, intermittently at least. I have come back to primal because I do believe it is a better way of eating for long term health etc. I haven't successfully lost weight on it, but then I haven't done that on any other way of eating either. If that is going to be the case, then I much prefer to be on a diet that won't lead to diabetes and heart disease and whatever else the SAD is responsible for.
Weight wise - continued nothingness. I went off to count calories, try weight watchers, try a shake diet, do lite n easy etc, but nothing worked, and I am still at 72kg (and the same size).
However, there has been many ups and downs with my thyroid disease. I can't remember where I left off - possibly just on the natural thyroid hormone? Anyway, I was on huge doses of that and feeling zero effect, so the doc changed me to slow release t3-only. Zero, zero, zero effect still. I went back to see her about a week ago with more blood tests. The rt3 had cleared, so obviously I have some sort of cellular resistance to the t3. Also, adrenals are out of whack - cortisol too low in the morning, too high at night - handy in explaining my exhaustion during the day and inability to sleep at night. Also apparently can effect the effectiveness of t3, and weight gain (of course), and cause low blood sugar leading to constant hunger (hello!!), dizziness even when sitting (yes!) and more. Anyway, I asked to change to regular t3, as I have read (mainly from other patients' anecdotal evidence), that slow release t3 is no good at combating cellular resistance, that I need the waves of t3 release that comes with taking the regular t3. So I finally picked that up today and can start tomorrow.
So, fingers crosses, with a primal diet, and the new meds, I may start to 1) Lose weight, as that is the main issue in my mind this whole time, and 2) get some energy - which would be great too. If if could get through the day without napping, even better! Also it'd be nice if my hands and feet weren't yellow anymore...

subset: commoncrawl


text:
The season didnt end according to plan for the USC Aiken golf team.
Despite being ranked second nationally in the most recent coaches poll, the Pacers ended their season on Wednesday with a 12th-place finish and a three-round team score of 905 in the NCAA Division II National Championship at The Meadows in Allendale, Michigan. That left USCA 10 strokes out of eighth place and a spot in the match-play portion of the event, which will begin today.
Head coach Mike Carlisle said his team came in to the day knowing it had to play better to make the match-play. While the Pacers trimmed 10 strokes from their second-round score and turned in a final-round 292, that didnt get them into position.
It just wasnt meant to be, I guess, Carlisle said.
For the second year in a row, Florida Southerns Tim Crouch took home the individual title, this time with an even-par score of 213. He won with a score of 2-under last year at Hershey Country Club in Pennsylvania, knocking off USCAs Matt Atkins and Western Washingtons Jake Webb in a playoff.
Senior Kyle Godsman, a Division II PING All-Region selection, was the Pacers top individual finisher with a three-round total of 225 that was good enough for a 38th-place tie. He was able to save his best round for last, though, carding a 1-over 72 that including two bogeys and a birdie on Wednesday.
Fellow senior Hayden Letien also saved the best for last, finishing with a 74 to post a three-round score of 226 that was one stroke better than his score from a year ago.
Theyre still not very satisfied with our play here, Carlisle said of the seniors, noting the teams goal of competing for the national title.
Juniors Brandon Robinson-Thompson and Andrew Ward tied for 58th place at 228, and senior Gaines Milliner an Aiken High grad rounded out the group with a three-round score of 234. Robinson-Thompson was also an all-region honoree.
In all, six of the 12 golfers listed on the Pacer roster were seniors this season, with Joar Bjelkholm joining Ward and Robinson-Thompson as the only potentially returning golfers that played in an event during the spring season. The sophomore finished 22nd in the Wexford Plantationa Invitational in February with a three-round score of 226.
Coupled with the addition of incoming golfers like Axel Ostensson of Sweden and Samuel Schiff of Switzerland, Carlisle thinks that returning core could allow for another good season in 2014-15.
I think well be pretty competitive again next year, he said.
That was one of four events the Pacers won this season, including the abbreviated Peach Belt Conference Championship, marking the second consecutive PBC title for USCA. Robinson-Thompson also won the individual title with a 4-under 68 in the events only round, played at Callaway Gardens in Pine Mountain, Georgia, for the Pacers only individual win of the season.
Its like I told them at dinner tonight; Im real proud of them, Carlisle said after Wednesdays round. We had a lot of success on the year. We just didnt finish quite like we wanted to.
Jeremy Timmerman has a journalism degree from Mercer University. Follow him on Twitter @ASJTimm.


text:
- Atherton High School, Louisville KY
- Lutheran High School of Indianapolis
- Grafenwoehr and Vilseck DoDDS
- Plus ThreeOperations Lead, 2009 - 2013
- McClatchy InteractiveSoftware Developer, 2005 - 2009
- U.S. Air ForceAircraft Armament, 1999 - 2005
- Expression Analysisoperations / systems administrator, 2013 - present
Mozilla Stumbler
Mozilla is a nonprofit project and global community building a better internet. Mozilla Stumbler is an open-source wireless network scanner
Xbox SmartGlass
Xbox SmartGlass lets your phone work with your Xbox 360 console to bring rich, interactive experiences and unique content about what you're
Wifi Analyzer
Turns your android phone into a Wi-Fi analyzer!! Shows the Wi-Fi channels around you. Helps you to find a less crowded channel for your wire
TuneIn Radio Pro
TuneIn Radio Pro adds the ability to record everything you love from TuneIn Radio. TuneIn lets you listen to the world's radio with music, s
StopWatch & Timer+
Beautiful, powerful and simple Stopwatch & Timer+This is the paid version of the popular Stopwatch & Timer app with additional features:★ Up
Sakura Pro Live Wallpaper
A beautiful Sakura (Cherry Blossom) live wallpaper which lets you interact with falling leaves and flowers.Great for both spring and summer
NPR News
- Read, listen, or create a playlist of your favorite NPR stories and share with friends. - Hear live streams from hundreds of NPR stations:
Nova Launcher
Highly customizable, performance driven, home screen replacement for Android 4.0+Accept no substitutes! Nova Launcher is the original and mo
The ecobee Smart Thermostat is a WiFi enabled programmable thermostat that has a full-color LCD touch screen and easy to use interface. To t
Better Terminal Emulator Pro
BTEP is an advanced multi-session Terminal Emulator and SSH client for your phone, tablet and Google TV. It also supports Telnet and FTP. Un
AndChat (Donate)
Apologies for the crashing with the recent update. I forgot to update a config file and an essential file was stripped out >.Data Backup) to
*****Ingress is a closed-beta right now. Request an invite at http://www.ingress.com*****Ingress transforms the real world into the landscap
You Asked for It - Swype Now Available on the Play Store! Get it Today - Only 99 Cents - Limited Time Offer!• 250+ Million Users and Growing
Password Delay Full
"Optimal security, minimal frustration"Tired of entering your phone's lock password or PIN every time you've locked your phone? Use this app
Plus Three
Online technology, design, and strategy services for nonprofits and political organizations
isc Home | SANS Internet Storm Center; Cooperative Network Security Comm...
SANS Internet Storm Center - A global cooperative cyber threat / internet security monitor and alert system. Featuring daily handler diaries
Arts Sciences Philosophy Classical Languages History SIGs
Art Music Composition Studio, polymath persons and others who love to learn. Free open community portal - Wiki - CMS, any age, mostly over 1
BBC - Radio 1
Listen to BBC Radio 1, home of the Official Chart, the Live Lounge and the world's greatest DJs including Chris Moyles, Scott Mills, Fearne
"You Must Hate Version Control Systems"
I've been an independent consultant for a long time now. Over the last seventeen years I've worked for dozens of different clients.
CUergo: Sitting and Standing
Cornell University Ergonomics Web. Sitting and Standing at Work. The Perils of Sitting. Sitting for more than 1 hour has been shown to induc


text:
In 1983, Dan Marino's rookie year, three Dolphins' tight ends caught a combined 75 passes, including a franchise-high 46 by Rose's backups (Bruce Hardy and Dan Johnson).
"It was nice to finally get a catch, get that first one out of the way," Shuler said. "Then the rest of them seem a little easier."
John Nalbone was active the first two weeks before being waived. Jeron Mastrud was the choice for seven out of the next 11 weeks, with Shuler, a rookie out of Penn State, getting a few cracks as well.
Dedrick Epps took his turn against the Jets and Bills. He was used differently, getting split out wide to take advantage of his speed, but he still failed to end the production drought.
Finally, with his catch across the middle that set up the Dolphins' go-ahead touchdown against the Lions, Shuler stopped the madness. He also caused quite a sideline stir among his position mates.
"They were all happy," Shuler said. "We didn't care who got it. We just wanted a second tight end to get a catch."
Shuler added another catch for 16 yards on the game's final drive. With one game left at New England, the Dolphins have avoided joining the 1990 edition as the only team in franchise history to produce zero catches from backup tight ends. Ferrell Edmunds caught all 31 passes directed at Dolphins' tight ends that season.
Only one other Dolphins' season (1974) has seen backup tight ends catch fewer passes than this year's group. Marv Fleming had just one catch that season.


text:
Display caption
This portrait is distinguished by the artist's fascination with the textures and play of light on the sitter's clothing. Its style shows how strongly Frye was influenced by Hogarth. Henry Crispe was Registrar of Certificates and Examiner of Debentures at the Custom House, London. He died the year after this portrait was painted. His epitaph records that 'in him was shewn that polite literature and ev'n a poetical genius best form the man of business', skills which are indicated in this portrait by the presence of the quill and the writing materials on the table.
August 2004


text:
To have your basket delivered guaranteed by Rosh Hashanah, please be sure to order before the following cut-off dates:
Transit Time Last Day To order
1 Day -Wed. Sep. 28 2pm ET
2 Day -Tue. Sep. 27 2pm ET 3 Day -Mon. Sep. 26 2pm ET 4 Day -Fri. Sep. 23 2pm ET 5 Day -Thu. Sep. 22 2pm ET
Items shipping via USPS take approx. 3-5 business days (regardless of location)
Rosh Hashanah Baskets Delivery in Israel: Monday, Sep. 26 4:00pm ET, For Jerusalem September 27 4:00pm ET
Ingredients: Sugar, Corn Syrup, Natural & Artificial Flavors, FD&C Yellow #5, Yellow #6, Blue #1, Red #3, & Red #40.
Allergen Information: Processed in a facility that also processes Peanuts, Tree Nuts, Wheat, Soy and Milk products


text:
Another rematch ahead for Cathedral Prep
Cathedral Prep could call this the Revenge Tour.
The Prep football team, however, isn't out for vengeance. After all, the Ramblers won the 2012 PIAA title and have won 28 games in a row.
Rather, Prep's opponents are the ones looking for payback.
As the Ramblers make their way through the postseason, they continue to face teams that they defeated in the 2012 playoffs.
The procession of rematches began in the District 10 Class AAA championship game against General McLane. Prep easily passed that test with a 63-21 victory.
The next challenge came a week ago against previously unbeaten WPIAL champion West Allegheny in the PIAA quarterfinals. The Ramblers shut down West Allegheny 28-0 after beating the Indians in the same round in 2012.
Saturday night Prep will face a third high-powered opponent that is looking for revenge, and this foe promises to be the toughest yet.
A talented Bishop McDevitt team will take on Prep in the PIAA semifinals Saturday at 5 p.m. at DuBois High School. (The game originally was scheduled for today at 7 p.m. at Clearfield, but it was postponed this afternoon because of the threat of a winter storm.)
In the 2012 semifinals, the Ramblers put together their most complete game of the season when they routed an unbeaten, No. 1-ranked Bishop McDevitt team 38-3.
This could be a game to remember. Both McDevitt (13-1) and Prep (13-0) are averaging more than 40 points per game, and both have an abundance of speed and offensive talent.
Prep's defense turned in one of its best performances of the season against West Allegheny and will need a similar effort to slow down the Crusaders.
If Prep can get past McDevitt, another rematch could await the Ramblers in the state championship game. Eastern powerhouse Archbishop Wood (12-2) takes on Berwick (14-0) in the other semifinal.
Prep beat Archbishop Wood 24-14 in the 2012 title game, and if both advance this week, that would set up another intense showdown for PIAA gold.
Follow the action Saturday night on the Varsity blog.
Winter sports seasons open:
This is the opening day of the PIAA winter sports season, and many District 10 basketball and wrestling teams will be in action during the next few days.
Today's Varsity print edition was a 24-page Basketball Preview. Hoops fans can read a variety of features on the Varsity home page at GoErie.com/Varsity, including a look at the D-10 boys season outlook and girls season outlook, team rosters, the Preseason Boys Player of the Year and Preseason Girls Player of the Year, and stories on the wide-open Class AA girls class and Class AAA boys class.
The District 10 swimming and wrestling previews will be in the Dec. 13 Varsity edition.
Varsity Letter feedback:
To provide feedback or ideas, send an e-mail to email@example.com. Write "Varsity Letter" in the subject line.
-- Jeff Kirik, sports editor


text:
MegaSaw – Concrete Cutting Melbourne, Drilling and Grinding Experts
Are you looking for professionals to deal with your construction projects with a high level of expertise and experience? Look no further than Megasaw-your one-stop concrete solution providers. We offer an exhaustive range of services to make your life easier. These include
- Concrete cutting
- Concrete drilling
- Concrete sawing
- Concrete grinding
Based in Melbourne, Victoria, Megasaw has over 20 years of experience in the industry. With the use of innovative technologies, we ensure high levels of client satisfaction in every concrete cutting, drilling or grinding contract that we take up. Depend on us to deliver work on time and well within your budget. We deal with both residential and commercial projects, and use the latest tools for high quality construction work. Our company has varied experience working in diverse environments and conditions. Megasaw professionals have performed well with sensitive architectural projects, in high security regions, and in clean room conditions.
At Megasaw, we are prompt in our dealings and waste no time to heed the call of our clients. Ten fully equipped vans are ever ready to give an instant start whenever required and all you need to do is call!
We offer tailor made concrete cutting & drilling services for simple to complex projects. Our specialist service offers accuracy, reliability, promptness, quality, and reasonable pricing to top it off! No wonder people who deal with us return again and again and even recommend others to do the same. Call us today and get full value for money on your construction projects.
Megasaw is a trusted name in the industry. You can 'Depend on us to Deliver'!!


text:
Nadim Houry
Nadim Houry is Human Rights Watch's deputy director of its Middle East and North Africa division, and he is director of the Beirut office. Prior to joining Human Rights Watch, Houry served as deputy counsel for the Volcker Commission, where he spent more than a year conducting fact-finding missions in the Middle East as part of the United Nation's corruption inquiry into the Oil-for-Food Programme. An attorney by training, Nadim worked as a corporate lawyer for Shearman & Sterling in New York for two years. He is fluent in Arabic and French.
Articles Authored
- CommentaryPublished in The Daily Star
- Commentary
Police Brutality in Lebanon
- Commentary
(Un)happily Ever After
- Commentary
Making Local Ceasefires Work in SyriaPublished in Open Democracy
- Commentary
The Unsung HeroesPublished in The Daily Star
- Commentary
Paying the Clergy is Not the Way to GoPublished in The Daily Star
- Commentary
Time for an Anti-discrimination Law
- Commentary
An Unnecessary Tragedy
- Commentary
Anthony Shadid
- Commentary
Brazil and the Syrian PeoplePublished in O Globo
Connect On Twitter
Reports Authored
Without Protection
How the Lebanese Justice System Fails Migrant Domestic Workers
A Wasted Decade
Human Rights in Syria during Bashar al-Asad's First Ten Years in Power
Group Denial
Repression of Kurdish Political and Cultural Rights in Syria
Far From Justice
Syria's Supreme State Security Court


text:
Pitfalls of steroid use
Steroid side effects August 15, 2012 Clemdog
Steroids make the news quite often, but with the Olympic Games here again steroids and "doping" are back in the headlines. When a young girl from China, which happens to be one of the countries with a history of steroid use by it's athletes, is able to beat Ryan Lochte's record everyone wants to know how she did it.
What makes the Olympics different than other major sporting events is that they are watched by nearly everyone in every country, young and old over a 2 week period. During these 2 weeks kids and teens see thousands of 'buff" athletes and think "I want to be like that". Some of these kids will look to steroids to help them along. The problem with steroids is not only are they illegal they can have serious and dangerous side effects. Steroids fall into 2 categories, anabolic steroids and corticosteoids. Both have significant medicinal value as well as significant side effects. Anabolic steroids or AAS's are the type used by athletes and body builders for their muscle building and masculine properties. The thing that makes them so potentially dangerous is that in order for them to be effective for those purposes they need to be taken in doses 10 to 100 times higher than the highest therapeutic dos given for treatment of a medical condition. Taking any medication 10 to 100 times the normal therapeutic dose significantly increases your chances of experiencing side effects. So before you consider using steroids to accomplish your goal you need to think about the potential consequences. First of all if your goal is to become an Olympian or a professional athlete steroids are illegal and you will be tested. If you are considering steroids for other reasons you need to carefully research the steroids you are considering and know the potential side effects.
One of the things that makes steroid use so dangerous is that many of the users take a combination of several different types of AAS's and non-steroidal supplements to get the maximum effect. Long term steroid use affects several chemicals and pathways in the brain including serotonin and dopamine which have a significant effect on our moods and behavior. So while most steroid users say they feel good even great while taking steroids there are also severe mood swings that occur. These mood swings can become viiolent, known as "roid rage" as well as lead to paranoia, and delusions. Though steroids don't become addictive in the same sense as a heroine user the body does develop a resistance requiring more and more of the drug to achieve the same effect. For this reason many steroid users will take them in an on – off cycle, taking them for a period of time then stopping for a period of time before starting again.
Long term steroid use/abuse can cause serious, irreversible health conditions as well including kidney failure, liver damage, and numerous cardiovascular problems like high blood pressure and enlargement of the heart and increase your risk of heart attack and stroke for all ages. That includes teens and young adults. There are also many side effects that may not be life threatening but also need to be considered if you are considering steroid use. In men that take steroids those would include a decreased sperm count and/or infertility so if you're thinking about having children you need to take this into consideration. There is also an increased chance of developing prostate cancer. Men using steroids also tend to develop alopecia or baldness as well as breasts known as gynecomastia. Women that take AAS's tend to develop male characteristics including facial hair and a deeper voice, they can also develop whats known as male pattern baldness. Women taking steroids will also usually notice changes or even cessation of their menstrual cycle. adolescents tend to have impaired growth, not attaining their expected height as well as accelerated puberty changes. If all that isn't enough, for those users that use injectable steroids there's also the risk of either contracting or giving hepatitis and HIV/AIDS.
If you are still thinking about trying steroids like it or not you reallu need to see your Dr for a complete physical. It's important to know if you have any previously unknown health issues before beginning a steroid regime. Then research, research, research! Become informed, know what you're taking and what to watch for.


text:
Newegg.com - A great place to buy computers, computer parts, electronics, software, accessories, and DVDs online. With great prices, fast shipping, and top-rated customer service - once you know, you Newegg.
If you are reading this message, Please click this link to reload this page.(Do not use your browser's "Refresh" button). Please email us if you're running the latest version of your browser and you still see this message.
Newegg.com - Computer Parts, Laptops, Electronics, HDTVs, Digital Cameras and More!
Showing Results: Most Recent
This review is from: memorex 4.7GB 4X DVD+RW 25 Packs Spindle Disc Model 05541
Pros: Don't have any.
Cons: I've had nothing but trouble from these, with read and write errors on most of the disks used so far.READ FULL REVIEW


text:
The 6 Top Myths About Plant-Based Diets
Would you like to consider a plant-based (aka vegan) diet, but find yourself confused by all the conflicting information? Let's look at some of the most persistent myths, one at a time. Excerpted and adapted from Plant Power: Transform Your Kitchen, Plate, and Life with More Than 150 Fresh and Flavorful Vegan Recipes by Nava Atlas. ©2014, published by HarperOne, reprinted by permission. Photos by Hannah Kaminsky.
Benefits of Using Stevia Instead of Sugar and Sugar Substitutes
Many people have stopped using sugar and have switched to stevia because it's healthier, and not chemically processed like artificial sweeteners. Stevia is an herb that comes from the same family as lettuce and marigolds and is native to the rain forests in Paraguay; although now it is grown all over the world. Stevia has been used for over 1500 years by the native indians of Paraguay. more→
Health Benefits of Chia, Flax, and Hemp Seeds
Chia, hemp, and flaxseeds seem to be everywhere these days! This trio of tiny seeds offers an abundance of health benefits, not the least of which are the valuable Omega-3 fatty acids. These seeds aren't just for those following plant-based diets, but anyone who wants to boost their intake of nutrients. Read on for a brief introduction to these small but mighty super foods, their comparative benefits, and some ways to use them in your daily fare. more→
6 Basic Guidelines for the Nutritarian Diet
Excerpted from The End of Dieting: How to Live for Life* by Joel Fuhrman, MD. © 2014 HarperOne, reprinted by permission. Everybody can do this, and here's the plan. But remember: These are just general guidelines; you don't have to follow them precisely. For example, you can go above or below the general serving recommendations depending on your height and degree of physical activity or exercise. A world-class athlete may need triple the calories of a sedentary office worker. To call yourself a nutritarian, follow these six basic guidelines:
Great Health Benefits from Berries and Pomegranates
Excerpted from End of Dieting: How to Live for Life* by Joel Fuhrman, MD. © 2014 HarperOne, reprinted by permission. Blueberries, raspberries, strawberries, and blackberries are vibrantly colored with antioxidant phytochemicals, and they are some of the highest antioxidant foods in existence. The deep red, blue, and purple pigments of berries are produced by anthocyanins, which are concentrated in the skins of the fruits. more→
Every Woman's Favorite Weight-Loss, Cancer-Prevention Diet
Contributed by Racheal L. Whitaker, M.D, excerpted from Rethink Food: 100+ Doctors Can't Be Wrong.* My gastric reflux was so bad it would wake me at night. I had been having episodes of reflux off and on for years, and accepted it as par for the course. As a doctor specializing in obstetrics and gynecology, I knew the rules—typical foods to avoid (coffee, citrus foods, alcohol) as well as the medications to take. However, despite following these guidelines my discomfort and symptoms only worsened. more→
Animal Protein vs. Plant-Based Protein
Excerpted from Super Immunity: The Essential Nutrition Guide for Boosting Your Body's Defenses to Live Longer, Stronger, and Disease Free* by Joel Fuhrman, @2011 HarperOne, reprinted by permission.The nutrition-related educational materials used in most schools have been provided "gratis" by the meat, dairy, and egg industries for over seventy years. Those industries have successfully lobbied and influenced the government, resulting in favorable laws and subsidies—and resulting in advertising propaganda being fed to every child. They have been selling the mistaken idea that we need meat, dairy, and eggs in order to be properly nourished. We have thus been programmed with incorrect and dangerous information. more→
Maca – Ancient Peruvian Superfood
By Paul E. Maca is a herb native of the high Andes of Bolivia and Peru for thousands of years. Maca is a member of the cruciferous family of plants. The plant is considered a member of the species Lepidium meyenii; it is a distant relative of the tuberous root vegetable radish. The Maca plant produces leaves that grow close to the ground and the plant produces a small, off-white flower. more→


text:
This guy is all ready to be stuffed and there is a big pink bunny sitting next to him... things are in fact happening. Slow yes, but surely just the same.
The studio has been busy. More busy that I have hours to give, but it feels good to be working furiously and then skip out on it all to care for my kids, myself, my family. They're still so little I keep reminding myself. Now just 3 and 6 they're all love and play and energy and chaos. I miss the days in my old big studio where I could spend long days and work into the night, but this... this right now: this is better. This is rich and full and hard and I love it. So with all that energy and heart, when I sit down to make one or two of these pieces, I'm showing up with my whole heart, and I think all that goodness gets in there too.
and other silly things
a few things in the works...
I've been working on a few new bears and animals. Many more are in the works and I'll post images as they come together over the new few weeks. My hope is to have a website update later in March. I'm excited to be working on some pieces that I've had cut out for years, and a few new pieces like this panda, which I just hand dyed the fabric for... it all feels new and fresh and I'm so pleased to be spending a little time just like this...
three oldies but goodies...
I just put three little sculptures/cake toppers in my etsy shop that I've had in the studio- they're mega on sale, and I'm excited to get them into someones hands who'll appreciate them rather than having them in a drawer in my studio...
Making two new bears old...
I've been surprisingly prolific in the studio the last few days. I had been starting so many bears and animals, and now things are quickly getting finished and ready for a website sale... Wednesday? Thursday? Stay tuned.
hello little one
I'm thinking the website update will be early next week... when the date's set I'll be sure to post it here and send out an email as well!
Subscribe to: Posts (Atom)


text:
Service animal wellness center coming to Orange
Horse Play Therapy and Tackett Service Dogs are teaming up to create a wellness center where animals help humans heal and improve their quality of life and mental health.
The center, which will operate at the former Ridgeline Country Club in Orange, will provide services to military personnel suffering from post-traumatic stress disorder and other mental health disorders, as well as anyone else who might benefit.
The groups hope the center will be open by June 1.
Dr. Carole Harris, who started an equine assisted psychotherapy practice at the Huntington Central Park Equestrian Center, and Tom Tackett, an experienced behavioral consultant and competition dog trainer based in Orange, will join forces for the center.
The property – a 51-acre site in Orange Park Acres – is owned by Milan REI, IV. The site has been approved for the development of 39 equestrian estate homes and new recreational facilities. However, according to a press release, the owner is welcoming the wellness center onto the site as a temporary activity as the state appellate court reviews a lawsuit pertaining to the development.
For more information about Harris and Horse Play Therapy, visit horseplaytherapy.net. For information on Tackett Service Dogs, visit tackettservicedogs.com. Both organizations are in the process of obtaining nonprofit status.
Most Popular
- Analysis: Is Donald Trump doomed after debate debacle?
- Luke Walton's first Lakers training camp practice is music to players' ears
- Friend: Fullerton homicide suspect talked about murder on Facebook 4 days before killings
- DMV employee in Placentia convicted of stealing car registration fees
- No charges are filed Tuesday against 17-year-old girl in triple homicide in Fullerton
User Agreement
Comments are encouraged, but you must follow our Privacy Policy Policy & Terms of Use
Keep it civil and stay on topic. No profanity, vulgarity, racial slurs or personal attacks. People who harass others or joke about tragedies will be blocked. By posting your comment, you agree to allow Orange County Register Communications, Inc. the right to republish your name and comment in additional Register publications without any notification or payment.


text:
Top Definition
Very posh and dated word meaning excellent, especially as used by upper-class toffs and rugger buggers.
I say, she's a lovely filly.
Oh yes, absolutely spiffing old chap.
Oh yes, absolutely spiffing old chap.
dodane przez onandon sierpień 01, 2005
Trending Now
Can you define these popular missing words?
lovely, desirable, super
retro term - ganking
retro term - ganking
We're having such a spiffing time
He's a spiffing bloke
He's a spiffing bloke
dodane przez Catherine wrzesień 30, 2003
A very dated word used by the upper-class British, and Americans that can't do impressions for shit.
Can be used for comedic value.
Usually found in sentences containing the terms; "Jolly good" "Old chap/chum" "Tea" "Wot wot" "I say" and "Earl grey"
Can be used for comedic value.
Usually found in sentences containing the terms; "Jolly good" "Old chap/chum" "Tea" "Wot wot" "I say" and "Earl grey"
I say, old chum. Would you like to come to Buckingham palace and share a spiffing pot of the old earl Grey, wot?
dodane przez PotHeadJesus luty 19, 2010
For something to be excellent or good. Word is mainly used by upper-class British
I say Grayson, that back-scratched you purchased for me the other day is rather spiffing.
dodane przez Superduperpooperscooper123123 styczeń 08, 2010
when something is fantabulous
of the upmost quality
dodane przez MrW maj 31, 2005
Old english word, used by Upper Classes (Private school types, Rugby Players, heirs etc.) to describe something or someone who absolutely brilliant cannot be exceeded.
"Hugos a jolly good shot!"
"Yes! That old chap is spiffing with a shotgun"
"Yes! That old chap is spiffing with a shotgun"
dodane przez Flossyyyy sierpień 30, 2015
Spiffing, or to spiff is to have sexual intercourse with your partner/person and leave either the person, or area in a mess.
Wow this room is a mess, somebody must have been spiffing!
dodane przez brokenvanity sierpień 17, 2010


text:
Newegg.com - A great place to buy computers, computer parts, electronics, software, accessories, and DVDs online. With great prices, fast shipping, and top-rated customer service - once you know, you Newegg.
If you are reading this message, Please click this link to reload this page.(Do not use your browser's "Refresh" button). Please email us if you're running the latest version of your browser and you still see this message.
Newegg.com - Computer Parts, Laptops, Electronics, HDTVs, Digital Cameras and More!
Ships from United States. Most customers receive within 6-10 days.
Sold and Shipped by VitaminLife
100% Vegetarian MSM & Glucosamine Description: KAL 100% Vegetarian MSM & Glucosamine provides MSM, a source of organic sulfur, that is intended to provide nutrative support for healthy joint function and is critical to the production of connective tissue and cartilage. Organic sulfur works in many pathways in the body and is also important for proper bone, gastrointestinal, respiratory and metabolic functions. Glucosamine is intended to provide nutritive support for connective tissue by helping to keep collagen supple and healthy in the joints. This revolutionary shellfish-free Glucosamine is manufactured through a fungal fermentation process.
Product #: 12959 Size: 60ct Directions: Take 1 tablet up to twice daily.
Serving Size: 1 Tablet 60 Servings per container Ingredients: Amount per serving: % Daily Value: + D-Glucosamine Hydrochloride (vegan)500 mgMethylsulfonylmethane (MSM)500 mgTotal Carbohydrate
Your request will be processed within the next 24 hours.
Please add "email@example.com" to your address book to ensure delivery.See Today's E-Blast Promo
Some manufacturers place restrictions on how details of their products may be communicated.
Some manufacturers place restrictions on how details of their products may be communicated.
Some manufacturers place restrictions on how details of their products may be communicated.