« first day (1439 days earlier)      last day (3504 days later) » 

5:00 PM
@Greg Handling for a default struct.
 
So in lamens terms, if the node doesn't exist wouldn't it still throw a Null Argument Exception?
 
@gurun There is a partial class which provides an implementation for Before/AfterDecode?
@Greg If value is null, then the if check will return false, therefore the function will not be executed and the method will return null (just as would happen with FirstOrDefault().
 
@user1112560 So, when I go to user this I could call .Value at the end?
Or would I let it build a Generic List<T> out of the var?
 
@Greg No, if you wanted to use .Value then you'd use ifValueExists to use the non-default value.
 
Essentially by not declaring the .Value it would convert the property into a List.
@user1112560 I'm saying in my code when I pass to the extension method.
@user1112560 Your solution interest me, but I'm almost positive it can be simplified in a manner to simplify my Linq Projections.
I don't want to over complicate the code, nor make the structure difficult to modify or change in the future.
 
5:07 PM
Yes, there is a partial class, both identical declarations.
 
@Greg I'm afraid I don't understand. Do you have some sample code with what you want to achieve?
@Greg I need to head out pretty soon, but will take a look when I get back.
 
@user1112560 The code above where I have this:
var date = responses.FirstOrDefault(obj => obj.Label.Contains("Date Signed")).Value;
To avoid the null error, if it was wrapped in an Extension Method example.
 
How does that work?
You still have to do a check..
no?
 
responses.FirstOrDefault(obj => obj.Label.Contains("Date Signed"), date => { CodeHere(); });
 
Oh God
 
5:11 PM
Bad style?
 
Probably not
responses.FirstOrDefault(obj => obj.Label.Contains("Date Signed"), date => methodName);
I still don't see it
So you return a lambda back?
 
Just trying to make it better.
 
Then what?
 
Here i'm trying to get Last Inserted Row ID for the InvoiceHD table.but there's a error in this code.could you please tell me how to solve it
 public int GetLastInsertedInvoiceHDRowId()
        {
            return (from x in context.InvoiceHDs
                    orderby x.InvoiceId 'DESC'
                    select x)
        }
 
@TechGuy I wish I were psychic.
 
5:13 PM
@user1112560 Then just call the method.
 
I don't see how you can avoid checking for null, or at least a valid value from the method
 
@LewsTherin I'm a newbie to mvc entity,pls help me
 
Well I tried reading your mind but failed miserably
 
@LewsTherin Well, was hoping that I could call the Extension Method maybe. Do the check, then return the straight value.
So no where in my core implementation I have to call date.Value.
 
Can you show me a snippet?
 
5:16 PM
        public static TNode VerifyXmlNode(IEnumerable<TNode> source, Func<TNode, bool> predicate, Action<TNode> NodeExist)
        {
            var value = source.FirstOrDefault(predicate);
            if (!EqualityComparer<TNode>.Default.Equals(value, default(TNode)))
                NodeExist(value);

            return value;
        }
 
What extension method is called?
Unless you always an object from the extension method that represents both valid and invalid state, not sure how that'd work
 
Well, @LewsTherin It would be like this:
 
@TechGuy You need to say what the error is.. srsly
 
morning guys
 
Evening!
 
5:23 PM
godamn... i can't get the partial to work :-(
 
@LewsTherin In here InvoiceId is Auto Increment Id and i need to get last inserted auto increment Id. this code snippet is incomplete, my knowlegde is not enough to go further :(
 
@Greg Are you still writing the example?
 
hey guys, only one question, how can i transform this number into this:
 
posted on September 24, 2014 by The .NET Team

Today the .NET Micro Framework team is releasing a beta update of the .NET Micro Framework SDK that adds support for Visual Studio 2013. The release also contains other improvements that will benefit developers and hardware partners, making the install and update experience better. Check out the .NET Micro Framework Team blog, and the Netmf.com site to learn more about .NET Micro Framework an

 
this = 1.34862996016481

into this = 1.34863
 
5:26 PM
@LewsTherin I'm really stuking here
 
> but there's a error in this code
-_-
context.InvoiceHDs.OrderByDescending(x=>x.InvoiceId).Single();
Try that I think
 
can someone tell me how to convert
this = 1.34862996016481

into this = 1.34863
?
 
Mmn does Math.Round specify number of digits to round? If not might have to do a string format first. Not sure..
 
let me see
it convert to the nearest integer value
but i would need like above
it might be somethin tricky
 
wow, read some fucking documentation
 
5:33 PM
^
 
var date = responses.FirstOrDefault(obj => obj.Label.Contains("Date Signed")), => APIValidate.VerifyXmlNode(date); for example?
 
Hi Guys, Can someone give me a solution for stackoverflow.com/questions/25785973/…
 
@Anish, no
 
@Greg What does Verify return... a bool? If it is verifying why return an object? -_-
 
Jesus fucking Christ
 
5:40 PM
@LewsTherin Whatever Node was placed.
@LewsTherin
        public static TNode VerifyXmlNode(IEnumerable<TNode> source, Func<TNode, bool> predicate, Action<TNode> NodeExist)
        {
            var value = source.FirstOrDefault(predicate);
            if (!EqualityComparer<TNode>.Default.Equals(value, default(TNode)))
                NodeExist(value);

            return value;
        }
 
var value = source.FirstOrDefault(predicate);
What if that returns null?
 
@LewsTherin Don't care, as long as it doesn't actually throw the entity logic handles it.
If it throws Null Reference Exception that breaks everything, as long as it is just null all good.
 
Mmn.. FirstOrDefault doesn't throw NRE
 
@LewsTherin It did with this line.
var date = responses.FirstOrDefault(obj => obj.Label.Contains("Date Signed")).Value;
@LewsTherin If the Xml Node doesn't exist, I mean it isn't present it totally will throw.
@ton.yeung I thought you were coming to Oregon.
 
@Greg Wtf how does VerifyXmlNode not throw then?
 
5:44 PM
@LewsTherin It might, I was talking to @user1112560 about it because he recommended it. I asked if it would throw and he said no, it would use the Default.Struct.
@LewsTherin I originally said, wouldn't this throw?
@ton.yeung No, I wasn't sure about why you asked about Tigard.
 
@Greg What do you want to do if it returns null?
 
@LewsTherin Well, originally I had the .Value but when we made a chance to our internal application the third party API didn't update all our users to the new node. So it left it out, which caused the Null Reference Exception. So I was hoping to modify it, so it was cleaner and prevented that should changes occur in the future.
@LewsTherin null is fine, I just can't have it throw. It is an internal service where this code is running.
 
Why not check for null or wrap in a try catch and log the error. At least then you know some users are missing from the new node.
 
I have a viewbag result in my MVC view i need to increment that value by 1. how can i do it ? mt viewbag like this .. @ViewBag.LastInsertedInvoiceId
 
You are losing information with that I think. Depends on your use case I guess
 
5:49 PM
it returns integer value
 
@LewsTherin It is fine.
 
Alright cool then
 
@LewsTherin ...?
 
I still doubt that @user solution won't throw
Should try it? But sounds like a hack :P
 
@Greg Back. It will throw if you're using .Value on FirstOrDefault. If you're supplying a delegate to the extension method, then that delegate will never receive a default(null) value.
 
5:53 PM
Web Development is not for me...
 
@JLott ?
 
@JLott Same
 
I just don't like it lol
 
Same..
 
I love it.
 
5:54 PM
@user1112560 Wait what?
@TravisJ Yeah, I like it as well.
 
I'm supposed to help a co worker with this website that we need to release soon.. and it sucks... it just all sucks
 
@JLott The iPhone 6 is bendable though.
 
So are other phones lol
 
@user1112560 FirstOrDefault iterates through the sequence. So how does verifyxmlnode know if it hasn't been found? Ah the NodeExists but then that sounds like a nested foreach.
 
@JLott - Needs more cowbell
 
5:55 PM
@user1112560 Question-

                var location = responses.FirstOrDefault(obj => obj.Label.Contains("Location")).Value;
                var date = responses.FirstOrDefault(obj => obj.Label.Contains("Date Signed"));

If the .Value will throw a Null Reference Exception but if I use the Extension Method how will it not throw?
@JLott The Note 3 and Lumia 1520 passed the bending test. So?
 
@Greg Greg, the simplest solution is to check for null and continue if it is :)
Cleaner as well
 
I just don't argue it lol. Everyone will always pick on Apple more than any other company haha. From an article "It's obvious of course that practically any smartphone will bend if you apply enough pressure - there were similar reports of Sony's Xperia Z1 warping earlier this year - but unfortunately for Apple, the prestige (and price) of their devices means any fault is taken far more seriously than those of their rivals'."
 
@LewsTherin I'm thinking about just writing a simple method, the takes a generic value and does a simple switch to test if it is null or not.
 
The issue with this website is that it needs to be offline and use like IndexedDBs
Which I have no experience with
 
@Greg The extension method will return null, calling null.Value will throw an NRE.
 
5:57 PM
@JLott Except Apple's iPhone 6 is bending in peoples pocket. That is flawed engineering.
 
@Greg Plus
 
@Greg You can do that but you will still have to return something that's not null. Otherwise you will have to do a sanity check
 
@ton.yeung Explain....
 
@user1112560 So, it won't really solve the problem.
 
@Greg Let me know what you find out
 
5:57 PM
@LewsTherin Yeah, it won't really solve the problem.
 
It solves the problem of not requiring a null check.
 
@JLott - The only way for a device to have access to data offline is to have it stored on the device
 
        IEnumerable<string> responses = new List<string> { "a", "b", "c" };
        string lastValidData = null;

        var check = responses.FirstOrDefaultEx(obj => obj == "a", data => lastValidData = data);
        //check is "a", lastValidData willbe mutated to "a".
        var check2 = responses.FirstOrDefaultEx(obj => obj == "a", data => lastValidData = data);
        //check2 is null, lastValidData will not be mutated.
 
@JLott - It would probably be cheaper to require a satellite internet connection than develop a solution which would backup databases and then sync them when the connection was available.
 
@user1112560 But the question will be does it make the code more legible in the check also?
 
6:00 PM
@TravisJ Doesn't HTML have like a IndexedDB... I honestly have no idea what I am talking about here lol
@TravisJ Right
HTML5
 
@JLott - There is a way to use LocalStorage to store object data.
However, as stated, it would require copying probably large amounts of data to store, and then syncing them on connection.
 
@user1112560 So what if I have date how would I call that extension method for example?
 
And this is a hard thing? @TravisJ
 
Hello all you lovely people.
 
6:02 PM
@JLott - Well, the sync is. Requires a lot of logic in many places. The storage on a device is also non trivial because of size considerations.
o/ spence
 
@SpencerRuport Hey.
 
@JLott - You can implement the IndexedDB if you want. "Web Databases are hosted and persisted inside a user's browser." In essence it is localstorage with an api
 
I'm wrapping up finishing a feature that should have been developed over 6 months that we did in about a month and a half.
 
6:03 PM
@SpencerRuport We've got two great conversations going, Web Development and XML/Extension Method.
 
I'm exhausted.
 
@SpencerRuport I imagine so.
 
@SpencerRuport enjoy the bugs
 
@Greg - Fantastic. I happen to enjoy both.
 
@TomW lol
 
6:05 PM
@ton.yeung @TomW - Right? I dunno. We were able to leverage a lot of existing code and I had a fantastic team so I think we're sitting pretty good. UA push is tomorrow though so we'll see.
 
@Greg It works on IEnumerable<T>, the predicate and supplied action must also work on T. The default value for the struct will be returned from FirstOrDefault (which is non-null), but the action will not be called.
 
@user1112560 So what it is called:

var date = responses.FirstOrDefault(obj => obj.Label.Contains("Date Signed")), => APIValidate.VerifyXmlNode(date); for example?
 
What would cause Application_End to be called (in ASP.NET) without IIS logging anything about any recycles?
 
@ton.yeung - TBH I really don't know.
 
Assuming that VerifyXMLNode is created with the extension method that I sent, and is an extension.

            IEnumerable<DateTime> responses = new List<DateTime> { new DateTime(2001, 3, 3), new DateTime(2002, 3, 4), new DateTime(2013, 3, 4) };

            DateTime lastValidData;

            var check = responses.VerifyXMLNode(obj => obj.Year == 2013, data => lastValidData = data);
            //check is (2013-03-04), lastValidData will not be mutated.

            var check2 = responses.VerifyXMLNode(obj => obj.Year == 2004, data => lastValidData = data);
 
6:08 PM
@user1112560 Well, remember:

responses... Is grabbing the data from XML so it includes a `Label, Value, and Field`.
 
so lastValidData = data.Value
AFK for a while now, will read the logs.
 
We get handed a business requirements doc and start work on it before it's complete, BRD never gets completed so after a while we just kinna... guess? I mean we're aware of what's needed so it's not entirely blind. Dev dev dev, release to internal QA team before we're dev complete. Dev, bug fix, dev bug fix. Dev complete. Bug fix, bug fix, bug fix, release to client User Acceptance team, bug fix, enhancement, push to production.
yeah
Definitely not ideal. But at least we have real QA / UA and PROD environments. Certainly more structured than I'm used to.
 
If I have a several List<T> how can I make a method that takes a those List?
 
@Greg with all T's the same or various types of T?
i.e. List<int>, List<float> or List<int> List<int>
 
List<List<T>>
 
6:20 PM
Basically I need to take four separate list of: List<string> and put it into one method.
@TravisJ You can nest it like that?
 
Yup
Dictionary<Type,List<Tuple<List<T>,int>>>
 
So long as a it's a type, you can use it as a generic type argument
 
@Greg - Call it with MyFunction(new List<List<T>>() { List1, List2, List3, List4 });
Everyone here is super co-operative. I've been really happy with the way everyone works together. We're more struggling with some poor decisions that were made years ago that have us up against the wall at the moment.
 
@TravisJ How much data do you think it could handle
 
@JLott - Depends on the device
 
6:26 PM
@SpencerRuport Okay. I'm trying to think of the cleanest way to do a check for null the best way possible.
 
@TravisJ What is your suggestion for an app for all platforms that can handle offline data?
 
@Greg - MyFunction((new List<List<T>>() { List1, List2, List3, List4 }).Where(l => l != null).ToList());
If you're just going to iterate through the lists in your function it might be better to use IEnumerable<List<T>>
So then you could drop the ToList() call at the end.
 
@SpencerRuport That is what I was thinking. Basically, I'm trying to avoid calling .Value on a null.
 
@Greg do you want to allow such values to be passed in?
 
@OMGtechy Well, I don't mind if the value is null just don't want the NRE
 
6:33 PM
@Greg how're you using the data? If it's in a loop, you can just add a null check
 
var time = responses.FirstOrDefault(obj => obj.Label.Contains("Time Signed"))
That would contain a List<string> time of:

- Label
- Value
- Field
 
@JLott - Well a web application can handle that. But no matter what platform you use, the device's available memory will limit what you can do as far as offline data goes.
 
I have seven of those currently, I want to avoid excessive redundant calls.  To avoid excessive:

if(time != null)

For example.
 
7:14 PM
@ton.yeung Yeah.
 
 
1 hour later…
8:33 PM
I don't have permission to comment yet. Would it be possible for someone to add a comment to this post: http://stackoverflow.com/questions/26025219/verifying-modular-sum-checksum-in-c-sharp , checking to see if the original data was delimited with any ASCII control characters (US seems likely).
 
@user1112560 If you have an answer, you should try to answer.
 
It's not an answer, it's a query that would be better expressed as a comment.
 
8:52 PM
@Pheonixblade9 you know anything about eToro?
 
@TomW never heard of it, sorry :(
 
now apologize
 
am I Canadian now? Sorery
 
Sorcery?
 
8:56 PM
:)
I need to subscribe to events with priority, highest prio called first when something happens. Don't have many ideas for a clean implementation.
 
Some musing:
void Main()
{
	Foo foo = new Foo();
	Action<Foo> bar = f => f.Bar();
	//Action<Foo> bar = foo.Bar;
	bar(foo);
}

class Foo
{
	public void Bar()
	{
		Console.WriteLine("Hello, World!");
	}
}
Is there a way to do something like the commented line?
(no reason)
 
@KendallFrey IIRC if you explicitly define a delegate type you can assign a value of that type then cast it to Action
oh hang on
is foo.Bar referencing the method Bar?
 
yeah
 
I don't think it'd be an Action<Foo>, rather an Action
 
Possible use case: something.Where(Item.Method)
 
9:05 PM
@KendallFrey I think you can do it easily in JS, but I'm not sure for C#.
 
I think you can, give me 5
 
@TomW hmm, yeah, but I don't actually want it bound to that instance
 
I haven't explicitly defined a delegate type 4evar
Oh I see. Hm
 
I know this is the first parameter, but I don't think that can be translated to a delegate
 
probably technically possible in CLR but I can't think of a way to express that in C#
 
9:07 PM
yeah
That's my mildy interesting code for today
 
Action bar =new Action(foo.Bar);
 
closure over foo, no?
but almost
 
I think with reflection you could create a helper
 
Anyone know how I can read a string from a windows service to a winform
 
9:17 PM
webclient.ReadString()?
 
@JohanLarsson where can I read up on this
 
9:32 PM
Best answer ever lol
 
not meant in a rude way, link to relevant docs
 
Lmao, I just meant that most questions can be answered with a link to msdn
 
@KendallFrey - You would need reflection to get the method handle by name
 
nah
Though I did just realize that there's no point in making a helper, because it would just do the lambda version anyway.
 
9:56 PM
youtube.com/watch?v=opuRggfHFck&feature=em-uploademail bitcoin speech, if anyone interested ;)
 
@KendallFrey
MethodInfo bar = typeof(Foo).GetMethod("Bar");
bar.Invoke(foo,null);?
 
That doesn't create the Action though
think bind
 
k
 
10:10 PM
yo
 
@Tokencodingnewbie yo yo
 
What's up
 
The sky!
 
no it isnt
 
I'm starting to think that C++ is my first language and English is my second now.
 
10:15 PM
I wish I was like that
 
Anyway, how're you doing with your program?
 
I just got home.
So I dunno haha
 
@KendallFrey - Like this?
Foo foo = new Foo();
var bar = foo.bar();
bar();
 
My motivation is kind of low right now too.
 
@TravisJ If I'm building a console application, what do you think is the best route to encrypt your config file?
 
10:28 PM
@Tokencodingnewbie cracks whip
 
@Greg - I don't have enough experience with encryption to tell you sorry
 
@Tokencodingnewbie Small steps, do you know what you want to do next?
 
@KendallFrey -
var bar = foo.bar;
bar();
class Foo
{
	public delegate void ar();

	public ar bar {
		get{
			ar fooAction = delegate()
			{
				this.Bar();
			};
			return fooAction;
		}
	}

	public void Bar()
	{
		Console.WriteLine("Hello, World!");
	}
}
 
I think, I dunno
 
10:33 PM
@TravisJ but it's bound to a single Foo instance
 
I'm just tired, work sucked
 
@KendallFrey - I thought that is what you wanted
 
no, I wanted it to bind the instance to the parameter of the Action
 
@TravisJ Fair enough.
 
@KendallFrey - isn't that what your original example did? bar(foo)?
 
10:37 PM
yes, but the commented version wasn't valid
This is purely a hypothetical question
 
I think it is possible, you would just have to define the use cases.
 
Wherever I do x => x.Foo()
 
@TravisJ @KendallFrey Is this worth doing:
        private IEnumerable<string> PopulateTo()
        {
            if (string.IsNullOrEmpty(ConfigurationManager.AppSettings[@"MailTo"]))
                throw new ArgumentNullException();

            string[] recipients = ConfigurationManager.AppSettings[@"MailTo"].Split(',');
            IEnumerable<string> addresses = recipients.Cast<string>();
            return addresses;
        }
 
It just seemed more elegant somehow
 
Or should I just use a List<string>?
 
10:39 PM
Instead of what?
 
@KendallFrey Using a List.
@KendallFrey Rather then Cast to IEnumerable just convert straight to a List?
 
If you have a reason to use a List, do, otherwise use IEnumerable
 
Not really, that is why I asked.
 
