« first day (832 days earlier)      last day (3317 days later) » 

12:44 AM
WPF validation is hard without a good library, though ;)
hard to do well, at least
 
No kidding
 
i'm just running myself in circles at this point
ggahhh
 
 
9 hours later…
10:02 AM
Good morning
 
10:38 AM
hi every one
is there anyone worked with telerik controls??
 
yes, why ?
good morning guys
 
Borning! hrmm.. Morning
 
Morning Morning :)
 
 
2 hours later…
12:17 PM
I'm here.
 
yayy
o/
 
my internet traffic is still getting routed through Taiwan. Not tickled about that. I feel like I ought to VPN back to the states before I check in my code.
 
how is that relevant?
 
I'm writing code for a security company. In America. My code is going through China, with whom America's relationship is tenuous.
well, it's not going through them because I'm not checking anything in... regardless the network guys have dropped the ball.
The reason I'm concerned, in case it wasn't clear, is because my code travels from here to TFS in cleartext (I think) which means it can be modified in transit. Not to mention the credentials that I don't want to transmit.
shit, they're on to me. I'm trying to pull up a reference page on MSDN and I'm getting prompted for a login.
 
 
1 hour later…
1:47 PM
I want to make sure a file path is valid, but that the file does not exist. How's this grab ya?
        try
        {
            var fi = new FileInfo(filePath);
            if (fi.Exists || !Path.IsPathRooted(filePath))
            {
                return null;
            }
        }
        catch (Exception e)
        {
            return null;
        }
 
why the try catch ?
 
FileInfo will throw if filePath has invalid characters.
at least, I think it does. Double checking
 
Here's what FileInfo gets me: Permissions check, character check, path length check, and colon check (which I think is valid for URIs)
 
and if you just want to know if file exists, why not just ask File.Exists ?
 
1:58 PM
I don't just want to know if the file exists.
 
good then, but I'd rather catch expected exceptions than the base class, like this guy does : stackoverflow.com/a/422111/414314
 
I actually do need to know if I have permission to write to the path, I was doing that elsewhere.
 
in that case i'd just do a file open and close it immediately
if it works, well it works, if it doesn't.. the exception will tell whats wrong
 
except it shouldn't exist.
 
Is there any better soundtrack to listen to while coding than the first Doom's OST ?
 
2:04 PM
Contagion. Most of the Bastion sound track. ...basically just look for Cliff Martenez or Darin Korb.
(Darren?)
 
thanks :)
 
 
3 hours later…
5:24 PM
heyyoo @BradleyDotNET
 
Good morning @NETscape
 
i plan on saving my ProjectModel to a file. Its okay for file details to exist in the model right? like FilePath and what not?
 
Its ok, yes
 
5:41 PM
basically i'm trying to achieve something like the MSBuild schema or whatever
aka a .csproj but for my application
 
Ah, then having the file path totally makes sense
 
mhhmm what comes first
file structure or file
that doesn't really make sense
lets say you create a folder in your C# project, then add a .cs file
 
then file structure is created before added to the project tree
but when you open the .csproj file
the only "definitions" of folders exist with the .cs defines
<Compile Include="Properties\Annotations.cs" /> tells us there is a Properties folder
so when opening the file, then the software folder "object" is added
just kinda talking out loud now, sorry!
 
6:00 PM
No problem, I was actually just verifying what you said
and you are totally correct
Note that if you just "link" against it, the folder you have is indicated by the "Link" property.
 
so i guess my question is, do i really need to have List<Folders> in my ProjectModel
 
I don't think you have to
But I think it makes everything a lot simpler
Just because VS doesn't do it, doesn't make it wrong
 
Well a folder is just really a container I'm thinking
so in my case the deepest a project could go is 3 levels including the root
and folders
if I just have Project, and that has Files... and a File has a Path... then I could technically save it as a two level structure
ahh nevermind that
because the file structure is there
Folders actually exist in the directory
I was thinking File would have Path like \FolderName\FileName.txt... and when I open, there wouldn't actually be a FolderName folder, instead I would just add a placeholder folder to the treeview/project named FolderName
 
Be careful with that, if your users want to construct their own folder structure, you should let them.
 
right. they should technically be able to. and i think i'll stick with treeview having same structure as file structure
kinda curious how they do the parsing/deserializing
 
6:15 PM
How so?
 
