Search Results

Search found 4755 results on 191 pages for 'scripting dictionary'.

Page 14/191 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • Specify a custom dictionary for FxCop and Visual Studio source analysis

    - by Marko Apfel
    Renaming the default custom dictionary from CustomDictionary.xml to an other name – for instance FxCop.CustomDictionary.xml needs some additional changes to work in involved applications. Visual Studio Team System code analysis For Visual Studio Team System code analysis this file should be added as a link to all projects and setted to be the Build Action CodeAnalysisDirectory. Build target In a build target the command line tool FxCopCmd should be called with the /dictionary parameter: <Target Name="FxCop"> <Exec Command="&quot;$(ProjectDir)..\..\build\FxCop\FxCopCmd.exe&quot; /file:&quot;$(TargetPath)&quot; /project:&quot;$(ProjectDir)..\EsriDE.SfgPraxair.FxCop&quot; /directory:&quot;$(ProjectDir)..\..\lib\Esri.ArcGIS&quot; /directory:&quot;$(ProjectDir)..\..\lib\Microsoft&quot; /dictionary:&quot;$(ProjectDir)..\FxCop.CustomDictionary.xml&quot; /out:&quot;$(OutDir)..\$(ProjectName).FxCopReport.xml&quot; /console /forceoutput /ignoregeneratedcode"> </Exec> <Message Text="FxCop finished." /> </Target> FxCop-GUI (standalone application) In FxCop-GUI is no option to specify an own file name – but you could add a hint in the FxCop project file. Open your this file and look for the line: <CustomDictionaries SearchFxCopDir="True" SearchUserProfile="True" SearchProjectDir="True" /> Then change it to: <CustomDictionaries SearchFxCopDir="True" SearchUserProfile="True" SearchProjectDir="True"> <CustomDictionary Path="FxCop.CustomDictionary.xml"/> </CustomDictionaries> Ready :-)

    Read the article

  • Switch or a Dictionary when assigning to new object

    - by KChaloux
    Recently, I've come to prefer mapping 1-1 relationships using Dictionaries instead of Switch statements. I find it to be a little faster to write and easier to mentally process. Unfortunately, when mapping to a new instance of an object, I don't want to define it like this: var fooDict = new Dictionary<int, IBigObject>() { { 0, new Foo() }, // Creates an instance of Foo { 1, new Bar() }, // Creates an instance of Bar { 2, new Baz() } // Creates an instance of Baz } var quux = fooDict[0]; // quux references Foo Given that construct, I've wasted CPU cycles and memory creating 3 objects, doing whatever their constructors might contain, and only ended up using one of them. I also believe that mapping other objects to fooDict[0] in this case will cause them to reference the same thing, rather than creating a new instance of Foo as intended. A solution would be to use a lambda instead: var fooDict = new Dictionary<int, Func<IBigObject>>() { { 0, () => new Foo() }, // Returns a new instance of Foo when invoked { 1, () => new Bar() }, // Ditto Bar { 2, () => new Baz() } // Ditto Baz } var quux = fooDict[0](); // equivalent to saying 'var quux = new Foo();' Is this getting to a point where it's too confusing? It's easy to miss that () on the end. Or is mapping to a function/expression a fairly common practice? The alternative would be to use a switch: IBigObject quux; switch(someInt) { case 0: quux = new Foo(); break; case 1: quux = new Bar(); break; case 2: quux = new Baz(); break; } Which invocation is more acceptable? Dictionary, for faster lookups and fewer keywords (case and break) Switch: More commonly found in code, doesn't require the use of a Func< object for indirection.

    Read the article

  • How to write scripts that can run in bash and csh?

    - by Victor Liu
    I'm not sure if this is even possible, but is there a way to write shell scripts that can be interpreted by both the Bourne shell as well as C shell? I want to avoid simply checking for the shell and running a shell-specific code. If this is possible, are there any guides on how to do it? I have always written my scripts for Bourne shell syntax, and I know next to nothing about csh, so this may be a stupid question. I have Google'd for the differences between shells, but there is little information (as far as I can tell) on its implications for scripting.

    Read the article

  • Auto SSH and execute script

    - by rohanbk
    I have roughly 12 computers that each have the same script on them. This script merely pings all the other machines, and prints out whether the machine is "reachable" or "unreachable". However, it is inefficient to login to each machine manually using ssh to execute this script. Suppose I'm logged into node 1. Is there any way to for me to login to node 2-12 automatically using SSH, execute the ping script, pipe the results to a file, logout and proceed to the next machine? Some kind of bash shell script? I'm afraid I'm at a loss here since I haven't had experience with shell-scripting before.

    Read the article

  • Hashtable/Dictionary but with key composed of multiple values?

    - by MC
    Lets say I have an object that has stringProp1, stringProp2. I wish to store each combination of stringProp1, stringProp2 in a Dictionary. Initially I was storing the key as key = stringProp1+stringProp2 but this can actually cause a bug depending on the 2 values. Is the best solution for this problem to create a custom dictionary class or is there a better way using built-in .NET classes?

    Read the article

  • Is there a way to keep track of the ordering of items in a dictionary?

    - by Corpsekicker
    I have a Dictionary<Guid, ElementViewModel>. (ElementViewModel is our own complex type.) I add items to the dictionary with a stock standard items.Add(Guid.NewGuid, new ElementViewModel() { /*setters go here*/ });, At a later stage I remove some or all of these items. A simplistic view of my ElementViewModel is this: class ElementViewModel { Guid Id { get; set; } string Name { get; set; } int SequenceNo { get; set; } } It may be significant to mention that the SequenceNos are compacted within the collection after adding, in case other operations like moving and copying took place. {1, 5, 6} - {1, 2, 3} A simplistic view of my remove operation is: public void RemoveElementViewModel(IEnumerable<ElementViewModel> elementsToDelete) { foreach (var elementViewModel in elementsToDelete) items.Remove(elementViewModel.Id); CompactSequenceNumbers(); } I will illustrate the problem with an example: I add 3 items to the dictionary: var newGuid = Guid.NewGuid(); items.Add(newGuid, new MineLayoutElementViewModel { Id = newGuid, SequenceNo = 1, Name = "Element 1" }); newGuid = Guid.NewGuid(); items.Add(newGuid, new MineLayoutElementViewModel { Id = newGuid, SequenceNo = 2, Name = "Element 2" }); newGuid = Guid.NewGuid(); items.Add(newGuid, new MineLayoutElementViewModel { Id = newGuid, SequenceNo = 3, Name = "Element 3" }); I remove 2 items RemoveElementViewModel(new List<ElementViewModel> { item2, item3 }); //imagine I had them cached somewhere. Now I want to add 2 other items: newGuid = Guid.NewGuid(); items.Add(newGuid, new MineLayoutElementViewModel { Id = newGuid, SequenceNo = 2, Name = "Element 2, Part 2" }); newGuid = Guid.NewGuid(); items.Add(newGuid, new MineLayoutElementViewModel { Id = newGuid, SequenceNo = 3, Name = "Element 3, Part 2" }); On evaluation of the dictionary at this point, I expected the order of items to be "Element 1", "Element 2, Part 2", "Element 3, Part 2" but it is actually in the following order: "Element 1", "Element 3, Part 2", "Element 2, Part 2" I rely on the order of these items to be a certain way. Why is it not as expected and what can I do about it?

    Read the article

  • Checking for cross-site scripting vulnerabilities in Perl web applications

    - by David Scholefield
    I'm putting together some notes for a dev team on how to write secure Perl code - especially taking into account the current OWASP top 10 web application vulnerabilities. For cross-site scripting I've included information on ensuring that all output to the browser is checked and escaped where necessary, but I'm looking for more automated mechanisms that would mean a developer doesn't have to think about every output statement and, potentially, miss one. Perl's 'taint' function sounds like it should be a help because it distrusts all user input, but it doesn't complain on tainted data being output to the browser. Apart from checking all output statements individually (probably by calling a generic sanitizing function) does anyone have any ideas on how Perl can help with this with existing libraries or techniques?

    Read the article

  • What is a good scripting language for FTP downloading

    - by WxPilot
    I need to develop some scripts for downloading files from a remote server to our file system. We need to grab files that have various timestamps, and place them into appropriate folders on our system. I'm probably opening quite the can of worms here, but which scripting language would be the best for getting this done? Right now I am using C Shell, which is working fine, but it is requiring multiple scripts because of the use of the ftp command. I wanted to know if there is a better option before I go too far into this project. There are no security concerns within the scripts as far as FTP accounts (public access FTP)

    Read the article

  • Binding to a dictionary in Silverlight with INotifyPropertyChanged

    - by rip
    In silverlight, I can not get INotifyPropertyChanged to work like I want it to when binding to a dictionary. In the example below, the page binds to the dictionary okay but when I change the content of one of the textboxes the CustomProperties property setter is not called. The CustomProperties property setter is only called when CustomProperties is set and not when the values within it are set. I am trying to do some validation on the dictionary values and so am looking to run some code when each value within the dictionary is changed. Is there anything I can do here? C# public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); MyEntity ent = new MyEntity(); ent.CustomProperties.Add("Title", "Mr"); ent.CustomProperties.Add("FirstName", "John"); ent.CustomProperties.Add("Name", "Smith"); this.DataContext = ent; } } public class MyEntity : INotifyPropertyChanged { public event PropertyChangedEventHandler System.ComponentModel.INotifyPropertyChanged.PropertyChanged; public delegate void PropertyChangedEventHandler(object sender, System.ComponentModel.PropertyChangedEventArgs e); private Dictionary<string, object> _customProps; public Dictionary<string, object> CustomProperties { get { if (_customProps == null) { _customProps = new Dictionary<string, object>(); } return _customProps; } set { _customProps = value; if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("CustomProperties")); } } } } VB Partial Public Class MainPage Inherits UserControl Public Sub New() InitializeComponent() Dim ent As New MyEntity ent.CustomProperties.Add("Title", "Mr") ent.CustomProperties.Add("FirstName", "John") ent.CustomProperties.Add("Name", "Smith") Me.DataContext = ent End Sub End Class Public Class MyEntity Implements INotifyPropertyChanged Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged Private _customProps As Dictionary(Of String, Object) Public Property CustomProperties As Dictionary(Of String, Object) Get If _customProps Is Nothing Then _customProps = New Dictionary(Of String, Object) End If Return _customProps End Get Set(ByVal value As Dictionary(Of String, Object)) _customProps = value RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs("CustomProperties")) End Set End Property End Class Xaml <TextBox Height="23" Name="TextBox1" Text="{Binding Path=CustomProperties[Title], Mode=TwoWay}" /> <TextBox Height="23" Name="TextBox2" Text="{Binding Path=CustomProperties[FirstName], Mode=TwoWay}" /> <TextBox Height="23" Name="TextBox3" Text="{Binding Path=CustomProperties[Name], Mode=TwoWay}" />

    Read the article

  • Sort Dictionary<> on value, lookup index from key

    - by paulio
    Hi, I have a Dictionary< which I want to sort based on value so I've done this by putting the dictionary into a List< then using the .Sort method. I've then added this back into a Dictionary<. Is it possible to lookup the new index/order by using the Dictionary key?? Dictionary<int, MyObject> toCompare = new Dictionary<int, MyObject>(); toCompare.Add(0, new MyObject()); toCompare.Add(1, new MyObject()); toCompare.Add(2, new MyObject()); Dictionary<int, MyObject> items = new Dictionary<int, MyObject>(); List<KeyValuePair<int, MyObject>> values = new List<KeyValuePair<int, MyObject>> (toCompare); // Sort. values.Sort(new MyComparer()); // Convert back into a dictionary. foreach(KeyValuePair<int, PropertyAppraisal> item in values) { // Add to collection. items.Add(item.Key, item.Value); } // THIS IS THE PART I CAN'T DO... int sortedIndex = items.GetItemIndexByKey(0);

    Read the article

  • Nails vs Screws (C# List vs Dictionary)

    - by MarkPearl
    General This may sound like a typical noob statement, but I’m finding out in a very real way that just because you have a solution to a problem, doesn’t necessarily mean it is the best solution. This was reiterated to me when a friend of mine suggested I look at using Dictionaries instead of Lists for a particular problem – he was right, I have always just assumed that because lists solved my problem I did not need to look elsewhere. So my new manifesto to counter this ageless problem is as follows… Look for a solution that will logically work Once you have a solution look for possible alternatives Decide why your current solution is the best approach compared to the alternatives If it is.. use it till something better comes along, if it isnt…. change What’s the difference between Lists & Dictionaries Both lists and dictionaries are used to store collections of data. Assume we had the following declarations… var dic = new Dictionary<string, long>(); var lst = new List<long>(); long data;   With a list, you simply add the item to the list and it will add the item to the end of the list. lst.Add(data); With a dictionary, you need to specify some sort of key and the data you want to add so that it can be uniquely identified. dic.Add(uniquekey, data);   Because with a dictionary you now have unique identifier, in the background they provide all sort’s of optimized algorithms to find your associated data. What this means is that if you are wanting to access your data it is a lot faster than a List. So when is it appropriate to use either class? For me, if I can guarantee that each item in my collection will have a unique identifier, then I will use Dictionaries instead of Lists as there is a considerable performance benefit when accessing each data item. If I cannot make this sort of guarantee, then by default I will use a list. I know this is all really basic, and I hope I haven’t missed some fundamental principle… If anyone would like to add their 2 cents, please feel free to do so…

    Read the article

  • Assigning an item to an existing array in a list within a dictionary [on hold]

    - by Rouke
    I have a Dictionary declared like: public var PoolDict : Dictionary.<String, List.<GameObject[]> >; I made a function to add items to the list and array function Add(key:String, obj:GameObject) { if(!PoolDict.ContainsKey(key)) { PoolDict[key] = new List.<GameObject[]>(); } //PlaceHolder - Not what will be in final version PoolDict[key].Add(null); //Attempts - Errors- How to add to existing array? PoolDict[key].Add(obj); PoolDict[key][0].Add(obj); } I'd like to replace the line after //PlaceHolder with code that will assign a gameObject to an existing array in a list that's associated with a key. How could this be done?

    Read the article

  • C#: Is it possible to use expressions or functions as keys in a dictionary?

    - by Svish
    Would it work to use Expression<Func<T>> or Func<T> as keys in a dictionary? For example to cache the result of heavy calculations. For example, changing my very basic cache from a different question of mine a bit: public static class Cache<T> { // Alternatively using Expression<Func<T>> instead private static Dictionary<Func<T>, T> cache; static Cache() { cache = new Dictionary<Func<T>, T>(); } public static T GetResult(Func<T> f) { if (cache.ContainsKey(f)) return cache[f]; return cache[f] = f(); } } Would this even work? Edit: After a quick test, it seems like it actually works. But I discovered that it could probably be more generic, since it would now be one cache per return type... not sure how to change it so that wouldn't happen though... hmm Edit 2: Noo, wait... it actually doesn't. Well, for regular methods it does. But not for lambdas. They get various random method names even if they look the same. Oh well c",)

    Read the article

  • How to refer to items in Dictionary<string, string> by integer index?

    - by Edward Tanguay
    I made a Dictionary<string, string> collection so that I can quickly reference the items by their string identifier. But I now also need to access this collective by index counter (foreach won't work in my real example). What do I have to do to the collection below so that I can access its items via integer index as well? using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace TestDict92929 { class Program { static void Main(string[] args) { Dictionary<string, string> events = new Dictionary<string, string>(); events.Add("first", "this is the first one"); events.Add("second", "this is the second one"); events.Add("third", "this is the third one"); string description = events["second"]; Console.WriteLine(description); string description = events[1]; //error Console.WriteLine(description); } } }

    Read the article

  • Is a python dictionary the best data structure to solve this problem?

    - by mikip
    Hi I have a number of processes running which are controlled by remote clients. A tcp server controls access to these processes, only one client per process. The processes are given an id number in the range of 0 - n-1. Were 'n' is the number of processes. I use a dictionary to map this id to the client sockets file descriptor. On startup I populate the dictionary with the ids as keys and socket fd of 'None' for the values, i.e no clients and all pocesses are available When a client connects, I map the id to the sockets fd. When a client disconnects I set the value for this id to None, i.e. process is available. So everytime a client connects I have to check each entry in the dictionary for a process which has a socket fd entry of None. If there are then the client is allowed to connect. This solution does not seem very elegant, are there other data structures which would be more suitable for solving this? Thanks

    Read the article

  • How to convert JavaScript dictionary into Python syntax

    - by Sputnix
    Writing out javascript dictionary from inside of JavaScript- enabled application (such as Adobe) into external .jsx file (or any other .txt file) the context of resulted file dictionary looks like: ({one:"1", two:"2"}) (Please note that each dictionary keys are written as they are the variables name (which is not true). A next step is to read this .jsx file with Python. I need to find a way to convert ({one:"1", two:"2"}) into Python dictionary syntax such as: {'one':"1", 'two':"2"} It has been already suggested that instead of using JavaScript's built-in dict.toSource() it would make more sense to use JSON which would write a dictionary content in similar to Python syntax. But unfortunately using JSON is not an option for me. I need to find a way to convert ({one:"1", two:"2"}) into {'one':"1", 'two':"2"} using Python alone. Any suggestions on how to achieve it? Once again, the problem mostly in dictionary keys syntax which inside of Python look like variable names instead of strings-like dictionary keys names: one vs "one"

    Read the article

  • Accessing items from a dictionary using pickle efficiently in Python

    - by user248237
    I have a large dictionary mapping keys (which are strings) to objects. I pickled this large dictionary and at certain times I want to pull out only a handful of entries from it. The dictionary has usually thousands of entries total. When I load the dictionary using pickle, as follows: from cPickle import * # my dictionary from pickle, containing thousands of entries mydict = open(load('mypickle.pickle')) # accessing only handful of entries here for entry in relevant_entries: # find relevant entry value = mydict[entry] I notice that it can take up to 3-4 seconds to load the entire pickle, which I don't need, since I access only a tiny subset of the dictionary entries later on (shown above.) How can I make it so pickle only loads those entries that I have from the dictionary, to make this faster? Thanks.

    Read the article

  • Dictionary as parameter, where the Value-Type is irrelevant

    - by aaginor
    Hi folks, I have a function, that returns the next higher value of a Dictionary-Keys-List compared to a given value. If we have a Key-List of {1, 4, 10, 24} and a given value of 8, the function would return 10. Obviously the type of the Value-Part of the Dictionary doesn't matter for the function, the function-code for a Dictionary<int, int> and Dictionary<int, myClass> would be the same. How has the method-head have to look like, when I want to call the function with any Dictionary, that has int as key-Type and the value-Type is irrelevant? I tried: private int GetClosedKey(Dictionary<int, object> list, int theValue); but it says that there are illegal arguments, when I call it with a Dictionary. I don't want to copy'n'paste the function for each different value-type that my function may be called. Any idea, how to accomplish that? Thanks in advance, Frank

    Read the article

  • ODI 11g - Scripting a Reverse Engineer

    - by David Allan
    A common question is related to how to script the reverse engineer using the ODI SDK. This follows on from some of my posts on scripting in general and accelerated model and topology setup. Check out this viewlet here to see how to define a reverse engineering process using ODI's package. Using the ODI SDK, you can script this up using the OdiPackage and StepOdiCommand classes as follows;  OdiPackage pkg = new OdiPackage(folder, "Pkg_Rev"+modName);   StepOdiCommand step1 = new StepOdiCommand(pkg,"step1_cmd_reset");   step1.setCommandExpression(new Expression("OdiReverseResetTable \"-MODEL="+mod.getModelId()+"\"",null, Expression.SqlGroupType.NONE));   StepOdiCommand step2 = new StepOdiCommand(pkg,"step2_cmd_reset");   step2.setCommandExpression(new Expression("OdiReverseGetMetaData \"-MODEL="+mod.getModelId()+"\"",null, Expression.SqlGroupType.NONE));   StepOdiCommand step3 = new StepOdiCommand(pkg,"step3_cmd_reset");   step3.setCommandExpression(new Expression("OdiReverseSetMetaData \"-MODEL="+mod.getModelId()+"\"",null, Expression.SqlGroupType.NONE));   pkg.setFirstStep(step1);   step1.setNextStepAfterSuccess(step2);   step2.setNextStepAfterSuccess(step3); The biggest leap of faith for users is getting to know which SDK classes have to be used to build the objects in the design, using StepOdiCommand isn't necessarily obvious, once you see it in action though it is very simple to use. The above snippet uses an OdiModel variable named mod, its a snippet I added to the accelerated model creation script in the post linked above.

    Read the article

  • SQL Server Configuration Scripting Utility Release 9

    - by Bill Graziano
    There’s another update to my little utility to script a SQL Server’s configuration.  I use this for two purposes.  First, I use it to keep my database mirroring servers up to date.  Second, I capture the output in a version control system and keep that for historical reference. In release 3.0.9 I made the following changes: Rewrote the encrypted trigger scripting.  It will now list the encrypted triggers in a comment in the table script but can’t actually script them. It now scripts any server event notifications. You can script a single database using the /scriptdb flag.  Please note that it will also script the instance and system databases when it does this. It will script any user-defined endpoints.  This will capture your mirroring endpoints and more importantly any service broker endpoints. It will gracefully skip database mail on the Express Edition. It still doesn’t support SQL Server 2012.  I think that’s the next feature to add though.

    Read the article

  • Cannot Add Particular Word to Dictionary

    - by WCWedin
    I am trying to add a particular word to my custom dictionary using Word 2007. (The word happens to be "deserialized".) When I right-click on the word and click Add to Dictionary, the red underline does not go away. When I use the Spelling & Grammar tool from the Review tab on the ribbon, it will stop on that word; clicking the Add to Dictionary button has no effect. Oddly, I am able to add other words to the custom dictionary without a problem. I recently added "deserializes", for instance. I have only encountered this problem with that one particular word. Does anyone know what might be wrong and how I might fix it? Clarifications My document and all its content is set to English (United States). My custom dictionary is set to apply to All Languages, which is the default value. "Serialize" is in the US English default dictionary, but "deserialize" and its various forms is not.

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >