Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
P

Phillip Donegan

@Phillip Donegan
About
Posts
30
Topics
13
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Validation of a combobox in Silverlight 4
    P Phillip Donegan

    This was actually a simple problem in th end, I assumed that the [Required] annotation would check that the association was present and not null. It seems that all it actually does is check that in this case that FrequencyId is not null. And there was the problem in that I was using a long and not a nullable long (long?). Once I made the change to make them nullable the validation started working as expected even with the bindings which made no sense to me. If anyone could explain them that would be great! Phil

    WPF wpf csharp wcf regex question

  • Validation of a combobox in Silverlight 4
    P Phillip Donegan

    I'm trying to understand how validation works for a combo box when its ItemsSource is bound to a ObserableCollection of complex types. I am using RIA as the serivce to connect the client tier to the middle tier. Also not sure if this makes a difference the combobox control is inside a dataform. I have done alot of reading on this and found this article to be the most useful: http://www.run80.net/?p=93 So firstly my entity: I have a field decorated like so:

    [Required]
    public virtual long FrequencyId { get; set; }

    \[Include\]
    \[Association("TreatmentFrequencyToTreatmentRecordAssociation", "FrequencyId", "Id", IsForeignKey = true)\]
    public virtual TreatmentFrequency Frequency
    {
        get
        {
            return this.frequency;
        }
    
        set
        {
            this.frequency = value;
    
            if (value != null)
            {
                this.FrequencyId = value.Id;
            }
        }
    }
    

    Now I belive that I cannot set the [Required] annotation on an association but instead on the foreign key id (what the above article says). The actual Treatment Frequency class looks like this:

    public class TreatmentFrequency
    {
    [Key]
    public virtual long Id { get; set; }

        \[Required\]
        \[StringLength(10)\]
        public virtual string Code { get; set; }
    
        \[Required\]
        \[StringLength(40)\]
        public virtual string Name { get; set; }
    
        public override bool Equals(object obj)
        {
            obj = obj as TreatmentFrequency;
            if (obj == null)
            {
                return false;
            }
    
            return this.Id == ((TreatmentFrequency)obj).Id;
        }
    
        public override int GetHashCode()
        {
            return this.Name.GetHashCode();
        }
    }
    

    I have overriden the Equals and GetHashCode method becuase in another article it said that when in a collection you need to override the equals to match on the key otherwise when you use SelectedItem although all the values would be the same between the item in the collection and the selecteditem they would be two different instances and thus not match with the default implementation of Equals. Now my xaml looks like this:

    <df:DataField Label="Frequency">
    <ComboBox SelectedItem="{Binding Path=CurrentItem.Frequency, Mode=TwoWay}" ItemsSource="{Binding Path=Frequenc

    WPF wpf csharp wcf regex question

  • PRISM - When is the module catalogue's modules registered with the container?
    P Phillip Donegan

    Hi All, As the title says really, when in PRISM are each of the modules in the module catalog registered with the container (in my case Castle). And can I override it? Basically the problem I have is that when doing this for example:

            this.ModuleCatalog.AddModule(AvailableApplicationModules.SampleModule);
    

    At some point that module is then registered with the container. Now in castle atleast when doing this if no Name is specified (which it isn't) then the default AssemblyQualifiedName of the implementation is used. This includes the version number and is causing problems on the build server when it will always be dynamic. So my plan is the set the .Name property when the module is registered with the container so that I can retrieve the module by using:

    this.windsorContainer.Resolve(string Key)

    But I can't find the part were the modules are registered with the container. I'm presuming that PRISM itself takes care of this so I guess I need to override something.

    WPF sysadmin docker help tutorial question

  • free cloud hosting for testing purpose
    P Phillip Donegan

    If you have an MSDN account (Premium or Ultimate) Azure is free (with certain restrictions like CPU size). You do still need to insert credit card details but you won't get charged unless you exceed your limits. If this isn't an option I seem to remember there be some dev utility that simulates the cloud locally on your workstation. I can't remember the name but it does sound familiar I'm sure a quick google would get you the name. Phil

    Cloud Computing hosting cloud testing beta-testing help

  • Dynamically Loaded Modules (.xap) with Build Server Versioning
    P Phillip Donegan

    Hi All, I recently started working on a new project. One of my first tasks was to make the modules load dynamically. Basically the client would download the shell xap then when they required another module this modules xap file would be downloaded. Doing this doesn't force the user to download one massive xap file and therefore improve performance. I have this working without too much trouble however the problem I have is that once on the client I have no reference to the xap file that I have downloaded unless I hard code something. So at the moment I have solved this by creating an AvailableApplicationModule.shared.cs file which contains a list of all dynamic modules in the solution, then in the bootstrapper these are loaded into the module catalog. E.g.

    public static ApplicationModuleInfo SampleModule
    {
    get
    {
    return new ApplicationModuleInfo
    {
    ModuleName = "SampleModule",
    ModuleType = GetModuleTypeForModule("SampleModule", "SampleModuleModule"),
    InitializationMode = InitializationMode.OnDemand,
    Ref = "Example.UI.SampleModule.xap"
    };
    }
    }

    The GetModuleTypeForModule will return the Fully qualified name like: Example.UI.SampleModule.SampleModuleModule, Example.UI.SampleModule, Version=1.1.0.0, Culture=neutral, PublicKeyToken=537c3450b3658434 Then in the client tier I can access the module catalog get the typename and then create an instance of this ModuleType which will then initialise itself. Unfortunatly by doing this I have to specify a build version. Now this is fine on a local machine as I can just override the build targets to force the version to 1.1.0.0 however once I commit this to TFS the actual build number will be used. Since I have to construct this fully qualified name in code it'll break as instead of getting 1.1.0.0 it'll be something like 1.0.15.1345. Which it won't be able to find as I need to specify the version number in code. I guess this is a common problem so I'm just looking for some adivce on how you guys handle this? Not sure if this is relevant but I'm using PRISM and Castle as the container. Thanks Phil

    WPF design sysadmin linux docker performance

  • Deep Linking between views when using PRISM
    P Phillip Donegan

    Hi All, I've started working on a new project which uses PRISM to create all of the modules. We also use Castle as the container. My question is I want to be able to deep link between views in the same module. All the examples on the web only show how to deep link between modules I.e. implement INavigationAware, register the view with the region manager and then if the IsNavigationTarget returns true then your pretty much done. But when I try to do this in the same module it doesn't work as the region manager wants to look in the module catalog for a specific view which obviously doesn't exist as its just a list of modules. In my example the module is called Search which is registered in the Bootstrapper with a ModuleInfo. ModuleName is set to "Search". I then register all of the Views/ViewModels with the container in the IWindsorInstaller implementation. In my Initialize method I then register the root view and the subsequent results view (which is were I want to navigate to) with the RegionManager. Then I think I should be set to go, only thing is I haven't set a URI anywhere for the results view unless its the view name (tried that didn't work). So I guess I need to do that somewhere but not sure were? Then once this is done I think I should be all set to go aslong as the Results view implements INavigationAware which it does but at the moment it never gets this far! Any help/pointers appreciated! Phil

    C# tutorial question docker help

  • Problem getting EditCommand event to fire in nested DataGrid
    P Phillip Donegan

    Still trying to solve this, anyone got any ideas at all?

    ASP.NET help question

  • TextBox Readonly Property
    P Phillip Donegan

    Can you not just disable the textbox and then change the text property? Then it will appear as if readonly but you should still be able to change the value.

    ASP.NET com sysadmin

  • Problem getting EditCommand event to fire in nested DataGrid
    P Phillip Donegan

    Hi All, I have a details view which contains a datagrid. They are both populating fine but now I want to edit the rows in the datagrid. I'm setting up the datagrid like so:

    protected override void OnInit(EventArgs e)
    {
    InitializeComponent();
    base.OnInit(e);
    }

        private void InitializeComponent()
        {
            DataGrid productCulturesDataGrid = ((DataGrid)ProductDetailsView.FindControl("ProductsCultureDataGrid"));
    
            productCulturesDataGrid.EditCommand += new DataGridCommandEventHandler(this.ProductsCultureDataGrid\_EditCommand);
            this.Load += new System.EventHandler(this.Page\_Load);
        }
    

    And then in the page load method i'm setting the datasource like so:

    //GetListOfProductCultures
    List<ProductsCultureInfo> productCultures = (List<ProductsCultureInfo>)ListOfProductCultures();

    DataGrid productCulturesDataGrid = ((DataGrid)ProductDetailsView.FindControl("ProductsCultureDataGrid"));
    productCulturesDataGrid.DataSource = productCultures;
    productCulturesDataGrid.DataBind();

    The EditCommand method looks like this but is never triggered:

        private void ProductsCultureDataGrid\_EditCommand(object sender, DataGridCommandEventArgs e)
        {
            DataGrid ProductsCultureDataGrod = (DataGrid)ProductDetailsView.FindControl("ProductsCultureDataGrid");
            ProductsCultureDataGrod.EditItemIndex = e.Item.ItemIndex;
        }
    

    Any ideas what i'm doing wrong? Also not sure if this has anything to do with it but this is a dotnetnuke module. Thanks Phil P.S. here is the ascx page encase that helps

    ASP.NET help question

  • Nested WCF Services
    P Phillip Donegan

    Hi All, The current application that I'm working on is made up of several modules which have a WCF tier to expose them to other projects. There is then another project which will consume all of these modules and then use these to perform logic and then expose itself with another WCF tier. E.g. Core | | | | \/ \/ Module1 Module2 etc etc When I execute a test that should access the Core WCF methods which then in turn should call a number of methods from the underlying modules which have a WCF tier, I get the following error: WCF_Core_Test.Class1.TestViewOrder: System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail] : Could not find default endpoint element that references contract 'OrderHistory_API.ILogic' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element. Basically the core WCF wants to know about each of the endpoints for the underlying modules, even though these are correctly working when they standalone. Shouldn't all of the be done automatically when I add a service reference? Any help would be appreciated. Phil

    WCF and WF help csharp asp-net wcf question

  • WCF: Return type should implement abstract method.
    P Phillip Donegan

    Ok, I'll give that a go, thanks for the help Ian, many Kudos!

    WCF and WF help csharp wcf

  • WCF: Return type should implement abstract method.
    P Phillip Donegan

    Ian Shlasko wrote:

    Anything in a DataContract class needs to have a visible implementation on the client side. No method calls in a DataContract class go over the network, so the client has to have a full implementation. If this is meant to run on the server side, it needs to be part of your ServiceContract class.

    Ok, so the Calculate method of Percentage should be run server side not client side. So how can I add this method to the Service Contract? This method is only called when a different method which is in the service contract is called. Its almost at the wrong level allow me to explain: The methods that are in the service contract are for manipulating a shopping cart. So AddItem, AddPromotionCode, SetDelivery, ViewBasket etc etc. The calculate method is a function that is called when the ViewBasket operation is called. This then checks to see if a promotion is applied and if true, what the value of the discount is. So this calculate method is an internal function and shouldn't be possible to be called directly. And its a functions of the basket not the shopping cart. All the methods in the service contract are for manipulating the shopping cart, not the basket directly. So Shopping Cart -- Service Contract at this level | | \/ Basket -- which has the Calculate method So if I add Calculate to the Service Contract i'm kind of breaking the architecture of the solution :/

    WCF and WF help csharp wcf

  • WCF: Return type should implement abstract method.
    P Phillip Donegan

    Hmm, just added Test() to the percentage class and the test suite could not see it. So that would that support my argument that I need to expose the Calculate method in Percentage to the WCF so that it knows its implemented?

    WCF and WF help csharp wcf

  • WCF: Return type should implement abstract method.
    P Phillip Donegan

    Ian Shlasko wrote:

    Does the test suite, where the compile-time error is occurring, reference these classes from the same library, or is it using a copy? If it's a copy, check the implementation of 'Percentage' in the test suite to make sure Calcluate() is implemented.

    Hmm, I've just done this in the test suite: ECommerce_API.Percentage percentage = new ECommerce_API.Percentage(); So that's me calling the Percentage class from the Service Reference (called ECommerece_API). This class has a method called Calculate which I can call so the IDE knows that its implemented. Its just the reference.cs file that's having trouble??

    WCF and WF help csharp wcf

  • WCF: Return type should implement abstract method.
    P Phillip Donegan

    Ok: How I've got it now: [DataContract] [Serializable] public abstract class Discount : IDiscount { #region Constructors internal Discount() { } #endregion //Should be abstract but then WCF engine will not compile public virtual void Calculate(VirtualObject.IBasket basket) { throw new NotImplementedException(); } #region Helper Methods protected decimal RoundToTwoDecimalPlaces(decimal amount) { return (Math.Ceiling(amount * 100) / 100); } #endregion } This compiles and works but really it should be abstract. So how it should be: [DataContract] [Serializable] public abstract class Discount : IDiscount { #region Constructors internal Discount() { } #endregion public abstract void Calculate(VirtualObject.IBasket basket); } And this is how its implemented in the concrete class Percentage: [DataContract] [Serializable] internal class Percentage:Discount { internal Percentage() { } public override void Calculate(VirtualObject.IBasket basket) { foreach (ECommerce_Module.VirtualObject.IBasketItem item in basket.Items) { decimal productPrice = item.ItemPricePreDiscount.Value; item.ItemPricePostDiscount = (item.ItemPricePreDiscount - RoundToTwoDecimalPlaces(productPrice * (DiscountValue.Value / 100)) * item.Quantity); } } } But this the returns the error: Error 2 'ECommerce_TestSuite.ECommerce_API.Percentage' does not implement inherited abstract member 'ECommerce_Module.BusinessObject.Discount.Discount.Calculate(ECommerce_Module.VirtualObject.IBasket)' ..\ECommerce_Module\v1\DotNet\ECommerce_TestSuite\Service References\ECommerce_API\Reference.cs 51 26 ECommerce_TestSuite This error is in the test suite, where ECommerce_API is the service reference to the WCF project. So that tells me that the WCF project doesn't know that the method Calculate is implemented in the concrete class because I haven't "opted" to expose the method, but how I do this I have no idea! Thanks for the help so far though

    WCF and WF help csharp wcf

  • WCF: Return type should implement abstract method.
    P Phillip Donegan

    It must be related to WCF as this error occurs in the test project were the service reference is. In the implementation the project compiles fine. The workaround I have at the moment is to make the Calculate method in the abstract class virtual. Then because it knows a type Discount is returned it will compile and all is well. However this should be an abstract method really I just need to tell the WCF project that this method is implemented in the concrete class Percentage somehow?

    WCF and WF help csharp wcf

  • WCF: Return type should implement abstract method.
    P Phillip Donegan

    Sorry forgot to say, its a compile time error.

    WCF and WF help csharp wcf

  • WCF: Return type should implement abstract method.
    P Phillip Donegan

    Nope, Error 1 Attribute 'DataMember' is not valid on this declaration type. It is only valid on 'property, indexer, field' declarations.

    WCF and WF help csharp wcf

  • Getting a value from a constructor
    P Phillip Donegan

    Maybe you should google encapsulation, since I think that is what your trying to do.

    C# question data-structures

  • WCF: Return type should implement abstract method.
    P Phillip Donegan

    Hi All, I think I'm just being stupid and I need to add an attribute to a method but despite endless googling I can still not find the answer so I thought I'd try my luck here. I have a abstract class called Discount, Discount has an abstract method called Calculate: [DataContract] [KnownType(typeof(Percentage))] public abstract class Discount : IDiscount { //Some data members here public abstract void Calculate(); } Here is the concrete implementation: [DataContract] internal class Percentage:Discount { internal Percentage() { } public override void Calculate() { //Logic here } } Now in the interface for the WCF project a generic type of Discount is returned (so I can return different implementations of discount), and this knows that it should implement a method called Calculate(). However because WCF is opt in with reagrds to data it doesn't yet know about the Calculate implementation. So I get this error: Error 1 'ECommerce_TestSuite.ECommerce_API.Percentage' does not implement inherited abstract member 'ECommerce_Module.BusinessObject.Discount.Discount.Calculate(ECommerce_Module.VirtualObject.IBasket)' So I think I just need to add an attribute to either the implementation of the Calculate method or to the abstract method declarations so that the WCF project knows that it does have an implemented method. However I do not know what attribute this is! Any help would be really appreciated. Phil

    WCF and WF help csharp wcf
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups