Search Results

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

Page 88/1046 | < Previous Page | 84 85 86 87 88 89 90 91 92 93 94 95  | Next Page >

  • Cannot create Windows Service for MySQL (Vista)

    - by Matt W
    I uninstalled MySQL 5.1 from Vista as I lost the username/password, however I forgot to stop the MySQL service before doing so. Now whenever I try to reinstall it I get to the final configuration screen which then fails with the message "Cannot create Windows Service for MySQL Error:0". I've uninstalled MySQL and removed all related files/folders/registry entries but still no joy... Does anyone know a way to resolve this as I can't seem to find a fix online anywhere!

    Read the article

  • C# Access the Properties of a Generic Object

    - by Jimbo
    I have a method that counts the number of Contacts each Supplier, Customer and Manufacturer has (this is a scenario to try make explaining easier!) The models are all created by Linq to SQL classes. Each Supplier, Customer and Manufacturer may have one or more Contacts public int CountContacts<TModel>(TModel entity) where TModel : class { return entity.Contacts.Count(); } The above of course doesnt work, because the 'entity' is generic and doesnt know whether it has the property 'Contacts'. Can someone help with how to achieve this?

    Read the article

  • Generic method to create deep copy of all elements in a collection

    - by bwarner
    I have various ObservableCollections of different object types. I'd like to write a single method that will take a collection of any of these object types and return a new collection where each element is a deep copy of elements in the given collection. Here is an example for a specifc class private static ObservableCollection<PropertyValueRow> DeepCopy(ObservableCollection<PropertyValueRow> list) { ObservableCollection<PropertyValueRow> newList = new ObservableCollection<PropertyValueRow>(); foreach (PropertyValueRow rec in list) { newList.Add((PropertyValueRow)rec.Clone()); } return newList; } How can I make this method generic for any class which implements ICloneable?

    Read the article

  • Generic Data Structure Description Language

    - by Jon Purdy
    I am wondering whether there exists any declarative language for arbitrarily describing the format and semantics of a data structure, that can be compiled to a specific implementation of that structure in any of a set of target languages. That is, something like a generic data definition language but geared toward describing arbitrary data structures such as vectors, lists, trees, etc., and the semantics of operations on those structures. I ask because I had an idea for a feasible implementation of this concept, and I'm just wondering whether it's worth it, and, consequently, whether it's been done before. Another, slightly more abstract question: is there any real difference between the normative specification of a data structure (what it does) and its implementation (how it does it)?

    Read the article

  • Calling generic method in spring.net application context

    - by Bert Vandamme
    Hi, I'm trying to invoke this method in spring.net, but i'm having trouble getting the configuration right. Method: public void AddRepository(IRepository repository) where TEntity : IEntity { Repositories.Add(repository.GetType().Name, repository); } Config: <object type="Spring.Objects.Factory.Config.MethodInvokingFactoryObject, Spring.Core"> <property name="TargetObject"> <ref local="RepositoryFactory" /> </property> <property name="TargetMethod" value="AddRepository"/> <property name="Arguments"> <list> <ref object="BinaryAssetFileRepository"/> </list> </property> </object>" Is it possible to address generic methods in this way? Thx, Bert

    Read the article

  • Is generic Money<T_amount> a good idea?

    - by jdk
    I have a Money Type that allows math operations and is sensitive to exchange rates so it will reduce one currency to another if rate is available to calculate in a given currency, rounds by various methods. It has other features that are sensitive to money, but I need to ask if the basic data type used should be made generic in nature. I've realized that the basic data type to hold an amount may differ for financial situations, for example: retail money might be expressed as all cents using int or long where fractions of cents do not matter, decimal is commonly used for its fixed behaviour, sometimes double seems to be used for big finance and large values sometimes a special BigInteger or 3rd-party type is used. I want to know if it would be considered good form to turn Money into Money<T_amount> so it can be used in any one of the above chosen scenarios?

    Read the article

  • Generic type parameters using out

    - by Mikael
    Im trying to make a universal parser using generic type parameters, but i can't grasp the concept 100% private bool TryParse<T>(XElement element, string attributeName, out T value) where T : struct { if (element.Attribute(attributeName) != null && !string.IsNullOrEmpty(element.Attribute(attributeName).Value)) { string valueString = element.Attribute(attributeName).Value; if (typeof(T) == typeof(int)) { int valueInt; if (int.TryParse(valueString, out valueInt)) { value = valueInt; return true; } } else if (typeof(T) == typeof(bool)) { bool valueBool; if (bool.TryParse(valueString, out valueBool)) { value = valueBool; return true; } } else { value = valueString; return true; } } return false; } As you might guess, the code doesn't compile, since i can't convert int|bool|string to T (eg. value = valueInt). Thankful for feedback, it might not even be possible to way i'm doing it. Using .NET 3.5

    Read the article

  • Why / When / How is this Android serviceBinder resetting to null?

    - by GaZ
    I've written a ListActivity for Android 2.1 which is used to display a list of event categories. As the user selects a category, the program calls a web service to retrieve a list of sub-events. For example, a top level event might be "soccer" and when the user selects this the web service would return various soccer associations (e.g. "english", "french", "german", etc.) and display them in a new list. The following code seems to work occasionally, however sometimes the call to the service (in EventsListTask) fails because the serviceBinder is null. How/Why does this happen? public class EventListsActivity extends ListActivity { private static final String EVENT_ID = "EventId"; private List<ListItem> eventList; private ArrayAdapter<ListItem> listItemArrayAdapter; private static final int LOADING_DIALOG = 1; private EventsListTask eventsListTask = null; private BFService serviceBinder; private ServiceConnection mConnection = new ServiceConnection() { public void onServiceConnected(ComponentName componentName, IBinder iBinder) { Log.i("EventListsActivity", "service connected"); serviceBinder = ((BFService.BFBinder)iBinder).getService(); } public void onServiceDisconnected(ComponentName componentName) { Log.i("EventListsActivity", "service disconnected"); serviceBinder = null; } }; @Override public void onCreate(Bundle savedInstanceState) { Log.i("EventListsActivity", "onCreate"); super.onCreate(savedInstanceState); setContentView(R.layout.list); eventList = new ArrayList<ListItem>(); listItemArrayAdapter = new ArrayAdapter<ListItem>(this, R.layout.row, eventList); setListAdapter(listItemArrayAdapter); Intent bindIntent = new Intent(this, BFService.class); bindService(bindIntent, mConnection, Context.BIND_AUTO_CREATE); int eventId = getIntent().getIntExtra(EVENT_ID, -1); if (eventsListTask == null || eventsListTask.getStatus() == AsyncTask.Status.FINISHED) { eventsListTask = new EventsListTask(); eventsListTask.execute(eventId); } } @Override protected void onDestroy() { Log.i("EventListsActivity", "destroyed"); super.onDestroy(); unbindService(mConnection); } @Override protected void onListItemClick(ListView listView, View view, int position, long id) { super.onListItemClick(listView, view, position, id); ListItem selectedItem = (ListItem) listView.getAdapter().getItem(position); Intent intent; if (selectedItem.getMarketType() != null) { intent = new Intent(this, MarketActivity.class); intent.putExtra(EVENT_ID, selectedItem.getId()); startActivityIfNeeded(intent, -1); } else if (selectedItem.getId() != -1) { intent = new Intent(this, EventListsActivity.class); intent.putExtra(EVENT_ID, selectedItem.getId()); startActivityIfNeeded(intent, -1); } else { Log.e("EventListsActivity", "unexpected item selected!"); } } @Override protected Dialog onCreateDialog(int id) { switch (id) { case (LOADING_DIALOG) : AlertDialog.Builder loadingDialog = new AlertDialog.Builder(this); loadingDialog.setTitle("Please Wait..."); loadingDialog.setMessage("Communicating with remote service."); return loadingDialog.create(); } return null; } private class EventsListTask extends AsyncTask<Integer, Void, LoginStatusEnum> { @Override protected void onPreExecute() { showDialog(LOADING_DIALOG); } @Override protected void onPostExecute(LoginStatusEnum loginStatusEnum) { dismissDialog(LOADING_DIALOG); if (loginStatusEnum != null) { switch (loginStatusEnum) { case OK: for (ListItem item : eventList) { listItemArrayAdapter.add(item); } listItemArrayAdapter.notifyDataSetChanged(); break; } } } @Override protected LoginStatusEnum doInBackground(Integer... params) { LoginStatusEnum result = LoginStatusEnum.OK; Integer eventId = params[0]; if (serviceBinder != null) { try { if (eventId == null || eventId == -1) { eventList = serviceBinder.getActiveEventTypes(); } else { eventList = serviceBinder.getEvents(eventId); } } catch (WebServiceException wse) { result = LoginStatusEnum.valueOf(wse.getMessage()); } } else { Log.e("EventListsActivity", "serviceBinder is null!"); } return result; } } } EDIT: The serviceBinder appears to be set to null when I reach the bottom of a list, when I change the target intent to go to a different activity: intent = new Intent(this, MarketActivity.class); intent.putExtra(EVENT_ID, selectedItem.getId()); startActivity(intent); This new activity also uses the same background service (binds in the same way, etc.). Is there anything I need to watch out for when doing this? Am I calling the target intent incorrectly? EDIT2: Here's the output from LogCat when I start the activity which calls the service (this time the service failed straight away!): 04-02 07:02:49.147: INFO/ActivityManager(61): Starting activity: Intent { cmp=net.foobar.activity/.EventListsActivity } 04-02 07:02:49.257: INFO/EventListsActivity(353): onCreate 04-02 07:02:49.426: INFO/EventListsActivity(353): service connected 04-02 07:02:49.437: ERROR/EventListsActivity(353): serviceBinder is null!

    Read the article

  • Android Context.bindService always returns false and ServiceConnection object is never triggered

    - by mosfet
    I have followed the Local Service example provided by Google, but my Context::bindService(...) always returns false and there is ServiceConnection::onServiceConnected is also never called. I understand that Context::bindService() returns immediately, but my ServiceConnection object is never triggered. I don't know if these apply My activity is running inside a tabHost and I was wondering if that can affect service binding in any way. The Service itself may have a problem, but I can call start service to the same service with the same Intent and it works as expected. Does anyone have experience with this? Please help me out. Thanks, P.S. I am targeting Android 1.6

    Read the article

  • Issue converting Sitecore Item[] using ToList<T>

    - by philba888
    Working with Sitecore and Linq extensions. I am trying to convert to from an item array to the list using the following piece of code: Item variationsFolder = masterDB.SelectSingleItem(VariationsFolderID.ToString()); List<Item> variationList = variationsFolder.GetChildren().ToList<Item>(); However I keep getting this error whenever I try to build: 'Sitecore.Collections.ChildList' does not contain a definition for 'ToList' and the best extension method overload 'System.Linq.Enumerable.ToList<TSource>(System.Collections.Generic.IEnumerable<TSource>)' has some invalid arguments I have the following usings: using System.Linq; using System.Xml.Linq; Am referencing: System.Core I've just copied this code from another location, so it should work fine, can only think that there is something simple (like a reference or something that I am missing).

    Read the article

  • calling Overloaded method from a generic method.

    - by asela38
    How to create a generic method which can call overloaded methods? I tried but it gives a compilation error. Test.java:19: incompatible types found : java.lang.Object required: T T newt = getCloneOf(t); ^ import java.util.*; public class Test { private Object getCloneOf(Object s) { return new Object(); } private String getCloneOf(String s) { return new String(s); } private <T> Set<T> getCloneOf(Set<T> set){ Set<T> newSet = null; if( null != set) { newSet = new HashSet<T>(); for (T t : set) { T newt = getCloneOf(t); newSet.add(newt); } } } }

    Read the article

  • Using Generics to typecast object type to generic type

    - by Shantanu Gupta
    I am very new to generics and trying to implement it. How can i use it here. private T returnValueFromGrid(int RowNo, int ColNo) { return Converter<dgvCurrencyMaster.Rows[RowNo].Cells[ColNo].Value,T>; } I am trying to convert below value to generic type and then return it. dgvCurrencyMaster.Rows[RowNo].Cells[ColNo].Value Here i need to know two things. How to do the above problem and how to use this in my code. Please provide some eg.

    Read the article

  • Is generic Money<TAmount> a good implementation idea?

    - by jdk
    I have a Money Type that allows math operations and is sensitive to exchange rates so it will reduce one currency to another if rate is available to calculate in a given currency, rounds by various methods. It has other features that are sensitive to money, but I need to ask if the basic data type used should be made generic in nature. I've realized that the basic data type to hold an amount may differ for financial situations, for example: retail money might be expressed as all cents using int or long where fractions of cents do not matter, decimal is commonly used for its fixed behaviour, sometimes double seems to be used for big finance and large values sometimes a special BigInteger or 3rd-party type is used. I want to know if it would be considered good form to turn Money into Money<T_amount> so it can be used in any one of the above chosen scenarios?

    Read the article

  • Castle Windsor - Resolving a generic implementation to a base type

    - by arootbeer
    I'm trying to use Windsor as a factory to provide specification implementations based on subtypes of XAbstractBase (an abstract message base class in my case). I have code like the following: public abstract class XAbstractBase { } public class YImplementation : XAbstractBase { } public class ZImplementation : XAbstractBase { } public interface ISpecification<T> where T : XAbstractBase { bool PredicateLogic(); } public class DefaultSpecificationImplementation : ISpecification<XAbstractBase> { public bool PredicateLogic() { return true; } } public class SpecificSpecificationImplementation : ISpecification<YImplementation> { public bool PredicateLogic() { /*do real work*/ } } My component registration code looks like this: container.Register( AllTypes.FromAssembly(Assembly.GetExecutingAssembly()) .BasedOn(typeof(ISpecification<>)) .WithService.FirstInterface() ) This works fine when I try to resolve ISpecification<YImplementation>; it correctly resolves SpecificSpecificationImplementation. However, when I try to resolve ISpecification<ZImplementation> Windsor throws an exception: "No component for supporting the service ISpecification'1[ZImplementation, AssemblyInfo...] was found" Does Windsor support resolving generic implementations down to base classes if no more specific implementation is registered?

    Read the article

  • Resolving the metadata token of a generic type parameter

    - by 280Z28
    Is there any way the .NET 4.0 (or earlier) reflection API to resolve a generic type parameter? See the two lines after my ArgumentException comment for my current attempt. [TestMethod] public void TestGenericParameterTokenResolution() { Type genericParameter = typeof(List<>).GetGenericArguments()[0]; Assert.IsTrue(genericParameter.IsGenericParameter); int metadataToken = genericParameter.MetadataToken; // make sure the metadata token is a GenericParam Assert.AreEqual(metadataToken & 0xFF000000, 0x2A000000); Module module = typeof(List<>).Module; // the following both throw an ArgumentException. Type resolvedParameter = module.ResolveType(metadataToken); resolvedParameter = (Type)module.ResolveMember(metadataToken); Assert.AreSame(genericParameter, resolvedParameter); }

    Read the article

  • Binary comparison operators on generic types

    - by Brian Triplett
    I have a generic class that takes a type T. Within this class I have a method were I need to compare a type T to another type T such as: public class MyClass<T> { public T MaxValue { // Implimentation for MaxValue } public T MyMethod(T argument) { if(argument > this.MaxValue) { // Then do something } } } The comparison operation inside of MyMethod fails with Compiler Error CS0019. Is it possible to add a constraint to T to make this work? I tried adding a where T: IComparable<T> to the class definition to no avail.

    Read the article

  • Iterate through a DataTable to find elements in a List object?

    - by Darth Continent
    As I iterate through a DataTable object, I need to check each of its DataRow objects against the items in a generic string List. I found a blog post using the List's Find method along with a delegate, but whereas that example has a separate class (Person), I'm attempting something like the following using an instance of the string object: // My definition of the List object. List<string> lstAccountNumbers = new List<string>(); ... // I populate the List via its Add method. ... foreach (DataRow drCurrentRow in dtMyDataTable.Rows) { if (lstAccounts.Find(delegate(string sAccountNumber) { return sAccountNumber == drCurrentRow["AccountNumber"]; }) { Found_DoSomething(); } else { NotFound_DoSomethingElse(); } } However, with this syntax I'm receiving "Cannot implicitly convert type 'string' to 'bool'" for the if block. Could someone please clarify what I'm doing wrong and how best to accomplish what I'm trying to do?

    Read the article

  • adding SSL to microchip Generic TCP server application

    - by Surjya Narayana Padhi
    Hi, Has anybody upgraded the code of generic tcp server application provided by Microchip to SSL? I added new listener port to existing server socket. But then also its not TCPPutIsReady state. When I tried to connect through ssh client Tera Term its asking for username and password. But does it required for client to provide username and password? I a bit new to SSL. So please let me know the steps to connect to any ssl server using Tera Term. Another doubt is that can i use a TCP server socket without using http or ftp or telnet session?

    Read the article

  • sOperator as and generic classes

    - by abatishchev
    I'm writing .NET On-the-Fly compiler for CLR scripting and want execution method make generic acceptable: object Execute() { return type.InvokeMember(..); } T Execute<T>() { return Execute() as T; /* doesn't work: The type parameter 'T' cannot be used with the 'as' operator because it does not have a class type constraint nor a 'class' constraint */ // also neither typeof(T) not T.GetType(), so on are possible return (T) Execute(); // ok } But I think operator as will be very useful: if result type isn't T method will return null, instead of an exception! Is it possible to do?

    Read the article

  • Mapping class properties to generic columns in table .NET

    - by Tony_Henrich
    I have have a SQL Server table which has generic names like Text1, Text2.. etc. The table was designed like this because the same structure is used for different projects. I have a class in .NET which has properties. Say a Customer class has a property called FirstName. How can I do the mapping from FirstName to Text1 just once (central place) in the application so that I don't have to remember and hard code the mappings all over the app when I create the different DAL methods? For example, I want the app to know when I want to update, insert a FirstName, the DAL automatically uses Text1. Basically I don't have to remember which property goes to which column. The idea is so the developers do not map the properlies/columns in a wrong way. It's always consistent. Note: Database inserts, updates and deletes are allowed through stored procedures only.

    Read the article

  • Building path independent mod_rewrite statements for generic .htaccess file

    - by Pekka
    Say I have three small web applications stored under a shared web root: www.example.com/app1/ www.example.com/app2/ www.example.com/app3/ www.example.com/app4/ each application has a .htaccess file containing some run-off-the-mill mod_rewrite statements to rewrite urls like RewriteCond %{REQUEST_URI} ^/app1/([^/]+)/([^/]+)\.html$ RewriteRule .* /app1/index.php?selectedProfile=%1&match=%2&%{QUERY_STRING} now, I would like to have a generic .htaccess file in each /app{n} directory. So, no RewriteBase and no /app{n} prefix in the RewriteConds. One idea I had was making the first level a wildcard directory as well: RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/]+)/([^/]+)\.html$ seeing as the .htaccess file gets triggered only when the /app{n} directory is entered, this should work. Is this an acceptable solution? Are there other, better ones?

    Read the article

  • StructureMap: Wiring (generic) implementations to an implementation of another type

    - by Jeremy Frey
    If I have an interface: public interface IRepository<T> And an abstract class: public abstract class LinqToSqlRepository<T, TContext> : IRepository<T> where T : class where TContext : DataContext And a whole bunch of implementations of IRepository / LinqToSqlRepository (e.g. AccountRepository, ContactRepository, etc.), what's the best way to to use StructureMap (2.5.3) to generically wire them all up? e.g., I want this code to pass: [Test] public void ShouldWireUpAccountRepositories { var accountRepo = ObjectFactory.GetInstance<IRepository<Account>>(); Assert.IsInstanceOf<AccountRepository>(accountRepo); } Without explicitly writing this: ObjectFactory.Configure(x => x.ForRequestedType<IRepository<Account>>() .TheDefaultIsConcreteType<AccountRepository>()); In the past, we've always created a specific interface on each repository that inherited from the generic one, and used the default scanner to automatically wire all of those instances, but I'd like to be able to ask specifically for an IRepository<Account> without cluttering up the project with additional interfaces / configurations.

    Read the article

  • Dynamically set generic type argument

    - by fearofawhackplanet
    Following on from my question here, I'm trying to create a generic value equality comparer. I've never played with reflection before so not sure if I'm on the right track, but anyway I've got this idea so far: bool ContainSameValues<T>(T t1, T t2) { if (t1 is ValueType || t1 is string) { return t1.Equals(t2); } else { IEnumerable<PropertyInfo> properties = t1.GetType().GetProperties().Where(p => p.CanRead); foreach (var property in properties) { var p1 = property.GetValue(t1, null); var p2 = property.GetValue(t2, null); if( !ContainSameValues<p1.GetType()>(p1, p2) ) return false; } } return true; } This doesn't compile because I can't work out how to set the type of T in the recursive call. Is it possible to do this dynamically at all? There are a couple of related questions on here which I have read but I couldn't follow them enough to work out how they might apply in my situation.

    Read the article

  • Looking for a generic handler/service for mongodb and asp.net / c#

    - by JohnAgan
    I am new to MongoDB and have a perfect place in mind to use it. However, it's only worth it if I can make the queries from JavaScript and return JSON. I read another post on here of someone asking a similar question, but not specific to C#. What's the easiest way I can implement a generic service/handler in asp.net/c# that would allow me to interact with mongodb via JavaScript? I understand JavaScript can't call mongodb directly, so the next best thing is what I'm looking for.

    Read the article

  • Cannot implicitly convert type System.Collection.Generic.IEnumberable

    - by Cen
    I'm receiving this error in my Linq statement --- Cannot implicitly convert type 'System.Collections.Generic.IEnumerable' to 'hcgames.ObjectClasses.ShoppingCart.ShoppingCartCartAddon'. An explicit conversion exists (are you missing a cast?) From this query ShoppingCartItems items = Cart.GetAllItems(); ShoppingCartCartAddons addons = Cart.GetAllAddons(); var stuff = from x in items select new ShoppingCartItem() { ProductID = x.ProductID, Quantity = x.Quantity, Name = x.Name, Price = x.Price, Weight = x.Weight, Addons = (from y in addons where y.ShoppingCartItemID == x.ID select y) }; I can not figure out how to cast this properly. Any suggestions? Thanks for your help!

    Read the article

< Previous Page | 84 85 86 87 88 89 90 91 92 93 94 95  | Next Page >