Search Results

Search found 1010 results on 41 pages for 'reuse'.

Page 4/41 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Reuse Hibernate session in thread

    - by Marco
    Hello, I've read somewhere that when a session is flushed or a transaction is committed, the session itself is closed by Hibernate. So, how can i reuse an Hibernate Session, in the same thread, that has been previously closed? Thanks

    Read the article

  • Easily reuse views, controller, layout in a command line interface

    - by Alex
    My Zend application is going to get an command line php script that should email reports. There generation depends on Zend_View, Zend_Layout and is currently already working fine in the web interface. How can I reuse this whole MVC functionality in the command line? Should I add a new controller CommandLineController and call this somehow from the commandline? How can I kick of such a Controller manually, without having a HTTP request?

    Read the article

  • Reuse classes and objects for both WCF and non-WCF

    - by joebeazelman
    I have several classes such as Order, Customer, etc. These classes serve for holding data and nothing more. I want to be able to reuse these classes in other projects in the future, but for some reason I don't quite understand, WCF forces me to decorate the data members with the [DataMember] attribute, forcing me to reference WCF plumbing that I will never use in other projects. I would imagine that WCF lets you take any serializable class and use it as a content type. Am I understanding this correctly?

    Read the article

  • how to reuse subquery result in mysql

    - by chris
    I'm doing a statistic job like this: SUM |COND1 |COND2 |... -------------------------- 100 |80 | 70 |... The SUM result is calculated from multiple tables, and the CONDs are subset of that. I wrote a sql like this: select tmp1.id,sum,cond1,cond2 as count from ( select id, count(*) as sum from table_1 group by table1.id) tmp1 left join ( select id, count(*) as cond1 from table1 where condition1 group by table1.id) tmp2 on tmp1.id=tmp2.id left join ( select id, count(*) as cond2 from table1 where condition2 group by table1.id) tmp3 on tmp1.id=tmp3.id the problem is that this is very poor efficiency, it will be better if i could use the result of tmp1, but i don't know how to do that. update: simplified the sql, what i mean is how to reuse the first select result of table_1

    Read the article

  • unittest tests reuse for family of classes

    - by zaharpopov
    I have problem organizing my unittest based class test for family of tests. For example assume I implement a "dictionary" interface, and have 5 different implementations want to testing. I do write one test class that tests a dictionary interface. But how can I nicely reuse it to test my all classes? So far I do ugly: DictType = hashtable.HashDict In top of file and then use DictType in test class. To test another class I manually change the DictType to something else. How can do this otherwise? Can't pass arguments to unittest classes so is there a nicer way?

    Read the article

  • Django, javascript and code reuse problem

    - by dragoon
    Hi, I have some sort of a design problem with my Django AJAX application. I have a template where I initialize js variable from django context variable like so: var test = "{{ test }}"; This variable is than used in a number of js functions that are needed for interface to work properly. So now I'm trying to reuse some content from this page in another page that loads it dynamically on some user interaction using jQuery.load(..), and I don't see any way how I can initialize that variable, so js functions don't work now. Is there any solution for this or may be I'm doing it wrong? Thanks.

    Read the article

  • how do you reuse a partial view with different ids

    - by oo
    i have a partial view with a dropdown in it. the code looks like this: <%=Html.DropDownListFor(x => Model.Exercises, new SelectList(Model.Exercises, "Id", "Name", Model.SelectedExercise), new { @id = "exerciseDropdown", @class = "autoComplete" })%> the issue is that i want to reuse this partial view in multiple places but i want to have a different id assigned to the control (instead of exerciseDropdown always) but on the outside i only have this . . <% Html.RenderPartial("ExerciseList", Model); %> is there anyway to pass in an id into a partial view. should i stick this into my view model as a seperate property "Model.ExerciseDropdown2" for example. is there a better way ?

    Read the article

  • SQL Server: collect values in an aggregation temporarily and reuse in the same query

    - by Erwin Brandstetter
    How do I accumulate values in t-SQL? AFAIK there is no ARRAY type. I want to reuse the values like demonstrated in this PostgreSQL example using array_agg(). SELECT a[1] || a[i] AS foo ,a[2] || a[5] AS bar -- assuming we have >= 5 rows for simplicity FROM ( SELECT array_agg(text_col ORDER BY text_col) AS a ,count(*)::int4 AS i FROM tbl WHERE id between 10 AND 100 ) x How would I best solve this with t-SQL? Best I could come up with are two CTE and subselects: ;WITH x AS ( SELECT row_number() OVER (ORDER BY name) AS rn ,name AS a FROM #t WHERE id between 10 AND 100 ), i AS ( SELECT count(*) AS i FROM x ) SELECT (SELECT a FROM x WHERE rn = 1) + (SELECT a FROM x WHERE rn = i) AS foo ,(SELECT a FROM x WHERE rn = 2) + (SELECT a FROM x WHERE rn = 5) AS bar FROM i Test setup: CREATE TABLE #t( id INT PRIMARY KEY ,name NVARCHAR(100)) INSERT INTO #t VALUES (3 , 'John') ,(5 , 'Mary') ,(8 , 'Michael') ,(13, 'Steve') ,(21, 'Jack') ,(34, 'Pete') ,(57, 'Ami') ,(88, 'Bob') Is there a simpler way?

    Read the article

  • how do you reuse a partial view with setting different ids

    - by oo
    i have a partial view with a dropdown in it. the code looks like this: <%=Html.DropDownListFor(x => Model.Exercises, new SelectList(Model.Exercises, "Id", "Name", Model.SelectedExercise), new { @id = "exerciseDropdown", @class = "autoComplete" })%> the issue is that i want to reuse this partial view in multiple places but i want to have a different id assigned to the control (instead of exerciseDropdown always) but on the outside i only have this . . <% Html.RenderPartial("ExerciseList", Model); %> is there anyway to pass in an id into a partial view. is there a standard way to inject the ids into a partial view ? right now i am doing things like this: <% Html.RenderPartial("ExerciseList", Model); %> <% Html.RenderPartial("ExerciseList2", Model); %> where ExerciseList and ExerciseList2 are identical but with different ids but i am sure there is a better way.

    Read the article

  • Reuse select query in a procedure in Oracle

    - by Jer
    How would I store the result of a select statement so I can reuse the results with an in clause for other queries? Here's some pseudo code: declare ids <type?>; begin ids := select id from table_with_ids; select * from table1 where id in (ids); select * from table2 where id in (ids); end; ... or will the optimizer do this for me if I simply put the sub-query in both select statements?

    Read the article

  • Reuse C++ Header files

    - by Amrish
    Guys, I have a Visual C++ solution with 2 projects AlgorithmA & AlgorithmB and both share a common header file RunAlgo.h with the class declaration. Each project in the solution has its own unique implementation for the header file. I am trying to compile a DLL out of the common header file RunAlgo.h and add reference to this DLL in the projects AlgorithmA & AlgorithmB. I have then included separate RunAlgo.cpp definition file in both my projects. The problem is that I am getting linker errors while compiling the new DLL project which has only the header file. So, the question is Can a header file with only class declaration be compiled into a DLL (Similar to class library containing an Interface in C#)? For the above scenario, is there a better approach to reuse the common Header file among projects? Should the above method work (re-check my code?)

    Read the article

  • How can I reuse a base class function in a derived class

    - by Armen Ablak
    Let's say we have these four classes: BinaryTree, SplayTree (which is a sub-class of BinaryTree), BinaryNode and SplayNode (which is a sub-class of BinaryNode). In class BinaryTree I have 2 Find functions, like this bool Find(const T &) const; virtual Node<T> * Find(const T &, Node<T> *) const; and in SplayTree I would like to reuse the second one, because it works in the same way (for example) as in SplayTree, the only thing different is the return type, which is SplayNode. I thought it might be enough if I use this line in SplayTree.cpp using BinaryTree::Find; but it isn't. So, how can I do this?

    Read the article

  • Best practice for near reuse of model components?

    - by Chris Knight
    I have a requirement to use a Fund model in my code. It will contain a fund name and fund code. In the interest of reuse I've poked around the package containing the other models used and found an existing Fund model. However the issue here is that, in addition to fund name and code, it also contains an amount. Amount isn't directly relevant in my context. So, do I: 1) Use the existing Fund model as is, ignoring the setters/getters for fund amount. 2) Put a FundDescription interface onto the existing Fund model for accessing only the information I'm interested in. 3) Make a FundDescription base class from which the existing Fund model could now extend 4) Create a whole new seperate model since the two are slightly contextually different

    Read the article

  • Linq to Sql query reuse

    - by UserControl
    Let's say we have a view V1 and V2 that is declared like: create view V2 as select V1.*, V2.C1, V2.C2, V2.C3 from V1 join V2 on V1.Key = V2.Key where bla-bla So V2 narrows down the result set of V1 and adds some joins. And there is a retrieval routine in C# IEnumerable<V1> GetData(MyFilter filter, MySortOrder order) {} I want to reuse with V2. Is it possible without performing joins in L2S rather than in database? Should i manually create a base class in the database context or something?

    Read the article

  • [SOLVED] flash 10, as3 - save text of textarea and reuse it to replace text in textarea

    - by user427969
    hi everyone Is it possible to save text of textarea (flash 10, as3, cs5) in some variable or so and with its textformat (more than one color) and then reuse it to replace text in textarea? I tried saving htmlText of textarea but the problem is when i replace it in textarea tags causes problem. There will always be another extra line. If anyone wants to view p tags problem try following. Just click on text and then move your down arrow key, cursor will go to next line. import fl.controls.TextArea; var txtHTML:TextArea = new TextArea(); txtHTML.move(0,0); var default_format:TextFormat = new TextFormat(); default_format.font = "Arial"; default_format.bold = false; default_format.align = "center"; default_format.color = 0xFFFF00; default_format.size = 14; var field:TextField = txtHTML.textField; field.defaultTextFormat = default_format; field.setTextFormat(default_format); field.alwaysShowSelection = true; field.background = true; field.type = 'input'; field.multiline = true; field.backgroundColor = 0x777777; field.embedFonts = true; txtHTML.htmlText = '<P ALIGN="CENTER"><FONT FACE="_sans" SIZE="14" COLOR="#FFFF00" LETTERSPACING="0" KERNING="0">ASDF</FONT></P>'; field.x = 0; field.y = 0; field.width = 400; field.height = 200; field.text = ""; addChild(txtHTML); Is there a way to do this? Thanks alot for any help. Regards

    Read the article

  • Is possible to reuse subqueries?

    - by Gothmog
    Hello, I'm having some problems trying to perform a query. I have two tables, one with elements information, and another one with records related with the elements of the first table. The idea is to get in the same row the element information plus several records information. Structure could be explain like this: table [ id, name ] [1, '1'], [2, '2'] table2 [ id, type, value ] [1, 1, '2009-12-02'] [1, 2, '2010-01-03'] [1, 4, '2010-01-03'] [2, 1, '2010-01-02'] [2, 2, '2010-01-02'] [2, 2, '2010-01-03'] [2, 3, '2010-01-07'] [2, 4, '2010-01-07'] And this is want I would like to achieve: result [id, name, Column1, Column2, Column3, Column4] [1, '1', '2009-12-02', '2010-01-03', , '2010-01-03'] [2, '2', '2010-01-02', '2010-01-02', '2010-01-07', '2010-01-07'] The following query gets the proper result, but it seems to me extremely inefficient, having to iterate table2 for each column. Would be possible in anyway to do a subquery and reuse it? SELECT a.id, a.name, (select min(value) from table2 t where t.id = subquery.id and t.type = 1 group by t.type) as Column1, (select min(value) from table2 t where t.id = subquery.id and t.type = 2 group by t.type) as Column2, (select min(value) from table2 t where t.id = subquery.id and t.type = 3 group by t.type) as Column3, (select min(value) from table2 t where t.id = subquery.id and t.type = 4 group by t.type) as Column4 FROM (SELECT distinct id FROM table2 t WHERE (t.type in (1, 2, 3, 4)) AND t.value between '2010-01-01' and '2010-01-07') as subquery LEFT JOIN table a ON a.id = subquery.id

    Read the article

  • Boost Unit testing memory reuse causing tests that should fail to pass

    - by Knyphe
    We have started using the boost unit testing library for a large existing code base, and I have run into some trouble with unit tests incorrectly passing, seemingly due to the reuse of memory on the stack. Here is my situation: BOOST_AUTO_TEST_CASE(test_select_base_instantiation_default) { SelectBase selectBase(); BOOST_CHECK_EQUAL( selectBase.getSelectType(), false); BOOST_CHECK_EQUAL( selectBase.getTypeName(_T("")); BOOST_CHECK_EQUAL( selectBase.getEntityType(), -1); BOOST_CHECK_EQUAL( selectBase.getDataPos(), -1); } BOOST_AUTO_TEST_CASE(test_select_base_instantiation_default) { SelectBase selectBase(true, _T("abc")); BOOST_CHECK_EQUAL( selectBase.getSelectType(), false); BOOST_CHECK_EQUAL( selectBase.getTypeName(_T("abc")); BOOST_CHECK_EQUAL( selectBase.getEntityType(), -1); BOOST_CHECK_EQUAL( selectBase.getDataPos(), -1); } The first test passed correctly, initializing all the variables. The constructor in the second unit test did not correctly set EntityType or DataPosition, but the unit test passed. I was able to get it to fail by placing some variables on the stack in the second test, like so: BOOST_AUTO_TEST_CASE(test_select_base_instantiation_default) { int a, b; SelectBase selectBase(true, _T("abc")); BOOST_CHECK_EQUAL( selectBase.getSelectType(), false); BOOST_CHECK_EQUAL( selectBase.getTypeName(_T("abc")); BOOST_CHECK_EQUAL( selectBase.getEntityType(), -1); BOOST_CHECK_EQUAL( selectBase.getDataPos(), -1); } If there is only one int, only the dataPos CHECK_EQUAL fails, but if there are two, both EntityType and DataPos fail, so it seems pretty clear that this is an issue with the variables being created on the same stack memory or some such. Is there a good way to clear the memory between each unit test, or am I potentially using the library incorrectly or writing bad tests? Any help would be appreciated.

    Read the article

  • Retain, reuse, release?

    - by Typeoneerror
    I've got a series of buttons that each use a different image. Can I reuse a retained variable like this below: // set images UIImage *image = [[dice1 backgroundImageForState:UIControlStateHighlighted] retain]; [dice1 setBackgroundImage:image forState:(UIControlStateHighlighted|UIControlStateSelected)]; image = [dice2 backgroundImageForState:UIControlStateHighlighted]; [dice2 setBackgroundImage:image forState:(UIControlStateHighlighted|UIControlStateSelected)]; image = [dice3 backgroundImageForState:UIControlStateHighlighted]; [dice3 setBackgroundImage:image forState:(UIControlStateHighlighted|UIControlStateSelected)]; image = [dice4 backgroundImageForState:UIControlStateHighlighted]; [dice4 setBackgroundImage:image forState:(UIControlStateHighlighted|UIControlStateSelected)]; image = [dice5 backgroundImageForState:UIControlStateHighlighted]; [dice5 setBackgroundImage:image forState:(UIControlStateHighlighted|UIControlStateSelected)]; image = [dice6 backgroundImageForState:UIControlStateHighlighted]; [dice6 setBackgroundImage:image forState:(UIControlStateHighlighted|UIControlStateSelected)]; [image release]; or do I need to create a new UIImage for each image passed to each button's setBackgroundImage: like so: // set images UIImage *image1 = [dice1 backgroundImageForState:UIControlStateHighlighted]; [dice1 setBackgroundImage:image1 forState:(UIControlStateHighlighted|UIControlStateSelected)]; UIImage *image2 = [dice2 backgroundImageForState:UIControlStateHighlighted]; [dice2 setBackgroundImage:image forState:(UIControlStateHighlighted|UIControlStateSelected)]; and rely on autorelease rather than a retained UIImage. I'm not sure if assigning the image to a different UIImage would effect the retain count.

    Read the article

  • Linq - reuse expression on child property

    - by user175528
    Not sure if what I am trying is possible or not, but I'd like to reuse a linq expression on an objects parent property. With the given classes: class Parent { int Id { get; set; } IList<Child> Children { get; set; } string Name { get; set; } } class Child{ int Id { get; set; } Parent Dad { get; set; } string Name { get; set; } } If i then have a helper Expression<Func<Parent,bool> ParentQuery() { Expression<Func<Parent,bool> q = p => p.Name=="foo"; } I then want to use this when querying data out for a child, along the lines of: using(var context=new Entities.Context) { var data=context.Child.Where(c => c.Name=="bar" && c.Dad.Where(ParentQuery)); } I know I can do that on child collections: using(var context=new Entities.Context) { var data=context.Parent.Where(p => p.Name=="foo" && p.Childen.Where(childQuery)); } but cant see any way to do this on a property that isnt a collection. This is just a simplified example, actually the ParentQuery will be more complex and I want to avoid having this repeated in multiple places as rather than just having 2 layers I'll have closer to 5 or 6, but all of them will need to reference the parent query to ensure security.

    Read the article

  • using Silverlight 3's HtmlPage.Window.Navigate method to reuse an already open browser window

    - by Phil
    Hi, I want to use an external browser window to implement a preview functionality in a silverlight application. There is a list of items and whenever the user clicks one of these items, it's opened in a separate browser window (the content is a pdf document, which is why it is handled ouside of the SL app). Now, to achieve this, I simply use HtmlPage.Window.Navigate(new Uri("http://www.bing.com")); which works fine. Now my client doesn't like the fact that every click opens up a new browser window. He would like to see the browser window reused every time an item is clicked. So I went out and tried implementing this: Option 1 - Use the overload of the Navigate method, like so: HtmlPage.Window.Navigate(new Uri("http://www.bing.com"), "foo"); I was assuming that the window would be reused when the same target parameter value (foo) would be used in subsequent calls. This does not work. I get a new window every time. Option 2 - Use the PopupWindow method on the HtmlPage HtmlPage.PopupWindow(new Uri("http://www.bing.com"), "blah", new HtmlPopupWindowOptions()); This does not work. I get a new window every time. Option 3 - Get a handle to the opened window and reuse that in subsequent calls private HtmlWindow window; private void navigationButton_Click(object sender, RoutedEventArgs e) { if (window == null) window = HtmlPage.Window.Navigate(new Uri("http://www.bing.com"), "blah"); else window.Navigate(new Uri("http://www.bing.com"), "blah"); if (window == null) MessageBox.Show("it's null"); } This does not work. I tried the same for the PopupWindow() method and the window is null every time, so a new window is opened on every click. I have checked both the EnableHtmlAccess and the IsPopupWindowAllowed properties, and they return true, as they should. Option 4 - Use Eval method to execute some custom javascript private const string javascript = @"var popup = window.open('', 'blah') ; if(popup.location != 'http://www.bing.com' ){ popup.location = 'http://www.bing.com'; } popup.focus();"; private void navigationButton_Click(object sender, RoutedEventArgs e) { HtmlPage.Window.Eval(javascript); } This does not work. I get a new window every time. option 5 - Use CreateInstance to run some custom javascript on the page private void navigationButton_Click(object sender, RoutedEventArgs e) { HtmlPage.Window.CreateInstance("thisIsPlainHell"); } and in my aspx I have function thisIsPlainHell() { var popup = window.open('http://www.bing.com', 'blah'); popup.focus(); } Guess what? This does work. The only thing is that the window behaves a little strange and I'm not sure why: I'm behind a proxy and in all other scenarios I'm being prompted for my password. In this case however I am not (and am thus not able to reach the external site - bing in this case). This is not really a huge issue atm, but I just don't understand what's goign on here. Whenever I type another url in the address bar of the popup window (eg www.google.com) and press enter, it opens up another window and prompts me for my proxy password. As a temporary solution option 5 could do, but I don't like the fact that Silverlight is not able to manage this. One of the main reasons my client has opted for Silverlight is to be protected against all the browser specific hacking that comes with javascript. Am I doing something wrong? I'm definitely no javascript expert, so I'm hoping it's something obvious I'm missing here. Cheers, Phil

    Read the article

  • Reuse a facelet in multiple beans

    - by Seitaridis
    How do I invoke/access a property of a managed bean when the bean name is known, but is not yet constructed? For example: <p:selectOneMenu value="#{eval.evaluateAsBean(bean).text}" > <f:selectItems value="#{eval.evaluateAsBean(bean).values}" var="val" itemLabel="#{val}" itemValue="#{val}" /> </p:selectOneMenu> If there is a managed bean called testBean and in my view bean has the "testBean"value, I want the text or values property of testBean to be called. EDIT1 The context An object consists of a list of properties(values). One property is modified with a custom JSF editor, depending on its type. The list of editors is determined from the object's type, and displayed in a form using custom:include tags. This custom tag is used to dynamically include the editors <custom:include src="#{editor.component}">. The component property points to the location of the JSF editor. In my example some editors(rendered as select boxes) will use the same facelet(dynamicDropdown.xhtml). Every editor has a session scoped managed bean. I want to reuse the same facelet with multiple beans and to pass the name of the bean to dynamicDropdown.xhtml using the bean param. genericAccount.xhtml <p:dataTable value="#{group.editors}" var="editor"> <p:column headerText="Key"> <h:outputText value="#{editor.name}" /> </p:column> <p:column headerText="Value"> <h:panelGroup rendered="#{not editor.href}"> <h:outputText value="#{editor.component}" escape="false" /> </h:panelGroup> <h:panelGroup rendered="#{editor.href}"> <custom:include src="#{editor.component}"> <ui:param name="enabled" value="#{editor.enabled}"/> <ui:param name="bean" value="#{editor.bean}"/> <custom:include> </h:panelGroup> </p:column> </p:dataTable> #{editor.component} refers to a dynamicDropdown.xhtml file. dynamicDropdown.xhtml <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.prime.com.tr/ui"> <p:selectOneMenu value="#{eval.evaluateAsBean(bean).text}" > <f:selectItems value="#{eval.evaluateAsBean(bean).values}" var="val" itemLabel="#{val}" itemValue="#{val}" /> </p:selectOneMenu> </ui:composition> eval is a managed bean: @ManagedBean(name = "eval") @ApplicationScoped public class ELEvaluator { ... public Object evaluateAsBean(String el) { FacesContext context = FacesContext.getCurrentInstance(); Object bean = context.getELContext() .getELResolver().getValue(context.getELContext(), null, el); return bean; } ... }

    Read the article

  • How to customize and reuse a DataGridColumnHeader style?

    - by instcode
    Hi all, I'm trying to customize the column headers of a DataGrid to show sub-column headers as in the following screenshot: I've made a style for 2 sub-column as in the following XAML: <UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data" xmlns:primitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data" xmlns:sl="clr-namespace:UI" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" x:Class="UI.ColumnHeaderGrid" mc:Ignorable="d"> <UserControl.Resources> <Style x:Key="SplitColumnHeaderStyle" TargetType="primitives:DataGridColumnHeader"> <Setter Property="Foreground" Value="#FF000000"/> <Setter Property="HorizontalContentAlignment" Value="Center"/> <Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="IsTabStop" Value="False"/> <Setter Property="SeparatorBrush" Value="#FFC9CACA"/> <Setter Property="Padding" Value="4"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="primitives:DataGridColumnHeader"> <Grid x:Name="Root"> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <Rectangle x:Name="BackgroundRectangle" Fill="#FF1F3B53" Stretch="Fill" Grid.ColumnSpan="2"/> <Rectangle x:Name="BackgroundGradient" Stretch="Fill" Grid.ColumnSpan="2"> <Rectangle.Fill> <LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0"> <GradientStop Color="#FCFFFFFF" Offset="0.015"/> <GradientStop Color="#F7FFFFFF" Offset="0.375"/> <GradientStop Color="#E5FFFFFF" Offset="0.6"/> <GradientStop Color="#D1FFFFFF" Offset="1"/> </LinearGradientBrush> </Rectangle.Fill> </Rectangle> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition Width="1"/> <ColumnDefinition/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> <RowDefinition/> </Grid.RowDefinitions> <TextBlock Grid.Row="0" Grid.ColumnSpan="3" Text="Headers" TextAlignment="Center"/> <Rectangle Grid.Row="1" Grid.ColumnSpan="3" Fill="{TemplateBinding SeparatorBrush}" Height="1"/> <TextBlock Grid.Row="2" Grid.Column="0" Text="Header 1" TextAlignment="Center"/> <Rectangle Grid.Row="2" Grid.Column="1" Fill="{TemplateBinding SeparatorBrush}" Width="1"/> <TextBlock Grid.Row="2" Grid.Column="2" Text="Header 2" TextAlignment="Center"/> <Path x:Name="SortIcon" Grid.Column="2" Fill="#FF444444" Stretch="Uniform" HorizontalAlignment="Left" Margin="4,0,0,0" VerticalAlignment="Center" Width="8" Opacity="0" RenderTransformOrigin=".5,.5" Data="F1 M -5.215,6.099L 5.215,6.099L 0,0L -5.215,6.099 Z "/> </Grid> <Rectangle x:Name="VerticalSeparator" Fill="{TemplateBinding SeparatorBrush}" VerticalAlignment="Stretch" Width="1" Visibility="{TemplateBinding SeparatorVisibility}" Grid.Column="1"/> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </UserControl.Resources> <data:DataGrid x:Name="LayoutRoot"> <data:DataGrid.Columns> <data:DataGridTemplateColumn HeaderStyle="{StaticResource SplitColumnHeaderStyle}"> <data:DataGridTemplateColumn.CellTemplate> <DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> <Border Grid.Column="0" BorderBrush="#FFC9CACA" BorderThickness="0,0,0,0"> <TextBlock Grid.Column="0" Text="{Binding GridData.Column1}"/> </Border> <Border Grid.Column="1" BorderBrush="#FFC9CACA" BorderThickness="1,0,0,0"> <TextBlock Grid.Column="0" Text="{Binding GridData.Column2}"/> </Border> </Grid> </DataTemplate> </data:DataGridTemplateColumn.CellTemplate> </data:DataGridTemplateColumn> </data:DataGrid.Columns> </data:DataGrid> Now I want to reuse & extend this style to support 2-6 sub-column headers but I don't know if there is a way to do this, like ContentPresenter "overriding": <Style x:Key="SplitColumnHeaderStyle" TargetType="primitives:DataGridColumnHeader"> <Setter property="Template"> <Setter.Value> ... <ContentPresenter Content="{TemplateBinding Content}".../> ... </Setter.Value> </Setter> </Style> <Style x:Key="TwoSubColumnHeaderStyle" BasedOn="SplitColumnHeaderStyle"> <Setter property="Content"> <Setter.Value> <Grid 2x2.../> </Setter.Value> </Setter> </Style> <Style x:Key="ThreeSubColumnHeaderStyle" BasedOn="SplitColumnHeaderStyle"> <Setter property="Content"> <Setter.Value> <Grid 2x3.../> </Setter.Value> </Setter> </Style> Anyway, please help me on these issues: Given the template above, how to support more sub-column headers without having to create new new new new template for each? Assume that the issue above is solved. How could I attach column names outside the styles? I see that some parts, properties & visualization rules in the XAML are just copies from the original Silverlight component's style, i.e. BackgroundGradient, BackgroundRectangle, VisualStateManager... They must be there in order to support default behaviors or effects but... does anyone know how to remove them, but keep all the default behaviors/effects? Please be specific because I'm just getting start with C# & Silverlight. Thanks.

    Read the article

  • How can I write reusable Javascript?

    - by RenderIn
    I've started to wrap my functions inside of Objects, e.g.: var Search = { carSearch: function(color) { }, peopleSearch: function(name) { }, ... } This helps a lot with readability, but I continue to have issues with reusabilty. To be more specific, the difficulty is in two areas: Receiving parameters. A lot of times I will have a search screen with multiple input fields and a button that calls the javascript search function. I have to either put a bunch of code in the onclick of the button to retrieve and then martial the values from the input fields into the function call, or I have to hardcode the HTML input field names/IDs so that I can subsequently retrieve them with Javascript. The solution I've settled on for this is to pass the field names/IDs into the function, which it then uses to retrieve the values from the input fields. This is simple but really seems improper. Returning values. The effect of most Javascript calls tends to be one in which some visual on the screen changes directly, or as a result of another action performed in the call. Reusability is toast when I put these screen-altering effects at the end of a function. For example, after a search is completed I need to display the results on the screen. How do others handle these issues? Putting my thinking cap on leads me to believe that I need to have an page-specific layer of Javascript between each use in my application and the generic methods I create which are to be used application-wide. Using the previous example, I would have a search button whose onclick calls a myPageSpecificSearchFunction, in which the search field IDs/names are hardcoded, which marshals the parameters and calls the generic search function. The generic function would return data/objects/variables only, and would not directly read from or make any changes to the DOM. The page-specific search function would then receive this data back and alter the DOM appropriately. Am I on the right path or is there a better pattern to handle the reuse of Javascript objects/methods?

    Read the article

  • Why does reusing arrays increase performance so significantly in c#?

    - by Willem
    In my code, I perform a large number of tasks, each requiring a large array of memory to temporarily store data. I have about 500 tasks. At the beginning of each task, I allocate memory for an array : double[] tempDoubleArray = new double[M]; M is a large number depending on the precise task, typically around 2000000. Now, I do some complex calculations to fill the array, and in the end I use the array to determine the result of this task. After that, the tempDoubleArray goes out of scope. Profiling reveals that the calls to construct the arrays are time consuming. So, I decide to try and reuse the array, by making it static and reusing it. It requires some additional juggling to figure out the minimum size of the array, requiring an extra pass through all tasks, but it works. Now, the program is much faster (from 80 sec to 22 sec for execution of all tasks). double[] tempDoubleArray = staticDoubleArray; However, I'm a bit in the dark of why precisely this works so well. Id say that in the original code, when the tempDoubleArray goes out of scope, it can be collected, so allocating a new array should not be that hard right? I ask this because understanding why it works might help me figuring out other ways to achieve the same effect, and because I would like to know in what cases allocation gives performance issues.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >