I welcome to invite people who interest in building flexible, scalable system with the help of CQRS principle. Event will be organized in Kharkiv, Ciklum office, July 07, 2011 18.00-19.00.
And Let the wheels run!
Отмечено на карте:
Ciklum
And Let the wheels run!
Sys.Mvc.ValidatorRegistry.validators.remote = function (rule) {
var url = rule.ValidationParameters.url;
var parameterName = rule.ValidationParameters.parameterName;
var isAsync = rule.ValidationParameters.isAsync=='true' || false;
var message = rule.ErrorMessage;
var result = true;
var onComplete = function (responseData) {
var lowerData = responseData.toLowerCase();
if (lowerData != 'true') {
var newMessage = (lowerData == 'false' ? message : responseData);
result = newMessage;
}
};
return function (value, context) {
if (!value || !value.length) {
return true;
}
if (context.eventName == 'blur') {
return true;
}
var ajaxCallParam = {
url: url,
async: isAsync,
data: $.param([{ name: parameterName, value: value}])
}
if (isAsync) {
ajaxCallParam.success = onComplete;
}
var responseData = $.ajax(ajaxCallParam);
if (!isAsync) {
onComplete(responseData.responseText);
}
return result;
};
}; Where custom Remote validation attribute:public sealed class RemoteValidationAttribute : ValidationAttribute
{
public string Action { get; set; }
public string Area { get; set; }
public string Controller { get; set; }
public string ParameterName { get; set; }
public string RouteName { get; set; }
public bool IsAsync { get; set; }
public override bool IsValid(object value)
{
return true;
}
} With actual Remote Validator:public class RemoteValidator : DataAnnotationsModelValidatorThat we have to register on application start up:{ public RemoteValidator(ModelMetadata metadata, ControllerContext context, RemoteValidationAttribute attribute) : base(metadata, context, attribute) { } public override IEnumerable GetClientValidationRules() { var rule = new ModelClientValidationRule { ErrorMessage = ErrorMessage, ValidationType = "remote" }; rule.ValidationParameters["url"] = GetUrl(); rule.ValidationParameters["parameterName"] = Attribute.ParameterName; rule.ValidationParameters["isAsync"] = Attribute.IsAsync.ToString().ToLower(); return new[] {rule}; } private string GetUrl() { var rvd = new RouteValueDictionary { {"area", Attribute.Area ?? string.Empty }, {"controller", Attribute.Controller}, {"action", Attribute.Action} }; var virtualPath = RouteTable.Routes.GetVirtualPath(ControllerContext.RequestContext, Attribute.RouteName, rvd); if (virtualPath == null) { throw new InvalidOperationException("No route matched!"); } return virtualPath.VirtualPath; } }
DataAnnotationsModelValidatorProvider.RegisterAdapter(
typeof(RemoteValidationAttribute),
typeof(RemoteValidator)
);
Please, be polite to this article, because it's only example and experiment, for production ready solution we have to measure different velocity and productivity values.
public static class ReflectionUtil<T>
{
static ReflectionUtil()
{
Properties = typeof (T).GetProperties();
GetProperties = Properties.Select(_ => new
{
Func = GetGetFunc(_),
_.Name,
})
.Where(_ => _.Func != null)
.ToDictionary(_ => _.Name, _ => _.Func);
SetProperties = Properties.Select(_ => new
{
Func = GetSetFunc(_),
_.Name,
})
.Where(_ => _.Func != null)
.ToDictionary(_ => _.Name, _ => _.Func);
}
public static Func<T, object> GetGetFunc(PropertyInfo propertyInfo)
{
MethodInfo methodInfo = propertyInfo.GetGetMethod();
if (methodInfo != null)
{
return _ => methodInfo.Invoke(_, ArrayUtil.Empty<object>());
}
return null;
}
public static Func<T, object, T> GetSetFunc(PropertyInfo propertyInfo)
{
MethodInfo methodInfo = propertyInfo.GetSetMethod();
if (methodInfo != null)
{
return delegate(T _, object val)
{
methodInfo.Invoke(_, new[] {val});
return _;
};
}
return null;
}
public static Dictionary<string, Func<T, object>> GetProperties { get; private set; }
public static Dictionary<string, Func<T, object, T>> SetProperties { get; private set; }
public static PropertyInfo[] Properties { get; private set; }
}
public static class ObjectReflectionExtension
{
public static Dictionary<string, Func<T, object>> GetProperties<T>(this T value)
{
return ReflectionUtil<T>.GetProperties;
}
public static Dictionary<string, Func<T, object, T>> SetProperties<T>(this T value)
{
return ReflectionUtil<T>.SetProperties;
}
public static PropertyInfo[] Properties<T>(this T value)
{
return ReflectionUtil<T>.Properties;
}
}
var getProperties = fromObj.GetProperties(); var setProperties = toObj.SetProperties();
var map = from getProp in getProperties
join setProp in setProperties on getProp.Key equals setProp.Key
select new { From = getProp.Value, To = setProp.Value };
map.ForEach(
_ => _.To(toObj, _.From(fromObj) )
);
Find enough clever things to say, and you're a Prime Minister; write them down and you're a Shakespeare.
George Bernard Shaw
EXEC sp_configure 'show advanced options' , '1' GO reconfigure GO EXEC sp_configure 'clr enabled' , '1' GO reconfigure -- turn back advanced options EXEC sp_configure 'show advanced options' , '0' GOAfter we can write any user-defined functions aggregates, stored procedures, etc...using high versatile and flexible .NET Framework infrastructure in C# or VB.NET.
That's all for today. If you don't mind my dear reader, I will post short tips for myself from time to time, maybe you also find them useful in some cases.
So, now we have two main questions: will the geoinformational service be used and what type of service will it be?We can divide it using different criterias, but I will look at three of them: detalisation, validity and sources of retrieving.
I will notify in next post about details and process of contributing and organization of this project.All feedback and participating is welcome!
Пример из wiki насторек SyntaxHighlighter для Blogger не заработал.Привожу краткий результат какие необходимы шаги для успешной интеграции SyntaxHighlighter 3 и Blogger:
<link href='/syntaxhighlighter/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/> <link href='/syntaxhighlighter/styles/shCore.css' rel='stylesheet' type='text/css'/> <script src='/syntaxhighlighter/scripts/shCore.js' type='text/javascript'/> <script src='/syntaxhighlighter/scripts/shAutoloader.js' type='text/javascript'/>У меня выделена папка syntaxhighlighter для всех файлов библиотеки.
<script type='text/javascript'>
//<![CDATA[
function path()
{
var args = arguments, result = [];
for(var i = 0; i < args.length; i++)
result.push(args[i].replace('@', '/syntaxhighlighter/scripts/'));
return result;
};
SyntaxHighlighter.autoloader.apply(null, path(
'applescript @shBrushAppleScript.js',
'actionscript3 as3 @shBrushAS3.js',
'bash shell @shBrushBash.js',
'coldfusion cf @shBrushColdFusion.js',
'cpp c @shBrushCpp.js',
'c# c-sharp csharp @shBrushCSharp.js',
'css @shBrushCss.js',
'delphi pascal @shBrushDelphi.js',
'diff patch pas @shBrushDiff.js',
'erl erlang @shBrushErlang.js',
'groovy @shBrushGroovy.js',
'java @shBrushJava.js',
'jfx javafx @shBrushJavaFX.js',
'js jscript javascript @shBrushJScript.js',
'perl pl @shBrushPerl.js',
'php @shBrushPhp.js',
'text plain @shBrushPlain.js',
'py python @shBrushPython.js',
'ruby rails ror rb @shBrushRuby.js',
'sass scss @shBrushSass.js',
'scala @shBrushScala.js',
'sql @shBrushSql.js',
'vb vbnet @shBrushVb.js',
'xml xhtml xslt html @shBrushXml.js'
));
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.all();
//]]>
</script>
The Project Management Triangle (called also Triple Constraint) is a model of the constraints of project management. It is often used to illustrate that project management success is measured by the project team's ability to manage the project, so that the expected results are produced while managing time and cost.
Michael W. Newell, Marina N. Grashina (2004). The Project Management Question and Answer Book