Search Results

Search found 6328 results on 254 pages for 'anonymous person'.

Page 17/254 | < Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >

  • UndoRedo on Nodes

    - by Geertjan
    When a change is made to the property in the Properties Window, below, the undo/redo functionality becomes enabled: When undo/redo are invoked, e.g., via the buttons in the toolbar, the display name of the node changes accordingly. The only problem I have is that the buttons only become enabled when the Person Window is selected, not when the Properties Window is selected, which would be desirable. Here's the Person object: public class Person implements PropertyChangeListener {     private String name;     public static final String PROP_NAME = "name";     public Person(String name) {         this.name = name;     }     public String getName() {         return name;     }     public void setName(String name) {         String oldName = this.name;         this.name = name;         propertyChangeSupport.firePropertyChange(PROP_NAME, oldName, name);     }     private transient final PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);     public void addPropertyChangeListener(PropertyChangeListener listener) {         propertyChangeSupport.addPropertyChangeListener(listener);     }     public void removePropertyChangeListener(PropertyChangeListener listener) {         propertyChangeSupport.removePropertyChangeListener(listener);     }     @Override     public void propertyChange(PropertyChangeEvent evt) {         propertyChangeSupport.firePropertyChange(evt);     } } And here's the Node with UndoRedo enablement: public class PersonNode extends AbstractNode implements UndoRedo.Provider, PropertyChangeListener {     private UndoRedo.Manager manager = new UndoRedo.Manager();     private boolean undoRedoEvent;     public PersonNode(Person person) {         super(Children.LEAF, Lookups.singleton(person));         person.addPropertyChangeListener(this);         setDisplayName(person.getName());     }     @Override     protected Sheet createSheet() {         Sheet sheet = Sheet.createDefault();         Sheet.Set set = Sheet.createPropertiesSet();         set.put(new NameProperty(getLookup().lookup(Person.class)));         sheet.put(set);         return sheet;     }     @Override     public void propertyChange(PropertyChangeEvent evt) {         if (evt.getPropertyName().equals(Person.PROP_NAME)) {             firePropertyChange(evt.getPropertyName(), evt.getOldValue(), evt.getNewValue());         }     }     public void fireUndoableEvent(String property, Person source, Object oldValue, Object newValue) {         manager.addEdit(new MyAbstractUndoableEdit(source, oldValue, newValue));     }     @Override     public UndoRedo getUndoRedo() {         return manager;     }     @Override     public String getDisplayName() {         Person p = getLookup().lookup(Person.class);         if (p != null) {             return p.getName();         }         return super.getDisplayName();     }     private class NameProperty extends PropertySupport.ReadWrite<String> {         private Person p;         public NameProperty(Person p) {             super("name", String.class, "Name", "Name of Person");             this.p = p;         }         @Override         public String getValue() throws IllegalAccessException, InvocationTargetException {             return p.getName();         }         @Override         public void setValue(String newValue) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {             String oldValue = p.getName();             p.setName(newValue);             if (!undoRedoEvent) {                 fireUndoableEvent("name", p, oldValue, newValue);                 fireDisplayNameChange(oldValue, newValue);             }         }     }     class MyAbstractUndoableEdit extends AbstractUndoableEdit {         private final String oldValue;         private final String newValue;         private final Person source;         private MyAbstractUndoableEdit(Person source, Object oldValue, Object newValue) {             this.oldValue = oldValue.toString();             this.newValue = newValue.toString();             this.source = source;         }         @Override         public boolean canRedo() {             return true;         }         @Override         public boolean canUndo() {             return true;         }         @Override         public void undo() throws CannotUndoException {             undoRedoEvent = true;             source.setName(oldValue.toString());             fireDisplayNameChange(oldValue, newValue);             undoRedoEvent = false;         }         @Override         public void redo() throws CannotUndoException {             undoRedoEvent = true;             source.setName(newValue.toString());             fireDisplayNameChange(oldValue, newValue);             undoRedoEvent = false;         }     } } Does anyone out there know how to have the Undo/Redo functionality enabled when the Properties Window is selected?

    Read the article

  • Anonymous function vs. separate named function for initialization in jquery

    - by Martin N.
    We just had some controversial discussion and I would like to see your opinions on the issue: Let's say we have some code that is used to initialize things when a page is loaded and it looks like this: function initStuff() { ...} ... $(document).ready(initStuff); The initStuff function is only called from the third line of the snippet. Never again. Now I would say: Usually people put this into an anonymous callback like that: $(document).ready(function() { //Body of initStuff }); because having the function in a dedicated location in the code is not really helping with readability, because with the call on ready() makes it obvious, that this code is initialization stuff. Would you agree or disagree with that decision? And why? Thank you very much for your opinion!

    Read the article

  • EPM 11.1.2 - Receive Anonymous Level Security token message in IE8 when trying to access Shared Services or Workspace URL

    - by Ahmed A
    If you get "Receive Anonymous Level Security token" message in IE8 when trying to access Shared Services or Workspace URL.Workaround:a. Go to Start > Run and enter dcomcnfgb. Expand Component Services, Expand Computers and right click on My Computer and select Propertiesc. Click on the Default Properties tab.  Change the Default Authentication Level to Connect.  Click apply and then OK.d. Launch the IE browser again and you will be able to access the URL.

    Read the article

  • How to be anonymous on IPV6 protocol by not using MAC address in EUI-64?

    - by iugamarian
    The IPV6 protocol has a feature called "Extended Unique Identifier" or EUI-64 witch in short uses the MAC address of the network card when choosing an IPV6 Adress. Proof: http://www.youtube.com/watch?v=30CnqRK0GHE&NR=1 at 7:36 video time. If you want to be anonymous on the internet (so that nobody can find you when you download something, etc.) you need this EUI-64 to be bipassed in order for the MAC address not to be discovered by harmful third parties on the internet and for privacy. How do you avoid EUI-64 MAC address usage in IPV6 selection in Ubuntu? Also for DHCP IPV6?

    Read the article

  • How do I configure Mediawiki on EC2 if anonymous browsing is disabled?

    - by Feasoron
    So I have new MediaWiki instance install on a brand new Amazon EC2 instances. All is going swimmingly, until I have to log in via the web browser to configure it. Since I'm running on a hosted server, I can't hit http://localhost/mediawiki/config/index.php like the instructions say to. If I try to hit it via http://<My IP address>/mediawiki/config/index.php, my browser just tries to download the file because anonymous browsing isn't enabled. I seem to be before LocalSettings.php is created, so I don't know how to move forward from here.

    Read the article

  • Populate Multiple PDFs

    - by gmcalab
    I am using itextsharp to populate my PDFs. I have no issues with this. Basically what I am doing is getting the PDF and populating the fields in memory then passing back the MemoryStream to be displayed on a webpage. All this is working with a single document PDF. What I am trying to figure out now, is merging multiple PDFs into one MemoryStream. The part I cant figure out is, the documents I am populating are identical. So for example, I have a List<Person> that contains 5 persons. I want to fill out a PDF for each person and merge them all into one, in memory. Bare in mind I am going to fill out the same type of document for each person. The problem I am getting is that when I try to add a second copy of the same PDF to be filled out for the second iteration, it just overwrites the first populated PDF, since it's the same document, therefore not adding a second copy for the second Person at all. So basically if I had the 5 people, I would end up with a single page with the data of the 5th person, instead of a PDF with 5 like pages that contain the data of each person respectively. Here's some code... MemoryStream ms = ms = new MemoryStream(); PdfReader docReader = null; PdfStamper Stamper = null; List<Person> persons = new List<Person>() { new Person("Larry", "David"), new Person("Dustin", "Byfuglien"), new Person("Patrick", "Kane"), new Person("Johnathan", "Toews"), new Person("Marian", "Hossa") }; try { // Iterate thru all persons and populate a PDF for each foreach(var person in persons){ PdfCopyFields Copier = new PdfCopyFields(ms); Copier.AddDocument(GetReader("Person.pdf")); Copier.Close(); docReader = new PdfReader(ms.ToArray()); Stamper = new PdfStamper(docReader, ms); AcroFields Fields = Stamper.AcroFields; Fields.SetField("FirstName", person.FirstName); } }catch(Exception e){ // handle error }finally{ if (Stamper != null) { Stamper.Close(); } if (docReader != null) { docReader.Close(); } }

    Read the article

  • BDD for C# NUnit

    - by mjezzi
    I've been using a home brewed BDD Spec extension for writing BDD style tests in NUnit, and I wanted to see what everyone thought. Does it add value? Does is suck? If so why? Is there something better out there? Here's the source: https://github.com/mjezzi/NSpec There are two reasons I created this To make my tests easy to read. To produce a plain english output to review specs. Here's an example of how a test will look: -since zombies seem to be popular these days.. Given a Zombie, Peson, and IWeapon: namespace Project.Tests.PersonVsZombie { public class Zombie { } public interface IWeapon { void UseAgainst( Zombie zombie ); } public class Person { private IWeapon _weapon; public bool IsStillAlive { get; set; } public Person( IWeapon weapon ) { IsStillAlive = true; _weapon = weapon; } public void Attack( Zombie zombie ) { if( _weapon != null ) _weapon.UseAgainst( zombie ); else IsStillAlive = false; } } } And the NSpec styled tests: public class PersonAttacksZombieTests { [Test] public void When_a_person_with_a_weapon_attacks_a_zombie() { var zombie = new Zombie(); var weaponMock = new Mock<IWeapon>(); var person = new Person( weaponMock.Object ); person.Attack( zombie ); "It should use the weapon against the zombie".ProveBy( spec => weaponMock.Verify( x => x.UseAgainst( zombie ), spec ) ); "It should keep the person alive".ProveBy( spec => Assert.That( person.IsStillAlive, Is.True, spec ) ); } [Test] public void When_a_person_without_a_weapon_attacks_a_zombie() { var zombie = new Zombie(); var person = new Person( null ); person.Attack( zombie ); "It should cause the person to die".ProveBy( spec => Assert.That( person.IsStillAlive, Is.False, spec ) ); } } You'll get the Spec output in the output window: [PersonVsZombie] - PersonAttacksZombieTests When a person with a weapon attacks a zombie It should use the weapon against the zombie It should keep the person alive When a person without a weapon attacks a zombie It should cause the person to die 2 passed, 0 failed, 0 skipped, took 0.39 seconds (NUnit 2.5.5).

    Read the article

  • XSLT: How to remove the self-closed elment

    - by Daoming Yang
    I have a large xml file which contents a lot of self-closed tags. How could remove all them by using XSLT. eg. <?xml version="1.0" encoding="utf-8" ?> <Persons> <Person> <Name>user1</Name> <Tel /> <Mobile>123</Mobile> </Person> <Person> <Name>user2</Name> <Tel>456</Tel> <Mobile /> </Person> <Person> <Name /> <Tel>123</Tel> <Mobile /> </Person> <Person> <Name>user4</Name> <Tel /> <Mobile /> </Person> </Persons> I'm expecting the result: <?xml version="1.0" encoding="utf-8" ?> <Persons> <Person> <Name>user1</Name> <Mobile>123</Mobile> </Person> <Person> <Name>user2</Name> <Tel>456</Tel> </Person> <Person> <Tel>123</Tel> </Person> <Person> <Name>user4</Name> </Person> </Persons> Note: there are thousands of different elements, how can I programmatically remove all the self-closed tags. Another question is how to remove the empty element such as <name></name> as well. Can anyone help me on this? Many thanks.

    Read the article

  • How to join two collections with LINQ

    - by JustinGreenwood
    Here is a simple and complete example of how to perform joins on two collections with LINQ. I wrote it for a friend to show him, in one simple file, the power of LINQ queries and anonymous objects. In the file below, there are two simple data classes defined: Person and Item. In the beginning of the main method, two collections are created. Note that the Item's OwnerId field reference the PersonId of a Person object. The effect of the LINQ query below is equivalent to a SQL statement looking like this: select Person.PersonName as OwnerName, Item.ItemName as OwnedItem from Person inner join Item on Item.OwnerId = Person.PersonId order by Item.ItemName desc; using System; using System.Collections.Generic; using System.Linq; namespace LinqJoinAnonymousObjects { class Program { class Person { public int PersonId { get; set; } public string PersonName { get; set; } } class Item { public string ItemName { get; set; } public int OwnerId { get; set; } } static void Main(string[] args) { // Create two collections: one of people, and another with their possessions. var people = new List<Person> { new Person { PersonId=1, PersonName="Justin" }, new Person { PersonId=2, PersonName="Arthur" }, new Person { PersonId=3, PersonName="Bob" } }; var items = new List<Item> { new Item { OwnerId=1, ItemName="Armor" }, new Item { OwnerId=1, ItemName="Book" }, new Item { OwnerId=2, ItemName="Chain Mail" }, new Item { OwnerId=2, ItemName="Excalibur" }, new Item { OwnerId=3, ItemName="Bubbles" }, new Item { OwnerId=3, ItemName="Gold" } }; // Create a new, anonymous composite result for person id=2. var compositeResult = from p in people join i in items on p.PersonId equals i.OwnerId where p.PersonId == 2 orderby i.ItemName descending select new { OwnerName = p.PersonName, OwnedItem = i.ItemName }; // The query doesn't evaluate until you iterate through the query or convert it to a list Console.WriteLine("[" + compositeResult.GetType().Name + "]"); // Convert to a list and loop through it. var compositeList = compositeResult.ToList(); Console.WriteLine("[" + compositeList.GetType().Name + "]"); foreach (var o in compositeList) { Console.WriteLine("\t[" + o.GetType().Name + "] " + o.OwnerName + " - " + o.OwnedItem); } Console.ReadKey(); } } } The output of the program is below: [WhereSelectEnumerableIterator`2] [List`1] [<>f__AnonymousType1`2] Arthur - Excalibur [<>f__AnonymousType1`2] Arthur - Chain Mail

    Read the article

  • Is browser fingerprinting a viable technique for identifying anonymous users?

    - by SMrF
    Is browser fingerprinting a sufficient method for uniquely identifying anonymous users? What if you incorporate biometric data like mouse gestures or typing patterns? The other day I ran into the Panopticlick experiment EFF is running on browser fingerprints. Of course I immediately thought of the privacy repercussions and how it could be used for evil. But on the other hand, this could be used for great good and, at the very least, it's a tempting problem to work on. While researching the topic I found a few companies using browser fingerprinting to attack fraud. And after sending out a few emails I can confirm at least one major dating site is using browser fingerprinting as but one mechanism to detect fake accounts. (Note: They have found it's not unique enough to act as an identity when scaling up to millions of users. But, my programmer brain doesn't want to believe them). Here is one company using browser fingerprints for fraud detection and prevention: http://www.bluecava.com/ Here is a pretty comprehensive list of stuff you can use as unique identifiers in a browser: http://browserspy.dk/

    Read the article

  • I'm getting an error in my Java code but I can't see whats wrong with it. Help?

    - by Fraz
    The error i'm getting is in the fillPayroll() method in the while loop where it says payroll.add(employee). The error says I can't invoke add() on an array type Person but the Employee class inherits from Person so I thought this would be possible. Can anyone clarify this for me? import java.io.*; import java.util.*; public class Payroll { private int monthlyPay, tax; private Person [] payroll = new Person [1]; //Method adds person to payroll array public void add(Person person) { if(payroll[0] == null) //If array is empty, fill first element with person { payroll[payroll.length-1] = person; } else //Creates copy of payroll with new person added { Person [] newPayroll = new Person [payroll.length+1]; for(int i = 0;i<payroll.length;i++) { newPayroll[i] = payroll[i]; } newPayroll[newPayroll.length] = person; payroll = newPayroll; } } public void fillPayroll() { try { FileReader fromEmployee = new FileReader ("EmployeeData.txt"); Scanner data = new Scanner(fromEmployee); Employee employee = new Employee(); while (data.hasNextLine()) { employee.readData(data.nextLine()); payroll.add(employee); } } catch (FileNotFoundException e) { System.out.println("Error: File Not Found"); } } }

    Read the article

  • Help with Hashmaps in Java

    - by Crystal
    I'm not sure how I use get() to get my information. Looking at my book, they pass the key to get(). I thought that get() returns the object associated with that key looking at the documentation. But I must be doing something wrong here.... Any thoughts? import java.util.*; public class OrganizeThis { /** Add a person to the organizer @param p A person object */ public void add(Person p) { staff.put(p, p.getEmail()); System.out.println("Person " + p + "added"); } /** * Find the person stored in the organizer with the email address. * Note, each person will have a unique email address. * * @param email The person email address you are looking for. * */ public Person findByEmail(String email) { Person aPerson = staff.get(email); return aPerson; } private Map<Person, String> staff = new HashMap<Person, String>(); public static void main(String[] args) { OrganizeThis testObj = new OrganizeThis(); Person person1 = new Person("J", "W", "111-222-3333", "[email protected]"); testObj.add(person1); System.out.println(testObj.findByEmail("[email protected]")); } }

    Read the article

  • ASP.NET MVC - How to Unit Test boundaries in the Repository pattern?

    - by JK
    Given a basic repository interface: public interface IPersonRepository { void AddPerson(Person person); List<Person> GetAllPeople(); } With a basic implementation: public class PersonRepository: IPersonRepository { public void AddPerson(Person person) { ObjectContext.AddObject(person); } public List<Person> GetAllPeople() { return ObjectSet.AsQueryable().ToList(); } } How can you unit test this in a meaningful way? Since it crosses the boundary and physically updates and reads from the database, thats not a unit test, its an integration test. Or is it wrong to want to unit test this in the first place? Should I only have integration tests on the repository? I've been googling the subject and blogs often say to make a stub that implements the IRepository: public class PersonRepositoryTestStub: IPersonRepository { private List<Person> people = new List<Person>(); public void AddPerson(Person person) { people.Add(person); } public List<Person> GetAllPeople() { return people; } } But that doesnt unit test PersonRepository, it tests the implementation of PersonRepositoryTestStub (not very helpful).

    Read the article

  • How do I alias the scala setter method 'myvar_$(myval)' to something more pleasing when in java?

    - by feydr
    I've been converting some code from java to scala lately trying to tech myself the language. Suppose we have this scala class: class Person() { var name:String = "joebob" } Now I want to access it from java so I can't use dot-notation like I would if I was in scala. So I can get my var's contents by issuing: person = Person.new(); System.out.println(person.name()); and set it via: person = Person.new(); person.name_$eq("sallysue"); System.out.println(person.name()); This holds true cause our Person Class looks like this in javap: Compiled from "Person.scala" public class Person extends java.lang.Object implements scala.ScalaObject{ public Person(); public void name_$eq(java.lang.String); public java.lang.String name(); public int $tag() throws java.rmi.RemoteException; } Yes, I could write my own getters/setters but I hate filling classes up with that and it doesn't make a ton of sense considering I already have them -- I just want to alias the _$eq method better. (This actually gets worse when you are dealing with stuff like antlr because then you have to escape it and it ends up looking like person.name_\$eq("newname"); Note: I'd much rather have to put up with this rather than fill my classes with more setter methods. So what would you do in this situation?

    Read the article

  • How do I alias the scala setter method 'myvar_$eq(myval)' to something more pleasing when in java?

    - by feydr
    I've been converting some code from java to scala lately trying to teach myself the language. Suppose we have this scala class: class Person() { var name:String = "joebob" } Now I want to access it from java so I can't use dot-notation like I would if I was in scala. So I can get my var's contents by issuing: person = Person.new(); System.out.println(person.name()); and set it via: person = Person.new(); person.name_$eq("sallysue"); System.out.println(person.name()); This holds true cause our Person Class looks like this in javap: Compiled from "Person.scala" public class Person extends java.lang.Object implements scala.ScalaObject{ public Person(); public void name_$eq(java.lang.String); public java.lang.String name(); public int $tag() throws java.rmi.RemoteException; } Yes, I could write my own getters/setters but I hate filling classes up with that and it doesn't make a ton of sense considering I already have them -- I just want to alias the _$eq method better. (This actually gets worse when you are dealing with stuff like antlr because then you have to escape it and it ends up looking like person.name_\$eq("newname"); Note: I'd much rather have to put up with this rather than fill my classes with more setter methods. So what would you do in this situation?

    Read the article

  • JavaScript setTimeout setInterval within one function

    - by dagoof
    I think I might be overtired but I cannot for the life of me make sense of this, and I think it's due to a lack of knowledge of javascript var itv=function(){ return setInterval(function(){ sys.puts('interval'); }, 1000); } var tout=function(itv){ return setTimeout(function(){ sys.puts('timeout'); clearInterval(itv); }, 5500); } With these two functions I can call a=tout(itv()); and get a looping timer to run for 5.5 seconds and then exit, essentially. By my logic, this should work but it simply is not var dotime=function(){ return setTimeout(function(){ clearInterval(function(){ return setInterval(function(){ sys.puts("interval"); }, 1000); }); }, 5500); } any insight in this matter would be appreciated.

    Read the article

  • Named Function Expressions in IE, part 2

    - by Polshgiant
    I asked this question a while back and was happy with the accepted answer. I just now realized, however, that the following technique: var testaroo = 0; (function executeOnLoad() { if (testaroo++ < 5) { setTimeout(executeOnLoad, 25); return; } alert(testaroo); // alerts "6" })(); returns the result I expect. If T.J.Crowder's answer from my first question is correct, then shouldn't this technique not work?

    Read the article

  • Func<sometype,bool> to Func<T,bool>

    - by user175528
    If i have: public static Func<SomeType, bool> GetQuery() { return a => a.Foo=="Bar"; } and a generic version public static Func<T, bool> GetQuery<T>() { return (Func<T,bool>)GetQuery(); } how can I do the case? The only way I have found so far is to try and combine it with a mock function: Func<T, bool> q=a => true; return (Func<T, bool>)Delegate.Combine(GetQuery(), q); I know how to do that with Expression.Lambda, but I need to work with plain functions, not expression trees

    Read the article

  • setting up subreport in ireport using XML datasource

    - by shyam
    can anyone explain in detail(if possible with screen shorts) how to add subreport (one to many relation) this being the xml data source <addressbook> <category name="home"> <person id="1"> <LASTNAME>Davolio</LASTNAME> <FIRSTNAME>Nancy</FIRSTNAME> <hobbies> <hobby>Radio Control</hobby> <hobby>R/C Cars</hobby> <hobby>Micro R/C Cars</hobby> <hobby>Die-Cast Models</hobby> </hobbies> <email>[email protected]</email> <email>[email protected]</email> </person> <person id="2"> <LASTNAME>Fuller</LASTNAME> <FIRSTNAME>Andrew</FIRSTNAME> <email>[email protected]</email> <email>[email protected]</email> </person> <person id="3"> <LASTNAME>Leverling</LASTNAME> <FIRSTNAME>Janet</FIRSTNAME> <hobbies> <hobby>Rockets</hobby> <hobby>Puzzles</hobby> <hobby>Science Hobby</hobby> <hobby>Toy Horse</hobby> </hobbies> <email>[email protected]</email> <email>[email protected]</email> </person> </category> <category name="work"> <person id="4"> <LASTNAME>Peacock</LASTNAME> <FIRSTNAME>Margaret</FIRSTNAME> <hobbies> <hobby>Toy Horse</hobby> </hobbies> <email>[email protected]</email> </person> <person id="5"> <LASTNAME>Buchanan</LASTNAME> <FIRSTNAME>Steven</FIRSTNAME> <hobbies> </hobbies> <email>[email protected]</email> </person> <person id="6"> <LASTNAME>Suyama</LASTNAME> <FIRSTNAME>Michael</FIRSTNAME> </person> <person id="7"> <LASTNAME>King</LASTNAME> <FIRSTNAME>Robert</FIRSTNAME> </person> </category> <category name="Other"> <person id="8"> <LASTNAME>Callahan</LASTNAME> <FIRSTNAME>Laura</FIRSTNAME> <email>[email protected]</email> </person> <person id="9"> <LASTNAME>Dodsworth</LASTNAME> <email>[email protected]</email> </person> </category> </addressbook>

    Read the article

  • Trouble with LINQ databind to GridView and RowDataBound

    - by Michael
    Greetings all, I am working on redesigning my personal Web site using VS 2008 and have chosen to use LINQ to create by data-access layer. Part of my site will be a little app to help manage my budget better. My first LINQ query does successfully execute and display in a GridView, but when I try to use a RowDataBound event to work with the results and refine them a bit, I get the error: The type or namespace name 'var' could not be found (are you missing a using directive or an assembly reference?) This interesting part is, if I just try to put in a var s = "s"; anywhere else in the same file, I get the same error too. If I go to other files in the web project, var s = "s"; compiles fine. Here is the LINQ Query call: public static IQueryable pubGetRecentTransactions(int param_accountid) { clsDataContext db; db = new clsDataContext(); var query = from d in db.tblMoneyTransactions join p in db.tblMoneyTransactions on d.iParentTransID equals p.iTransID into dp from p in dp.DefaultIfEmpty() where d.iAccountID == param_accountid orderby d.dtTransDate descending, d.iTransID ascending select new { d.iTransID, d.dtTransDate, sTransDesc = p != null ? p.sTransDesc : d.sTransDesc, d.sTransMemo, d.mTransAmt, d.iCheckNum, d.iParentTransID, d.iReconciled, d.bIsTransfer }; return query; } protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { this.prvLoadData(); } } internal void prvLoadData() { prvCtlGridTransactions.DataSource = clsMoneyTransactions.pubGetRecentTransactions(2); prvCtlGridTransactions.DataBind(); } protected void prvCtlGridTransactions_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var datarow = e.Row.DataItem; var s = "s"; e.Row.Cells[0].Text = datarow.dtTransDate.ToShortDateString(); e.Row.Cells[1].Text = datarow.sTransDesc; e.Row.Cells[2].Text = datarow.mTransAmt.ToString("c"); e.Row.Cells[3].Text = datarow.iReconciled.ToString(); }//end if }//end RowDataBound My googling to date hasn't found a good answer, so I turn it over to this trusted community. I appreciate your time in assisting me.

    Read the article

  • "Decompile" Javascript function? *ADVANCED*

    - by caesar2k
    [1] Ok, I don't even know how to call this, to be honest. So let me get some semi-pseudo code, to show what I'm trying to do. I'm using jquery to get an already existing script declared inside the page, inside a createDocument() element, from an AJAX call. GM_xmlhttprequest({ ... load:function(r){ var doc = document_from_string(r.responseText); script_content = $('body script:regex(html, local_xw_sig)', doc).html(); var scriptEl = document.createElement('script'); scriptEl.type = 'text/javascript'; scriptEl.innerHTML = script_content; // good till here (function(sc){ eval(sc.innerHTML); // not exactly like this, but you get the idea, errors alert('wont get here ' + local_xw_sig); // local_xw_sig is a global "var" inside the source })(scriptEl); } }); so far so good, the script indeed contains the source from the entire script block. Now, inside this "script_content", there are auto executing functions, like $(document).ready(function(){...}) that, everything I "eval" the innerHTML, it executes this code, halting my encapsulated script. like variables that doesn't exist, etc removing certain parts of the script using regex isn't really an option... what I really wanted is to "walk" inside the function. like do a (completely fictional): script = eval("function(){" + script_content + "};"); alert(script['local_xw_sig']); // a03ucc34095cw3495 is there any way to 'disassemble' the function, and be able to reach the "var"s inside of it? like this function: function hello(){ var message = "hello"; } alert(hello.message); // message = var inside the function is it possible at all? or I will have to hack my way using regex? ;P [2] also, is there any way I can access javascript inside a document created with "createDocument"?

    Read the article

  • If I select from an IQueryable then the Include is lost

    - by Connor Murphy
    The include does not work after I perform a select on the IQueryable query. Is there a way arround this? My query is public IQueryable<Network> GetAllNetworks() { var query = (from n in _db.NetworkSet .Include("NetworkContacts.Contact") .Include("NetworkContacts.Contact.RelationshipSource.Target") .Include("NetworkContacts.Contact.RelationshipSource.Source") select (n)); return query;; } I then try to populate mya ViewModel in my WebUI layer using the following code var projectedNetworks = from n in GetAllNetworks() select new NetworkViewModel { Name = n.Name, Contacts = from contact in networkList .SelectMany(nc => nc.NetworkContacts) .Where(nc => nc.Member == true) .Where(nc => nc.NetworkId == n.ID) .Select(c => c.Contact) select contact, }; return projectedNetworks; The problem now occurs in my newly createdNetworkViewModel The Contacts object does include any loaded data for RelationshipSource.Target or RelationshipSource.Source The data should is there when run from the original Repository IQueryable object. However the related include data does not seem to get transferred into the new Contacts collection that is created from this IQueryable using the Select New {} code above. Is there a way to preserve this Include data when it gets passed into a new object?

    Read the article

  • Changing color of HighlighBrushKey in XAML

    - by phil
    Hi, I have the following problem. The background color in a ListView is set LightGreen or White, whether a boolflag is true or false. Example Screen Window1.xaml: <Window.Resources> <Style TargetType="{x:Type ListViewItem}"> <Style.Triggers> <DataTrigger Binding="{Binding Path=BoolFlag}" Value="True"> <Setter Property="Background" Value="LightGreen" /> </DataTrigger> </Style.Triggers> </Style> </Window.Resources> <StackPanel> <ListView ItemsSource="{Binding Path=Personen}" SelectionMode="Single" SelectionChanged="ListViewSelectionChanged"> <ListView.View> <GridView> <GridViewColumn DisplayMemberBinding="{Binding Path=Vorname}" Header="Vorname" /> <GridViewColumn DisplayMemberBinding="{Binding Path=Nachname}" Header="Nachname" /> <GridViewColumn DisplayMemberBinding="{Binding Path=Alter}" Header="Alter" /> <GridViewColumn DisplayMemberBinding="{Binding Path=BoolFlag}" Header="BoolFlag" /> </GridView> </ListView.View> </ListView> </StackPanel> Window1.xaml.cs: public partial class Window1 : Window { private IList<Person> _personen = new List<Person>(); public Window1() { _personen.Add(new Person { Vorname = "Max", Nachname = "Mustermann", Alter = 18, BoolFlag = false, }); _personen.Add(new Person { Vorname = "Karl", Nachname = "Mayer", Alter = 27, BoolFlag = true, }); _personen.Add(new Person { Vorname = "Josef", Nachname = "Huber", Alter = 38, BoolFlag = false, }); DataContext = this; InitializeComponent(); } public IList<Person> Personen { get { return _personen; } } private void ListViewSelectionChanged(object sender, SelectionChangedEventArgs e) { Person person = e.AddedItems[0] as Person; if (person != null) { if (person.BoolFlag) { this.Resources[SystemColors.HighlightBrushKey] = Brushes.Green; } else { this.Resources[SystemColors.HighlightBrushKey] = Brushes.RoyalBlue; } } } } Person.cs: public class Person { public string Vorname { get; set; } public string Nachname { get; set; } public int Alter { get; set; } public bool BoolFlag { get; set; } } Now I want to set the highlight color of the selected item, depending on the boolflag. In Code-Behind I do this with: private void ListViewSelectionChanged(object sender, SelectionChangedEventArgs e) { Person person = e.AddedItems[0] as Person; if (person != null) { if (person.BoolFlag) { this.Resources[SystemColors.HighlightBrushKey] = Brushes.Green; } else { this.Resources[SystemColors.HighlightBrushKey] = Brushes.RoyalBlue; } } } } This works fine, but now I want to define the code above in the XAML-file. With <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Green" /> I can overwrite the default-value. However, it works, but the color is set to Green for all selected items. I have tried different ways to switch the color of HighlightBrushKey between Green and Blue in XAML, depending on the boolflag, but I didn't succeed. May you can help me and give me some examples?

    Read the article

  • Basic Java Multi-Threading Question

    - by Veered
    When an object is instantiated in Java, is it bound to the thread that instantiated in? Because when I anonymously implement an interface in one thread, and pass it to another thread to be run, all of its methods are run in the original thread. If they are bound to their creation thread, is there anyway to create an object that will run in whatever thread calls it?

    Read the article

  • Issue with translating a delegate function from c# to vb.net for use with Google OAuth 2

    - by Jeremy
    I've been trying to translate a Google OAuth 2 example from C# to Vb.net for a co-worker's project. I'm having on end of issues translating the following methods: private OAuth2Authenticator<WebServerClient> CreateAuthenticator() { // Register the authenticator. var provider = new WebServerClient(GoogleAuthenticationServer.Description); provider.ClientIdentifier = ClientCredentials.ClientID; provider.ClientSecret = ClientCredentials.ClientSecret; var authenticator = new OAuth2Authenticator<WebServerClient>(provider, GetAuthorization) { NoCaching = true }; return authenticator; } private IAuthorizationState GetAuthorization(WebServerClient client) { // If this user is already authenticated, then just return the auth state. IAuthorizationState state = AuthState; if (state != null) { return state; } // Check if an authorization request already is in progress. state = client.ProcessUserAuthorization(new HttpRequestInfo(HttpContext.Current.Request)); if (state != null && (!string.IsNullOrEmpty(state.AccessToken) || !string.IsNullOrEmpty(state.RefreshToken))) { // Store and return the credentials. HttpContext.Current.Session["AUTH_STATE"] = _state = state; return state; } // Otherwise do a new authorization request. string scope = TasksService.Scopes.TasksReadonly.GetStringValue(); OutgoingWebResponse response = client.PrepareRequestUserAuthorization(new[] { scope }); response.Send(); // Will throw a ThreadAbortException to prevent sending another response. return null; } The main issue being this line: var authenticator = new OAuth2Authenticator<WebServerClient>(provider, GetAuthorization) { NoCaching = true }; The Method signature reads as for this particular line reads as follows: Public Sub New(tokenProvider As TClient, authProvider As System.Func(Of TClient, DotNetOpenAuth.OAuth2.IAuthorizationState)) My understanding of Delegate functions in VB.net isn't the greatest. However I have read over all of the MSDN documentation and other relevant resources on the web, but I'm still stuck as to how to translate this particular line. So far all of my attempts have resulted in either the a cast error (see below) or no call to GetAuthorization. The Code (vb.net on .net 3.5) Private Function CreateAuthenticator() As OAuth2Authenticator(Of WebServerClient) ' Register the authenticator. Dim client As New WebServerClient(GoogleAuthenticationServer.Description, oauth.ClientID, oauth.ClientSecret) Dim authDelegate As Func(Of WebServerClient, IAuthorizationState) = AddressOf GetAuthorization Dim authenticator = New OAuth2Authenticator(Of WebServerClient)(client, authDelegate) With {.NoCaching = True} 'Dim authenticator = New OAuth2Authenticator(Of WebServerClient)(client, GetAuthorization(client)) With {.NoCaching = True} 'Dim authenticator = New OAuth2Authenticator(Of WebServerClient)(client, New Func(Of WebServerClient, IAuthorizationState)(Function(c) GetAuthorization(c))) With {.NoCaching = True} 'Dim authenticator = New OAuth2Authenticator(Of WebServerClient)(client, New Func(Of WebServerClient, IAuthorizationState)(AddressOf GetAuthorization)) With {.NoCaching = True} Return authenticator End Function Private Function GetAuthorization(arg As WebServerClient) As IAuthorizationState ' If this user is already authenticated, then just return the auth state. Dim state As IAuthorizationState = AuthState If (Not state Is Nothing) Then Return state End If ' Check if an authorization request already is in progress. state = arg.ProcessUserAuthorization(New HttpRequestInfo(HttpContext.Current.Request)) If (state IsNot Nothing) Then If ((String.IsNullOrEmpty(state.AccessToken) = False Or String.IsNullOrEmpty(state.RefreshToken) = False)) Then ' Store Credentials HttpContext.Current.Session("AUTH_STATE") = state _state = state Return state End If End If ' Otherwise do a new authorization request. Dim scope As String = AnalyticsService.Scopes.AnalyticsReadonly.GetStringValue() Dim _response As OutgoingWebResponse = arg.PrepareRequestUserAuthorization(New String() {scope}) ' Add Offline Access and forced Approval _response.Headers("location") += "&access_type=offline&approval_prompt=force" _response.Send() ' Will throw a ThreadAbortException to prevent sending another response. Return Nothing End Function The Cast Error Server Error in '/' Application. Unable to cast object of type 'DotNetOpenAuth.OAuth2.AuthorizationState' to type 'System.Func`2[DotNetOpenAuth.OAuth2.WebServerClient,DotNetOpenAuth.OAuth2.IAuthorizationState]'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidCastException: Unable to cast object of type 'DotNetOpenAuth.OAuth2.AuthorizationState' to type 'System.Func`2[DotNetOpenAuth.OAuth2.WebServerClient,DotNetOpenAuth.OAuth2.IAuthorizationState]'. I've spent the better part of a day on this, and it's starting to drive me nuts. Help is much appreciated.

    Read the article

< Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >