Search Results

Search found 26126 results on 1046 pages for 'generic service contract'.

Page 220/1046 | < Previous Page | 216 217 218 219 220 221 222 223 224 225 226 227  | Next Page >

  • How to keep a Generic list unmodified when its copy is modified?

    - by user1801934
    When I create a copy of the original list lstStudent in lstCopy and send the lstCopy to modification function, the lstStudent also gets modified. I want to keep this list unmodified. List<Student> lstStudent = new List<Student>(); Student s = new Student(); s.Name = "Akash"; s.ID = "1"; lstStudent.Add(s); List<Student> lstCopy = new List<Student>(lstStudent); Logic.ModifyList(lstCopy); // "Want to use lstStudent(original list) for rest part of the code" public static void ModifyList(List<Student> lstIntegers) { foreach (Student s in lstIntegers) { if (s.ID.Equals("1")) { s.ID = "4"; s.Name = "APS"; } } }

    Read the article

  • Could I return a FileStream as a generic interface to a file?

    - by Eric
    I'm writing a class interface that needs to return references to binary files. Typically I would provide a reference to a file as a file path. However, I'm considering storing some of the files (such as a small thumbnail) in a database directly rather then on a file system. In this case I don't want to add the extra step of reading the thumbnail out of the database onto the disc and then returning a path to the file for my program to read. I'd want to stream the image directly out of the database into my program and avoid writing anything to the disc unless the user explicit wants to save something. Would having my interface return a FileStreamor even a Imagemake sense? Then it would be up to the implementing class to determine if the source of the FileStream or Image is a file on a disc or binary data in a database. public interface MyInterface { string Thumbnail {get;} string Attachment {get;} } vs public interface MyInterface { Image Thumbnail {get;} FileStream Attachment {get;} }

    Read the article

  • Identity alternative for SQL Azure Federation : are Azure Queues or Service Bus Queues a good choice?

    - by JYL
    As many of developers, I'm looking for a way to integrate my existing app to SQL Azure Federations, and replacing the Identity columns (the primary keys of my tables) is a big problem. For many reasons, I do NOT want use GUID for my primary keys (please don't open the debate about the GUID or not, it's not my question : i just don't want a GUID, period). So I need to build a key provider to replace the "identity" feature of a standard SQL database. I'm using Entity Framework, so i can easily find one place to set the Id value just before the insert (by overriding the SaveChanges method of my ObjectContext class). I just need to find a "not too complicated" implementation for getting the current Id, which is "farm-ready". I've read this SO post : "ID Generation for Sharded Database (Azure Federated Database)" and "Synchronizing Multiple Nodes in Windows Azure from MSDN Magazine", but this solution sounds a bit complicated for me. I'm thinking about creating (automatically) one azure queue for each SQL table, which contain a pre-loaded list of consecutive integer. When I want an Id value, I just have to get a message from the queue (which becomes invisible and is deleted on the way), which give me the current available Id. About the choice between "Windows Azure Queues" and "Windows Azure Service Bus Queues", I prefere "Windows Azure Queues", due to the "high" latency of Service Bus Queues. I don't think that the lack of "ordering garantee" of Azure Queues is a problem. What do you think about that idea of using Azure Queues to provide Id values ? Do you see any argument to give up that idea ? Do you have a better idea, or even a good practice, to provider integer ids in SQL Azure Federation databases ? Thanks.

    Read the article

  • Call an action from another controller

    - by Brian
    I have two different objects: contracts, and task orders. My requirements specify that in order to view the Details for either object, the Url should be "http://.../Contract/Details" or "http://.../TaskOrder/Details" depending on which type. They are both very similar and the details pages are almost identical, so I made a class that can either be a contract or a task order, and has a variable "objectTypeID" that says which type it is. I wrote the action "Details" in the task order controller, but now I want to call that from the contract controller instead of recopying the code. So is there any way to have the url still say ".../Contract/Details" but call the action in the TaskOrder controller instead? I tried using TaskOrderController TOController = new TaskOrderController(); TOController.Details(id); This would have worked except that I can't use the HttpContext.Session anymore, which I used several times in the action.

    Read the article

  • Is possible to set generic type by another class?

    - by Soul_Master
    I use ASP.NET MVC for serving web application and I want to create something like the following code. <% using(HTML.Form(Model)) { %> <% HTML.CreateTextBox('txt1', x => x.Property1); <% } From the above code, Form extension method will receive object that represent type of current Model object in current View page. Next, CreateTextBox method will receive type from Form method and I can bind textbox to some property of this model. Update 1 The following code is code of CreateTextBox method that will create instance of TextBox class. public static CreateTextBox(string value, Expression<Func<object>> bindedProperty) { // T should be receive from HTML.Form method or class return new TextBox<T>(value); } Is it possible to creating some code that doing something like the above code? Thanks,

    Read the article

  • How to get a nicely formatted PHP Web Service response?

    - by Bruno
    I called an API like this: $service = new Class_Service(); $parameters = new GetClasses(); $parameters->Request = new GetClassesRequest(); $parameters->Request->SourceCredentials = new SourceCredentials(); $parameters->Request->SourceCredentials->SourceName = "Name"; $parameters->Request->SourceCredentials->Password = "Pass"; $parameters->Request->SourceCredentials->SiteIDs = array( 12 ); $classes = $service->GetClasses($parameters); var_dump($classes); And received a response like this: object(GetClassesResponse)#7 (1) { ["GetClassesResult"]=> object(GetClassesResult)#8 (6 { ["Classes"]=> object(stdClass)#9 (1) { ["Class"]=> array(25) { [0]=> object(Mi_Class)#10 (21) { ["ClassScheduleID"]=> int(15) ["Visits"]=> NULL ["Clients"]=> NULL ["Location"]=> object(Location)#11 (30) { ["BusinessID"]=> NULL ["SiteID"]=> int(12) ["BusinessDescription"]=> NULL ["AdditionalImageURLs"]=> object(stdClass)#12 (0) { } ["FacilitySquareFeet"]=> NULL Does a response normally look like this? How do I go about getting the data in a formatted manner?

    Read the article

  • PropertyInfo.GetValue() - how do you index into a generic parameter using reflection in C#?

    - by flesh
    This (shortened) code.. for (int i = 0; i < count; i++) { object obj = propertyInfo.GetValue(Tcurrent, new object[] { i }); } .. is throwing a 'TargetParameterCountException : Parameter count mismatch' exception. The underlying type of 'propertyInfo' is a Collection of some T. 'count' is the number of items in the collection. I need to iterate through the collection and perform an operation on obj. Advice appreciated.

    Read the article

  • Generic overloading tells me this is the same function. Not agree.

    - by serhio
    base class: Class List(Of T) Function Contains(ByVal value As T) As Boolean derived class: Class Bar : List(Of Exception) ' Exception type as example ' Function Contains(Of U)(ByVal value As U) As Boolean compiler tells me that that two are the same, so I need to declare Overloads/new this second function. But I want use U to differentiate the type (one logic) like NullReferenceException, ArgumentNull Exception, etc. but want to leave the base function(no differentiation by type - other logic) as well.

    Read the article

  • Delphi 2010 - Why can't I declare an abstract method with a generic type parameter?

    - by James
    I am trying to do the following in Delphi 2010: TDataConverter = class abstract public function Convert<T>(const AData: T): string; virtual; abstract; end; However, I keep getting the following compiler error: E2533 Virtual, dynamic and message methods cannot have type parameters I don't quite understand the reason why I can't do this. I can do this in C# e.g. public abstract class DataConverter { public abstract string Convert<T>(T data); } Anyone know the reasoning behind this?

    Read the article

  • Any way to make a generic List where I can add a type AND a subtype?

    - by user383178
    I understand why I cannot do the following: private class Parent { }; private class Child extends Parent { }; private class GrandChild extends Child { }; public void wontCompile(List<? extends Parent> genericList, Child itemToAdd) { genericList.add(itemToAdd); } My question is there ANY practical way to have a typesafe List where you can call add(E) where E is known to be only a Parent or a Child? I vaguely remember some use of the "|" operator as used for wildcard bounds, but I cannot find it in the spec... Thanks!

    Read the article

  • Is there a generic open-source reporting system out there?

    - by syntactico
    I recently started a position at a new company, and one of the first projects they want is an internal reporting system that points at database A, B, C and reports various metrics/statistics/predictions. Basically, the same thing I've done or worked on and every company I've ever been hired by. Since this gets a bit boring after a while, I was wondering if there already exists some sort of open-source package that accomplishes this goal. Ideally, it would work with multiple databases out-of-box (PostgreSQL, MySQL, MSSQL, Oracle minimally), determine relationships between tables (either automatically from their schemas, or allow you to manually set them up after pooling all the tables), allow you to create reports based on a subset of tables, customizing what data you wanted to be displayed/calculated (I suppose this would be challenging since you've no idea what every audience wants, and would need to make this flexible) I'm debating making something like this in my spare time if one does not already exist. Just curious.

    Read the article

  • New to threading in C#, can you make thread methods generic and what are the dangers?

    - by ibarczewski
    Hey all, I'm just now starting to get into the idea of threading, and wanted to know if I could make this more abstract. Both foo and bar derive methods from a base class, so I'd like to pass in one or the other and be able to do work using a method that was derived. I'd also like to know how you properly name threads and the methods inside threads. if (ChkFoo.Checked) { Thread fooThread = new Thread(new ThreadStart(this.ThreadedFooMethod)); fooThread.Start(); } if (ChkBar.Checked) { Thread barThread = new Thread(new ThreadStart(this.ThreadedBarMethod)); barThread.Start(); } . . . public void ThreadedFooMethod() { Foo newFoo = new Foo(); //Do work on newFoo } public void ThreadedBarMethod() { Bar newBar = new Bar(); //Do similar work } Thanks all!

    Read the article

  • NULL value in :conditions =>

    - by Horace Ho
    Contract.all(:conditions => ['voided == ?', 0]).size => 364 Contract.all(:conditions => ['voided != ?', 0]).size => 8 Contract.all.size => 441 the 3 numbers does not added up (364 + 8 != 441). What's the proper way write the :conditions to count the rows which the voided column value is NULL or equal to zero?

    Read the article

  • Java: Is it possible to have a generic class that only takes types that can be compared?

    - by mr popo
    I wanted to do something along the lines of: public class MyClass<T implements Comparable> { .... } But I can't, since, apparently, generics only accept restrictions with subclasses, and not interfaces. It's important that I'm able to compare the types inside the class, so how should I go about doing this? Ideally I'd be able to keep the type safety of Generics and not have to convert the T's to Object as well, or just not write a lot of code overall. In other words, the simplest the better.

    Read the article

  • What's the right Java generic for a collection of elements with unique addressable indices?

    - by Rocreex
    I'm on my way to programming a database application and in our course we are told to implement a library of elements using one of the Java Collections. Each of the elements has a unique ID with which it's supposed to be addressed. Now I am wondering how this can be done. I though about using a ListArray but this won't work because the only way of addressing List elements is through the index which you can't control. Do you have some advice for me?

    Read the article

  • How can i add column name in list generic?

    - by Phsika
    class MyExcelSheets { public List MyColumnNames { get; set; } } how can i add Excel data's column name in "List MyColumnNames ". it returns to me Object reference not set to an instance of an object. i want to use above class in: myexcelSheet = new MyExcelSheets(); myexcelSheet.MyColumnNames = new MyExcelSheets().MyColumnNames; foreach (DataColumn col in dTable.Columns) myexcelSheet.MyColumnNames.Add(col.ColumnName.ToString()); How can i solve it? Error: NullReferenceException

    Read the article

  • What kind of online hosting do I need for a WCF-based service?

    - by mafutrct
    First of all, I'm not sure if SO is the right place to ask. Please migrate me if needed. I would like to host a WCF-based service so it is available for everyone. While hosting it on my personal, local servers succeeded, I would prefer to move it to an external service provider for various reasons. I'll be blunt: I have no clue about hosting providers. I know there are webhosters, virtual and root servers and several other services. What I would like to know is what kind of hosting I need in my case. I understand that a root server would easily fulfill my requirements, but that is not exactly cheap. The program I'd like to run on the server requires .NET 4, preferably on a windows machine. Access to a folder in the file system is much appreciated (1 GB storage is enough by far). Communication with clients (in form of an applications written in .NET) via opening a port on the server. Traffic is low (<<1 GB/month?) There is no website. Having the provider perform updates would be nice. My understanding is that a virtual server would be a possible solution. Prices seem start at around 5€/month, which is ok for me. However, I read that for these cheap solutions RAM is severely limited (~400 MB), and I'm not confident that is enough to run windows and a .NET application.

    Read the article

  • Can I find out what WCF methods are supported on the endpoint before calling it?

    - by alord1689
    I have a versioning issue with a WCF service contract in which one of the many endpoints which are called for the operation is missing one method from the contract. My question is, how can I make sure the command is available on the client before attempting to call it? I tried: foreach (var od in proxy.Endpoint.Contract.Operations) { if (od.Name == "MyMethodName") { hasMethod = true; break; } } Unfortunately, this is using the contract from the calling app and does not actually describe the implementations on the endpoint itself. As a result, it returns true even though the endpoint has failed to implement the command.

    Read the article

  • How do you create a generic method in a class?

    - by Seth Spearman
    Hello, I am really trying to follow the DRY principle. I have a sub that looks like this? Private Sub DoSupplyModel OutputLine("ITEM SUMMARIES") Dim ItemSumms As New SupplyModel.ItemSummaries(_currentSupplyModel, _excelRows) ItemSumms.FillRows() OutputLine("") OutputLine("NUMBERED INVENTORIES") Dim numInvs As New SupplyModel.NumberedInventories(_currentSupplyModel, _excelRows) numInvs.FillRows() OutputLine("") End Sub I would like to collapse these into a single method using generics. For the record, ItemSummaries and NumberedInventories are both derived from the same base class DataBuilderBase. I can't figure out the syntax that will allow me to do ItemSumms.FillRows and numInvs.FillRows in the method. FillRows is declared as Public Overridable Sub FillRows in the base class. Thanks in advance. EDIT Here is my end result Private Sub DoSupplyModels() DoSupplyModelType("ITEM SUMMARIES",New DataBlocks(_currentSupplyModel,_excelRows) DoSupplyModelType("DATA BLOCKS",New DataBlocks(_currentSupplyModel,_excelRows) End Sub Private Sub DoSupplyModelType(ByVal outputDescription As String, ByVal type As DataBuilderBase) OutputLine(outputDescription) type.FillRows() OutputLine("") End Sub But to answer my own question...I could have done this... Private Sub DoSupplyModels() DoSupplyModelType(Of Projections)("ITEM SUMMARIES") DoSupplyModelType(Of DataBlocks)("DATA BLOCKS") End Sub Private Sub DoSupplyModelType(Of T as DataBuilderBase)(ByVal outputDescription As String, ByVal type As T) OutputLine(outputDescription) dim type as New T(_currentSupplyModel,_excelRows) type.FillRows() OutputLine("") End Sub Is that right? Does the New T() work? Seth

    Read the article

  • setting default values for empty nodes

    - by azathoth
    Hello all I need to transform a piece of XML, so that the value of every node in a list I specify is set to "0" for example: <contract> <customerName>foo</customerName> <contractID /> <customerID>912</customerID> <countryCode/> <cityCode>7823</cityCode> </contract> would be transformed into <contract> <customerName>foo</customerName> <contractID>0</contractID> <customerID>912</customerID> <countryCode>0</contractID> <cityCode>7823</cityCode> </contract> How can this be accomplished using XSLT? I have tried some examples I found but none works as expected Thank you

    Read the article

  • How to use custom attributes over a web service?

    - by gfeli
    Hi. I am currently trying to add a custom "column name" to a property in a web service. Here is my class. public class OrderCost { public int OrderNum { get; set; } public int OrderLine { get; set; } public int OrderRel { get; set; } public DateTime OrderDate { get; set; } public string PartNum { get; set; } public string Description { get; set; } public decimal Qty { get; set; } public string SalesUM { get; set; } public decimal Cost { get; set; } public decimal Price { get; set; } public decimal Net { get; set; } public decimal Margin { get; set; } public string EntryPerson { get; set; } public string CustID { get; set; } public string Customer { get; set; } } Basically I have another class (on the Silverlight side) that loops through all the properties and creates a column for each property. Thing is, I want to use a different name other than the name of the property. For example, I would like to show "Order Number" instead of OrderNum. I have attempted to use custom attributes but that does not seem to work. Is there way I can provide a different name to these properties over a web service with a use of an attribute? Is there another way I can achieve what I am trying to do?

    Read the article

  • Elegent methods for caching search results from RESTful service?

    - by Paul
    I have a RESTful web service which I access from the browser using JavaScript. As an example, say that this web service returns a list of all the Message resources assigned to me when I send a GET request to /messages/me. For performance reasons, I'd like to cache this response so that I don't have to re-fetch it every time I visit my Manage Messages web page. The cached response would expire after 5 minutes. If a Message resource is created "behind my back", say by the system admin, it's possible that I won't know about it for up to 5 minutes, until the cached search response expires and is re-fetched. This is acceptable, because it creates no confusion for me. However if I create a new Message resource which I know should be part of the search response, it becomes confusing when it doesn't appear on my Manage Messages page immediately. In general, when I knowingly create/delete/update a resource that invalidates a cached search response, I need that cached response to be expired/flushed immediately. The core problem which I can't figure out: I see no simple way of connecting the task of creating/deleting/updating a resource with the task of expiring the appropriate cached responses. In this example it seems simple, I could manually expire the cached search response whenever I create/delete/update a(ny) Message resource. But in a more complex system, keeping track of which search responses to expire under what circumstances will get clumsy quickly. If someone could suggest a simple solution or some clarifying thoughts, I'd appreciate it.

    Read the article

  • Why does this static factory method involving implied generic types, work?

    - by Cheeso
    Consider public class Tuple<T1, T2> { public Tuple(T1 v1, T2 v2) { V1 = v1; V2 = v2; } public T1 V1 { get; set; } public T2 V2 { get; set; } } public static class Tuple { // MAGIC!! public static Tuple<T1, T2> New<T1, T2>(T1 v1, T2 v2) { return new Tuple<T1, T2>(v1, v2); } } Why does the part labeled "MAGIC" in the above work? It allows syntax like Tuple.New(1, "2") instead of new Tuple<int, string>(1, "2"), but ... how and why? Why do I not need Tuple.New<int,string>(1, "2") ??

    Read the article

< Previous Page | 216 217 218 219 220 221 222 223 224 225 226 227  | Next Page >