namespaces

TypeScript extend JQuery under Namespace

若如初见. 提交于 2020-01-01 11:39:11
问题 I'm trying to extend the default JQuery interface and the default object jQuery by a function in TypeScript Code /// <reference path="jquery.d.ts" /> namespace MyNameSpace { var $ = jQuery; export interface JQuery { test(options: Object): JQuery; } $.fn.test = function(options: Object): JQuery { if (this.length === 0) { console.log('Error!'); return this; } console.log(options); return this; } export var testBody = function() { jQuery('body').test({ 'HELLO': 'TEST' }); } } The Problem Now I'm

Why does iostream include time.h?

感情迁移 提交于 2020-01-01 10:57:14
问题 Consider this code: #include <iostream> template<class C> struct time { }; int main() { } It produces (GCC 4.5): error: ‘template<class C> struct time’ redeclared as different kind of symbol /usr/include/time.h:186:15: error: previous declaration of ‘time_t time(time_t*)’ Why does iostream include time_t time(time_t*) ? Why does iostream include time_t time(time_t*) outside std namespace? (unanswered) Why, if I remove template<class C> , do I not get this error? 回答1: If you run g++ -H -Wall

How do I wrangle python lookups: make.up.a.dot.separated.name.and.use.it.until.destroyed = 777

帅比萌擦擦* 提交于 2020-01-01 10:14:10
问题 I'm a Python newbie with a very particular itch to experiment with Python's dot-name-lookup process. How do I code either a class or function in "make.py" so that these assignment statements work succesfully? import make make.a.dot.separated.name = 666 make.something.else.up = 123 make.anything.i.want = 777 回答1: #!/usr/bin/env python class Make: def __getattr__(self, name): self.__dict__[name] = Make() return self.__dict__[name] make = Make() make.a.dot.separated.name = 666 make.anything.i

Can you put a library inside a namespace?

孤者浪人 提交于 2020-01-01 09:43:27
问题 I am working with OpenCV and I would like to put the entire library inside it's own namespace. I've looked around quite a bit but haven't found an answer... Can you do this without modifying the library source code? If then how? 回答1: Basically no. You could attempt to do it by writing wrappers and macros, but it would be unlikely to work. If you really need to do this, a better approach is to fork the library and make the needed namespace additions. Of course, you would REALLY need to do it

Turn Off the Folder/Namespace Convention

假装没事ソ 提交于 2020-01-01 09:09:15
问题 I see people talking about the annoyance of Visual Studio automatically creating a namespace to correspond with project folders. Is there a way to turn this off in VS 2010, without resorting to modifying class templates? 回答1: If you use Resharper, there is an attribute on the folder 'Namespace Provider'. Even if you set it to false, Visual Studio will still add folder name as a namespace. However, Resharper fixes it with one click on the namespace. 回答2: Use Resharper. Turn off the "Namespace

Importing a namespace vs. including files in PHP

情到浓时终转凉″ 提交于 2020-01-01 08:53:38
问题 I have started building my code library since PHP 4. I have used require_once to import classes. Now with PHP 5.3 I have met defining namespaces and importing them. I would like to change my source files to use importing ( use statement) instead of using require_once . Is this the right decision, I am not sure. I guess it would be easy. Defining namespace at the top of class files and doing a search & replace on other files that use them (replace require_once with use ). On practice what may

Load Ruby gem into a user-defined namespace

风格不统一 提交于 2020-01-01 08:52:49
问题 Given a gem that defines top-level classes that clash with some code I have written, is it possible to require the gem in such a way that all its classes are grouped inside a module I can define? For example, if an unsafe_gem defines a class: class Word # ... some code end I would need something like: class Word # My word class. end module SafeContainer # This obviously doesn't work # (i.e. the gem still defines ::Word). require 'unsafe_gem' end So that I can distinguish between: Word.new # =

how i can list out all the namespace in XML?

和自甴很熟 提交于 2020-01-01 08:20:51
问题 My basic requirement is to get element value from the XML file, i have used XMLDoxument.SelectSingleNode. My XML file contains some Namespace in header, so i have used NameSpaceManager to add namespace-prefix and i have used prefix to get that particular element. Now in my XML files that namespaces are getting vary, i don’t want to do any hard coding, is there any way that i can find out all the namespaces and i can add it to NameSpaceManager. Thanks. 回答1: Namespaces can be found anywhere

Way to get VS 2008 to stop forcing indentation on namespaces?

≯℡__Kan透↙ 提交于 2020-01-01 08:17:11
问题 I've never really been a big fan of the way most editors handle namespaces. They always force you to add an extra pointless level of indentation. For instance, I have a lot of code in a page that I would much rather prefer formatted as namespace mycode{ class myclass{ void function(){ foo(); } void foo(){ bar(); } void bar(){ //code.. } } } and not something like namespace mycode{ class myclass{ void function(){ foo(); } void foo(){ bar(); } void bar(){ //code.. } } } Honestly, I don't really

Iterate through a Namespace

点点圈 提交于 2020-01-01 08:06:50
问题 I have got a namespace looking like this : Namespace(aTQ=None, bE=None, bEQ=None, b=None, bQ=None, c=None, c=None, cJ=None, d=None, g=None, jR=['xx', '015'], lC=None, l=None) How can I iterate through it so I can find and replace the 'xx' value for the "jR" key in place ? 回答1: I'm not sure what you know in advance, (the name jR , or only that one name has a not None value) but you can try using vars() which, like __dict__ should be a dict that has the names in your namespace as its keys. So