There is Project > PropertyGroup > RootNamespace > Name of project
I would htink it would be Project > RootNamespace
guess msbuild/vs2013 just knows how to handle it
 
I'm guessing the abstraction of all properties into PropertyGroups made things simpler
 
i'm basically trying to visualize a Project model when looking at .csproj in a text file
 
but thats just a guess
 
and i noticed it is dynamic number of Groups I'm guessing
So would Project have List<PropertyGroup> PropertyGroups
and when serializing, instead of saving the List automatically, they have logic to persist each individual item
basically I'm thinking they have custom serialization rather than using something like XmlSerializer or whatever
 
6:26 PM
one of you guys got time for a quick question about interfaces?
in C#
 
shoot
 
or ask, whichever you prefer ;) I for one, would prefer to not get shot today
 
so im trying to write an XML serializer to marshal some streams on an Endpoint which could be serial or socket.... and I got to looking at this code another dev wrote. In here he defines an interface called IEndpoint, which declares a few abstract methods, and strangely.... 3 events. The events cannot have access modifiers, and I read that thats because they are public implicitly, and no access modifier (including public) can be explicitly provided in source (enforced by the compiler)
so theres another class called SerialEndpoint, which redeclares the same events
because without declarations in SerialEndpoint, they are not available in that context
what purpose are the events serving in the interface?
 
Its not just "redeclaring them"
 
SerialEndpoint implements the interface
 
6:30 PM
You have to rewrite the events in order to implement the interface
just like with properties
Notice the same behavior in INPC
 
but its the same code verbatim...
 
The events are in the interface so an outside class that has an interface reference knows the events exist
 
thats just weird
 
I know
Both properties and events work that way in an interface
 
fields in interfaces are a new concept to me...
I get it now I suppose
 
6:32 PM
Property != field
 
its you can call the event when referencing an interface type
 
even though we use them like that :)
I believe the reason its in both is that interfaces can't contain fields
 
but its strange that to me that the compiler requires you to add literally the exact same code in the implementation
so an event technically isnt a field then
event though it looks quite a bit like one
 
so the properties and events are just methods that you have to implement, which the most convenient way to do that is to just write the same code that does implement a backing field
 
can interfaces have default methods in C#?
 
6:34 PM
In other words, there is no requirement that you use the exact same code, its just that in practice thats what happens
What exactly is a "default method"?
 
sorry... java speak
a default implementation for a contracted method in an interface
 
No
That would be an abstract class at that point
 
as it was in java until java 8
still not sure I like the idea of default methods in interfaces
kinda on the fence
 
With an abstract class you (1) can't multiply inherit, and (2) can't have covariant generic parameters
there might be some other differences, but those are the two I can think of off the top of my head.
 
but I want diamonds of death
they are pretty
lol
wierd to that you cant put public in the event declaration in the interface
I get that it can ONLY be public, but you would think the compiler woudl let you explicitly say so, so that another developer doesnt have to just 'know' they are public
I guess if you thought about it enough it would reason out that way
 
6:38 PM
Yeah, and the access modifiers just don't make sense in an interface
internal maybe but its just a contract
And if you had internal members, why not just make the interface internal to start with?
 
access modifiers are a bit wierd in .NET
still trying to wrap my head around them completely
they seem to be much stricter
but meh...thats a convo for another time
thanks again Bradley for clearing that up
also, is there an equivilent to java's 'transient' keyword that I can use with an XMLSerializer?
to skip a field I dont want persisted
 
if i remember correctly, interfaces and XML serialization can get ugly
 
in what way?
 
I had a lot of luck with abstract classes
i can't remember off the top of my head, but its probably something like, they have no type information really...
 
im not sure I understand.... in java, if I call a GetClass() (I think this is roughly the same as typeof in .net) on an interface type, I will get the concrete implementations class name as a return value
is that not the case in .NET?
 
6:46 PM
SerialEndpoint : IEndpoint is probably not as useful as what SerialEndpoint : BaseEndpoint would be
 
@MarkW Yes, there is, I just need to go find it again :)
 
sure you might, during runtime, but not during persistence unless you'll manually building XML i guess.
 
If you do derivedInstance.GetType(); you should get the derived type, yes
if you just do typeof(IMyStuff) you'll get the interface type
 
if you're persisting IEndpoint, all you know is that it follows a contract. You won't be able to say that it is a SerialEndpoint or SocketEndpoint
 
