I want to have an extension method for XElement/XAttribute that allows me to apply a "ValueOrDefault" logic - perhaps with various slightly different implementations: ValueOrNull, ValueOrDefault, NumericValueOrDefault (which validates if the value is numeric), but I want to constrain these methods so that they can only work with ValueTypes or String (i.e. it does not really make sense to use any other reference types. Is it possible to do this with one implementation of each method, or will I have to have one where the constraint is "Structure" and one where the constraint is "String" - if I combine Structure and String in the generic constraint, I get the error :
'Structure' constraint and a specific class type constraint cannot be combined.
An example of the current method implementation is as follows:
<Extension()> _
Public Function ValueOrDefault(Of T As {Structure})(ByVal xe As XElement, ByVal defaultValue As T) As T
If xe Is Nothing or xe.Value = "" Then
Return defaultValue
End If
Return CType(Convert.ChangeType(xe.Value, GetType(T)), T)
End Function
Hi
I want to send emails using
HtmlEmail email = new HtmlEmail();
i added Base64 Encoded image to email
email sent successfully but gmail adds <wbr> tag in encoded image
Please help me ..
Hello,
I have created a custom button as i wanted an image and a text inside it as follows:
<Style TargetType="{x:Type Local:ImageButton}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Local:ImageButton}">
<StackPanel Height="Auto" Orientation="Horizontal">
<Image Margin="0,0,3,0" Source="{TemplateBinding ImageSource}"/>
<TextBlock Text="{TemplateBinding Content}" />
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Here, ImageButton is a class which inherits from Button class and has ImageSource as a dependency property.
But i want to keep the look and feel of the original button.
How can i do it?
Thanks.
As I familiarize myself with Asp.Net MVC, I am using MVC 2, I have noticed the use of a BaseViewData class in the Kigg project which I am unsure how to implement.
I want each of my ViewModels to have certain values available. Using an iterface comes to mind but I am wondering what the best practice is and how does Kigg do it?
Kigg
public abstract class BaseViewData
{
public string SiteTitle { get; set; }
// ...other properties
}
public class UserListViewData : BaseViewData
{
public string Title { get; set; }
// .. other stuff
}
In my WebForms application I use a BasePage that inherits from System.Web.UI.Page.
So, in my MVC project, I have this:
public abstract class BaseViewModel
{
public int SiteId { get; set; }
}
public class UserViewModel : BaseViewModel
{
// Some arbitrary ViewModel
}
Referencing the Kigg methodology, how do I make sure that each of my ViewModel that inherits from the BaseViewModel have the SiteId property?
What is the best practice, samples or patterns I should be using?
Hi,
I have the following hierarchy of classes
class classOne
{
virtual void abstractMethod() = 0;
};
class classTwo : public classOne
{
};
class classThree : public classTwo
{
};
All classOne, classTwo and classThree are abstract classes, and I have another class that is defining the pure virtual methods
class classNonAbstract : public classThree
{
void abstractMethod();
// Couple of new methods
void doIt();
void doItToo();
};
And right now I need it differently...I need it like
class classNonAbstractOne : public classOne
{
void abstractMethod();
// Couple of new methods
void doIt();
void doItToo();
};
class classNonAbstractTwo : public classTwo
{
void abstractMethod();
// Couple of new methods
void doIt();
void doItToo();
};
and
class classNonAbstractThree : public classThree
{
void abstractMethod();
// Couple of new methods
void doIt();
void doItToo();
};
But all the nonAbstract classes have the same new methods, with the same code...and I would like to avoid copying all the methods and it's code to every nonAbstract class. How could I accomplish that?
Hopefully it's understandable...
The popular PTS (Platform Technology Services) technical trainings for partners now include a workshop on Big Data.
First workshop will take place in Milan on July 10-12. (You can register by clicking the link below)
Oracle Big Data
Technical
Workshop
July
10-12,
2012: Cinisello Balsamo, Milan, Italy
For more info contact [email protected]
I have illustrated my question in this example
class Car {
public void start(){
System.out.println("Car Started!!!");
}
}
class Mercedes extends Car {
public void start(){
System.out.println("Mercedes Started!!!");
}
}
Now, in my main program, I write
Mercedes m = new Mercedes();
m.start();
It prints: Mercedes Started!!!
How do I call the start() method of Car class using the same object so that the output can be
Car Started!!!.
Edit:
Actually It was asked in an interview I attended. I gave the super keyword answer. But the interviewer denied it. He said he'd give me a hint and said Virtual Function. I have no idea how to use that hint.
Is it possible to use ASP.NET Dynamic Data with SubSonic 3 in-place of Linq to SQL classes or the Entity Framework? MetaModel.RegisterContext() throws an exception if you use the context class that SubSonic generates. I thought I remembered coming across a SubSonic/Dynamic Data example back before SubSonic 3 was released but I can't find it now. Has anyone been able to get this to work?
Hi,
I am able to debug my ruby program. At times, I would want to go inside the library methods and see what is happening. How to achieve it in Ruby.
For example,
[ 3, 1, 7, 0 ].sort
i would want to go inside the sort method and see how that works lively. In Java+Eclipse this is possible, all I have to do is to attach the source of Foundation classes in Eclipse. Is it possible in Ruby with Netbeans as IDE?
Thanks
My class diagram:
BaseContentClass
Page inherits BaseContentClass
Tab inherits BaseContentClass
...
If I do this
ModelBinders.Binders.Add(typeof(BaseContentObject), new BaseContentObjectCommonPropertiesBinder());
then when in controller action parameter of type Tab appears, custom model binder is not fired.
It gets fired if I do this:
ModelBinders.Binders.Add(typeof(Tab), new BaseContentObjectCommonPropertiesBinder());
But I don't want to go writing "n" number of Add statements in my global.asax.cs to associate all the derived classes with my custom model binder, do I? I don't know if I have any other option.
I have the following code:
[SetUp]
public void SetMeUp()
{
Mapper.CreateMap<SourceObject, DestinationObject>();
}
[Test]
public void Testing()
{
var source = new SourceObject {Id = 123};
var destination1 = Mapper.Map<SourceObject, DestinationObject>(source);
var destination2 = Mapper.Map<ObjectBase, ObjectBase>(source);
//Works
Assert.That(destination1.Id == source.Id);
//Fails, gives the same object back
Assert.That(destination2 is DestinationObject);
}
public class ObjectBase
{
public int Id { get; set; }
}
public class SourceObject : ObjectBase { }
public class DestinationObject : ObjectBase { }
So basically, I want AutoMapper to automatically resolve the destination type to "DestinationObject" based on the existing Maps set up in AutoMapper. Is there a way to achieve this?
Hi,
I'm currently working with an massive PHP codebase, witch is completely undocumented.
Here's the deal. All of the PHP code is included every page call. They build a simple include all kinda function that scan's the directory and includes all PHP files it can find. It works recursively for all the subfolders.
I would like to know what functions are used in what files and from which files those functions came.
I need to know this in order to switch to normale includes. Also it gives me more information about not used functions and files (since it a really old and big codebase, there is a lot of legacy in it).
It there a tool or something for PHP that can check this kind of stuff in a codebase?
Take the following code
class A {
};
class B : public A {
};
class C : public A {
int x;
};
int main (int argc, char** argv) {
A* b = new B();
A* c = new C();
//in both cases, only ~A() is called, not ~B() or ~C()
delete b; //is this ok?
delete c; //does this line leak memory?
return 0;
}
when calling delete on a class with a non-virtual destructor with member functions (like class C), can the memory allocator tell what the proper size of the object is? If not, is memory leaked?
Secondly, if the class has no member functions, and no explicit destructor behaviour (like class B), is everything ok?
I ask this because I wanted to create a class to extend std::string, (which I know is not recommended, but for the sake of the discussion just bear with it), and overload the +=,+ operator. -Weffc++ gives me a warning because std::string has a non virtual destructor, but does it matter if the sub-class has no members and does not need to do anything in its destructor?
-- FYI the += overload was to do proper file path formatting, so the path class could be used like
class path : public std::string {
//... overload, +=, +
//... add last_path_component, remove_path_component, ext, etc...
};
path foo = "/some/file/path";
foo = foo + "filename.txt";
//and so on...
I just wanted to make sure someone doing this
path* foo = new path();
std::string* bar = foo;
delete bar;
would not cause any problems with memory allocation
IT security organizations are spending too much on data protection for compliance but not enough on securing key trade secrets, the real crown jewels of corporate data.
When you create a new Uri like this:
New Uri(New Uri("http://example.com/test.php"),"?x=y")
it returns:
http://example.com/?x=y
It was supposed to return:
http://example.com/test.php?x=y
according to the every major browser out there (I'm not quite sure what RFC says though).
Is this is a bug or is there any other function out there which behaves correctly, also what's the best way to fix it without reinventing the wheel?
I was wondering how to do this, consider the following classes
public class Fruit
{
public string Name { get; set; }
public Color Color { get; set; }
}
public class Apple : Fruit
{
public Apple()
{
}
}
How can I instantiate a new fruit but upcast to Apple, is there a way to instantiate a bunch of Fruit and make them apples with the name & color set. Do I need to manually deep copy?
Of course this fails
Fruit a = new Fruit();
a.Name = "FirstApple";
a.Color = Color.Red;
Apple wa = a as Apple;
System.Diagnostics.Debug.Print("Apple name: " + wa.Name);
Do I need to pass in a Fruit to the AppleCTor and manually set the name and color( or 1-n properties) Is there an better design to do this?
I have made a class in php which is goind to be inherited by another class in the other folder.
when i put echo $this-protectedvariableofclass; //in subclass function
it gives no value
remember my base class is stored \class\user.php
sublass is stored as \model\model_user.php
Please help me out
Thanks in advance
My client wants to standardize address information for existing and future addresses collected for their customers, particularly the street suffixes. The application used to enter and collect address information has the street suffix separated from the address field, but it is a textbox instead of a drop down list therefore things are not standardized. I know there are some options out there to standarize data, but they would like a less expensive alternative. Are there any functions in SQL Server that I can use to standardized data?
In my last question i asked how to best send a string from one view controller to another, both which were on a navigation stack:
http://stackoverflow.com/questions/2898860/pass-string-from-tableviewcontroller-to-viewcontroller-in-navigation-stack
However I just realised I can either pass the path to the file in the app's document's folder as the first (the table view) has already accessed the data in the file should I pass viewcontroller the data to the pushed VC?
Oracle's Master Data Management suite has seen remarkable development progress in the past year and a half. Leveraging out-of-the-box integration to applications provided by Application Integration Architecture, the cost, risk and time it takes to implement an MDM solution has been cut in half. Oracle Applications are now 'MDM Aware', Data Quality tools have reached state-of-the-art status, and new hubs are coming on line. In this AppsCast, Pascal Laik, VP MDM Products discusses this progress, what it means for Oracle customers, and where we are going from here.
Tens of thousands of Arkansas National Guard soldiers became the latest victims of a security breach at a military base after an unencrypted external hard drive was discovered missing last month.
States are passing more and more data security laws, the US Senate and the House have bills meandering through Congress, securing personal information and encrypting that data is no longer optional.
I am writing a game editor, and have a lot of different "tool" objects. They all inherit from BTool and have the same constructor.
I would like to dynamically populate a toolbox at runtime with buttons that correspond to these tools, and when clicked have them create an instance of that tool and set it as the current tool.
Is this possible, and if so will it be better/easier than creating those buttons by hand?
hi , in my project i need a tow tables each of it has about 2000 row , i want my application to be speed
so my db should load into memory (cached) when the app start and before it close the db have to be saved on the disk . i am using java and i want to use sql