Actually, don't use a List
return an IEnumerable or a string[]
What's up with the redundant Cast?
 
@Greg string[] implements IEnumerable<string>, so it can just be returned. ArgumentNullException shouldn't be thrown as the error in question doesn't come from an argument (InvalidOperationException?). It would be best to load the configuration file once, rather than potentially hitting the disk twice.
 
10:44 PM
InvalidOperationException seems to be a bit of a catch-all
Or am I the only one that uses it when nothing else is suitable?
 
private IEnumerable<string> PopulateTo()
        {
            if (string.IsNullOrEmpty(ConfigurationManager.AppSettings[@"MailTo"]))
                throw new ArgumentNullException();

            return ConfigurationManager.AppSettings[@"MailTo"].Split(',');
        }
 
@KendallFrey don't you have a catch all in C#?
 
And ffs, don't throw a null anything when the string isn't null
 
I'd factor out the ConfigurationManager.AppSettings[@"MailTo"] into a string to avoid two potential IO hits.
 
like the C++ catch(...)
 
10:46 PM
It's more of a throw-all than a catch all.
 
@OMGtechy I'm not talking about exception handling
 
Ah
 
I use it pretty much always when the class is in an invalid state and I wouldn't want to catch the exception specifically.
 
I wouldn't throw ArgNull if it's not null
that's just plain misleading.
 