you ever heard of spring beans?
 
6:48 PM
no...
 
Oct 13 '14 at 4:37, by Moses Aprico
It seems that XMLSerializer can't serialize interface. But, quite frankly, my ViewModel have ICommand. There's some solution I read about tagging [NonSerializable] to that. If so, isn't that command will be missing if I load the saved file again? Or not? Since the it's the initialization of the ICommand that is saved in the file? So, the interface doesn't really need to be serialized?
 
@MarkW To mark a field to be ignored, add [NonSerialized] above it
 
this is what i remember talking about awhile ago, Moses was having a lot of trouble when trying to serialize interfaces
 
thx
 
If it has a property that exposes it, you need to put [XmlIgnore] above that
 
6:51 PM
so in java, there is a framework called Spring.... one of the features that Spring provides is this idea of a Bean.... basically there is an interface your class can implement that contracts a method called afterPropertiesSet(). Spring can take an XML file which defines the values for fields / constructor args in the XML, and marshal an instance of a given type via injection of the values in the XML into the constructors / fields, then run the afterpropertiesset method
we used this in java all over to make it so that we could configure any type of endpoint we wanted
and marshal them as an IEndpoint at runtime
im looking to do something similar here
 
but he's going to want to save IEndpoint right? I don't think XmlSerializer persists any type information when you serialize, so you can't really deserialize because it can't create a IEndpoint type, I could be wrong though.
 
yes he will only be refering to them as IEndpoint
good to know that
im just starting into this little venture here
that will save me time
 
why aren't you doing public abstract class BaseEndpoint?
 
I didnt write it
 
then something like
 
6:53 PM
I dont know dudes reasons for writing this
 
Aug 6 '14 at 19:36, by NETscape
[XmlInclude(typeof(BaseA))]
[XmlInclude(typeof(BaseB))]
public abstract class Base { .... }
ahh, I thought you were writing it
 
just the serialization / marshaling side
 
but basically XmlSerializer is the same idea as SpringBeans ?
 
no, I was hoping to use it in a similar way.... but I doubt it will work out that way
basically im looking for a convienent way of defining everything that makes up a concrete implementation of an interface / abstract class in XML (or other human readable serialized format) and be able to marshal that concrete class as the interface / abstract type at runtime
I dont need to be able to serialize, but I must be able to marshal
 
var doc = new XmlSerializer(typeof(ClassName));
var des = (ClassName)doc.Deserialize(xmlFilestuff);
that would take your xml file and turn it into runtime objects for you to use
 
6:57 PM
where ClassName is the Abstract class?
 
<Person>
    <Name>Mike</Name>
</Person>
deserializing that would work assuming you have a Person class with a string Name property
it all depends how you format/design I guess
there are a bunch of XML attributes for classes, fields, properties, etc.
XmlRoot, XmlAttribute, XmlElement, XmlArray, etc.
 
just for clarity:

I have two classes ABase and MyClass where MyClass derives from ABase
In your example I could create an XmlSerialzier of type ABase, deserialize an XML storing a MyClass objects fields, and put it in a variable of type ABase
and not lose any of MyClass's info
 
you mean serialize it?
 
no
deserialize
im not concerned with writing the XML at runtime
 
if you format it properly
 
7:02 PM
its a configuration thing
 
xsi:type=.... or something
 
kk I will read more into this then
 
you could test it out.
[XmlRoot("SerializeData")]
public class SerializeData
{
    [XmlArray("Classes")]
    [XmlArrayItem("MyClass")]
    public List<MyClass> Classes {get;set;}
}

public class MyClass : ABase
{
    [XmlAttribute]
    public string Name { get; set; }

   ctor()
   { Name = "Class"; }
}
 
lol
thats pretty much what I was doing here
 
