Search Results

Search found 269 results on 11 pages for 'sealed'.

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

  • Add the path _vti_bin/Lists.asmx to an ASP.NET MVC 2 web application

    - by Philipp Schmid
    I am trying to add the path /_vti_bin/Lists.asmx to my ASP.NET MVC 2 web application. I am registering the route as follows: routes.IgnoreRoute("{resource}.asmx/{*pathInfo}"); routes.Add(new Route("_vti_bin/Lists.asmx", new ListsHandler())); where ListHandler is defined as: public sealed class ListsHandler : IRouteHandler { #region IRouteHandler Members public IHttpHandler GetHttpHandler(RequestContext requestContext) { throw new NotImplementedException(); } #endregion } But when I start the MVC application and try to navigate to http://localhost:8888/_vti_bin/Lists.asmx, I get an HTTP 404 error, rather than an exception raised. Is this even possible in MVC? Do I need to add an Lists.asmx ASPX web service file to my project in a particular place (I cannot create the _vti_bin folder in the Visual Studio project)?

    Read the article

  • How do I invoke my custom settings provider?

    - by joebeazelman
    I need to specify a different location for my settings file. After many long hours of searching, I found out that I have to write my own SettingsProvider. I succeeded in creating one which allows me to specify a path for settings file via its constructor. Programatically, I can contruct it like this: var mycustomprovider = new CustomSettingsProvider(path); The problem I am having is that there's no way to invoke my custom provider. I can decorate the VS 2008 generated setting file with the following attribute: [SettingsProvider(typeof(CustomSettingProviders.CustomSettingsProvider))] internal sealed partial class Settings { } However, the attribute doesn't allow me to construct the object with a path. Also, I want to be able to set the SettingsProvider programmatically so that I can pass in any path I want at runtime and save my settings. The examples I've seen on the net have never mentioned how to use a invoke a SettingsProvider programmatically.

    Read the article

  • C# thread with multiple parameters

    - by Lucas B
    Does anyone know how to pass multiple parameters into a Thread.Start routine? I thought of extending the class, but the C# Thread class is sealed. Here is what I think the code would look like: ... Thread standardTCPServerThread = new Thread(startSocketServerAsThread); standardServerThread.Start( orchestrator, initializeMemberBalance, arg, 60000); ... } static void startSocketServerAsThread(ServiceOrchestrator orchestrator, List<int> memberBalances, string arg, int port) { startSocketServer(orchestrator, memberBalances, arg, port); } Thank you in advance. BTW, I start a number of threads with different orchestrators, balances and ports. Please consider thread safety also.

    Read the article

  • Referring to the type of an inner class in Scala

    - by saucisson
    The following code tries to mimic Polymorphic Embedding of DSLs: rather than giving the behavior in Inner, it is encoded in the useInner method of its enclosing class. I added the enclosing method so that user has only to keep a reference to Inner instances, but can always get their enclosing instance. By doing this, all Inner instances from a specific Outer instance are bound to only one behavior (but it is wanted here). abstract class Outer { sealed class Inner { def enclosing = Outer.this } def useInner(x:Inner) : Boolean } def toBoolean(x:Outer#Inner) : Boolean = x.enclosing.useInner(x) It does not compile and scala 2.8 complains about: type mismatch; found: sandbox.Outer#Inner required: _81.Inner where val _81:sandbox.Outer From Programming Scala: Nested classes and A Tour of Scala: Inner Classes, it seems to me that the problem is that useInnerexpects as argument an Inner instance from a specific Outer instance. What is the true explanation and how to solve this problem ?

    Read the article

  • How can you extend the Bitmap class

    - by vrish88
    Hello, I am trying to extend the Bitmap class so that I can apply my own effects to an image. When I use this code: namespace ImageEditor { public class Effects : System.Drawing.Bitmap { public void toBlackAndWhite() { System.Drawing.Bitmap image = (Bitmap)this; AForge.Imaging.Filters.Grayscale filter = new AForge.Imaging.Filters.Grayscale(); this = filter.Apply(this); } } } I get the following error: 'ImageEditor.Effects': cannot derive from sealed type 'System.Drawing.Bitmap' So is there a way to get around this or is it simply not possible to extend the class? Thanks.

    Read the article

  • Different return XML in a WCF Operation

    - by Sean Hederman
    I am writing a service to a international HTTP standard, and there is one method that can return three different XML results, call them Single, Multiple and Error. Now I've written an IXmlSerializable class that can consume each of these results and generate them. However, WCF seems to insist that I can only have a single return XML root name. I have to choose an XmlRoot for my custom object of either Single, Multiple or Error. How can I set up WCF so that I can choose at runtime what the root will be? This is what I have currently. /// <summary> /// A collection of items. /// </summary> [XmlRoot("Multiple", Namespace = "DAV:")] public sealed class ItemCollection : IEnumerable<Item>, IXmlSerializable /// <summary> /// Processes and returns the items. /// </summary> [WebInvoke(Method = "POST", UriTemplate = "{*path}", BodyStyle = WebMessageBodyStyle.Bare)] [OperationContract] [XmlSerializerFormat] ItemCollection Process(string path);

    Read the article

  • Flex AS3 - Creating a dynamic property, and then binding a control to it

    - by Caleb Cittadino
    I am trying to: 1) create a dynamic property 2) bind that property to a label This works great for "sealed properties", but for dynamic properties there doesn't appear to be any event triggered. Are dynamic properties implicityly not bindable? var myObj:MyType = new MyType(); // MyType is dynamic myObj["myDynamicPropertyName"] = "initialized"; BindingUtils.bindProperty(myLabel, "data", myObj, repeatedLabel.name); // myLabel now displays "initialized" myObj["myDynamicPropertyName"] = "changed"; // myLabel still displays "initialized", it should say "changed" !!!

    Read the article

  • How to test silverlight behaviors using Rhino Mocks?

    - by Derek
    I have slightly adapted the custom behavior code that can be found here: http://www.reflectionit.nl/blog/default.aspx?guid=d81a8cf8-0345-48ee-bbde-84c2e3f21a25 that controls a MediaElement. I need to know how to go about testing this with Rhino Mocks e.g. how to instantiate a new ControlMediaElementAction in test code and then call the Invoke method etc. Doing something simple like this in test code: mMediaElementControlBehaviour = new ControlMediaElementAction (); gives me an exception "The type initializer for 'System.Windows.DependencyObject' throw an exception. Thinking it was the instantiation of the MediaElement, I tried this two lines of code: MediaElement mediaElementStub = MockRepository.GenerateStub(); this.Container.RegisterInstance(mediaElementStub); This gave the exception 'Can't create mocks of sealed classes' If someone can point me in the right direction, it would be apreciated. Silverlight 4, Rhino Mocks 3.5 Silverlight v2.0.50727 Thanks,

    Read the article

  • Populate properties decorated with an attribute

    - by PUT
    Are there any frameworks that assist me with this: (thinking that perhaps StructureMap can help me) Whenever I create a new instance of "MyClass" or any other class that inherits from IMyInterface I want all properties decorated with [MyPropertyAttribute] to be populated with values from a database or some other data storage using the property Name in the attribute. public class MyClass : IMyInterface { [MyPropertyAttribute("foo")] public string Foo { get; set; } } [AttributeUsage(AttributeTargets.Property)] public sealed class MyPropertyAttribute : System.Attribute { public string Name { get; private set; } public MyPropertyAttribute(string name) { Name = name; } }

    Read the article

  • Mapping child objects in fluent nhibernate to a read-only view

    - by grenade
    Given that I am implementing a read-only UI, how do I create a ClassMap for Shop: public class Shop { public int Id { get; set; } public City City { get; set; } } public class City { public string Name { get; set; } public string CountryCode { get; set; } } The DB interface for Shops is a View containing 3 columns (ShopId, CityName, CountryCode). I was hoping to do something like this: public sealed class ShopMap : ClassMap<Shop> { public ShopMap() { Table("Shop"); Id(x => x.Id, "ShopId"); Map(x => x.City.Name, "CityName"); Map(x => x.City.CountryCode, "CountryCode"); } } Will fluent auto-instantiate Shop.City?

    Read the article

  • Can't Use Generic C# Class in Using Statement

    - by Eric J.
    I'm trying to use a generic class in a using statement but the compiler can't seem to treat it as implementing IDisposable. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.Objects; namespace Sandbox { public sealed class UnitOfWorkScope<T> where T : ObjectContext, IDisposable, new() { public void Dispose() { } } public class MyObjectContext : ObjectContext, IDisposable { public MyObjectContext() : base("DummyConnectionString") { } #region IDisposable Members void IDisposable.Dispose() { throw new NotImplementedException(); } #endregion } public class Consumer { public void DoSomething() { using (new UnitOfWorkScope<MyObjectContext>()) { } } } } Compiler error is: Error 1 'Sandbox.UnitOfWorkScope<Sandbox.MyObjectContext>': type used in a using statement must be implicitly convertible to 'System.IDisposable' I implemented IDisposable on UnitOfWorkScope (and to see if that was the problem, also on MyObjectContext). What am I missing?

    Read the article

  • How to customize an OpenFileDialog using nested types?

    - by vitorbal
    Say I wanted to customize an OpenFileDialog and change, for example, the way the filter for file extensions work, as in the case of this question. After I pointed out to the author of said question that the OpenFileDialog is not inheritable, I got a comment with the following: Even though the OpenFileDialog is sealed (not inheritable), you may use it as a nested type. For instance, using a property that will get the NativeDialog. Then, you write your method always using the NativeDialog property and you're done. My question is, can someone provide me with an example code on how would I proceed on doing something like that? I'm kind of new to the concept of nested types so I'm having a hard time figuring that out by myself, and I searched around the web and couldn't find anything too concrete about it. Thanks!

    Read the article

  • Do I still have to implement a singleton class by hand in .net, even when using .Net4.0?

    - by Hamish Grubijan
    Once the singleton pattern is understood, writing subsequent singleton classes in C# is a brainless exercise. I would hope that the framework would help you by providing an interface or a base class to do that. Here is how I envision it: public sealed class Schablone : ISingleton<Schablone> { // Stuff forced by the interface goes here // Extra logic goes here } Does what I am looking for exist? Is there some syntactic sugar for constructing a singleton class - whether with an interface, a class attribute, etc.? Can one write a useful and bullet-proof ISingleton themselves? Care to try? Thanks!

    Read the article

  • How to implement cancellable worker thread

    - by Arnold Zokas
    Hi, I'm trying to implement a cancellable worker thread using the new threading constructs in System.Threading.Tasks namespace. So far I have have come up with this implementation: public sealed class Scheduler { private CancellationTokenSource _cancellationTokenSource; public System.Threading.Tasks.Task Worker { get; private set; } public void Start() { _cancellationTokenSource = new CancellationTokenSource(); Worker = System.Threading.Tasks.Task.Factory.StartNew( () => RunTasks(_cancellationTokenSource.Token), _cancellationTokenSource.Token ); } private static void RunTasks(CancellationToken cancellationToken) { while (!cancellationToken.IsCancellationRequested) { Thread.Sleep(1000); // simulate work } } public void Stop() { try { _cancellationTokenSource.Cancel(); Worker.Wait(_cancellationTokenSource.Token); } catch (OperationCanceledException) { // OperationCanceledException is expected when a Task is cancelled. } } } When Stop() returns I expect Worker.Status to be TaskStatus.Canceled. My unit tests have shown that under certain conditions Worker.Status remains set to TaskStatus.Running. Is this a correct way to implement a cancellable worker thread?

    Read the article

  • C# Using singleton instead of a global static instance

    - by Farstucker
    I ran into a problem today and a friend recommended I use a global static instance or more elegantly a singleton pattern. I spent a few hours reading about singletons but a few things still escape me. Background: What Im trying to accomplish is creating an instance of an API and use this one instance in all my classes (as opposed to making a new connection, etc). There seems to be about 100 ways of creating a singleton but with some help from yoda I found some thread safe examples. ..so given the following code: public sealed class Singleton { public static Singleton Instance { get; private set; } static Singleton() { Instance = new Singleton(); } } How/Where would you instantiate the this new class and how should it be called from a separate class? Thanks for your help.

    Read the article

  • How do I refactor this IEnumerable<T> to be thread-safe?

    - by DayOne
    I am looking at Skeet's AtomicEnumerable but I'm not sure how to integrate it into my current IEnumerable exmaple below (http://msmvps.com/blogs/jon_skeet/archive/2009/10/23/iterating-atomically.aspx) Basically I want to foreach my blahs type in a thread-safe way. thanks public sealed class Blahs : IEnumerable<string> { private readonly IList<string> _data = new List<string>() { "blah1", "blah2", "blah3" }; public IEnumerator<string> GetEnumerator() { return _data.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } }

    Read the article

  • how to translate Haskell into Scalaz?

    - by TOB
    One of my high school students and I are going to try to do a port of Haskell's Parsec parser combinator library into Scala. (It has the advantage over Scala's built-in parsing library that you can pass state around fairly easily because all the parsers are monads.) The first hitch I've come across is trying to figure out how Functor works in scalaz. Can someone explain how to convert this Haskell code: data Reply s u a = Ok a !(State s u) ParseError | Error ParseError instance Functor (Reply s u) where fmap f (Ok x s e) = Ok (f x) s e fmap _ (Error e) = Error e -- XXX into Scala (using Scalaz, I assume). I got as far as sealed abstract class Reply[S, U, A] case class Ok[S, U, A](a: A, state: State[S, U], error: ParseError) extends Reply[S, U, A] case class Error[S, U, A](error: ParseError) extends Reply[S, U, A] and know that I should make Reply extend the scalaz.Functor trait, but I can't figure out how to do that. (Mostly I'm having trouble figuring out what the F[_] parameter does.) Any help appreciated! Thanks, Todd

    Read the article

  • how can i use switch statement on type-safe enum pattern

    - by Fer
    I found a goodlooking example about implementation enums in a different way. That is called type-safe enum pattern i think. I started using it but i realized that i can not use it in a switch statement. My implementation looks like the following: public sealed class MyState { private readonly string m_Name; private readonly int m_Value; public static readonly MyState PASSED= new MyState(1, "OK"); public static readonly MyState FAILED= new MyState(2, "ERROR"); private MyState(int value, string name) { m_Name = name; m_Value = value; } public override string ToString() { return m_Name; } public int GetIntValue() { return m_Value; } } What can i add to my class in order to be able to use this pattern in switch statements in C#? Thanks.

    Read the article

  • Why is String final in Java?

    - by Alex
    From when I learned that the class java.lang.String is declared as final in Java, I was wondering why is that? I didn't find any answer back then, but this post: How to create a replica of String class in Java? reminded me of my query. Sure, String provides all the functionality I ever needed, and never thought of any operation that would require an extension of class String, but still you'll never know what someone might need! So, does anyone know what was the intent of the designers when they decided to make it final? See also: Why is String a sealed class in C#?

    Read the article

  • [C#] How to create a constructor of a class that return a collection of instances of that class?

    - by codemonkie
    My program has the following class definition: public sealed class Subscriber { private subscription; public Subscriber(int id) { using (DataContext dc = new DataContext()) { this.subscription = dc._GetSubscription(id).SingleOrDefault(); } } } ,where _GetSubscription() is a sproc which returns a value of type ISingleResult<_GetSubscriptionResult> Say, I have a list of type List<int> full of 1000 ids and I want to create a collection of subscribers of type List<Subscriber>. How can I do that without calling the constructor in a loop for 1000 times? Since I am trying to avoid switching the DataContext on/off so frequently that may stress the database. TIA.

    Read the article

  • Is is possible to intercept a constructor on a class you do not own?

    - by code poet
    Referring to my possible answer to this question: http://stackoverflow.com/questions/2907535/how-would-you-audit-asp-net-membership-tables-while-recording-what-user-made-the/2911616#2911616 Is it possible to intercept a call, coming from code you do not own, to a ctor on a sealed internal class that you do not own with the intention of manipulating the object before returning? Concrete example: SqlMembershipProvider, for all of it's data access, instantiates a connection helper class, System.Web.DataAccess.SqlConnectionHolder. The desired result is to intercept this instantiation and perform an operation on the public connection that is opened in the ctor of System.Web.DataAccess.SqlConnectionHolder before letting execution continue. Is this possible. If so, an brief example would be appreciated.

    Read the article

  • Can C# make my class look like another class?

    - by Vaccano
    I have a class that look like this: public class BasePadWI { public WorkItem WorkItemReference { get; set; } .... Other stuff ...... } I then have a dictionary that is defined like this: public Dictionary<BasePadWI, Canvas> Pad { get; set; } I would then like to make a call like this: List<WorkItem> workItems = Pad.Keys.ToList(); (Note: WorkItem is a sealed class, so I cannot inherit.) Is there some trickery that I could do in the class to make it look like a WorkItem? I have done this in the mean time: List<WorkItem> workItems = Pad.Keys.ToList().ConvertAll(x=>x.WorkItem);

    Read the article

  • Does this simple cache class need thread synchronization?

    - by DayOne
    Does this simple cache class need thread synchronization ... if I remove the lock _syncLock statement will encounter any problems? I think i can remove the locks as the references should be updated correctly right? ... BUt i'm think whar happens if client code is iterating over the GetMyDataStructure method and it get replaced? Thanks! public sealed class Cache { private readonly object _syncLock = new object(); private IDictionary<int, MyDataStructure> _cache; public Cache() { Refresh(); } public void Refresh() { lock (_syncLock) { _cache = DAL.GetMyDataStructure(); } } public IDictionary<int, MyDataStructure> **GetMyDataStructure**() { lock (_syncLock) { return _cache; } } }

    Read the article

  • Is this a valid, lazy, thread-safe Singleton implementation for C#?

    - by Matthew
    I implemented a Singleton pattern like this: public sealed class MyClass { ... public static MyClass Instance { get { return SingletonHolder.instance; } } ... static class SingletonHolder { public static MyClass instance = new MyClass (); } } From Googling around for C# Singleton implementations, it doesn't seem like this is a common way to do things in C#. I found one similar implementation, but the SingletonHolder class wasn't static, and included an explicit (empty) static constructor. Is this a valid, lazy, thread-safe way to implement the Singleton pattern? Or is there something I'm missing?

    Read the article

  • Overloading Console.ReadLine possible? (or any static class method)

    - by comecme
    I'm trying to create an overload of the System.Console.ReadLine() method that will take a string argument. My intention basically is to be able to write string s = Console.ReadLine("Please enter a number: "); in stead of Console.Write("Please enter a number: "); string s = Console.ReadLine(); I don't think it is possible to overload Console.ReadLine itself, so I tried implementing an inherited class, like this: public static class MyConsole : System.Console { public static string ReadLine(string s) { Write(s); return ReadLine(); } } That doesn't work though, cause it is not possible to inherit from System.Console (because it is a static class which automatically makes is a sealed class). Does it make sense what I'm trying to do here? Or is it never a good idea to want to overload something from a static class?

    Read the article

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