hayl no
 
10:47 PM
Agreed
 
At least it's not throw new NullReferenceException();
 
True
 
THAT is inexcusable
 
Eugh, make that a compile-time error.
 
maybe argument out of range?
Not sure what you have available in C#
 
10:48 PM
There is no argument.
 
spoon
 
haha
watched that the other day...again.
 
spoon?
 
the scene, or the film?
 
The film
 
10:48 PM
ArgumentException?
 
@user1112560 The Matrix!
@TravisJ if that exists, sounds much better than ANE :P
 
Oh, d'oh
 
I cba to type it all out
 
Fuck, something's wrong with my KSP save
fix that later
Time to write some motherfucking.codes
I don't care if I promoted that site, the name is awesome
 
There is a OnSuspending event. Is there some sort of on exit event?
 
10:53 PM
wut
context please
 
@KendallFrey Basically, the BackgroundAudio continues to play the audio even after the app is forcefully closed.
which is awkward.
 
Presumably, you can't run arbitrary code during a forceful exit
Either the code isn't arbitrary, or the exit isn't forceful
 
I used the task switcher to close the app.
I think that's forcefull...?
 
I would figure so
Therefore, there may not be an event fired
 
THEN WHY DOESN'T THE FREAKING BACKGROUND AUDIO STOP PLAYING?!
AAAAHHHHHHHHHHH
 

« first day (1439 days earlier)      last day (3504 days later) »