Hi,
I'm using linq to sql and I need to have a class in the dbml file which some of its properties are creating dynamically . Is there any way to have a class in dbml file with some pre defined properties and some dynamic properties .
Or is there any way to create a class in dbml file dynamically?
Thank you,
everyone!
I process video from IP cameras and have wrote a motion detection algorithm based on decompressed video analysis. But i really something more fast. I've found several papers about compressed domain analysis but have failed to find any implementations.
Can anyone recommend me some code?
found materials:
http://www.ist-live.org/intranet/school-of-informatics-university-of-bradford001-7/41410206.pdf/view
http://doc.rero.ch/lm.php?url=1000,43,4,20061128120121-NA/Bracamonte_Javier_-_A_Low_Complexity_Change_Detection_Algorithm_20061128.pdf
Given the classes:
public class Person
{
public string Name { get; set; }
}
public class Student : Person
{
public int StudentId { get; set; }
}
public class Source
{
public Person Person { get; set; }
}
public class Dest
{
public string PersonName { get; set; }
public int? PersonStudentId { get; set; }
}
I want to use Automapper to map Source - Dest.
This test obviously fails:
Mapper.CreateMap<Source, Dest>();
var source = new Source() { Person = new Student(){ Name = "J", StudentId = 5 }};
var dest = Mapper.Map<Source, Dest>(source);
Assert.AreEqual(5, dest.PersonStudentId);
What would be the best approach to mapping this given that "Person" is actually a heavily used data-type throughout our domain model.
I'm trying to find the actual class of a django-model object, when using model-inheritance.
Some code to describe the problem:
class Base(models.model):
def basemethod(self):
...
class Child_1(Base):
pass
class Child_2(Base):
pass
If I create various objects of the two Child classes and the create a queryset containing them all:
Child_1().save()
Child_2().save()
(o1, o2) = Base.objects.all()
I want to determine if the object is of type Child_1 or Child_2 in basemethod, I can get to the child object via o1.child_1 and o2.child_2 but that reconquers knowledge about the childclasses in the baseclass.
I have come up with the following code:
def concrete_instance(self):
instance = None
for subclass in self._meta.get_all_related_objects():
acc_name = subclass.get_accessor_name()
try:
instance = self.__getattribute__(acc_name)
return instance
except Exception, e:
pass
But it feels brittle and I'm not sure of what happens when if I inherit in more levels.
Hi,
We cannot mock his class in RhinoMocks.
public class Service
{
public Service(Command[] commands){}
}
public abstract class Command {}
// Code
var mock = MockRepository.GenerateMock<Service>(new Command[]{}); // or
mock = MockRepository.GenerateMock<Service>(null)
Rhino mocks fails complaining that it cannot find a constructor with matching arguments.
What am I doing wrong?
Thanks,
Has anybody bench marked selecting elements with id's and class's from CSS and javascript?
It would make sense that an element with an id is faster to select than if it had a class even if it was the only element with that class.
Do I really need to be concerned?
I've got a method that gets called on an event, which presents me with two variables varA, varB (both strings). This method gets called with new information quite frequently, thus I have created a separate method that takes in the two parameters. I want to run this method in a thread, however have struck the issue that Thread.Start will not accept parameters.
I've tried a few supposed methods, but have so far had no luck.. I think my best bet is to create a separate class, and handle it there.. However I have a List which I am inserting data into, and hit a dead end when the separate class tried to access that list, since it was in a different class.
Can someone help me out here please?
I have a header file:
class A
{
public:
DeviceProxyPtr GetDeviceProxy();
};
DeviceProxyPtr is defined in a different header file like this:
typedef SmartPtrC<DeviceProxyC> DeviceProxyPtr;
I don't want to include DeviceProxyPtr definition header.
If a return type was DeviceProxy* I could simply use predeclaration class DeviceProxy.
Is there any way to do the same with my smart pointer class?
how does this work?
in irb:
>> class A
>> b = [1, 2,3]
>> end
=> [1, 2, 3]
Is b an instance variable? class variable? how would I access b from
outside the class? Is it used for meta-programming?
I get the ff. error in Java Console occassionally:
Exception in thread "thread applet-my.package.MyApplet-10" java.lang.NoClassDefFoundError: another/package/SomeClass
at my.package.MyApplet.init(MyApplet.java:95)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: another.package.SomeClass
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 3 more
Caused by: java.io.IOException: open HTTP connection failed:https://myserver/mycontext/applets/another/package/SomeClass.class
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 7 more
My applet tag is as follows:
<applet codebase="../../applets" code="my.package.MyApplet" class="invisible" id="myApplet">
<param value="value0" name="param0"/>
...
<param value="valueN" name="paramN" />
<param value="folder/myApplet__0.0.1177.jar,folder/commons-io-1.3.2__0.0.1177.jar,..." name="cache_archive"/>
<param value="0.0.1177.0,0.0.1177.0,...," name="cache_version"/>
</applet>
It is important I stress the word "occasionally". Sometimes the applet is initialized without a hitch. This also means that, often, when the browser is restarted, the problem goes away.
I am aware of http://stackoverflow.com/questions/698890/applet-fails-to-load-class-from-jar and http://stackoverflow.com/questions/872905/applet-class-loader-cannot-find-a-class-in-the-applets-jar but I think they are not applicable to my case. SomeClass and MyApplet are in the same jar and the page is being accessed locally.
It seems to me that there must be some public domain collection of gettext compatible PO files that we could search for 1:1 or fuzzy translations for strings commonly used in software applications?
Is there a technical and copyright friendly way to query services like Google's Translator Toolkit, LaunchPad, Mygengo, etc. to find translations for common strings?
Thank you,
Malcolm
I'm currently reading "Effective C++" and there is a chapter that contains code similiar to this:
template <typename T>
class Num {
public:
Num(int n) { ... }
};
template <typename T>
Num<T> operator*(const Num<T>& lhs, const Num<T>& rhs) { ... }
Num<int> n = 5 * Num<int>(10);
The book says that this won't work (and indeed it doesn't) because you can't expect the compiler to use implicit typecasting to specialize a template.
As a soluting it is suggested to use the "friend" syntax to define the function inside the class.
//It works
template <typename T>
class Num {
public:
Num(int n) { ... }
friend
Num operator*(const Num& lhs, const Num& rhs) { ... }
};
Num<int> n = 5 * Num<int>(10);
And the book suggests to use this friend-declaration thing whenever I need implicit conversion to a template class type. And it all seems to make sense.
But why can't I get the same example working with a common function, not an operator?
template <typename T>
class Num {
public:
Num(int n) { ... }
friend
void doFoo(const Num& lhs) { ... }
};
doFoo(5);
This time the compiler complaints that he can't find any 'doFoo' at all.
And if i declare the doFoo outside the class, i get the reasonable mismatched types error. Seems like the "friend ..." part is just being ignored.
So is there a problem with my understanding? What is the difference between a function and an operator in this case?
hi all,
i'm accessing the stylesheet collection like this:
var css = document.styleSheets[0];
it returns eg. http://www.mydomain.com/css/main.css
question: how can i strip the domain name to just get /css/main.css ?
thx
Hi,
I've got a movie clip symbol in my .fla file that I need to reference in an .as file which is in a subfolder in the project. I select the symbol in the library and edit its properties.
Its name is bubble; I Export for ActionScript and Export in frame 1. I give it a class name of Bubble.
Now I need to go to my .as class, called SomeClass.as
There, I need to reference the symbol, because I want to move it from within related code in that .as file. But if I try bubble.x I get an error. If I try var myBubble:Bubble = new Bubble(); I get 'Access of undefined property myBubble'.
I was told that I might try 'importing the document class' but how do you import a class which is in the root directory of your app from within a class that's in a subfolder? (Don't know if this would provide the solution anyway)...
Tanks.
Every time I create an instance of the TestForm specified below, I have to overwrite the standard id format with auto_id=True. How can this be done once only in the form class instead? Any hints are very welcome.
views.py
from django.forms import ModelForm
from models import Test
class TestForm(ModelForm):
class Meta:
model = Test
def test(request):
form = TestForm(auto_id=True)
I have a class Car and a derived SportsCar: Car
Something like this:
public class Car
{
public int TopSpeed{ get; set; }
}
public class SportsCar : Car
{
public string GirlFriend { get; set; }
}
I have a webservice with methods returning Cars i.e:
[WebMethod]
public Car GetCar()
{
return new Car() { TopSpeed = 100 };
}
It returns:
<Car>
<TopSpeed>100</TopSpeed>
</Car>
I have another method that also returns cars like this:
[WebMethod]
public Car GetMyCar()
{
Car mycar = new SportsCar() { GirlFriend = "JLo", TopSpeed = 300 };
return mycar;
}
It compiles fine and everything, but when invoking it I get:
System.InvalidOperationException: There was an error generating the XML document. --- System.InvalidOperationException: The type wsBaseDerived.SportsCar was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.
I find it strange that it can't serialize this as a straight car, as mycar is a car.
Adding XmlInclude on the WebMethod of ourse removes the error:
[WebMethod]
[XmlInclude(typeof(SportsCar))]
public Car GetMyCar()
{
Car mycar = new SportsCar() { GirlFriend = "JLo", TopSpeed = 300 };
return mycar;
}
and it now returns:
<Car xsi:type="SportsCar">
<TopSpeed>300</TopSpeed>
<GirlFriend>JLo</GirlFriend>
</Car>
But I really want the base class returned,
without the extra properties etc from the derived class.
Is that at all possible without creating mappers etc?
Please say yes ;)
Please take a look at this code:
template<class T>
class A
{
class base
{
};
class derived : public A<T>::base
{
};
public:
int f(typename A<T>::base& arg = typename A<T>::derived())
{
return 0;
}
};
int main()
{
A<int> a;
a.f();
return 0;
}
Compiling generates the following error message in g++:
test.cpp: In function 'int main()':
test.cpp:25: error: default argument for parameter of type
'A<int>::base&' has type 'A<int>::derived'
The basic idea (using derived class as default value for base-reference-type argument) works in visual studio, but not in g++. I have to publish my code to the university server where they compile it with gcc. What can I do? Is there something I am missing?
I want to make an email for my website like "[email protected]" where people can send their feedbacks and suggestions to it. How can I do it? Can I do it with PHP or there is something else needed?
I have a method like the following:
public IEnumerable<T> GetControls<T>()
: where T : ControlBase
{
// removed.
}
I then created a class:
public class HandleBase<TOwner> : ControlBase
: TOwner
{
// Removed
}
I'd like to be able to call
GetControls<HandleBase<this.GetType()>>;
where it would use the type of THIS class to pass to the HandleBase. This would in essentially get all HandleBase that have an owner of THIS type.
How can I achieve this?
How can I make a javascript file only work on a single domain. I'll compress this file and when somebody tries to use it by copying my web site or just the javascript file, it won't work and give alert.
Hi,
I have an abstract class with some methods,including an abstract method(Execute()).This method is overridden in child class.Now, an event is raised(somewhere in application),and for this event there is a handler in base class.And,in this handler,I call Execute.
Now, the method of chilobject is executed.I am bit confused,how this works under the hood?
In visiting http://to./ you are given a legitimate website.
Is to. a valid domain name then, despite not ending with a TLD and having a superfluous period? Why?
Being valid, what would its DNS hierarchy be?