namespaces

Namespace Rule of Thumb

Is there a general rule of thumb as to how many classes, interfaces etc should go in to a given name space before the items should be further classfied in to a new name space? Like a best practice or a community preference? Or is this all personal preference? namespace: MyExample.Namespace interface1 interface2 interface3 interface...

When making-up new XML tags, do they need to be in a namespace?

I'm not sure if namespaces are required for valid/correct XML. Can I add arbitrary tags to an XML document without having to define/declare a namespace for them? I think namespaces are a good idea and are probably best practice but I just want to know if they are mandatory or not. ...

How do you use namespaces?

Namespace are pretty cool: with them, you can organize your libraries and you can avoid name conflicts. Well, this is the intention, I think. I think that a lot of people do not use it like it should be used... Every day, I see 95 char long namespaces scattering the code and hiding the really important information. Here is an example:...

Creating a specific XML document using namespaces in C#

We were given a sample document, and need to be able to reproduce the structure of the document exactly for a vendor. However, I'm a little lost with how C# handles namespaces. Here's a sample of the document: <?xml version="1.0" encoding="UTF-8"?> <Doc1 xmlns="http://www.sample.com/file" xmlns:xsi="http://www.w3.org/2001/XMLSchema-in...

Should dependencies walk up or down the namespace tree?

In a framework, should class dependencies run down a namespace (root to leaf) or up a namespace (think of it as an inverted tree with the root at the top)? I'm having a hard time describing this, so let's look at an example: namespace foo { class snafu : fubar {} } namespace foo.bar { class tarfu : snafu {} class fubar {} } I...

GAC Assembly naming (ASP.Net 2 + IIS7 + Windows Vista Home Premium)

I have a membership provider assembly that I wish to add to IIS7. I was going to leave this in the App_Code file for the web app, but IIS7 has asked me to provide a strong name assembly, which I have. Now I get this when trying to acccess ASP.Net Users in IIS The assembly name or codebase was invalid. Exception from HRESULT 0x80131047...

Putting separate python packages into same namespace?

Hey everyone, I'm developing a python framework that would have "addons" written as separate packages. I.e.: import myframework from myframework.addons import foo, bar Now, what I'm trying to arrange is so that these addons can be distributed separately from core framework and injected into myframework.addons namespace. Currently my...

Add XML Namespace attribute to 3rd party xml?

Hi there I'm using VB 2008 and I'm trying to add a xmlns="mynamespace" attribute to an XDocument's root element. The XML document is created by a 3rd party, and I have loaded it into a VB XDocument object. As it comes, it has no namespaces. I have been working on a local copy and I added in a namespace in a text editor, so that I can u...

Root namespace missing in DataSet.WriteToXml

Hi, 1) I do a Dataset.WriteToXml(memory stream object) 2) Then i create a XMLDocument object 3) I then XMLDocument.Load (memory stream object) I get a "XML Root namespace not found" exception. Does the Dataset XML not include the required namespace ? Thanks. ...

Groovy+ XML: handle Attributes with Namespace-Prefix

Hi, I'm working on a XML-document with Groovy and test a node for a certain attribute, which has a namespace prefix. How could it work: in groovy-script: ... Element.Subelement.each { if (it.'@type'=='ns2:xyType') ...do what ever... } in XML document: <Element> <Subelement xsi:type="ns2:xyType"> <!-- or another type...

Is there a quick way to remove using statements in C#?

Is there a quick way to determine whether you are using certain namespaces in your application. I want to remove all the unneccessary using statements like using System.Reflection and so on, but I need a way to determine if I am using those libraries or not. I know that the tool Resharper does this for you, but is there a quick and dirty...

What are some concrete examples of using namespaces Silverlight/XAML?

In Silverlight/XAML you have namespaces such as: xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" and so elements have namespaced attributes like this: <TextBlock x:Name="theMessage" Margin="10">Testing...</TextBlock> When would this be a benefit for me? Would I at some point create another namespace, e.g.: xmlns:edward="ht...

How to create XElement with default namespace for children without using XNamespace in all child nodes

I'm trying to use System.Xml.Linq to create XHTML documents. Thus, the vast majority of the nodes in my trees ought to use this namespace: http://www.w3.org/1999/xhtml I can create XElement nodes scoped to this namespace easily enough, using an XNamespace, like this: XNamespace xhtml = "http://www.w3.org/1999/xhtml"; // ... new XElem...

Possible to override VB.NET root namespace?

VB.NET automatically prefixes the root namespace set in the project properties to the namespace of each class. This is different from C#, where the full namespace must be declared each time. Is it possible to override this behaviour, creating a namespace outside of the root namespace? ...

Remove xml namespaces from WCF restful response

I am using WCF to return a plain old XML (POX) document to the caller. I am using the XML Serializer formatter to turn the objects into XML. In the returned document I have some extraneous xml namespace references (that weren't there in the ASMX version) for the XML Schema and instance. I have seen various arguments on the web that ...

Implementation in global functions, or in a class wrapped by global functions

I have to implement a set of 60 functions, according to the predefined signatures. They must be global functions, and not some class's member functions. When I implement them, I use a set of nicely done classes provided by 3rd party. My implementation of most functions is quite short, about 5-10 lines, and deals mostly with different ac...

Is it possible to treat a template instance as a namespace?

Suppose I have template< unsigned int num > class SomeFunctionality { static unsigned int DoSomething() { //... } static void DoSomethingElse() { } }; typedef SomeFunctionality<6> SomeFunctionalityFor6; Semantically, "SomeFunctionalityFor6" is essentially a namespace specific to the templ...

C++ compiler unable to find function (namespace related)

I'm working in Visual Studio 2008 on a C++ programming assignment. We were supplied with files that define the following namespace hierarchy (the names are just for the sake of this post, I know "namespace XYZ-NAMESPACE" is redundant): (MAIN-NAMESPACE){ a bunch of functions/classes I need to implement... (EXCEPTIONS-NAMES...

actionscript ExternalInterface namespace collisions

A have a flash widget (a music player) and there are about 10 instances of it on one page. I need to communicate between the flash and the javascript of the page it's embedded in. I haven't done much with actionscript for a long time, but some googling led me here, and to ExternalInterface. It seemed perfect, however there is one problem...

Should I wrap all my c++ code in its own namespace?

I come from a c# background where everything has its own namespace, but this practice appears to be uncommon in the c++ world. Should I wrap my code in it's own namespace, the unnamed namespace, or no namespace? ...