What's wrong with my code snippet? - visual-studio

I have a code snippet that's giving me some slightly annoying problems. Here's the snippet:
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets
xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Set With Notify</Title>
<Description>Code snippet for common model setters</Description>
<Shortcut>notify_member</Shortcut>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>type</ID>
<ToolTip>The type of both members</ToolTip>
</Literal>
<Literal>
<ID>member</ID>
<ToolTip>The member symbol</ToolTip>
</Literal>
</Declarations>
<Code Language="CSharp">
<![CDATA[
private $type$ _$member$;
public $type$ $member$
{
get
{
return _$member$;
}
set
{
if (value != this._$member$)
{
this._$member$ = value;
this.OnPropertyChanged();
}
}
}
]]>
</Code>
</Snippet>
</CodeSnippet>
So, first issue I've already worked around but it made my snippet slightly more difficult to use: When using only 2 Declarations/Replacements the snippet would just get pasted into the editor without an opportunity to specify type, or member.
Currently, whenever I use this snippet, the two braces following my set function are not properly indented. The final brace is in the right spot and all other code is indented correctly.
So, what am I missing or doing improperly to cause this formatting issue?

Related

How to replace my custom template for product detail page in Magento2?

I need to replace my custom template for product detail page in magento2.
I have followed this link and updated my code but it is not working.
In my module, I have added catalog_product_view.xml and below code.
Mynamespace\Catalog\view\frontend\layout\catalog_product_view.xml
<referenceContainer name="content">
<block class="Mynamepace\Catalog\Block\Product\View\Article" name="product.view.art" template="Mynamespace_Catalog::product\view\article.phtml">
</block>
</referenceContainer>
This is not working. Can anyone suggest what I am missing here?
My Block Code:
Mynamepace\Catalog\Block\Product\View\Article.php
<?php
namespace Mynamespace\Catalog\Block\Product\View;
use Magento\Catalog\Block\Product\AbstractProduct;
class Article extends AbstractProduct
{
public function showPages()
{
return 'Article';
}
}
My phtml - Mynamespace\Catalog\view\frontend\templates\product\view\article.phtml
I am in Article
<?php
My Module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="Mynamespace_Catalog" setup_version="1.0.0" schema_version="1.0.0">
<sequence>
<module name="Magento_Catalog"/>
</sequence>
</module>
</config>
Please tell me if I have missed something Or at least tell me how to debug this code.
I see a wrong syntax on your layout file Mynamespace\Catalog\view\frontend\layout\catalog_product_view.xml
template="Mynamespace_Catalog::product\view\article.phtml"
Change it to:
template="Mynamespace_Catalog::product/view/article.phtml"

Issues with Adobe AIR File access when file name has a semi-colon

I have a piece of code in AIR that accesses a file on the hard drive. This fails to work on a mac if the file name contains a semi-colon. It throws an exception that it can't find the file. If I rename the file and remove the semi-colon and point to it it works fine so the code is ok. The only problem is when the filename contains a semi-colon. The exception occurs on the line where I request file.size.
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="windowedapplication1_creationCompleteHandler(event)">
<fx:Script> <![CDATA[
import mx.events.FlexEvent;
protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void
{
// TODO Auto-generated method stub
var f:File = new File("file:///Users/foo/pix/test;1.JPG");
trace (" here" + f.size );
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
</s:WindowedApplication>
Don't use semi colons in filenames.
See this article from 2007
http://www.portfoliofaq.com/pfaq/FAQ00352.htm
Deprecated filename characters (; and ,). (All OSs).

JAXB Moxy getValueByXpath gives null

I want to see if a theme element exists with specified name in the following xml file.
input.xml
<data>
<artifacts>
<document id="efqw4eads">
<name>composite</name>
</document>
<theme id="1">
<name>Terrace</name>
</theme>
<theme id="2">
<name>Garage</name>
</theme>
<theme id="3">
<name>Reception</name>
</theme>
<theme id="4">
<name>Grade II</name>
</theme>
</artifacts>
</data>
I have the following code. return true statement of the method is never executed. answer always contains a null value.
public boolean themeExists(String name, Data data){
String expression = "artifacts/theme[name='"+name+"']/name/text()";
String answer = jaxbContext.getValueByXPath(data, expression, null, String.class);
if(answer == null || answer.equals("")){
return false;
}
return true;
}
This use case isn't currently supported by EclipseLink JAXB (MOXy). I have opened the following enhancement you can use to track our progress:
http://bugs.eclipse.org/413823
There is no <artifacts/> element you're look for in the first axis step. Your XPath expression should be something like
String expression = "data/theme[name='"+name+"']/name/text()";

How to remove namespace from xml

I have a XML in following format
<Body xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<TransactionAcknowledgement xmlns="">
<TransactionId>HELLO </TransactionId>
<UserId>MC</UserId>
<SendingPartyType>SE</SendingPartyType>
</TransactionAcknowledgement>
</Body>
I want to user XQuery or XPath expression for it.
Now I want to remove only
xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"
namespace from xml.
Is there any way to achieve it.
Thanks
Try to use functx:change-element-ns-deep:
let $xml := <Body xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<TransactionAcknowledgement xmlns="">
<TransactionId>HELLO </TransactionId>
<UserId>MC</UserId>
<SendingPartyType>SE</SendingPartyType>
</TransactionAcknowledgement>
</Body>
return functx:change-element-ns-deep($xml, "http://schemas.xmlsoap.org/soap/envelope/", "")
But as said Dimitre Novatchev this function doesn't change namespace of the source xml, it creates a new XML.

Listening for dataChange event in AdvancedDataGrid

This is my code:
<controls:AdvancedDataGrid id="adg" dataChange="adg_dataChangeHandler(event)">
<!-- other stuff goes here -->
</controls:AdvancedDataGrid>
and in my ActionScript code:
protected function adg_dataChangeHandler(event:FlexEvent):void
{
trace(1);
}
When I edit a cell in advancedDataGrid (making the columns editable of course) it never dispatches an event. Or, in other words, my function is never called. How can I fix this?
I think that the better option for my scenario is to use an itemEditor, that has a listener put on the change event. Code looks like :
<controls:AdvancedDataGrid id="adg">
<controls:groupedColumns>
<adgs:AdvancedDataGridColumn headerText="A" wordWrap="true" dataField="name" editable="false" itemEditor="Aaa"/>
</controls:groupedColumns>
</controls:AdvancedDataGrid>
and the item editor class is here :
<?xml version="1.0" encoding="utf-8"?>
<mx:TextInput xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" change="textinput1_changeHandler(event)" restrict="0-9">
<fx:Script>
<![CDATA[
protected function textinput1_changeHandler(event:Event):void
{
trace("ha");
}
]]>
</fx:Script>
</mx:TextInput>

Resources