[XmlInclude(typeof(MyClass)]
public abstract class ABase
{
    [XmlAttribute("Name")]
    public string Name { get; set; }
}
 
7:07 PM
it makes it convenient, because we can just deploy an XML for any type of endpoint we require for that implementation, without having to modify code.... its just 'oh this is a serial connection, heres the serial XML you need' then move on
if this works out in the same way it did with Spring
human readable so you can like... just edit the XML to change a com port or whatever
 
right
 
are the XML attributes required?
the [XMLwhatever] guys
 
I don't think so, I just did it because I was running into problems at one point and just added them all to help try to debug
 
I've never needed them
 
I needed them when I was trying to do stuff with arrays... or thats when I ran into trouble
because you can do:
<Person>
    <Legs>
       <Leg />
       <Leg />
    </Legs>
</Person>
and it would be expecting List<Leg> Legs
or you can do
<Person>
    <Leg />
    <Leg />
</Person>
and using the attributes you can make it deserialize into List<Leg> Legs correctly
 
7:12 PM
right
 
which might be how they do it with msbuild .csproj
 
7:57 PM
Does it make sense to do public abstract class Base item : IItem
Or would Public class ProjectItem : BaseItem, IItem be better.
 
Probably the first one
Will anything else implement IItem though?
 
8:52 PM
public abstract class BaseItem
public class FolderItem : BaseItem, IItem
public class FileItem : BaseItem, IItem

public class Root
{
    List<BaseItem> Items;
    // or should it be List<IItem> Items
}
 
why do you have a base class and an interface?
do you need both?
 
s'what I'm trying to figure out. And I don't think I do... not sure why I even asked it lol
 
there are times when it makes sense
but if you're controlling everything, you probably don't need the interface
 
Thats why I asked if anything else implemented IItem
if its just the base class, the interface isn't buying you anything
 
i think i was thinking dependency injection
public Root(IItem item)
vs
public Root(BaseItem item)
all the DI examples I see always involve interfaces
@ReedCopsey is that a case in which you'd want to do it
public RootVM(IItem item)
 
9:03 PM
You can DI with almost anything. Interfaces are just really convenient, especially since they allow for multiple "inheritance"
 
ahh okay
if you have RelayCommand in your VM, does it make sense to make the function for Execute and CanExecute static?
i don't want to lazy instantiate it, and i don't want to clutter the ctor with command initialization.
 
static readonly List<Assembly> _LoadedAsses = new List<Assembly>();
static PluginLoader()
{
    //load the plugin assemblies
    foreach (string assPath in Directory.GetFiles(PLUGIN_DIRECTORY, "*.dll"))
    {
        var AssName = AssemblyName.GetAssemblyName(assPath);
        var Ass = Assembly.Load(AssName);
        _LoadedAsses.Add(Ass);
    }
}
hehe
its like the angry video game nerd wrote that
 
should be assName and ass ;)
 
lol if thats the only complaint ill take it
 
according to most coding standards
 
9:17 PM
javas are like almost opposite of .NET
classes are the only thing thats upper case
so I sorta... mix them mindlessly
 
The _ syntax is debated as far as standards go
 
I can't tell what LoadedAsses is though
mostly because plural assembly is assemblies
 
@NETscape I'm not sure why you would make that static
 
its exposed in a method GetPluginAssemblies()
 
most of the time, private fields are just camelCase
 
9:19 PM
@BradleyDotNET because otherwise you can't do a field declaration
 
Oh, I see
As long as its not dependent on VM state, there's nothing technically wrong with it
I just put a section in my constructor for command instantiation
 
private RelayCommand _myCommand = new RelayCommand(param => Exec(), param => CanExec); <-- can't do
 
Right
Normally I just do public ICommand MyCommand {get; private set;}
and then assign it in the constructor
 
@NETscape most DI works against classes, too, just as easily
@NETscape it's uncommon, since a command is "doing something", which typically requires the state on the type
 
select portInfo["Caption"]
    into captionObj
    select captionObj.ToString()
        into name
        select new Caption(name)
whats the equivalent in LINQ expression
 
9:32 PM
Is that standard LINQ?
And you want the lambda expressions?
 
yes, sorry
lambada
 
I'm not really sure what the into does. Does that whole line just take portInfo["Caption"] and make a new Caption out of it?
because that would just be: myCollection.Select(r => new Caption(r["Caption"].ToString());
I think
Try that and let me know if it works :)
 
10:11 PM
@NETscape where' sthe "from" section?
 
just above
 
you're not showing the entire thing, so we can't translate entirely
but into is supposed to only be for grouping operations anyways - so that's a pretty weird query :S
 
from Port portInfo from collection.Ports
select portInfo["Caption"]
    into captionObj
    select captionObj.ToString()
        into name
        select new Caption(name)
 
yeah - Bradley's statement (with myCollection -> collection.Ports) would be all that's required
 
