|
Sheesh! So much for code elegance!
|
|
|
|
|
If that is implemented in F# originally (or was compiled by a compiler that supports tail recursion), then there is no additional funciton overhead.
In fact, if the code is reordered correctly, it's faster than a loop.
The guy who wrote it probably knew a lot more about what he was doing than it appears at first glance.
|
|
|
|
|
Assert.IsFalse(!CallMethod()); Only the method name changed to protect the (not so) innocent.
|
|
|
|
|
HEY! You left out the important part! Did the test pass?
Attempting to load signature...
A NullSignatureException was unhandled.
Message: "No signature exists"
All of the books in the world contain no more information than is broadcast as video in a single large American city in a single year. Not all bits have equal value.
Carl Sagan
|
|
|
|
|
No test ain't gonna fail on my watch
I'm invincible, I can't be vinced
|
|
|
|
|
|
Initially, the success of running test was !true . After some work, it is !false .
|
|
|
|
|
|
|
The horror is allowing creation of a view with an order by in the first place.
Just say no.
|
|
|
|
|
My thoughts exactly.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
Well, Order By is of some use, even in views.
But it should ALWAYS be paired with a TOP(X).
SELECT TOP 100 PERCENT *
FROM Somewhere
ORDER BY whatever
is a true, classic, horror.
|
|
|
|
|
Doing some maintenance on an application which I developed a few years ago, I found a small gem:
public string formatDateMySQL(DateTime date)
{
StringBuilder strTmp = new StringBuilder(date.Year.ToString());
strTmp.Append("-");
strTmp.Append(date.Month.ToString());
strTmp.Append("-");
strTmp.Append(date.Day.ToString());
return strTmp.ToString();
}
Yeah, formatting DateTime values works different everywhere, and that's a very "clever" way of coping with that...
License: You may use this code according to the CodeProject license.
|
|
|
|
|
Shirley AppendFormat is the way to go.
|
|
|
|
|
No, but ISO-8601 is IIRC.
|
|
|
|
|
Bernhard Hiller wrote: License: You may use this code according to the CodeProject license.
Don't you mean, "License: You must never use this code under penalty of tar-and-feathering"?
|
|
|
|
|
Just wait a little, and you'll see it becoming the solution for date/time formatting problems with MySQL server in Quick Answers...
|
|
|
|
|
Is this written in C#? I guess the more simpler way would be.
date.ToString("yyyy-MM-dd") out puts the date as 2012-04-18
or
date.ToString("yyyy-M-dd") out puts the date as 2012-4-18
If not C# Kudos to you
Sastry
|
|
|
|
|
ServiceCallInfo is actually a DataContract.
Yes... I have actually implemented a service that can call any other service it happens to find in it's configuration.
I'm sure none of this would be necessary in a dynamic language like Ruby, however what other framework/language provides such a comprehensive and flexible service framework like WCF?
I wasn't sure if this should go in "Clever Code" or "Hall of Shame" for it's meta-ness. I put it here, because I like to doubt myself
Right now it depends on all the service contracts being contained in one interface assembly though... I suppose I could also pass in the assembly name containing the contract and have it dynamically try to find or load the assembly too. Or would that be too far?
internal class ReflectedServiceChannelMethod
{
private static readonly Assembly InterfaceAssem = Assembly.GetAssembly(typeof(IGeneralLookupService));
private readonly Type _contractType;
private readonly Type _channelFactoryType;
private readonly object _channelFactory;
private readonly MethodInfo _createChannelMethod;
private readonly MethodInfo _callMethodInfo;
private readonly ParameterInfo[] _methodParams;
public ReflectedServiceChannelMethod(string interfaceName, string methodName)
{
_contractType = _interfaceAssem.GetType(interfaceName);
_channelFactoryType = typeof(EdsChannelFactory<>).MakeGenericType(_contractType);
_callMethodInfo = _contractType.GetMethod(methodName);
_methodParams = _callMethodInfo.GetParameters();
var channelFactoryConstructor = _channelFactoryType.GetConstructor(new Type[] {});
_channelFactory = channelFactoryConstructor.Invoke(new object[] {});
_createChannelMethod = _channelFactoryType.GetMethod("CreateDefaultChannel", new Type[]{});
}
public object CallService(ServiceCallInfo job)
{
object channel = null;
try
{
channel = _createChannelMethod.Invoke(_channelFactory, new object[] { });
var parameters = new List<object>();
foreach (var methodParam in _methodParams)
{
object value = null;
var paramType = methodParam.ParameterType.MakeByValType();
if (job.Parameters != null)
{
ParameterInfo param = methodParam;
var jobParam = job.Parameters.FirstOrDefault(p => p.Name == param.Name);
if (jobParam != null)
{
value = jobParam.Value;
}
if (paramType != typeof(string))
{
value = Convert.ChangeType(value, paramType);
}
}
parameters.Add(value);
}
return _callMethodInfo.Invoke(channel, parameters.ToArray());
}
catch (Exception ex)
{
ex.LogAsCritical();
return null;
}
finally
{
if (channel != null)
{
((IDisposable) channel).Dispose();
}
}
}
}
modified 29-Mar-12 14:07pm.
|
|
|
|
|
ObjectServiceFactoryServiceObjectAutomationLinkFactoryServiceFactoryObjectMetaObjectBuilderFactory .
Software Zen: delete this;
|
|
|
|
|
Gary R. Wheeler wrote: ObjectServiceFactoryServiceObjectAutomationLinkFactoryServiceFactoryObjectMetaObjectBuilderFactory .
You forgot "GoldProTeamEdition"...
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
|
Let me be the first to congratulate you.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
Just spent 1,5 hours on error which came out to be just a tupotypo. I had a simple WPF binding:
public static readonly DependencyProperty SopranTextProperty =
DependencyProperty.Register("SopranText", typeof(string), typeof(SeparateVoicesInputVM), new UIPropertyMetadata(""));
In a user-control. Tired of trying to get UserControl-HostWindow binding working (at least 4 hours), I have given up and broke design rules by pastying all the stuff to the MainWindow. Still, it didn't work. Time was passing while I was switching binding parameters with no effect. Finally, I decided to ask CP for this and, while writing a message, I have noticed one detail...
public static readonly DependencyProperty SopranTextProperty =
DependencyProperty.Register("SopranText", typeof(string), typeof(MainWindowVM), new UIPropertyMetadata(""));
Oh dear
Greetings - Jacek
|
|
|
|
|