-
a merge function
function merge(root){ for ( var i = 0; i < arguments.length; i++ ) for ( var key in arguments[i] ) root[key] = arguments[i][key]; return root; }
-
position property
In css the position properties, such as top, left, right, bottom is auto by default, one miss conception is that they are 0. Which is not the case. So when you change from positon values (static, relative; absolute, fixed) without setting the top/left/right/bottom, there should be no change, except that absolute and fixed value will disable the margin merge.
-
Loading common model into view
In our view, there are some data which are require across all page, such as site bar data, menu, and so on. We can split them into partial view and using Html.RenderAction. But this should not be overused, because of performance issue and also it kind of violate separation of concerns. In this case, the view is controlling data. If we want to use Html.RenderPartial, data can be explictly passed in Parent View, or we can inject the data into ViewData in the stack before ActionResult is returned from controller. For example, we can use base controller, and override
public void BaseController : Controller { protected override OnActionExecuting(ActionExecutingContext context) { ViewData.Add(your_data); } }
Another option is use ActionFilterAttribute. It is designed to solve cross-cutting concerns, like authorization, logging and so on. But we can use it to load common data as well.
public class RequireCommonDataAttribute : ActionFilterAttribute { public override void OnActionExecuting(ActionExecutionContext filterContext) { filterContext.Controller.ViewData.Add(your_data);
-
How to use bookmark in WF4
BookMark can be used to implement event driven style workflow. Below is some sample code.
//in your activity, you override Execute method, to put your workflow idle protected override void Execute(NativeActivityContext context) { string bookmark = this.BookmarkName.Get(context); context.CreateBookmark(bookmark, delegate(NativeActivityContext ctx, Bookmark bMark, object state) { string input = state as string; ctx.SetValue(this.Result, input); }); }
-
Loading string as workflow
Here is some sample code that loads string as workflow
Stream stream = new MemoryStream(ASCIIEncoding.Default.GetBytes(stringXaml)); Activity wf = ActivityXamlServices.Load(stream); IDictionary<string, object> results = WorkflowInvoker.Invoke(wf);