ahh i see why you're asking for the whole thing now
because the Ports collection returns doesn't have a .Select available
 
10:15 PM
probablyneeds to be
 
collection.Ports.Cast<Port>().Select(p => new Caption(p["Caption"].ToString()))
 
so that from is doing a cast?
How can I see if MyFile.txt is inside a folder \SomeFolder\MyFile.txt... testing the string only and not the actual path on the machine
basically I'm looking for
		var v = Path.GetPathRoot(@"\Something\MyFile.txt");
		Console.WriteLine(v);
"\Something" or "Something" to be returned
 
10:32 PM
You could split on "\"
 
that's what I was kinda thinking
thought there might be some Path or DirectoryInfo method
 
I'm not super aware of all the Path methods
so maybe
GetPathRoot looks like a no-go since you have a relative path
IsPathRooted might work though
 
10:51 PM
can you yield during a Select?
meh, nevermind. it wouldn't make sense for me to yield in this case
 
Select usually isn't returning an IEnumerable
if it was, I guess you could
but I'm not sure why you ever would
 
@BradleyDotNET it isn't?
usually is, do you mean?
so I feel like I could do a lot with one LINQ statement/function, but it would end up doing multiple things
 
Sorry, should have been more clear
The selector you pass to Select isn't usually returning an IEnumerable
so using yield would rarely make sense
Does that clear up the confusion?
 
right... however if you do a Select and are returned a IEnumerable<T>, you could loop through it and yield each item... but that's kinda pointless I'd assume
because the result is already achieved
 
Basically
I've never seen a yield in a selector
I'm not saying it would never be useful, I just can't think of a case where it would be
 
11:03 PM
i agree with you
but back to my question I had, example:
<Compile Include="Converters\InvertBoolConverter.cs" />
<Compile Include="Converters\NewlineToSpaceConverter.cs" />
<Compile Include="Converters\ParamModifiedConverter.cs" />
<Compile Include="Properties\Annotations.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<Compile Include="InvertBoolConverter.cs" />
<Compile Include="NewlineToSpaceConverter.cs" />
<Compile Include="ParamModifiedConverter.cs" />
<Compile Include="Annotations.cs" />
<Compile Include="Resources.Designer.cs">
So lets say I have a bunch of Compile items... those would be models, with a string Include property
Now, I have a List<Compile> Items right.
and each represent a file
so each one gets a CompileViewModel
and lets say Project is the model that has the List<Compile> Items.
 
and of course Project can be represented as a item in the treeview, so you have ProjectViewModel
 
sounds correct
 
ctor looks like public ProjectViewModel(Project project)
so basically a Project would be deserialized, and Project and Project.Items would be populated and a ProjectViewModel is then created
 
right
 
11:10 PM
ProjectViewModel.TVItems is the collection that represents the structure of the treeview
ObservableCollection<BaseTVItem> TVItems
now, each file is either under root, or is in a folder as indicated by the `\` in the Include property
 
did you guys ever try to implement property system like that of a WPF? Damn its a mess
 
I'm assuming when I pass Project into ProjectViewModel, I should start "parse" my project items to generate FolderViewModels and FileViewModels
 
Like the PropertyChanged mech and all that
Does not sound like fun
@NETscape Yep
which is why seperating your model/VM data objects is such a pain
 
so I'd take Project.Items and take each Compile that is in a directory and create a FolderViewModel
(distinct folder of course)
 
11:13 PM
Right
 
what should FolderViewModel take as param for ctor?
technically you could have a Folder with no Compile items I guess
empty ctor I'm guessing
 
I would think it would pass all the subitems
though that doesn't sound like fun
If it had no items, the enumerable would be empty
 
then new FolderViewModel().Files.Add(new CompileViewModel(compile));
 
That would work too
 
or should I create new CompileViewModel(compile) for each item in Project.Items. then enumerate all the CompileViewModels and determine if they are in a folder, and if so create a ProjectViewModel.BaseTVItems.Add(new FolderViewModel().Items.Add(compileVM))
 
11:20 PM
That version will be messy
since you then have to go find the existing folders in order to do the add
I would pass it on the constructor, or do your first approach
 
what is it in this case?
Compile model to the FolderViewModel ctor?
 
An IEnumerable<CompileViewModel>
presumably you already did the filter and select
 

« first day (832 days earlier)      last day (3317 days later) »