FAQ Database Discussion Community

## Constructor function - in simple namespace - Javascript

javascript,object,namespaces,prototype
In want to define a function-constructor inside a namespace. The way in which I defined the constructor till now was a simple constructor function without NS, combined with prototypal inheritance. The code looked kind of like: function mySuperObject() { var self = this; self.p1 = ""; self.p2 = "jkejie"; //...

## how to use class of other project in a solution (internal)? [duplicate]

c#,namespaces
This question already has an answer here: How to use a Class from one C# project with another C# project 7 answers Environment : In C#, I have a solution with many project. They were added with *.csproj files. Problem : In a project, you can use classes of...

## Laravel 5 - constantly repeating use statements

Is there a central place where I can put 'use' statements so I don't have to keep doing things like this with every single controller I create? <?php namespace App/Http/Controllers use Session; use Auth; use Input; use Log; use Carbon; use Response; use Illuminate\Routing\Controller; class BlaBlaController extends Controller {} Just...

## Namespace keyword in TypeScript

c#,namespaces,typescript,keyword
Trying to find out what does namespace keyword mean in TypeScript? Here's some reshuffle they've done recently to use namespace instead of module: https://github.com/Microsoft/TypeScript/commit/224e7630ea17c4547e97f85634f446b877955a67 In the absence of namespace spec, it looks like a rather pointless rename to make the language look C#-like. Or is there an obscure little difference...

## Silex namespace : class MainController does not exist

I try to use Silex Framework, but i have a problem with namespaces I think. when I instanciate my class MainController i have the following error : Class "MainController" does not exist here the namespace declaration in my MainController.php : namespace App\Controllers; use Silex\Application; class MainController implements \Silex\ControllerProviderInterface { .......

## How to get all namespace in project by assembly? [duplicate]

c#,reflection,namespaces
This question already has an answer here: Finding all Namespaces in an assembly using Reflection (DotNET) 6 answers I want get all namespace in main project by method assembly.(Not all aseembly) I read below question but not useful. Getting all types in a namespace via reflection for example class...

## Where is the Conversion Namespace in Windows Store Apps

.net,namespaces,windows-store-apps,windows-8.1
I am trying to write my first Windows Store App and am using some code from an old project. I am developing on a Windows 8.1 Pro machine with Visual Studio 2013 Express. I have no idea what people are calling the version of .NET I'm targeting and therefore, cannot...

## Why is ::class appended to PHP class in Laravel 5.1

php,namespaces,laravel-5
In Laravel 5.0 code like this is used for names-pacing/loading classes: 'providers' => [ /* * Laravel Framework Service Providers... */ 'Illuminate\Foundation\Providers\ArtisanServiceProvider', 'Illuminate\Auth\AuthServiceProvider', 'Illuminate\Broadcasting\BroadcastServiceProvider', 'Illuminate\Bus\BusServiceProvider', ] However, am seeing this in Laravel 5.1 'providers' => [ /* * Laravel Framework Service Providers... */ Illuminate\Foundation\Providers\ArtisanServiceProvider::class, Illuminate\Auth\AuthServiceProvider::class,...

## Namespace scope in C#

c#,namespaces,scope
Does the name of namespace also define the scope in the class? For example, I have namespace that is named by solution by default. Lets say in Program.cs name of namespace is "MySolution". in the next file interface that I have created, name of namespace is "Interfaces" When I go...

## Javascript variable is set in one function, but undefined in another function

javascript,jquery,namespaces,scope
I have the following Javascript, eventManager: { $musicGenres : null, //$musicGenres is the selector for a div-container of inputs musicGenres : [], // Functions handle : function(selectors) { selectors = (typeof selectors === 'undefined') ? { 'musicGenres' : '#musicGenres' } : selectors; // selectors default values... this.$musicGenres =$(selectors['musicGenres']);...

## Subroutines defined in required file assigned to wrong namespace after use of custom module

perl,module,namespaces
In a script I am working on, I have something similar to the following: require "environment.pm"; # Various definitions, including subroutine get_coll() use Custom::Module; In the Custom::Module file, I start with package Custom::Module; and end with 1; When I try to call get_coll() I get an error about it: (...

## Deleting namespace in Socket IO

node.js,namespaces,socket.io,typescript
This question has been asked before here, but I've implemented the answer and the problem has persisted. I'm working in typescript and I have a Room class that encapsulates a namespace (among other things), and a RoomManager class that maintains a list of rooms. I recently added functionality where a...

## silex file structure for custom service providers

php,namespaces,silex
I am working on a Silex project which requires some custom service providers and their related classes to be written. I am aware of the preferred file structure of silex projects but cannot anywhere find information on where custom classes should fit into this structure. All composer supplied libraries are...

## Namespace for (DDD) entities cutting across domains

namespaces,domain-driven-design,modeling
I have a couple of business-related domains like Purchase, Marketing and Economy. Having the models arranged into a namespace* for each domain would be nice, but there are some entities cutting across domains, like an Item. How to organize those cross-cutting objects? * = As in C#/Java/Python namespaces....

## Ruby namespacing

ruby-on-rails,ruby,namespaces
I'm pretty new to ruby, coming from a php background, but something is not clicking with me. So, let's say I have a Ruby on Rails application and I am versioning my API like so: app |_controllers |_api | |_v1 | | |_application_controller.rb | | |_user_controller.rb | |_application_controller.rb |_application_controller.rb With...

## Disabling default namespaces

namespaces,rust
Rust seems to use some namespaces by default. For example, I don't have to use std::string::String and can simply type String. How can I define my own struct String without clashing with std::string::String? And where can I find a list of the namespaces that are included by default?

## TYPO3-Upgrade 4.5 to 6.2: namespaces

namespaces,typo3,typo3-6.2.x
I'm updating an old TYPO3 to latest verison 6.2.12. As I do so I replace deprecated classes with the proper namespaces. E.g. t3lib_div to \TYPO3\CMS\Core\Utility\GeneralUtility or t3lib_extmgm to \TYPO3\CMS\Core\Utility\ExtensionManagementUtility. But I cant find the proper namespaced class for t3lib_svbase. Any suggestions? . And I absolutely have no clue what I...

## Single using statement, multiple MVC views

c#,asp.net,asp.net-mvc,namespaces,html-helper
I've written a few extension methods (HTML helpers) and would like to use them throughout multiple views, this... @using My.Extensions.Namespace @Html.MyExtension() ...obviously works. But it means including the using statement in every single view (there'll be many). If this is the only approach, that's fine, but I'm interested if there's...

## Reference C# type within XML schema?

c#,xml,namespaces,xml-namespaces
Is it possible to reference types within a C# project in an XML Schema file? For validation and intelli-sense I mean... Lets say I have the following: namespace Example { class myType { int test = 0; } } How would I reference the Example namespace within the schema file...

## Python: is there a way to use “unimported” objects in function definitions?

python,function,namespaces,python-module
I'm modifying a simple recursive function to draw a dragon curve using turtle: def draw_dragon(t, order, size, L=turtle.left, R=turtle.right): """ Draw a dragon curve """ if not order: t.forward(size) return size /= 1.41421 t.R(45) draw_dragon(t, order-1, size, L, R) t.L(90) draw_dragon(t, order-1, size, R, L) t.R(45) if __name__=="__main__": import turtle...

## C# : Why is First namespace redundant?

c#,namespaces,projects-and-solutions,qualifiers
This is a little spooky. I'm thinking there must be a setting somewhere that explains why this is happening. In our solution there are about 50 different projects. For the most part, the libraries start with the namespace OurCompany. We have OurComany.This.That and OurCompany.Foo.Bar... etc. There is a namespace/class clash...

## Does it matter how many models are in a single namespace?

asp.net-mvc,model,namespaces
In an MVC app, does it matter how many models are in the MyApp.Models namespace? I have just enough models to make it worthwhile splitting them into separate folders (e.g. /Models/Users, /Models/Emails, /Models/Messages, etc). MVC by default gives new models a namespace corresponding to the folder structure (e.g. MyApp.Models.Users, MyApp.Models.Emails,...

## The name 'Thread' does not exist in the current context

c#,visual-studio-2013,namespaces

## Enumerate namespaces and dynamically load them in ClojureScript

clojure,namespaces,clojurescript,reagent
This may actually be a bit of an XY-problem, so I'll try to explain what the goal is first. I'm building a ClojureScript application which is composed of a set of Reagent components. It provides a user interface where you can dynamically add or remove UI elements. These UI elements...

## C++ header-only library avoid “using namespace” pollution

c++,c++11,namespaces
I have a header-only C++ library with sevaral namespaces. For example one header file may contain //header1.h namespace library{ namespace componentA{ template<typename T> class Someclass{}; } } And another one //header2.h namespace library{ namespace componentB{ template<typename T> class SomeOtherClass{ void Foo(const componentA::Someclass<T>& reference); void Bar(const componentA::Someclass<T>& reference); }; } }...

## XML, XSL namespaces

xml,xslt,namespaces
I'm new to XML especially namespaces. I made all the documents and everything seems to work fine, but I don't know whether I'm really using namespaces (which is requirement). Except that my html file are not valid because off this: "Attribute xmlns:xsi not allowed here." and "Attribute xmlns:xslformatting not allowed...

## Why are these global variables when they have namespace scope?

c++,namespaces,scope,global-variables,forward-declaration
In the following code, this is calling the variables in the globals.cpp namespace actual global variables. globals.h #ifndef GLOBALS_H_ #define GLOBALS_H_ namespace Constants { // forward declarations only extern const double pi; extern const double avogadro; extern const double my_gravity; } #endif globals.cpp namespace Constants { // actual global variables...

## Rails namespaced models give uninitialized constant errors

ruby-on-rails,ruby,namespaces
I have two models in namespace project like this: class Project::Foo and class Project::Bar They have this relationship in app/models/project/foo.rb has_many :bars in app/models/project/bar.rb belongs_to :foo However when I want to call Project::Foo.create(...) or even Project::Bar.create(...) I get a NameError with uninitialized constant Foo or Bar respectively. Do I need...

## Usage of enum name as value identifier in Objective-C

objective-c,enums,namespaces,declaration,redefinition
Referring to this post it seems that there is no possibility in Objective-C to define two enums with the same value as in this example: enum AnEnum { AnyValue }; enum AnotherEnum { AnyValue // Error: Redefinition of enumerator 'AnyValue' }; I would like to understand the backgrounds why an...

## Adding default namespace conditionally using xslt

xml,xslt,namespaces,xml-namespaces,ibm-datapower
Requirement: Check whether a default namespace declaration xmlns="http://www.origoservices.com present in the request xml. If not, add the default namespace declaration. Sample Request xml 1: <message xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <m_control> <control_timestamp>2014-11-05T09:30:38.308</control_timestamp> <retry_number>0</retry_number> <expected_response_type>synchronous</expected_response_type> <responder_id>Exchange Life 1</responder_id>...

## Usings and assembly references are not automatically imported from C# snippet

c#,.net,visual-studio,namespaces,code-snippets
I'm trying to write a C# snippet with this content: ... <References> <Reference><Assembly>Microsoft.VisualBasic.dll</Assembly></Reference> </References> <Imports> <Import><Namespace>Microsoft.VisualBasic</Namespace></Import> <Import><Namespace>System.Text</Namespace></Import> <Import><Namespace>System.Xml</Namespace></Import> </Imports> ... As explained in the MSDN docs, im following the good structure:...

## Delete modules to clean namespace?

python,module,namespaces,package
I am working on a pretty huge Python package. Inside several modules, different programmers import other modules to do calculations. For the sake of this discussion, let's stick to numpy. Common practice, when importing modules is defining an alias for easier programming, so let's say in a module foo.py there...

php,laravel,namespaces,laravel-5,artisan
I am in new Laravel and trying to learn by coding. I created migration and seed and both working fine when I call them from terminal, but I wanted to try this code in my HomeController and I get a big error. Error FatalErrorException in HomeController.php line 23: Class 'App\Http\Controllers\Artisan'...

## MonoDevelop 4.0.1: Creating a new namespace in a project (on Windows 8.1 64-bit)

c#,namespaces,monodevelop
How do I create a namespace on MonoDevelop 4.0.1 for the same project? I am following along the exercises from Practice Exercises C# Sharp where there are 11 lessons with multiple exercises each, and so far I am using only one namespace in the project. Instead of having all the...

## Mysqli inside namespace

php,methods,mysqli,namespaces
I need to use mysqli and prepared statements inside a namespace, this is working fine up until the point where I try and bind parameters, it connects find and prepare works but form there on I get an error saying call to undefined method. I have already googled this and...

## ExtJS5 Namespace Confusion

extjs,namespaces
I am completely confused on the namespaces in ExtJS5 application. I am using a common folder under the sencha workspace where I keep code I will be using for multiple pages (multiple SPA's). In one application definition I have the following snippet: Ext.define('Admin.Application', { extend: 'Ext.app.Application', name: 'Admin', namespaces: ['ALT'],...

## Include ggplot2 function in package

r,plot,ggplot2,namespaces,r-package
I am trying to include the following ggplot2 helper function in a package [it wraps labels in grid_facet(.~variable, labeller = "plot.label.wrap")]: #' Label wrapper for ggplot #' #' Include in the facet_grid option of ggplot. #' @param variable #' @param value #' @return wrapper #' @export plot.label.wrap <- function(variable, value)...

## how to solve the type and namespace could not be found

c#,namespaces,mono
I am trying to make a cross platform application using MONO. i developed the project into c#(windows) and I want to run that project into Linux. For that purpose i am using MONO.But when i am running my project then I am getting error that the type and namespace could...

This question already has an answer here: how to load ns by default when starting repl 2 answers I'm new to Clojure so this could very well be an easy question. I'm having an issue with the REPL while using Leiningen. Previously, I had created an app project while...

## Namespace prefix NS1 for href on %tagElement% is not defined, setAttributeNS

svg,safari,namespaces,xml-namespaces,setattribute
I got this error in safari while trying to convert svg to base64 url via code: $svgCopy =$('svg').clone() html = $('<div>').append($svgCopy).html() imgSrc = 'data:image/svg+xml;base64,' + btoa(html) imgEl.src = imgSrc The problem is that when you set attribute with NS (setAttributeNS) safari sets NS\d+ namespace and do not sets xmlns:NS\d+...

## How to use namespaces properly in vb.net

vb.net,namespaces
I have a WebApplication project called WebApp and I have a Library Project called LibProj where I define a namespace like Namespace LibProj Public Class Employee Public Property Name As String End Class End Namespace Now I add the reference to WebApp and try to use the namespace with Imports...

## Displaying XML nodes with XSL but keeping the order on XML - With multiple namespaces

html,xml,xslt,dom,namespaces
I have the following multi namespaces XML file: objects.xml <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="objects.xsl"?> <objects xmlns:objA="http://www.mywebsite.com/objectA" xmlns:objB="http://www.mywebsite.com/objectB" > <objA:objectA> <objA:attrA1>Instance 1 Value 1</objA:attrA1> <objA:attrA2>Instance 1 Value 2</objA:attrA2> </objA:objectA> <objB:objectB> <objB:attrB1>Instance 2 Value 1</objB:attrB1>...

## Javascript utility function to safely create a namespace

javascript,namespaces
What is the best and most failsafe way to dynamically and safely create namespaces in JS? I need a utility function for a small utility library I'm working on currently. Basically, I want it to check if any part of my namespace already exists, and is an object, otherwise this...

## Namespace entries in PSR-1 standard?

php,namespaces,standards,psr-1
I am looking for the correct way (if either is correct please let me know) to write namespaces in PHP classes that follow PSR-1 standard. I looked around but didn't see anything specific. Is the correct way to use Namespace Foo\Bar; or is it correct to use curly braces such...

## How to use an operation which is defined in another namespace in c++

c++,namespaces,operator-keyword
I have a definition for an operation in a namespace and I want to use it in another name space, how I can do this: for example, assume that I have this: operation defined: namespace op { inline cv::Matx21f operator/(const cv::Matx21f &v, float a) { return cv::Matx21f(v(0) / a, v(1)...

## Safely creating namespaces in JavaScript

javascript,namespaces
I understand why namespaces are good - to prevent too many global definitions and to prevent code from being overwritten, but i'm trying to dig a bit further into the following syntax: // not safe, if there's another object with this name we will overwrite it var MYAPPLICATION = {};...

php,namespaces

## How to follow DRY principles in different namespaces Rails 4.2?

ruby-on-rails,api,ruby-on-rails-4,namespaces
Basically I've developed an app which has two namespaces: admin, api and the public one (simply resources :users for instance). All works fine, however I'm repeating myself quite a bit as some of the controllers in api for instance could easily be used in admin. How can I DRY my...

## Fatal error: Class 'Psr\Log\AbstractLogger' not found in Logger.php on line 30

php,namespaces,rackspace-cloud,rackspace,psr-3
I'm getting this error: Fatal error: Class 'Psr\Log\AbstractLogger' not found in /var/www/html/rackspace/vendor/rackspace/php-opencloud/lib/OpenCloud/Common/Log/Logger.php on line 30 This is my Logger.php file <?php /** * Copyright 2012-2014 Rackspace US, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with...

php,namespaces

## C++11 cannot resolve nested namespace

c++,namespaces,nested
say I create a class Foo in foo.h under namespace Fooo like follows: foo.h: namespace Fooo { class Foo { }; } and its corresponding source file: foo.cpp: namespace Fooo { Foo::Foo() { } } I write another source file util.cpp to create some utility functions for the Foo class...

## Xsd Schema Namespace

c#,xml,xsd,namespaces
Please consider below PspShoppingCartServiceRequest.Xsd <?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:tns="http://www.example.com" elementFormDefault="qualified" targetNamespace="http://www.example.com" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:common="http://www.example.com/common" <xs:import namespace= "http://www.example.com/common" schemaLocation="common.xsd" /> <xs:element name="PspShoppingCartServiceRequest" type="tns:PspShoppingCartServiceRequest" /> <xs:complexType...

## Namespaces with multiple cyclic inclusion

I've 3 classes that belong to a namespace "MyNS". "A" uses the "B" and "C", while both "B" and "C" use "A". Here are the structure of my headers: //mynamespace.h #ifndef SOMENAMESPACE_H #define SOMENAMESPACE_H namespace MyNS { class A; class B; class C; } #endif /*******************************************************/ //A.h #ifndef A_H #define...

## friendship and namespace issue

c++,namespaces
I'm having troubles with friendship between a class of a namespace and a function as below: How to tell that the friend function is outside of the namespace? Thanks namespace NS { class Class { public: Class(); virtual ~Class(); private: void Foo(); friend void Bar(Class&); }; } void Bar(NS::Class& c)...

php,laravel,namespaces,laravel-excel
In my controller I have the code as below: Excel::create('Laravel Excel', function($excel) {$excel->sheet('Excel sheet', function($sheet) {$sheet->setOrientation('landscape'); }); })->export('xls'); In config/app.php in aliases array i have defined this: 'Excel' => 'Maatwebsite\Excel\ExcelServiceProvider', I dont know why i cant make it work this library... Any idea?...

## 'Class' is a namespace but is used like a 'type'

c#,visual-studio,namespaces
First, this is not the same as the many highly upvoted questions on this exact topic unless I'm missing one of them. All of them point that the issue is I have a namespace with the same name as the class. This is not the case (but it was). I...

## xsl: template and namespaces

xslt,namespaces
My appologies for asking this question again. I know this has been answered here already several times, but it seems that I still don't get it. My XML (basically the XML output from Open Office draw, here simplified) <?xml version="1.0" encoding="UTF-8"?> <office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"...

php,namespaces,psr-0,psr-4
I have created a very basic validator class. My base code is in a my src/ folder, which gets autoloader with "kevdotbadger\\Validator\\": "src/" this works fine, so that when I instantiate a new "kevdotbadger\Validator\ Validator is gives me src/Validator.php My Validator.php class then loads a bunch of sub-classes in my...

## How to add a name to namespace?

linux,networking,namespaces,ip
As I know, I can use the "clone" to create a process and a namespace, but the namespace created in this way has no name. For example, I create a network namespace with the parameter: CLONE_NEWNS, but in the command "ip netns list", there is no namespace list because the...

## pyinstaller with namespace packages

python,namespaces,package,pyinstaller
I have a module/package structure where I am using namespace packages, I have multiple user made libraries which I keep in separate repositories, and they have fairly generic names like db, io, utils and so on. To avoid conflict with other packages I have a top level/namespace package named acme,...

## C# Obtaining Namespace Based on CSProj settings

c#,.net,c#-4.0,visual-studio-2013,namespaces
Is there a way to obtain the .csproj Default Namespace and Visual Studios understanding it without using preprocessor directives? For example: CS Project 1 has a Default Namespace of SomeCompany.ProductA CS Project 2 has a Default Namesapce of SomeCompany.ProductB CS Project 1 has a cs file that exists in BaseClasses/MySpecialBase.cs...

## Inherit a class with same namespace and same class name

c#,class,inheritance,namespaces,.net-assembly
I manage to work it out in 2 Classes, but I failed in 3. Let's say I have an assembly A.DLL which have namespace = "City" and a class= "NY" (I will refer this class in my question as "A") In My new project My namespace is = "City" and...

## Typescript One File Per Class

file,class,module,namespaces,typescript
I have just started with Typescript, using Visual Studio 2015, and can't find a way to use classes in separate files. In a single file, there is no problem: module someModule { export class TitleScreenState extends Phaser.State { game: Phaser.Game; constructor() { super(); } //some code here } class GameRunningState...

## How does extern work in namespaces?

c++,namespaces,global-variables,const,extern
I'm running a simple program similar to what I found here. It's meant to reduce code bloat when including constants in multiple files. It does this by using const global variables within a namespace with their respective extern forward declarations. globals.h #ifndef GLOBALS_H_ #define GLOBALS_H_ namespace Constants { // forward...

## How to use namespace System; in MFC application with VC++

c++,sql,visual-c++,mfc,namespaces
help me,am new, I want to use some features(i don't know the specific word to use) present in System namespace, but when i try to add it to my project by "using namespace System",i want this to use SQLCLIENT ,i saw below link giving answer but dont have a clue...

## KDB+ / Q Accessing root namespace from namespace

namespaces,q,kdb
how can I access functions/variables in the root namespace once I jumped into another namespace. Example like this: q)\d .cfg q)domIV:1000 q)\d . q)n:1000 And then later on I know how to access the variable domIV from the other namespace, but I dont know how to access the variable n...

## C++: Does inheriting from a class bring it into the namespace?

c++,namespaces
Here's some contrived example code: template<typename T> void Do(T arg) { (void)arg->b; } namespace A { struct Foo { int a; }; } namespace B { struct Foo { int b; }; struct Bar : A::Foo { void Blah() { Do((Foo *)0); } }; } Which when compiled with gcc...