Search Results

Search found 1919 results on 77 pages for 'typeof'.

Page 33/77 | < Previous Page | 29 30 31 32 33 34 35 36 37 38 39 40  | Next Page >

  • CultureManager issue

    - by Serge
    I have a bug I don't understand. While the following works fine: Resources.Classes.AFieldFormula.DirectFieldFormula this one throws an exception: new ResourceManager(typeof(Resources.Classes.AFieldFormula)).GetString("DirectFieldFormula"); Could not find any resources appropriate for the specified culture or the neutral culture. Make sure \"Resources.Classes.AFieldFormula.resources\" was correctly embedded or linked into assembly \"MygLogWeb\" at compile time, or that all the satellite assemblies required are loadable and fully signed. How comes? Resource designer.cs file: //------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // Runtime Version:4.0.30319.18408 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ namespace Resources.Classes { using System; /// <summary> /// A strongly-typed resource class, for looking up localized strings, etc. /// </summary> // This class was auto-generated by the StronglyTypedResourceBuilder // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] public class AFieldFormula { private static global::System.Resources.ResourceManager resourceMan; private static global::System.Globalization.CultureInfo resourceCulture; [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal AFieldFormula() { } /// <summary> /// Returns the cached ResourceManager instance used by this class. /// </summary> [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] public static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MygLogWeb.Classes.AFieldFormula", typeof(AFieldFormula).Assembly); resourceMan = temp; } return resourceMan; } } /// <summary> /// Overrides the current thread's CurrentUICulture property for all /// resource lookups using this strongly typed resource class. /// </summary> [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] public static global::System.Globalization.CultureInfo Culture { get { return resourceCulture; } set { resourceCulture = value; } } /// <summary> /// Looks up a localized string similar to Direct field. /// </summary> public static string DirectFieldFormula { get { return ResourceManager.GetString("DirectFieldFormula", resourceCulture); } } } }

    Read the article

  • Saving an xml file without

    - by little
    Hi, How do I work with an xml file that when updating it, after saving the commented lines would still be present. Here's my code snippet for saving the file: public static void WriteSettings(Settings settings, string path) { XmlSerializer serializer = new XmlSerializer(typeof(Settings)); TextWriter writer = new StreamWriter(path); serializer.Serialize(writer, settings); writer.Close(); }

    Read the article

  • DRY-ing very similar specs for ASP.NET MVC controller action with MSpec (BDD guidelines)

    - by spapaseit
    Hi all, I have two very similar specs for two very similar controller actions: VoteUp(int id) and VoteDown(int id). These methods allow a user to vote a post up or down; kinda like the vote up/down functionality for StackOverflow questions. The specs are: VoteDown: [Subject(typeof(SomeController))] public class When_user_clicks_the_vote_down_button_on_a_post : SomeControllerContext { Establish context = () => { post = PostFakes.VanillaPost(); post.Votes = 10; session.Setup(s => s.Single(Moq.It.IsAny<Expression<Func<Post, bool>>>())).Returns(post); session.Setup(s => s.CommitChanges()); }; Because of = () => result = controller.VoteDown(1); It should_decrement_the_votes_of_the_post_by_1 = () => suggestion.Votes.ShouldEqual(9); It should_not_let_the_user_vote_more_than_once; } VoteUp: [Subject(typeof(SomeController))] public class When_user_clicks_the_vote_down_button_on_a_post : SomeControllerContext { Establish context = () => { post = PostFakes.VanillaPost(); post.Votes = 0; session.Setup(s => s.Single(Moq.It.IsAny<Expression<Func<Post, bool>>>())).Returns(post); session.Setup(s => s.CommitChanges()); }; Because of = () => result = controller.VoteUp(1); It should_increment_the_votes_of_the_post_by_1 = () => suggestion.Votes.ShouldEqual(1); It should_not_let_the_user_vote_more_than_once; } So I have two questions: How should I go about DRY-ing these two specs? Is it even advisable or should I actually have one spec per controller action? I know I Normally should, but this feels like repeating myself a lot. Is there any way to implement the second It within the same spec? Note that the It should_not_let_the_user_vote_more_than_once; requires me the spec to call controller.VoteDown(1) twice. I know the easiest would be to create a separate spec for it too, but it'd be copying and pasting the same code yet again... I'm still getting the hang of BDD (and MSpec) and many times it is not clear which way I should go, or what the best practices or guidelines for BDD are. Any help would be appreciated.

    Read the article

  • Adding user role constraint redirects Browser to jsf.js script?

    - by simgineer
    My JSF form login was working with Constraint 1 however when I added Constraint 2 to my web.xml doing a submit on the form now takes me to a jsf javascript page. Can someone tell me what I am doing wrong? I would like only administrators to be able to access the /admin/* pages and only registered users to access the entire site included admin files. BTW after I see the java script page I can still navigate to the intended page in the browser, I just don't want the user to see the intermediate js page or need to know the target page URL. Constraint 1 <security-constraint> <display-name>Admin</display-name> <web-resource-collection> <url-pattern>/admin/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>ADMIN</role-name> </auth-constraint> </security-constraint> Constraint 2 <security-constraint> <display-name>Users</display-name> <web-resource-collection> <url-pattern>/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>USER</role-name> </auth-constraint> </security-constraint> Here is the undesired url I am being redirected to: javax.faces.resource/jsf.js.xhtml?ln=javax.faces&stage=Development Here is the start of the jsf.js.xhtml... /** @project JSF JavaScript Library @version 2.0 @description This is the standard implementation of the JSF JavaScript Library. */ /** * Register with OpenAjax */ if (typeof OpenAjax !== "undefined" && typeof OpenAjax.hub.registerLibrary !== "undefined") { OpenAjax.hub.registerLibrary("jsf", "www.sun.com", "2.0", null); } // Detect if this is already loaded, and if loaded, if it's a higher version if (!((jsf && jsf.specversion && jsf.specversion >= 20000 ) && (jsf.implversion && jsf.implversion >= 3))) { ... Notes I'm using Firefox 10.0.4, Glassfish 3.1 w JSF2.0 lib, j_security_check, and my login realm setup is similar to this

    Read the article

  • How can I use Generics to create a way of making an IEnumerable from an enum?

    - by Samantha J
    Given an enum like this: public enum City { London = 1, Liverpool = 20, Leeds = 25 } public enum House { OneFloor = 1, TwoFloors = 2 } I am using the following code to give me an IEnumerable: City[] values = (City[])Enum.GetValues(typeof(City)); var valuesWithNames = from value in values select new { value = (int)value, name = value.ToString() }; The code works very good however I have to do this for quite a lot of enums. Is there a way I could create a generic way of doing this?

    Read the article

  • c# reflection: How can I invoke a method with an out parameter ?

    - by ldp615
    I want expose WebClient.DownloadDataInternal method like below: [ComVisible(true)] public class MyWebClient : WebClient { private MethodInfo _DownloadDataInternal; public MyWebClient() { _DownloadDataInternal = typeof(WebClient).GetMethod("DownloadDataInternal", BindingFlags.NonPublic | BindingFlags.Instance); } public byte[] DownloadDataInternal(Uri address, out WebRequest request) { _DownloadDataInternal.Invoke(this, new object[] { address, out request }); } } WebClient.DownloadDataInternal has a out parameter, I don't know how to invoke it. Help!

    Read the article

  • Javascript - proper getAttributeNode on IE6+

    - by Darrow
    I have a regular input box (no onchange attribute). <input type="text" id="bar" name="bar" /> For some reason, IE6+ does returns [object], while FF and Chrome returns null. if ((elem.getAttributeNode('onchange')) != null) elem.onchange(); I did also try as: if (typeof(elem.onchange) !== 'undefined') elem.onchange(); What would be the proper cross-browser way to check if the element has the attribute? Thanks

    Read the article

  • Appending javascript code piece to end of the body tag

    - by uzay95
    I am looking for a way to insert javascript code block to end of ASP.NET page. Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "showVideo", sScript, true); is appending to body but js codes are always requesting some js files didn't load or some functions are below of the script. How can i append scripts that i generated dynamically to the bottom of body? Thanks for your help.

    Read the article

  • Are NHibernate lists loaded on demand?

    - by André Pena
    This is a pretty simple question. When I do this: session.CreateCriteria(typeof(Product)).List(); The resulting list will load as I access it? Let's say, from 100 to 100 elements for example? Or will it load all once? In the case it's not "virtual" how can I make it so? What's the best pratice about it? Thanks;

    Read the article

  • Processing an XML file removes comments

    - by little
    This snippet <!--Please don't delete this--> is part of my xml file. After running this method, the resulting xml file does not contain this snippet anymore <!--Please don't delete this-->. Why is this? Here's my method: XmlSerializer serializer = new XmlSerializer(typeof(Settings)); TextWriter writer = new StreamWriter(path); serializer.Serialize(writer, settings); writer.Close();

    Read the article

  • C# Type Casting at Runtimefor Array.SetValue

    - by sprocketonline
    I'm trying to create an array using reflection, and insert values into it. I'm trying to do this for many different types so would like a createAndFillArray function capable of this : Type t1 = typeof(A); Type t2 = typeof(B); double exampleA = 22.5; int exampleB = 43; Array arrA = createAndFillArray(t1, exampleA); Array arrB = createAndFillArray(t2, exampleB); private Array createAndFillArray(Type t, object val){ Array arr = Array.CreateInstance( t, 1); //length 1 in this example only, real-world is of variable length. arr.SetValue( val, 0 ); //this causes the following error: "System.InvalidCastException : Object cannot be stored in an array of this type." return arr; } with the class A being as follows: public class A{ public A(){} private double val; public double Value{ get{ return val; } set{ this.val = value; } } public static implicit operator A(double d){ A a = new A(); a.Value = d; return a; } } and class B being very similar, but with int: public class B{ public B(){} private double val; public double Value{ get{ return val; } set{ this.val = value; } } public static implicit operator B(double d){ B b = new B(); b.Value = d; return b; } } I hoped that the implicit operator would have ensured that the double be converted to class A, or the int to class B, and the error avoided; but this is obviously not so. The above is used in a custom deserialization class, which takes data from a custom data format and fills in the corresponding .Net object properties. I'm doing this via reflection and at runtime, so I think both are unavoidable. I'm targeting the C# 2.0 framework. I've dozens, if not hundreds, of classes similar to A and B, so would prefer to find a solution which improved on the createAndFillArray method rather than a solution which altered these classes.

    Read the article

  • Another void C# question

    - by Jim Jones
    Have a type in the header files I'm working with called VTVOID it is the type of a struct element and a number of parameters. In the header file defining types is the line #define VTVOID void I read in another discussion the void maps to System.Void however when I plug that into the C# code I get the error "System.Void cannot be used in C# -- use typeof(void) to get the void object." So what type do I plug in? Jim

    Read the article

  • Inheritance of jQuery's prototype partially fails

    - by user1065745
    I want to use Coffeescript to create an UIObject class. This class should inherit from jQuery, so that instances of UIObject can be used as if they where created with jQuery. class UIObject isObject: (val) -> typeof val is "object" constructor: (tag, attributes) -> @merge jQuery(tag, attributes), this @UIObjectProperties = {} merge: (source, destination) -> for key of source if destination[key] is undefined destination[key] = source[key] else if @isObject(source[key]) @merge(source[key], destination[key]) return It partially works. Consider the Foobar class below: class Foobar extends UIObject constructor: -> super("<h1/>", html: "Foobar") $("body").append(new Foobar) works fine. BUT: (new Foobar).appendTo("body") places the tag, but also raises RangeError: Maximum call stack size exceeded. Was it just a bad idea to inherit from jQuery? Or is there a solurion? For those who don't know CoffeeScript, the JavaScript source is: var Foobar, UIObject; var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }; UIObject = (function () { UIObject.prototype.isObject = function (val) { return typeof val === "object"; }; function UIObject(tag, attributes) { this.merge(jQuery(tag, attributes), this); this.UIObjectProperties = {}; } UIObject.prototype.merge = function (source, destination) { var key; for (key in source) { if (destination[key] === void 0) { destination[key] = source[key]; } else if (this.isObject(source[key])) { this.merge(source[key], destination[key]); } } }; return UIObject; })(); Foobar = (function () { __extends(Foobar, UIObject); function Foobar() { Foobar.__super__.constructor.call(this, "<h1/>", { html: "Foobar" }); } return Foobar; })();

    Read the article

  • How can I prevent a field from being copied to the client proxy in WCF RIA?

    - by Martin Doms
    Is there a metadata attribute I can use to prevent a field from being accessible on the client in a WCF RIA services? I sure I have seen this before, but I'm drawing a blank and Google isn't helping. It would look something like [MetadataType(typeof(User.UserMetadata))] public partial class User { internal sealed class UserMetadata { private UserMetadata() { } public int Id { get; set; } [HideFromClientProxy] public string PasswordSalt { get; set; } } }

    Read the article

  • Get the value of an attribute Jquery

    - by Abu Hamzah
    i am trying to get EmployeeId withitn the DOM something like this: var o = obj[$(this).attr("EmployeeId")]; but getting undefined when i debug i see the following: $(this)[0].data data "{EmployeeId: 'A42345'}" here is my source code: $.ajax({ type: "POST", url: url, data: "{EmployeeId: '" + id + "'}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (response) { var obj = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d; var o = obj[$(this).attr("EmployeeId")]; //<<<<undefined

    Read the article

  • Cannot .Count() on IQueryable (NHibernate)

    - by Bruno Reis
    Hello, I'm with an irritating problem. It might be something stupid, but I couldn't find out. I'm using Linq to NHibernate, and I would like to count how many items are there in a repository. Here is a very simplified definition of my repository, with the code that matters: public class Repository { private ISession session; /* ... */ public virtual IQueryable<Product> GetAll() { return session.Linq<Product>(); } } All the relevant code in the end of the question. Then, to count the items on my repository, I do something like: var total = productRepository.GetAll().Count(); The problem is that total is 0. Always. However there are items in the repository. Furthermore, I can .Get(id) any of them. My NHibernate log shows that the following query was executed: SELECT count(*) as y0_ FROM [Product] this_ WHERE not (1=1) That must be that "WHERE not (1=1)" clause the cause of this problem. What can I do to be able .Count() the items in my repository? Thanks! EDIT: Actually the repository.GetAll() code is a little bit different... and that might change something! It is actually a generic repository for Entities. Some of the entities implement also the ILogicalDeletable interface (it contains a single bool property "IsDeleted"). Just before the "return" inside the GetAll() method I check if if the Entity I'm querying implements ILogicalDeletable. public interface IRepository<TEntity, TId> where TEntity : Entity<TEntity, TId> { IQueryable<TEntity> GetAll(); ... } public abstract class Repository<TEntity, TId> : IRepository<TEntity, TId> where TEntity : Entity<TEntity, TId> { public virtual IQueryable<TEntity> GetAll() { if (typeof (ILogicalDeletable).IsAssignableFrom(typeof (TEntity))) { return session.Linq<TEntity>() .Where(x => (x as ILogicalDeletable).IsDeleted == false); } else { return session.Linq<TEntity>(); } } } public interface ILogicalDeletable { bool IsDeleted {get; set;} } public Product : Entity<Product, int>, ILogicalDeletable { ... } public IProductRepository : IRepository<Product, int> {} public ProductRepository : Repository<Product, int>, IProductRepository {} Edit 2: actually the .GetAll() is always returning an empty result-set for entities that implement the ILogicalDeletable interface (ie, it ALWAYS add a WHERE NOT (1=1) clause. I think Linq to NHibernate does not like the typecast.

    Read the article

  • Url routing asp.net 4

    - by user510336
    Hello all , I am trying to create url routing like this http://msdn.microsoft.com/en-us/magazine/dd347546.aspx but I am having few questions , first why he is adding lines to the web.config , I tested it and it didnt appear that they're doing something as I commented them and nothing major appeared second I am having this line of code that is crashing var display = BuildManager.CreateInstanceFromVirtualPath(_virtualPath,typeof(Page)) as IProfileHandler; when casted as ihttphandler it's working , but when I am casting it to iprofilehandler(which is implemeting ihttphandler) it's giving null !

    Read the article

  • Reflection: different ways to retrieve property value

    - by jules
    I'm retrieving an IEnumerable list of properties via following code: BindingFlags bindingFlag = BindingFlags.Instance | BindingFlags.Public; var dataProperties = typeof(myParentObject).GetProperties(bindingFlag); Then I'm iterating through the list and retrieving the value for each property. I've come across two different approaches to doing this, and just wondered what the difference is between them: 1) object propertyValue = property.GetGetMethod().Invoke(myObject, null); 2) object propertValue = property.GetValue(myObject, null)

    Read the article

  • log4net configuration problem

    - by user177883
    I have a seperate Log4Net.config file. I added [assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log4Net.config", Watch = true)] to AssemblyInfo.cs When I run the application with debug mode, lognet is logging. When i publish the application to IIS, lognet is not logging anything. I have the followings also : BasicConfigurator.Configure(); // in a method private static readonly ILog _logger = LogManager.GetLogger(typeof(_Default)); // for the instance What would be the reason for this?

    Read the article

  • Why is my Type.GetFields(BindingFlags.Instance|BindingFlags.Public) not working?

    - by granadaCoder
    My code can see the non-public members, but not the public ones. Why? FieldInfo[] publicFieldInfos = t.GetFields(BindingFlags.Instance | BindingFlags.Public); is returning nothing. Note: I'm trying to get at the properties on the abstract class as well as the concrete class. (And read the attributes as well). The MSDN example works with the 2 flags (BindingFlags.Instance | BindingFlags.Public) but my mini inheritance example below does not. private void RunTest1() { try { textBox1.Text = string.Empty; Type t = typeof(MyInheritedClass); //Look at the BindingFlags *** NonPublic *** int fieldCount = 0; while (null != t) { fieldCount += t.GetFields(BindingFlags.Instance | BindingFlags.NonPublic).Length; FieldInfo[] nonPublicFieldInfos = t.GetFields(BindingFlags.Instance | BindingFlags.NonPublic); foreach (FieldInfo field in nonPublicFieldInfos) { if (null != field) { Console.WriteLine(field.Name); } } t = t.BaseType; } Console.WriteLine("\n\r------------------\n\r"); //Look at the BindingFlags *** Public *** t = typeof(MyInheritedClass); FieldInfo[] publicFieldInfos = t.GetFields(BindingFlags.Instance | BindingFlags.Public); foreach (FieldInfo field in publicFieldInfos) { if (null != field) { Console.WriteLine(field.Name); object[] attributes = field.GetCustomAttributes(t, true); if (attributes != null && attributes.Length > 0) { foreach (Attribute att in attributes) { Console.WriteLine(att.GetType().Name); } } } } } catch (Exception ex) { ReportException(ex); } } private void ReportException(Exception ex) { Exception innerException = ex; while (innerException != null) { Console.WriteLine(innerException.Message + System.Environment.NewLine + innerException.StackTrace + System.Environment.NewLine + System.Environment.NewLine); innerException = innerException.InnerException; } } public abstract class MySuperType { public MySuperType(string st) { this.STString = st; } public string STString { get; set; } public abstract string MyAbstractString { get; set; } } public class MyInheritedClass : MySuperType { public MyInheritedClass(string ic) : base(ic) { this.ICString = ic; } [Description("This is an important property"), Category("HowImportant")] public string ICString { get; set; } private string _oldSchoolPropertyString = string.Empty; public string OldSchoolPropertyString { get { return _oldSchoolPropertyString; } set { _oldSchoolPropertyString = value; } } [Description("This is a not so importarnt property"), Category("HowImportant")] public override string MyAbstractString { get; set; } }

    Read the article

  • url routing with strongly typed objects

    - by user510336
    hello all , I am trying to create url routing with strongly typed objects for pages but I keep getting null object on the first line so it's crashing //Getting the suitable executing Page var display = BuildManager.CreateInstanceFromVirtualPath(_virtualPath,typeof(Page)) as IProfileHandler; //Setting Page Parameters display.MemberId = Convert.ToInt32(requestContext.RouteData.Values["ID"]); //Return Page return display; public interface IProfileHandler : IHttpHandler { int MemberId { get; set; } }

    Read the article

< Previous Page | 29 30 31 32 33 34 35 36 37 38 39 40  | Next Page >