text stringlengths 0 30.5k | title stringclasses 1
value | embeddings listlengths 768 768 |
|---|---|---|
I have the following xml I'd like to deserialize into a class
```
<?xml version="1.0" encoding="utf-8" ?>
<root>
<element1>String1</element1>
<element2>String2</element2>
</root>
```
I am trying to serialize it into the following class:
```csharp
[XmlRoot("root")]
public class root
{
[XmlEle... | [
0.32155025005340576,
-0.012956442311406136,
0.187114879488945,
-0.11071418225765228,
-0.09647554904222488,
-0.15723535418510437,
0.3470989465713501,
-0.2555372416973114,
-0.2012215107679367,
-0.7281398177146912,
-0.18771065771579742,
0.22163963317871094,
-0.4190710783004761,
0.338178634643... | |
object is instantiated, but the strings are null.
```csharp
using (TextReader reader = new StreamReader(configFile))
{
XmlSerializer serializer = new XmlSerializer(typeof(root));
this.config = (root)serializer.Deserialize(reader);
}
```
I've tried using xsd.exe to create ... | [
-0.20452052354812622,
0.001502810511738062,
0.5585168600082397,
0.03880659118294716,
-0.1594998687505722,
-0.003289151471108198,
0.3067925274372101,
-0.1333618015050888,
-0.3515910804271698,
-0.8394262790679932,
-0.3177328109741211,
0.4924221634864807,
-0.5040678977966309,
0.31505510210990... | |
serialise/deserialise internal properties - They have to be public. | [
0.43799343705177307,
0.6070896983146667,
0.21619726717472076,
-0.1808079481124878,
0.2668740749359131,
-0.14465771615505219,
0.09297789633274078,
0.21118713915348053,
-0.1537005752325058,
-0.2656325697898865,
-0.41800323128700256,
0.13785798847675323,
-0.1425740122795105,
0.434950292110443... | |
```
cmd /C "myshortcut1.lnk"
cmd /C "myshortcut2.lnk"
```
Works, but gives me a pop-up DOS window which, when closed, kills my two loaded programs. Same is true for this:
```
start /B cmd /C "1.lnk"
start /B cmd /C "2.lnk"
start /B cmd /C "3.lnk"
start /B cmd /C "4.lnk"
```
The MySQL JDBC driver times out after 8 h... | [
-0.19188110530376434,
0.33969366550445557,
0.7256280779838562,
-0.06815991550683975,
-0.08236799389123917,
-0.1672239750623703,
0.8382070064544678,
0.008902769535779953,
-0.038234349340200424,
-0.6665599346160889,
-0.3411789834499359,
0.868259072303772,
-0.29156380891799927,
0.398948669433... | |
JDBC connection is reestablished, but it doesn't automatically re-execute your query that got the exception. So you do need to catch `SQLException` in your application and retry queries.
Read <http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-configuration-properties.html> for more details. | [
0.053331293165683746,
0.14692188799381256,
0.512091875076294,
0.057755324989557266,
-0.14251627027988434,
-0.5008589625358582,
0.18725703656673431,
0.0708811804652214,
-0.2851432263851166,
-0.6267589926719666,
0.0024311502929776907,
0.4687209725379944,
-0.180828258395195,
0.306574225425720... | |
Has anyone else run into this problem before? I've got a method that calls a generic method with a delegate, inside of a generic class. I've marked the class as Serializable, and it serializes without complaint. But, when I try to deserialize an object of this class, it pegs the CPU and hangs the machine.
Code example... | [
0.40361762046813965,
-0.30227816104888916,
0.24916954338550568,
-0.04737576097249985,
0.05499371141195297,
-0.01588928885757923,
0.1938033252954483,
-0.3815162777900696,
-0.5309368371963501,
-0.4946652948856354,
-0.11961304396390915,
0.4226555824279785,
-0.5861056447029114,
0.4258036613464... | |
StreamingContext context)
: base(info, context)
{}
[SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
... | [
0.48461347818374634,
-0.6750575304031372,
0.6957038640975952,
-0.1608261913061142,
0.06472191959619522,
0.08194156736135483,
0.3576169013977051,
-0.5168617367744446,
-0.1723306030035019,
-0.6056104302406311,
-0.4918714165687561,
0.6708257794380188,
-0.5530405640602112,
0.14973941445350647,... | |
});
}
public List<U> Convert<U>(CombinationFunctionDelegate<U, TKey, TValue> converterFunction)
{
List<U> res = new List<U>();
foreach (TKey key in Keys)
res.Add(converterFunction(key, this[key]));
return res;
}
}
```
I can put an instance of this class into ViewS... | [
-0.0248117633163929,
-0.2560044527053833,
0.8437696099281311,
-0.27765557169914246,
0.11166158318519592,
0.15935762226581573,
0.4382038712501526,
-0.625970184803009,
-0.3314976990222931,
-0.7657695412635803,
-0.3133392930030823,
0.9307141304016113,
-0.3087089955806732,
0.563724935054779,
... | |
and the deserialization call never returns (ie, infinite loop).
When I remove the ToListItems() method, everything works wonderfully. Is this really weird, or do I just not understand serialization? =)
Are you using VS2008 SP1? There's a known problem with SP1.
<https://connect.microsoft.com/VisualStudio/feedback/V... | [
0.3828098773956299,
-0.4947100877761841,
0.48689931631088257,
0.20428156852722168,
-0.2632177770137787,
-0.06788595020771027,
0.4151636064052582,
-0.02267744019627571,
-0.682239830493927,
-0.5511407256126404,
0.04528150334954262,
0.48277774453163147,
-0.29644572734832764,
0.209789156913757... | |
I'd like to track down a possible bug in Visual Studio, but that's awfully hard without the debug symbols for Visual Studio itself. Does Microsoft make these available?
An up-to-date Visual Studio should already have the option to load symbols from Microsoft (Check: Tools->Options->Debug->Symbols). When it comes to deb... | [
0.5566939115524292,
0.05890639126300812,
-0.12686395645141602,
0.24190911650657654,
0.10632723569869995,
-0.2175402045249939,
0.2855623960494995,
0.15920285880565643,
-0.1985461264848709,
-0.4921514689922333,
0.03244021162390709,
0.6344795823097229,
0.011103947646915913,
-0.202586606144905... | |
I'm using a large open-source control and I can't seem to find the code that handles a double-click event. Could I perhaps have the debugger break when a double-click occurs or otherwise learn what code is associated with that event?
It's not cp, it's tar. You are passing it -v, which makes it print the names of the fi... | [
0.5335217714309692,
0.22580158710479736,
0.04550247639417648,
0.25163301825523376,
0.19353291392326355,
-0.11894086003303528,
0.05017301067709923,
0.3179401159286499,
-0.2927796244621277,
-0.1322910338640213,
0.012192122638225555,
0.4355916678905487,
-0.2219342738389969,
0.5544734597206116... | |
I have a migration in Rails that inserts a record into the database. The Category model depends on this record. Since RSpec clears the database before each example, this record is lost and furthermore never seems to be created since RSpec does not seem to generate the database from migrations. What is the best way to c... | [
0.2842879295349121,
0.1621362268924713,
-0.10742006450891495,
0.23043200373649597,
-0.13814577460289001,
-0.2044908106327057,
0.21143999695777893,
-0.25944215059280396,
-0.40927350521087646,
-0.7422420978546143,
0.30044180154800415,
0.40230682492256165,
-0.3687092065811157,
0.4653480947017... | |
wrapped around each individual example - but a simple fixture file would also do the same job.
(There's a more complicated general solution to this issue: moving to a service-oriented architecture, where your 'dev' and 'test' services are going to be completely separate instances. You can then point your test db confi... | [
0.49004122614860535,
-0.029054732993245125,
-0.018539978191256523,
0.22984625399112701,
0.050012439489364624,
0.08795817196369171,
0.4791543781757355,
-0.42930737137794495,
-0.00042114724055863917,
-0.7394145727157593,
-0.265455037355423,
0.07758964598178864,
-0.32081910967826843,
0.323466... | |
I'm pretty new to the C++ build flow, and I'm thinking of switching to use partial linking for my libraries instead of creating `ar` archives. I'm hoping to reduce link time in an inevitable final compilation step that I have, and I figure partial linking some libraries once could save me time over linking everything i... | [
0.31945645809173584,
0.3129768967628479,
0.20816999673843384,
-0.18175195157527924,
-0.20550236105918884,
-0.09889163821935654,
0.10853821784257889,
-0.01234546396881342,
-0.14694750308990479,
-0.6414617896080017,
0.07012975215911865,
0.48013022541999817,
-0.42851418256759644,
0.0947449058... | |
archive, which is that only the referenced objects will be linked in.
If you have both `foo.o` with the symbol `foo` and bar.o with the symbol `bar` in an `ar` archive, and only reference the `foo` symbol, only `foo.o` would be linked in. If you instead do a partial link, the contents of both will end up in the execut... | [
0.37656790018081665,
0.5689911246299744,
0.24655276536941528,
-0.08109410107135773,
0.024508366361260414,
-0.25291305780410767,
-0.11949339509010315,
0.10264405608177185,
-0.5128706097602844,
-0.6065651178359985,
-0.10774078965187073,
0.18081411719322205,
-0.3926998972892761,
0.30534613132... | |
Does anyone know of a set of bindings for C# to drive the FFMpeg library directly ? I could shell to ffmpeg.exe directly but I found it hard to sync/control as a separate process. any help would be appreciated.
Tao.ffmpeg: <http://www.taoframework.com/project/ffmpeg>
it compiles and has a binary dist which is more than... | [
0.37831711769104004,
0.10551832616329193,
0.023920701816678047,
0.12072202563285828,
-0.5265204310417175,
-0.17833776772022247,
0.08544430136680603,
-0.038940392434597015,
-0.10319630801677704,
-0.3618655502796173,
0.2632371783256531,
0.6978779435157776,
-0.26022931933403015,
-0.1558191627... | |
Lots of people have things that their systems do for them or for their teams. Source control post-commit hooks are a standard example: have an automated build system that checks out the latest source, compiles, tests, and packages it is a back-office hack that most of us probably use.
What other cool things have you d... | [
0.7471928000450134,
-0.07364732772111893,
-0.24272564053535461,
0.40287622809410095,
0.054786935448646545,
-0.5051316022872925,
0.21574994921684265,
0.21916255354881287,
-0.39654532074928284,
-0.15766116976737976,
0.04352939873933792,
0.4377394914627075,
-0.30612361431121826,
-0.2069751769... | |
the file....)
Regardless to say, after the 5th time this occurred, and the 5th time that I had to explain why that defect that I just closed was reoccuring, I wrote a script.
It would diff for the changes to a file to see whether the consecutive checkin deleted all the previous changes and that they were done by the ... | [
0.0615074597299099,
0.09452500194311142,
0.6200234293937683,
-0.025902502238750458,
0.1228189468383789,
0.044988952577114105,
0.46375221014022827,
-0.09575311839580536,
-0.3560692071914673,
-0.3931787312030792,
-0.030279716476798058,
0.5850852131843567,
-0.23982571065425873,
0.298238784074... | |
I need to write a Stored procedure in SQL server whose data returned will be used to generate a XML file.
My XML file to be in structure of
```
<root>
<ANode></ANode>
<BNode></BNode>
<CNode>
<C1Node>
<C11Node></C11Node>
<C12Node></C12Node>
</C1Node>
<C2Node>
<C21Node></C21Node>
<C22Node></C22No... | [
-0.265912264585495,
0.30722588300704956,
0.14589911699295044,
-0.10400509089231491,
0.20232081413269043,
0.15599708259105682,
-0.08196210116147995,
-0.3300926685333252,
-0.15536250174045563,
-0.6427718997001648,
0.06966756284236908,
0.20455920696258545,
-0.07959423959255219,
-0.01815703883... | |
to get records for the CNode which is a subtree which has 3 or more(dynamic) separate nodes in it for each record in addition to the normal ANode and BNode.
See
[Nesting XML-returning scalar valued functions](https://stackoverflow.com/questions/147897/in-sql-server-can-i-insert-multiple-nodes-into-xml-from-a-table... | [
0.1258772760629654,
0.13064070045948029,
0.1644715815782547,
0.1158013790845871,
0.1808352768421173,
-0.033678922802209854,
0.03172430023550987,
-0.11277315765619278,
-0.7432668805122375,
-0.3074720799922943,
0.11814969033002853,
0.21325445175170898,
-0.15108805894851685,
0.115188911557197... | |
I've recently seen occasional problems with stored procedures on a legacy system which displays error messages like this:
> Server Message: Number 10901, Severity 17:
> This query requires *X* auxiliary scan
> descriptors but currently there are
> only *Y* auxiliary scan descriptors
> available. Either raise the ... | [
0.07102570682764053,
0.0944257527589798,
0.4498337507247925,
0.05080835521221161,
-0.1968134492635727,
0.0949244275689125,
0.49570220708847046,
-0.07958351820707321,
-0.6065980195999146,
-0.9135839939117432,
0.13252507150173187,
0.6402151584625244,
-0.03927081823348999,
0.19374564290046692... | |
The weird thing is, it's been working fine for years and the only thing that's changed is that we amended the data types of a couple of columns and added an index. Can anyone shed any light on this?
You don't say what version of Sybase you are on but the following is good for ASE 12.5 onwards.
I suspect that it's the ... | [
0.6044301986694336,
-0.0695648118853569,
0.39238816499710083,
0.09088184684515,
0.029261458665132523,
-0.2830488085746765,
0.2311122864484787,
0.205504909157753,
-0.6176135540008545,
-0.5524179935455322,
0.1837664395570755,
0.5117591619491577,
-0.14960011839866638,
0.02301057241857052,
-... | |
"aux scan descriptors"
```
and then increase that by running
```
sp_configure "aux scan descriptors", x
```
where x is the number of scan descriptors you require.
If you wish to reduce the number of scan descriptors that the store procedure is using then according to [here](http://infocenter.sybase.com/help/index... | [
0.25902947783470154,
-0.04530693218111992,
0.5815298557281494,
0.042797114700078964,
-0.1367761790752411,
-0.08332109451293945,
0.30023083090782166,
-0.3591334819793701,
-0.4389415383338928,
-0.7275726795196533,
-0.22056549787521362,
0.7295218706130981,
-0.3702608346939087,
-0.067323312163... | |
Here's something I know is probably possible but I've never managed to do
In VS2005(C++), While debugging, to be able to invoke a function from the code which I'm debugging.
This feature is sometimes essential when debugging complex data structures which can't be explored easily using just the normal capabilities... | [
0.06321761757135391,
0.13280771672725677,
0.025430437177419662,
0.1073748841881752,
0.07135215401649475,
-0.36485230922698975,
0.5691429376602173,
-0.11795049160718918,
-0.2674809992313385,
-0.25298938155174255,
0.028493458405137062,
0.630874514579773,
-0.25263598561286926,
0.0638824924826... | |
succeed in making this work properly?
What am I missing here?
**Edit:** clearly, the function called should be a symbol that exists in the current scope the debugger is in.
Ok, Here's what I found
CXX0040 means that "`The C expression evaluator does not support implicit conversions involving constructor calls.`"
... | [
0.05379244685173035,
0.2251201570034027,
0.05103042349219322,
-0.020561058074235916,
0.05141773819923401,
-0.15821802616119385,
0.6966489553451538,
-0.6725947260856628,
-0.07313425838947296,
-0.31301960349082947,
-0.11472535878419876,
0.9748901724815369,
-0.4170974791049957,
-0.18247742950... | |
the arguments should need a construction.
"implicit conversion" in this context seem to include trivial things like converting `'String'` to `'const String&'`.
"construction" seem to include trivial copy-construction. so passing by value anything that is not a primitive type will result in an error.
**So this ba... | [
0.03485386073589325,
0.258251816034317,
0.16692563891410828,
0.0037463551852852106,
-0.21425120532512665,
0.01731354184448719,
0.25670793652534485,
-0.34142762422561646,
-0.08247526735067368,
-0.4154534935951233,
0.04737946763634682,
0.8985869884490967,
-0.4494818449020386,
0.0370775051414... | |
object that is not a primitive pass its address. | [
-0.1898954063653946,
0.12141748517751694,
0.01939482055604458,
0.02691032551229,
-0.24707694351673126,
-0.3393747806549072,
0.30902624130249023,
-0.1915232539176941,
0.29044896364212036,
-0.6138464212417603,
-0.4192270338535309,
0.049553997814655304,
-0.13563421368598938,
0.282507330179214... | |
I'm using jQuery to post a form to a php file, simple script to verify user details.
```
var emailval = $("#email").val();
var invoiceIdval = $("#invoiceId").val();
$.post("includes/verify.php",
{invoiceId:invoiceIdval , email:emailval },
function(data) {
//stuff here.
});
```
PHP Code:
`... | [
0.3057841956615448,
0.30342093110084534,
0.5105578899383545,
-0.32896023988723755,
-0.27779969573020935,
0.0957484021782875,
0.5153756141662598,
-0.38154926896095276,
0.05724916607141495,
-0.7582094669342041,
0.02060713805258274,
0.4758923351764679,
-0.33201783895492554,
0.1232440844178199... | |
just nothing is actually received in the php file.
The form:
```
<form method="post" action="<?=$_SERVER['PHP_SELF']; ?>" enctype="application/x-www-form-urlencoded">
```
Anyone know what its doing?
thanks
---
found this - <http://www.bradino.com/php/empty-post-array/>
that a sensible route to go?
`$.post()` pa... | [
0.28783804178237915,
-0.1175348162651062,
0.7507061958312988,
-0.0068640015088021755,
0.126295804977417,
-0.30677348375320435,
0.40006259083747864,
0.10504470020532608,
-0.13512888550758362,
-0.4227779805660248,
-0.16781173646450043,
0.5556693077087402,
-0.17539598047733307,
0.047616805881... | |
I'm new to the MVC framework and wondering how to pass the RSS data from the controller to a view. I know there is a need to convert to an IEnumerable list of some sort. I have seen some examples of creating an anonymous type but can not figure out how to convert an RSS feed to a generic list and pass it to the view.
... | [
0.7129682898521423,
-0.10450022667646408,
0.410826176404953,
-0.016904979944229126,
-0.28276368975639343,
-0.17001895606517792,
0.012142054736614227,
0.0829087570309639,
-0.3021153211593628,
-0.5886648893356323,
0.30557727813720703,
0.41105517745018005,
-0.5233227014541626,
0.4643628597259... | |
basically UserControls wrapped in a webPart container. One of my test UserControls is an Rss Feed control. I use the RenderAction HtmlHelper extension in the Futures dll to display it so a controller action is called. I use the SyndicationFeed class to do most of the work
```
using (XmlReader reader = XmlReader.Create... | [
0.26914599537849426,
-0.3569655120372772,
0.7885184288024902,
-0.03897647559642792,
-0.05888810381293297,
-0.09420693665742874,
-0.2707527279853821,
0.03209764137864113,
-0.39625588059425354,
-0.5944127440452576,
-0.027461368590593338,
0.5376233458518982,
-0.5184857845306396,
0.36330309510... | |
public ActionResult Index(string feed)
{
string errorString = "";
try
{
if (String.IsNullOrEmpty(feed))
{ | [
0.13165512681007385,
-0.6744319200515747,
0.1188569962978363,
-0.3697257936000824,
0.4038922190666199,
0.16734464466571808,
0.3550556004047394,
-0.17410290241241455,
0.05869694799184799,
-0.2523784041404724,
-0.11845779418945312,
0.7389401197433472,
-0.6250329613685608,
-0.0303292796015739... | |
throw new ArgumentNullException("feed");
}
**using (XmlReader reader = XmlReader.Create(feed))
{
SyndicationFeed rssData = SyndicationFeed.Load(reader); | [
0.042547471821308136,
-0.30153629183769226,
0.4149978458881378,
-0.26498520374298096,
-0.26431652903556824,
-0.0058210063725709915,
0.15065427124500275,
-0.26133015751838684,
-0.11073131859302521,
-0.6014953851699829,
-0.385380357503891,
0.44353216886520386,
-0.6264788508415222,
0.39070719... | |
return View(rssData);
}**
}
catch (ArgumentNullException)
{
errorString = "No url for Rss feed | [
0.2468978762626648,
-0.39809462428092957,
0.24624347686767578,
-0.3486367166042328,
-0.030310411006212234,
0.1272607445716858,
0.3731108009815216,
0.07725399732589722,
-0.19772040843963623,
-0.1882992535829544,
-0.041211552917957306,
0.6414295434951782,
-0.6697351336479187,
0.3527472615242... | |
specified.";
}
catch (SecurityException)
{
errorString = "You do not have permission to access the specified Rss feed.";
}
catch (FileNotFoundException) | [
0.40726524591445923,
-0.4232935905456543,
0.14459799230098724,
-0.04583972319960594,
0.4243954122066498,
-0.34282955527305603,
0.2030237913131714,
-0.023378588259220123,
-0.10344815999269485,
-0.13786402344703674,
-0.2990380525588989,
0.45549923181533813,
-0.5998018980026245,
0.23600290715... | |
{
errorString = "The Rss feed was not found.";
}
catch (UriFormatException)
{
errorString = "The Rss feed specified was not a valid URI."; | [
0.13293033838272095,
-0.07035353034734726,
0.020867278799414635,
-0.20978471636772156,
0.12279839813709259,
-0.005251567345112562,
0.33438754081726074,
0.23872877657413483,
-0.07473435997962952,
-0.21575433015823364,
-0.065830759704113,
0.43957293033599854,
-0.6009934544563293,
0.359179913... | |
}
catch (Exception)
{
errorString = "An error occured accessing the RSS feed.";
}
var errorResult = new ContentResult();
errorResult.Content = errorString; | [
0.263427197933197,
-0.2995055615901947,
0.08757361024618149,
-0.2305125892162323,
0.03216441720724106,
-0.15225930511951447,
0.4287723898887634,
0.027025040239095688,
-0.22681476175785065,
-0.28406739234924316,
-0.20578418672084808,
0.38078707456588745,
-0.7627789974212646,
0.3097999393939... | |
return errorResult;
}
}
}
```
The UserControl
```
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Index.ascx.cs" Inherits="MvcWidgets.Views.RssWidget.Index" %>
<div class="RssFeedTitle"><%= Html.Encode(ViewData.Model.Title.Text) %> <%= Html.Encode(ViewData.Model.LastUpdatedTime.ToStr... | [
-0.27554115653038025,
-0.02277577854692936,
0.644734799861908,
-0.13420867919921875,
0.0015244695823639631,
0.11696401983499527,
0.4760895073413849,
-0.5607179999351501,
-0.536513090133667,
-0.49171286821365356,
-0.2673318088054657,
0.5015313029289246,
-0.31894469261169434,
0.3356021642684... | |
} %> </p>
</div>
```
with the code behind modified to have a typed Model
```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.ServiceModel.Syndication;
namespace MvcWidgets.Views.RssWidget
{
public partial class Index : System.Web.Mvc.ViewUs... | [
-0.09173937141895294,
-0.02639383263885975,
0.8050819635391235,
-0.2837512195110321,
-0.07804188877344131,
0.15816175937652588,
0.04087648540735245,
-0.20913119614124298,
-0.6056004166603088,
-0.5742290019989014,
-0.5279645919799805,
0.356545627117157,
-0.595564067363739,
0.489820480346679... | |
I'm using Emgu.CV which is a C# wrapper for the OpenCV libraries.
I changed the Emgu.CV source to invoke from the latest OpenCV library cv110.dll instead of cv100.dll and now I get this error (where ????? is cv110.dll). I have placed the cv110.dll file in all the same locations as the cv100.dll file however this does... | [
0.35402777791023254,
0.27993693947792053,
0.2692648768424988,
-0.06996560841798782,
-0.24339644610881805,
-0.2991141080856323,
0.33725306391716003,
0.14525143802165985,
-0.2196662724018097,
-0.7103099226951599,
0.24014131724834442,
0.801243245601654,
-0.3117384910583496,
0.5459215641021729... | |
One of my test UserControls is an Rss Feed control. I use the RenderAction HtmlHelper extension in the Futures dll to display it so a controller action is called. I use the SyndicationFeed class to do most of the work
```
using (XmlReader reader = XmlReader.Create(feed))
{
SyndicationFeed rssData = SyndicationFeed... | [
0.3270478844642639,
-0.3456490933895111,
0.7115157842636108,
-0.15562771260738373,
-0.14974680542945862,
0.05175899341702461,
-0.10379496961832047,
-0.1569412648677826,
-0.18479891121387482,
-0.489942342042923,
0.09478534013032913,
0.5543311834335327,
-0.5595375895500183,
0.292152613401412... | |
{
string errorString = "";
try
{
if (String.IsNullOrEmpty(feed))
{
throw | [
0.33043140172958374,
-0.3161344528198242,
-0.1282176673412323,
-0.49934467673301697,
0.45220309495925903,
-0.0061998628079891205,
0.481663316488266,
-0.1439571976661682,
0.26496657729148865,
-0.44706037640571594,
0.0851123109459877,
0.6417974233627319,
-0.33549660444259644,
0.0304865874350... | |
new ArgumentNullException("feed");
}
**using (XmlReader reader = XmlReader.Create(feed))
{
SyndicationFeed rssData = SyndicationFeed.Load(reader); | [
-0.07071007043123245,
-0.34710532426834106,
0.6423957347869873,
-0.2627246081829071,
-0.18290109932422638,
0.09389476478099823,
0.039126764982938766,
-0.20625637471675873,
-0.23016078770160675,
-0.6546138525009155,
-0.41944003105163574,
0.4719657301902771,
-0.606067419052124,
0.39841231703... | |
return View(rssData);
}**
}
catch (ArgumentNullException)
{
errorString = "No url for Rss feed specified."; | [
0.05054311454296112,
-0.36946070194244385,
0.21882463991641998,
-0.3749208152294159,
-0.03064117580652237,
0.18452142179012299,
0.3692510426044464,
0.011623301543295383,
-0.2055482417345047,
-0.1815520077943802,
-0.16367502510547638,
0.6138341426849365,
-0.6290459632873535,
0.3500907123088... | |
}
catch (SecurityException)
{
errorString = "You do not have permission to access the specified Rss feed.";
}
catch (FileNotFoundException)
{ | [
0.28549924492836,
-0.4397483468055725,
-0.030569320544600487,
-0.12499384582042694,
0.4215843677520752,
-0.356852263212204,
0.2582852244377136,
-0.046090081334114075,
-0.09470026195049286,
-0.10133116692304611,
-0.40057170391082764,
0.49802830815315247,
-0.5880261659622192,
0.1187525466084... | |
errorString = "The Rss feed was not found.";
}
catch (UriFormatException)
{
errorString = "The Rss feed specified was not a valid URI.";
} | [
0.14094284176826477,
0.010306336916983128,
0.0038411070127040148,
-0.18812572956085205,
0.07004053145647049,
0.05315099284052849,
0.3795355260372162,
0.23367376625537872,
-0.15994839370250702,
-0.22579647600650787,
-0.003126900177448988,
0.4289529621601105,
-0.545678973197937,
0.3703812658... | |
catch (Exception)
{
errorString = "An error occured accessing the RSS feed.";
}
var errorResult = new ContentResult();
errorResult.Content = errorString;
return errorResult; | [
0.28158819675445557,
-0.28666216135025024,
0.07839484512805939,
-0.24077387154102325,
0.030225351452827454,
-0.15275414288043976,
0.4089353680610657,
-0.004398874938488007,
-0.19059288501739502,
-0.2674604058265686,
-0.2698936462402344,
0.38895657658576965,
-0.7652887105941772,
0.324389934... | |
}
}
}
```
The UserControl
```
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Index.ascx.cs" Inherits="MvcWidgets.Views.RssWidget.Index" %>
<div class="RssFeedTitle"><%= Html.Encode(ViewData.Model.Title.Text) %> <%= Html.Encode(ViewData.Model.LastUpdatedTime.ToString("MMM dd, yyyy hh:mm:ss") ... | [
-0.12150762230157852,
0.0358303003013134,
0.8844308257102966,
-0.12469663470983505,
0.09631534665822983,
-0.11940139532089233,
0.21809738874435425,
-0.6491736769676208,
-0.5397943258285522,
-0.5805886387825012,
-0.3739064335823059,
0.47577160596847534,
-0.31133323907852173,
0.2970910966396... | |
behind modified to have a typed Model
```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.ServiceModel.Syndication;
namespace MvcWidgets.Views.RssWidget
{
public partial class Index : System.Web.Mvc.ViewUserControl<SyndicationFeed>
{
... | [
0.053437504917383194,
-0.163873553276062,
0.6312656402587891,
-0.2980159819126129,
0.04001805931329727,
0.2808213531970978,
0.13499893248081207,
-0.3197604715824127,
-0.3512887954711914,
-0.29259294271469116,
-0.3572247624397278,
0.360318124294281,
-0.4222724735736847,
0.5888859033584595,
... | |
Correct me if I am wrong,
int is 4 bytes, with a range of values from -2,147,483,648 to 2,147,483,647 (2^31)
long is 4 bytes, with a range of values from -2,147,483,648 to 2,147,483,647 (2^31)
What is the difference in C++? Can they be used interchangeably?
It is implementation dependent.
For example, under Wind... | [
0.06210927292704582,
0.2629588842391968,
0.24781598150730133,
-0.1247132271528244,
-0.06225086376070976,
0.28307732939720154,
0.33849912881851196,
-0.3181627690792084,
-0.0005690029938705266,
-0.1861661821603775,
0.058211442083120346,
0.5861294865608215,
-0.30107101798057556,
0.03057671152... | |
size
Windows IA-32 4 bytes
Windows Intel 64 4 bytes
Windows IA-64 4 bytes
Linux IA-32 4 bytes
Linux Intel 64 8 bytes
Linux IA-64 | [
-0.1570468246936798,
0.334209680557251,
0.18260905146598816,
-0.05900309607386589,
-0.19223861396312714,
0.5338094830513,
0.09235656261444092,
-0.1657007485628128,
-0.2570130527019501,
-0.41195598244667053,
-0.14141133427619934,
0.4811410903930664,
-0.1519910842180252,
0.22136132419109344,... | |
8 bytes
Mac OS X IA-32 4 bytes
Mac OS X Intel 64 8 bytes
``` | [
-0.317715048789978,
0.5195690989494324,
0.06081309914588928,
0.11358527094125748,
-0.15957330167293549,
0.46416473388671875,
0.289801687002182,
0.14924579858779907,
0.03675563260912895,
-0.28811728954315186,
-0.12757608294487,
0.5534167289733887,
-0.3975808024406433,
0.05228261277079582,
... | |
What is the best way to setup your pool with respect to:-
1. When do you create connections?
2. When do you close connections, and would you close all of them?
3. Do you test connections are still good. When and how?
4. How do you figure out a good number for the maximum number of connections?
5. What sort of monitori... | [
0.6247718930244446,
-0.013710648752748966,
0.15479925274848938,
0.4960106611251831,
0.33205682039260864,
-0.19491714239120483,
-0.19316260516643524,
-0.2627781629562378,
-0.36918336153030396,
-0.43242189288139343,
0.48241013288497925,
0.4297061562538147,
-0.23611903190612793,
-0.1529117524... | |
but comments about "features" of particular databases/languages are welcome. For example, it might be slower or more expensive to connect on some databases than others.
To clarify, I do not intend to write a pool from scratch, this question is more about how to configure an existing library that does pooling.
I wrote ... | [
0.5356753468513489,
0.03485245257616043,
0.03516755625605583,
-0.012179072014987469,
0.14411890506744385,
-0.2296711951494217,
-0.105302594602108,
-0.12516912817955017,
-0.30014005303382874,
-0.7460938096046448,
0.4713754653930664,
0.6607348322868347,
-0.5243595242500305,
-0.01514919009059... | |
are created upon launch. The pool is never allowed to drop below three.
2. maximumIdleTimeBeforeRemoval="60"... If a connect is idle for an hour, then drop it and create a new one. Idle time probably means there is only the minimum of three in the pool.
3. maximumInUseTimeBeforeRemoval="30"... If a given connection has... | [
0.42908117175102234,
-0.176974818110466,
0.7476214170455933,
0.05107560381293297,
0.3414379358291626,
-0.2660755217075348,
0.3760756850242615,
-0.08662573993206024,
-0.5874274373054504,
-0.5705065131187439,
-0.25965121388435364,
0.7622972130775452,
-0.2300083339214325,
0.271701842546463,
... | |
very well for a couple of years. The highest I ever saw the pool was 151 connections during a wild peek. Usually the pool was at about a dozen during heavy usage and idled down to the minimum three in the early morning hours.
I used Oracle's JDBC thin drivers and connected to an Oracle database. | [
0.4976952075958252,
-0.04297025874257088,
0.29324716329574585,
0.11064916104078293,
0.013227811083197594,
0.07932835817337036,
-0.32523560523986816,
0.3695819079875946,
-0.3601493835449219,
-0.27844277024269104,
0.5349532961845398,
0.6641467213630676,
0.15657715499401093,
-0.07476948946714... | |
Can anyone reccomend a .net control (winforms) that can be used to as a designer to edit xml files / DSL files ??
Why might an XSLT fail?
-----------------------
An XSLT will fail because of obvious things like typos. However, the most likely situation relates to namespace usage. If you declared a default namespace fo... | [
0.12724503874778748,
-0.053813207894563675,
0.4328690469264984,
0.31238076090812683,
-0.05679833143949509,
-0.23557187616825104,
0.25553539395332336,
-0.35188645124435425,
-0.021730901673436165,
-0.5683112740516663,
-0.27781739830970764,
0.602981686592102,
-0.24569295346736908,
0.212881520... | |
and Addresses template matches. Of course, you will need to change the namespace URI to whatever matches the default namespace of your XML file.
```
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:business... | [
0.02476450428366661,
0.2846129536628723,
0.6476656198501587,
0.018659140914678574,
0.009524066001176834,
-0.16343578696250916,
-0.011030550114810467,
-0.4637555480003357,
-0.11812558770179749,
-1.0639891624450684,
-0.2639917731285095,
0.3673584759235382,
-0.3281646966934204,
0.207053422927... | |
</xsl:copy>
</xsl:template>
<xsl:template match="business:Addresses">
<xsl:element name="BusinessAddresses">
<xsl:apply-templates select="@*|node()" />
</xsl:element>
</xsl:template>
<xsl:template match="business:Address">
<xsl:element name="BusinessAddress">
<xsl:apply-templates selec... | [
-0.1607019305229187,
0.25279200077056885,
0.5857550501823425,
0.06391356885433197,
0.15600308775901794,
-0.044257454574108124,
0.1315113753080368,
-0.6811376214027405,
-0.06377905607223511,
-0.7451417446136475,
-0.2522995173931122,
0.6846065521240234,
-0.32450202107429504,
-0.2800100147724... | |
for a node, this option becomes clearer (contents of templates left out for brevity):
```
<xsl:template match="business:Business/business:Addresses>
</xsl:template>
<xsl:template match="business:Business/business:Addresses/business:Address">
</xsl:template>
<xsl:template match="business:Contact/business:Addresses">
... | [
-0.2736458480358124,
-0.08315283805131912,
0.36573389172554016,
-0.1524616777896881,
0.15291887521743774,
-0.06717117875814438,
0.16779564321041107,
-0.35814446210861206,
-0.0802568793296814,
-0.690333366394043,
-0.47532182931900024,
0.29754146933555603,
-0.4624595642089844,
-0.00992458406... | |
I was in need of a way to compress images in .net so i looked into using the .net GZipStream class (or DeflateStream). However i found that decompression was not always successful, sometimes the images would decompress fine and other times i would get a GDI+ error that something is corrupted.
After investigating the i... | [
0.05030286684632301,
-0.06633614003658295,
0.11811188608407974,
0.367520809173584,
-0.2991081476211548,
0.07357360422611237,
0.46110448241233826,
-0.026263246312737465,
-0.26405414938926697,
-0.5968195199966431,
0.24527327716350555,
0.4143815040588379,
-0.39617499709129333,
0.1650966554880... | |
that compresses only 10 bytes and now i don't get back anything at all.
I tried it with both compression classes GZipStream and DeflateStream and i double checked my code for possible errors. I even tried positioning the stream to 0 and flushing all the streams but with no luck.
Here is my code:
```
public stati... | [
0.30293604731559753,
0.008870134130120277,
0.4615480303764343,
-0.20486387610435486,
0.07656405866146088,
0.4398144483566284,
0.414703369140625,
-0.2785238027572632,
-0.020197026431560516,
-0.4870886504650116,
-0.13571059703826904,
0.522443950176239,
-0.23997463285923004,
0.167514085769653... | |
// This will fail, result.Length is 0
Debug.Assert(result.Length == test.Length);
}
public static byte[] Compress(byte[] data)
{
var compressedStream = new MemoryStream();
var zipStream = new GZipStream(compressedStream, CompressionMode.Compress);
zipStream.Write(data, 0, da... | [
-0.045867614448070526,
-0.2475770115852356,
0.6422650814056396,
-0.006982598453760147,
0.28139224648475647,
0.09588340669870377,
0.34889689087867737,
-0.4510737955570221,
-0.1169147863984108,
-0.4224197566509247,
-0.4789099097251892,
0.7497808933258057,
-0.35109612345695496,
0.177282601594... | |
var compressedStream = new MemoryStream(data);
var zipStream = new GZipStream(compressedStream, CompressionMode.Decompress);
var resultStream = new MemoryStream();
var buffer = new byte[4096];
int read;
while ((read = zipStream.Read(buffer, 0, buffer.Length)) > 0) {
... | [
-0.26038506627082825,
-0.43990302085876465,
0.637008547782898,
-0.333912193775177,
0.09188473969697952,
0.43384650349617004,
0.2151598185300827,
-0.36910927295684814,
-0.20915906131267548,
-0.46389445662498474,
-0.34388136863708496,
0.49602487683296204,
-0.40175962448120117,
-0.04910971596... | |
return resultStream.ToArray();
}
```
You need to `Close()` the `ZipStream` after adding all the data you want to compress; it retains a buffer of unwritten bytes internally (even if you `Flush()`) that needs to be written.
More generally, `Stream` is `IDisposable`, so you should also be `using` each... (yes, I kn... | [
-0.04448971524834633,
0.07332073897123337,
0.45832303166389465,
-0.2382936179637909,
0.2566432058811188,
-0.35504961013793945,
0.24079394340515137,
-0.1691051572561264,
-0.17895427346229553,
-0.5931491255760193,
-0.32693684101104736,
0.687382698059082,
-0.4903244972229004,
0.10467746108770... | |
{
zipStream.Write(data, 0, data.Length);
zipStream.Close();
return compressedStream.ToArray();
}
}
public static byte[] Decompress(byte[] data)
{
using(var compressedStream = new MemoryStream(data))
using(var zipStream = new GZipStream(compressedStream, CompressionMode.Decompress))
... | [
0.2537423074245453,
-0.5078923106193542,
0.5197879672050476,
0.25187984108924866,
-0.05431948974728584,
-0.11276567727327347,
0.10450037568807602,
-0.44875937700271606,
-0.12006087601184845,
-0.398046612739563,
-0.28822246193885803,
0.564979612827301,
-0.5769727826118469,
-0.14844863116741... | |
know the answer...) How is `MemoryStream` implemented? is it a byte[] (owned by .NET)? is it a memory-mapped file (owned by the OS)?
The reason you aren't `using` it is because you are letting knowledge of internal implementation details change how you code against a public API - i.e. you just broke the laws of encaps... | [
0.4992888867855072,
0.19979563355445862,
0.011749707162380219,
0.30545881390571594,
0.285442054271698,
-0.31956419348716736,
0.19321413338184357,
0.0356392040848732,
-0.01606094278395176,
-0.39874300360679626,
-0.01477932371199131,
0.37430644035339355,
-0.20467178523540497,
0.4087203443050... | |
Is there some nice documentation for Windows batch scripting I can download and refer to while offline?
I can recommend:
> [An A-Z Index of the Windows XP command line](http://ss64.com/nt/).
It is more thorough than `help` and most importantly it provides several examples for each command. Example: [FIND](http://ss64... | [
0.17874416708946228,
-0.06312248110771179,
0.047484271228313446,
0.26196375489234924,
-0.13869540393352509,
-0.034768614917993546,
-0.1030898168683052,
0.10623397678136826,
-0.22832483053207397,
-0.7583266496658325,
-0.05124334245920181,
0.3524337708950043,
-0.13668055832386017,
-0.1307856... | |
If you have a Property that gets and sets to an instance variable then normally you always use the Property from outside that class to access it.
My question is should you also always do so within the class? I've always used the Property if there is one, even within the class, but would like to hear some arguments fo... | [
0.3987252712249756,
-0.0642356351017952,
-0.4774520695209503,
0.3421393632888794,
-0.005464703775942326,
-0.16913190484046936,
0.21793760359287262,
0.15933918952941895,
-0.2947690784931183,
-0.699347198009491,
0.057314835488796234,
0.48872798681259155,
-0.11376748234033585,
0.2232721298933... | |
add a level of abstraction in your class. If you change **any** logic concerning how that field is stored then the rest of your code will be left unaffected.
For example you might change that from a local variable to a property of a child object, to a database call, to a webservice call, to a static property on a clas... | [
0.22145473957061768,
-0.31872937083244324,
0.09224966913461685,
0.4258566200733185,
-0.0029528806917369366,
-0.019727442413568497,
0.028679748997092247,
-0.004678698256611824,
-0.16905689239501953,
-0.8008033037185669,
-0.1616135537624359,
0.454717218875885,
-0.2677510678768158,
0.41821828... | |
to apply business rules on the value of the property instead of having to enforce the same rule at each location where you'd directly access the field. Again, encapsulation
With the introduction of automatic properties there's even less reason to explicitly have a local variable, unless you need to apply business rule... | [
0.396091103553772,
-0.14628615975379944,
0.10701420158147812,
0.24619938433170319,
-0.047707658261060715,
-0.48753809928894043,
0.2833595871925354,
-0.40560492873191833,
-0.10540616512298584,
-0.44667500257492065,
-0.3203093111515045,
0.6710878610610962,
-0.1785246878862381,
-0.05240700393... | |
1. We currently just utilize soap webservices for all our communication but have been thinking about moving to WCF instead. What are the benefits of using it over an asmx service?
2. If we do go with a WCF service, can other languages still communicate with it? SOAP is standardized and all languages can interact with i... | [
0.548583447933197,
0.0019130533328279853,
0.20253752171993256,
0.04903573542833328,
-0.3424651026725769,
-0.24831891059875488,
0.42222490906715393,
-0.1273472160100937,
-0.0512198768556118,
-0.7232061624526978,
0.10543414205312729,
0.3772752583026886,
-0.12530478835105896,
-0.1811694204807... | |
WCF, but once you learn it it's no harder to implement than an asmx web services. One advantage is you can easily switch protocols and serialization from binary remoting all the way to [web protocols](http://msdn.microsoft.com/en-us/library/ms730294.aspx). It's also easy to host either in IIS or out.
2. Other languages... | [
0.3964137136936188,
-0.16947072744369507,
0.69249427318573,
-0.07356254756450653,
-0.30613258481025696,
-0.4497639536857605,
0.07022931426763535,
-0.22405831515789032,
-0.13064588606357574,
-0.9985319375991821,
0.22554899752140045,
0.540253758430481,
-0.2727431356906891,
0.2249502688646316... | |
I am refering to the [question](https://stackoverflow.com/questions/252893/how-do-you-change-the-classpath-within-java#252905) on changing the classpath programmatically.
I read and found out that there is some function under **System** class as getproperties where we can retrieve the properties and then also can set ... | [
0.15919797122478485,
-0.27906733751296997,
0.2869308590888977,
0.01307543646544218,
0.1771557629108429,
-0.09626396745443344,
0.07380866259336472,
-0.10211794078350067,
-0.3494980037212372,
-0.7562620639801025,
-0.1446036845445633,
0.6173600554466248,
-0.34660395979881287,
0.16534274816513... | |
really helpful?
You can certainly set any system properties you want at any point of time. The question is, will it have any effect? In the case of classpath, the answer is NO. The system class loader is initialized at a very early point in the startup sequence. It copies the classpath into its own data structures, and... | [
0.21762290596961975,
-0.3256259560585022,
0.1625586897134781,
0.33842116594314575,
0.10537966340780258,
-0.09046558290719986,
0.119021937251091,
0.37187355756759644,
-0.09293811768293381,
-0.7745375037193298,
-0.05647335946559906,
0.6431311368942261,
-0.24369116127490997,
0.101801633834838... | |
re-parsing classpath every time may be inefficient. The more important reason is security. You don't want a rogue class change the classpath under you and load compromised version of another class. | [
0.2475956827402115,
-0.19615164399147034,
-0.1114853098988533,
0.5065864324569702,
-0.19108276069164276,
-0.3237716257572174,
0.48754286766052246,
-0.03152848780155182,
-0.4097123444080353,
-0.5706859230995178,
0.01152527704834938,
0.6327077150344849,
-0.2879723310470581,
0.172732472419738... | |
Does anyone know any good and free .NET Windows Controls Library
I think [Component Factory](http://www.componentfactory.com/) has got some. | [
0.5877932906150818,
0.060636065900325775,
0.12254051864147186,
0.21861621737480164,
-0.11682283878326416,
-0.3260762393474579,
0.20925453305244446,
0.35952985286712646,
-0.2802997827529907,
-0.21586842834949493,
0.03314438834786415,
0.5356452465057373,
0.10134142637252808,
0.14250122010707... | |
I could do this in C#..
```
int number = 2;
string str = "Hello " + number + " world";
```
..and str ends up as "Hello 2 world".
In VB.NET i could do this..
```
Dim number As Integer = 2
Dim str As String = "Hello " + number + " world"
```
..but I get an InvalidCastException "Conversion from string "Hello " to t... | [
0.2902670204639435,
-0.07629042118787766,
0.3566206693649292,
-0.4741893708705902,
-0.18613968789577484,
-0.1649557501077652,
0.4589400291442871,
-0.2287122905254364,
-0.14383992552757263,
-0.49722686409950256,
-0.1090082973241806,
0.5767651796340942,
-0.4708101153373718,
0.094044707715511... | |
= 2
Dim str As String = "Hello " & number & " world"
```
Basically when VB sees + I suspect it tries do numeric addition or use the addition operator defined in a type (or no doubt other more complicated things, based on options...) Note that `System.String` doesn't define an addition operator - it's all hidden in th... | [
0.32543453574180603,
-0.07830031216144562,
0.4897862374782562,
-0.43090343475341797,
-0.23119288682937622,
-0.03225187957286835,
0.2902681827545166,
-0.4637022316455841,
-0.10319245606660843,
-0.18860922753810883,
-0.11820703744888306,
0.436937153339386,
-0.43483230471611023,
0.08568891137... | |
Sometimes when I am debugging code in Eclipse it happens that although I can see and inspect class member variables without any difficulty I am unable to inspect the values of variables declared locally within functions. As an aside, any parameters to the current function lose their 'real' names and instead one sees th... | [
0.24996419250965118,
0.11190898716449738,
0.07616402953863144,
-0.08327101171016693,
-0.27964526414871216,
-0.21025080978870392,
0.32607877254486084,
0.14851513504981995,
-0.25590965151786804,
-0.5210244059562683,
-0.1112484484910965,
0.6383742094039917,
-0.14787760376930237,
0.20379555225... | |
shed some light on this behaviour?
Apparently, the [answer](http://dev.eclipse.org/newslists/news.eclipse.platform/msg56943.html) is:
> the rt.jar that ships with the JDK (where the core Java classes live) is not compiled with full debug information included in the .class files, so the debugger does not have local var... | [
0.2240845263004303,
0.13580675423145294,
0.36315110325813293,
-0.18360625207424164,
-0.3744448721408844,
-0.2844812572002411,
0.5657873153686523,
-0.30754780769348145,
-0.1502975970506668,
-0.3217175006866455,
-0.2761889100074768,
0.5679235458374023,
-0.3765368163585663,
-0.000268664443865... | |
numbers and local variables. Quite often, class libraries (for example, "rt.jar") are compiled without complete debug attributes, and thus local variables and method arguments for those classes are not visible in the debugger. | [
0.04351034760475159,
0.19733285903930664,
-0.23958438634872437,
0.25256940722465515,
0.10469865053892136,
-0.09769013524055481,
0.4241052269935608,
-0.09310455620288849,
-0.10623441636562347,
-0.2648668587207794,
-0.42299437522888184,
0.751987636089325,
-0.28083616495132446,
0.103006623685... | |
I use `x != null` to avoid [`NullPointerException`](https://docs.oracle.com/javase/9/docs/api/java/lang/NullPointerException.html). Is there an alternative?
```java
if (x != null) {
// ...
}
```
This to me sounds like a reasonably common problem that junior to intermediate developers tend to face at some point: t... | [
0.38050875067710876,
0.22499285638332367,
-0.08962516486644745,
-0.20460782945156097,
-0.13101068139076233,
-0.20371955633163452,
0.37448421120643616,
-0.31441396474838257,
0.045481108129024506,
-0.5111994743347168,
0.01837007701396942,
0.575482964515686,
-0.21557027101516724,
-0.077873580... | |
response in terms of the contract; and
2. Where it isn't a valid response.
(2) is easy. As of Java 1.7 you can use [`Objects.requireNonNull(foo)`](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Objects.html#requireNonNull(T)). (If you are stuck with a previous version then [`assert`ions](https:... | [
-0.1431448757648468,
-0.08357154577970505,
0.6689585447311401,
-0.1891782432794571,
-0.4083458483219147,
0.06413965672254562,
0.31412941217422485,
-0.877546489238739,
-0.13589651882648468,
-0.2563815116882324,
-0.11518621444702148,
0.6187531352043152,
-0.5794862508773804,
0.097068995237350... | |
an exception if the object is null. In both uses, a message can be added which will be shown in the exception. Below is using it like an assertion and providing a message.
```
Objects.requireNonNull(someobject, "if someobject is null then something is wrong");
someobject.doCalc();
```
Generally throwing a specific e... | [
0.08573801070451736,
-0.12232030928134918,
0.12236277014017105,
-0.1990932822227478,
-0.22849777340888977,
-0.5658727884292603,
0.42299655079841614,
-0.18375331163406372,
-0.13924673199653625,
-0.35229992866516113,
-0.4361122250556946,
0.5400710105895996,
-0.4356183409690857,
-0.0280188191... | |
then you're stuck. If null is a valid response, you have to check for it.
If it's code that you do control, however (and this is often the case), then it's a different story. Avoid using nulls as a response. With methods that return collections, it's easy: return empty collections (or arrays) instead of nulls pretty m... | [
-0.045468393713235855,
-0.47978129982948303,
-0.0008724130457267165,
0.15181712806224823,
-0.014086618088185787,
0.06612364947795868,
0.24261437356472015,
-0.3207564651966095,
-0.3648199439048767,
-0.6065941452980042,
-0.24755945801734924,
0.5114440321922302,
-0.44459810853004456,
-0.13721... | |
implementing a command line interface for something. Now you might make the contract that it returns null if there's no appropriate action. That leads the null checking you're talking about.
An alternative solution is to never return null and instead use the [Null Object pattern](https://en.wikipedia.org/wiki/Null_Obj... | [
0.12593507766723633,
-0.2778031527996063,
0.19440282881259918,
-0.05686456337571144,
0.05032730475068092,
-0.0635053962469101,
0.4854860305786133,
-0.23443366587162018,
-0.1004403680562973,
-0.6897419095039368,
-0.1398605853319168,
0.5905763506889343,
-0.7497733235359192,
-0.13359856605529... | |
return DO_NOTHING;
}
}
}
```
Compare:
```
Parser parser = ParserFactory.getParser();
if (parser == null) {
// now what?
// this would be an example of where null isn't (or shouldn't be) a valid response
}
Action action = parser.findAction(someInput);
if (action == null) {
// do nothing
} else {
action.... | [
-0.12338119000196457,
-0.16946090757846832,
0.2408846616744995,
-0.25970491766929626,
-0.08553004264831543,
-0.042548101395368576,
0.5589677691459656,
-0.6837923526763916,
-0.17298240959644318,
-0.4450126588344574,
-0.3471912145614624,
0.6812777519226074,
-0.47683247923851013,
-0.290871262... | |
better for the findAction method to throw an Exception than for the calling method to blow up with a simple NullPointerException with no explanation.
```
try {
ParserFactory.getParser().findAction(someInput).doSomething();
} catch(ActionNotFoundException anfe) {
userConsole.err(anfe.getMessage());
}
```
Or i... | [
-0.014532756991684437,
-0.1830030381679535,
0.2619485855102539,
-0.3403204381465912,
0.16391661763191223,
0.0056288838386535645,
0.5020347833633423,
-0.5059142708778381,
0.003086899872869253,
-0.5976738333702087,
-0.28768330812454224,
0.7014080286026001,
-0.5383983254432678,
-0.13513232767... | |
userConsole.err("Action not found: " + userInput);
}
}
}
``` | [
-0.34715890884399414,
-0.11907551437616348,
0.48760145902633667,
-0.1516995131969452,
0.28043854236602783,
-0.24187450110912323,
0.24134308099746704,
0.010275239124894142,
-0.16327771544456482,
-0.5428558588027954,
-0.3268819749355316,
0.8453071117401123,
-0.3069544732570648,
0.07708891481... | |
There is an application with an extensive object graph. This graph mainly consists of a set of subgraphs which are connected to the rest of the graph through the only reference. But internally each such subgraph has some number of cross-references among objects. Once in a while such a sub graph needs to be thrown away.... | [
0.18854492902755737,
0.20267269015312195,
0.19765014946460724,
0.35041385889053345,
-0.19573046267032623,
-0.17352284491062164,
0.3523021936416626,
0.029316043481230736,
-0.38868123292922974,
-0.7619596123695374,
-0.029099956154823303,
0.19604714214801788,
-0.48890599608421326,
0.399124145... | |
wise enough to figure out that all references in a subgraph do not leave the boundaries of the subgraph and therefore entire subgraph can be purged.
As stated in this [SO question](https://stackoverflow.com/questions/176745/circular-references-in-java), circular reference is well managed.
Java does not do reference co... | [
-0.26790693402290344,
-0.15677937865257263,
0.43500906229019165,
0.2797461152076721,
-0.20084714889526367,
-0.386190801858902,
0.437493234872818,
-0.21148283779621124,
-0.4691157639026642,
-0.38215121626853943,
0.18629704415798187,
0.1474808007478714,
-0.40201714634895325,
0.03733469545841... | |
setting a reference to null might, conceivably, have a significant effect is in discarding a very large object in the middle of a long running method.
In that case, setting null to the reference of the graph will help making an **island of isolation** (even for internal circular references) as described in this [arti... | [
0.024573765695095062,
0.03615179285407066,
0.061812467873096466,
0.05675400048494339,
-0.2082386463880539,
-0.36053869128227234,
0.6299126148223877,
-0.08868493139743805,
-0.26981818675994873,
-0.46082690358161926,
-0.3092087209224701,
-0.04954269528388977,
-0.5224907398223877,
0.349132388... | |
object is a candidate for collection doesn’t mean it will be immediately
collected. The JVM is free to delay collection until there is an immediate need for thememory being consumed by the object.
It’s important to note that not just any strong reference will hold an object in memory. These must be references that cha... | [
-0.04833601415157318,
-0.14408078789710999,
0.2458437830209732,
0.223271906375885,
-0.22255678474903107,
-0.2515433430671692,
0.17173133790493011,
-0.015601706691086292,
-0.5300250053405762,
-0.3763059079647064,
-0.18948160111904144,
0.1626788228750229,
-0.25102075934410095,
0.530571818351... | |
and assigns them references to each other.
```
public void buidDog() {
Dog newDog = new Dog();
Tail newTail = new Tail();
newDog.tail = newTail;
newTail.dog = newDog;
}
```
Before the method returns, there are strong references from the temporary stack variables in the `buildDog` method pointing to both ... | [
0.1029834970831871,
0.16618600487709045,
0.48378854990005493,
-0.33204495906829834,
0.20178794860839844,
-0.011950078420341015,
0.3307219445705414,
-0.3396967947483063,
-0.12763872742652893,
-0.43552711606025696,
-0.4582384526729584,
0.4573512375354767,
-0.4671609103679657,
0.3677724003791... | |
I can't seem to set a ContentTemplate for a ComboBoxItem. There reason I'm trying to do this is I want to have 2 appearances for my data in the combo box. When the combo box is open (menu is down) I want a text box (with the name of the image) and an image control below it. When I select the item I want the combo box t... | [
0.11256372928619385,
-0.24424399435520172,
0.8168762922286987,
0.12799347937107086,
-0.20722228288650513,
-0.06616577506065369,
0.12266157567501068,
-0.11410439759492874,
-0.01478295773267746,
-0.8276586532592773,
-0.044182613492012024,
0.42675575613975525,
-0.11726196855306625,
0.07169567... | |
Margin="{TemplateBinding Padding}" x:Name="contentPresenter" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
```
So I assumed that I could just set the ContentTemplate here and it would work. But I can't seem to get it to work:
```
<DataTemplate x:Key="ComboBoxDataTemplate">... | [
0.0038246794138103724,
-0.20598050951957703,
0.8445473909378052,
0.0643322616815567,
-0.20882084965705872,
-0.1726163625717163,
-0.23743097484111786,
-0.6769156455993652,
0.21770909428596497,
-0.7010573148727417,
0.11476551741361618,
0.4342556297779083,
0.1981142908334732,
-0.1321481168270... | |
<TextBlock Text="{Binding Path='Name'}"/>
<Image Source="{Binding Path='Source'}" Width="64" Height="64"/>
</StackPanel>
</DataTemplate>
<Style x:Key="ComboBoxItemStyle1" TargetType="ComboBoxItem">
...
<Setter Property="ContentTemplate" Value="{StaticResource Com... | [
-0.0018902914598584175,
-0.03243473917245865,
0.8733922839164734,
-0.1960316151380539,
-0.04955106973648071,
0.08684202283620834,
0.01943212002515793,
-0.7085827589035034,
-0.025695033371448517,
-0.8151633739471436,
-0.04168344661593437,
0.3920151889324188,
-0.07151420414447784,
-0.2721857... | |
ItemsSource="{StaticResource Source}"
ItemTemplate="{StaticResource ComboBoxDataTemplate}"
ItemContainerStyle="{StaticResource ComboBoxItemStyle1}"
/>
```
The only way I can get this to work is to remove the ContentPresenter from the ItemContaine... | [
0.014447181485593319,
-0.22900119423866272,
0.6022982597351074,
-0.0013538871426135302,
-0.018427854403853416,
0.05092686414718628,
0.3992213010787964,
-0.19413627684116364,
-0.0075883702374994755,
-0.508089542388916,
-0.13518252968788147,
0.5080552101135254,
-0.3139208257198334,
0.1768074... | |
with the contents of my custom template (ComboBoxItemTemplate). But I didn't think I should use this approach as it would mean the ContentPresenter no longer exists (and code in the ComboBox might rely on it existing).
Any help on showing a combo box with a different drop down and selected template would be greatly ap... | [
0.5986353754997253,
-0.13924068212509155,
0.31570374965667725,
0.0416790246963501,
-0.3197185695171356,
0.05974126607179642,
-0.00593590410426259,
-0.3049277663230896,
-0.34173813462257385,
-0.6735050082206726,
0.19306670129299164,
0.6210482120513916,
-0.4204956293106079,
0.071017608046531... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.