本文整理汇总了C#中Namespace类的典型用法代码示例。如果您正苦于以下问题:C# Namespace类的具体用法?C# Namespace怎么用?C# Namespace使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Namespace类属于命名空间,在下文中一共展示了Namespace类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Connect
public Service Connect(Namespace ns)
{
var service = new Service(Scheme.Https, this.command.Host, this.command.Port, ns);
service.LoginAsync(this.command.Username, this.command.Password).Wait();
return service;
}
示例2: Emit
// Generates a codedom namespace and attaches it to the compile unit (the root of the tree)
public static void Emit(CodeCompileUnit codeCompileUnit, Namespace ns)
{
// Create the codedom namespace expression
var codeNamespace = new CodeNamespace();
// Assign the namespace name.
codeNamespace.Name = ns.GetFullName();
// Attach it to the root of the codedom tree.
codeCompileUnit.Namespaces.Add(codeNamespace);
// Create and attach the children of the namespace: classes, delegates, other namespaces, etc.
foreach (var e in ns.ChildExpressions)
{
if (e is Namespace)
Emit(codeCompileUnit, (Namespace)e);
if (e is Class)
ClassEmitter.Emit(codeNamespace, (Class)e);
if (e is Import)
{
var i = e as Import;
if (i.IsType) // Are we importing a class, enum, interface, struct, module?
codeNamespace.Imports.Add(new CodeNamespaceImport((e as Import).GetNamespace()));
else
codeNamespace.Imports.Add(new CodeNamespaceImport((e as Import).Name));
}
if (e is Pie.Expressions.Enum)
EnumEmitter.Emit(codeNamespace, e as Pie.Expressions.Enum);
if (e is DelegateDeclaration)
DelegateEmitter.Emit(codeNamespace, e as DelegateDeclaration);
if (e is Interface)
InterfaceEmitter.Emit(codeNamespace, e as Interface);
}
}
示例3: ConstantInfo
public ConstantInfo(object value, ProjectState projectState)
: base((BuiltinClassInfo)projectState.GetNamespaceFromObjects(DynamicHelpers.GetPythonType(value)))
{
_value = value;
_type = DynamicHelpers.GetPythonType(value);
_builtinInfo = ((BuiltinClassInfo)projectState.GetNamespaceFromObjects(_type)).Instance;
}
示例4: CreateServiceAndLogin
public Service CreateServiceAndLogin(Namespace ns = null)
{
var service = new Service(Config.Scheme, Config.Host, Config.Port, ns);
var task = service.LogOnAsync(Config.Username, Config.Password);
task.Wait();
return service;
}
示例5: GenerateSymbols
private static void GenerateSymbols(Namespace n, StringBuilder sb, string indent2)
{
foreach (Symbol s in n.Symbols)
{
if (s.Section <= 0) { continue; }
string name = s.Demangled;
if (s.Namespace.Length > 0)
{
string namespacetext = string.Join("::", s.Namespace) + "::";
name = name.Replace(namespacetext, "");
}
name = name.Replace("__thiscall ", "");
name = name.Replace("__cdecl ", "");
// C functions
if (s.Demangled == s.Name && s.DataType == IMAGE_SYM_DTYPE.IMAGE_SYM_DTYPE_FUNCTION)
{
name = name + "()";
}
sb.Append(indent2);
sb.AppendFormat("{0};\n", name);
}
}
示例6: GenerateComponent
public Dictionary<string, string> GenerateComponent(Namespace ns, List<Wire> wires, List<string> modules)
{
Dictionary<string, string> properties = new Dictionary<string, string>();
foreach (Component component in ns.Declarations.OfType<Component>())
{
modules.Add(component.Name);
ComponentType cType = ComponentType.IMPLEMENTATION;
Dictionary<Reference, Component> dependencyMap = this.dependencyDiscoverer.GetherDependencyMap(ns, wires, component);
List<string> dependencies = this.dependencyDiscoverer.GetherDependencies(dependencyMap);
bool directDataAccess = this.dataAccessFinder.HasAnyDirectDataAccess(ns, wires, component);
if (component.Services.Any())
{
this.GenerateServiceImplementations(ns, modules, wires, component, dependencies, dependencyMap);
}
else
{
if (component.Implementation != null && component.Implementation.Name.Equals("JSF"))
{
cType = ComponentType.WEB;
this.jSFGenerator.GenerateWebTier(ns, component, directDataAccess);
}
if (component is Composite)
{
string facadeDir = this.directoryHandler.createJavaDirectory(ns, component.Name, generatorUtil.Properties.serviceFacadePackage);
string facadeFile = Path.Combine(facadeDir, component.Name + "Facade.java");
using (StreamWriter writer = new StreamWriter(facadeFile))
{
writer.WriteLine(this.springClassGen.GenerateComponent(component));
}
}
}
BindingTypeHolder clientFor = new BindingTypeHolder();
if (component.References.Any())
{
clientFor = this.GenerateReferenceAccessors(ns, component, directDataAccess, dependencyMap, properties);
}
// generate pom.xml and spring-config.xml of Business Logic module
this.directoryHandler.createJavaDirectory(ns, component.Name, "");
string fileName = Path.Combine(ns.Name + "-" + component.Name, "pom.xml");
using (StreamWriter writer = new StreamWriter(fileName))
{
string s = this.springConfigGen.GenerateComponentPom(ns, component, dependencies,
clientFor.HasRestBinding, clientFor.HasWebServiceBinding, clientFor.HasWebSocketBinding, cType);
writer.WriteLine(s);
}
string javaDir = this.directoryHandler.createJavaDirectory(ns, component.Name, "", false);
fileName = Path.Combine(javaDir, "spring-config.xml");
using (StreamWriter writer = new StreamWriter(fileName))
{
writer.WriteLine(this.springConfigGen.GenerateComponentSpringConfig(ns));
}
}
return properties;
}
示例7: GetherDependencyMap
public Dictionary<Reference, Component> GetherDependencyMap(Namespace ns, List<Wire> wires, Component component)
{
Dictionary<Reference, Component> dependencies = new Dictionary<Reference, Component>();
foreach (Reference reference in component.References)
{
bool referenceStatisfied = false;
foreach (Wire wire in wires)
{
if (wire.Source.Equals(reference))
{
Component comp = wire.Target.Component;
Service target = wire.Target as Service;
if (target != null)
{
referenceStatisfied = true;
PutDependecy(dependencies, reference, target, comp);
}
}
}
if (!referenceStatisfied)
{
foreach (Component comp in ns.Declarations.OfType<Component>())
{
foreach (Service serv in comp.Services)
{
if (serv.Interface.Equals(reference.Interface))
{
PutDependecy(dependencies, reference, serv, comp);
}
}
}
}
}
return dependencies;
}
示例8: Process
public void Process(Namespace @namespace, bool filterNamespaces = false)
{
TranslationUnit = @namespace.TranslationUnit;
var collector = new RecordCollector(TranslationUnit);
@namespace.Visit(collector);
foreach (var record in collector.Declarations)
{
if (record.Value is Namespace)
continue;
if (record.Value.IsDependent)
continue;
if (filterNamespaces)
{
var declNamespace = GetEffectiveNamespace(record.Value);
var isSameNamespace = declNamespace == @namespace;
if (declNamespace != null)
isSameNamespace |= declNamespace.QualifiedName == @namespace.QualifiedName;
if (!isSameNamespace)
continue;
}
record.Value.Visit(this);
GenerateInclude(record);
}
}
示例9: CheckDirectDataAccess
private bool CheckDirectDataAccess(Namespace ns, List<Wire> wires, string dataModule, Reference reference, Service serv)
{
Component comp = serv.Component;
bool hasDirectDataAccess = false;
List<Binding> bindings = new List<Binding>();
if (serv.Binding != null)
bindings.Add(serv.Binding);
if (reference.Binding != null)
bindings.Add(reference.Binding);
BindingTypeHolder binding = bindingGenerator.CheckForBindings(bindings);
if (!binding.hasAnyBinding())
{
// direct access
if (comp.Name == dataModule || dataModule == ANY && serv.Interface is Database)
{
hasDirectDataAccess = true;
}
else
{
// need to check
hasDirectDataAccess = HasDirectDataAccess(ns, wires, comp, dataModule);
}
}
return hasDirectDataAccess;
}
示例10: Parse
public static IExpression Parse(ref string input, Namespace ns)
{
var orgInput = input;
var literal = Literal.Parse(ref input);
if (literal != null)
return literal;
input = orgInput;
var method = MethodCall.Parse(ref input, ns);
if (method != null)
return method;
input = orgInput;
var assignment = Assignment.Parse(ref input, ns);
if (assignment != null)
{
assignment.ExprMode = true;
return assignment;
}
input = orgInput;
var variable = Variable.Parse(ref input, ns);
if (variable != null)
return variable;
input = orgInput;
return null;
}
示例11: TestClassFullName
public void TestClassFullName()
{
Namespace n = new Namespace(null, null);
n.Name = "foo";
Class c = new Class(null, null);
c.UnqualifiedName = "bar";
Console.WriteLine(c.GetQualifiedName());
Assert.AreEqual("foo", n.Name, "namespace name1");
Assert.AreEqual("foo", n.GetFullName(), "namespace full name1");
Assert.AreEqual("bar", c.UnqualifiedName, "class name1");
Assert.AreEqual("bar", c.GetQualifiedName(), "class full name1");
c.ParentExpression = n;
Assert.AreEqual("foo", n.Name, "namespace name2");
Assert.AreEqual("foo", n.GetFullName(), "namespace full name2");
Assert.AreEqual("bar", c.UnqualifiedName, "class name2");
Assert.AreEqual("foo.bar", c.GetQualifiedName(), "class full name2");
c.ParentExpression = new Expression(null, null);
Assert.AreEqual("foo", n.Name, "namespace name3");
Assert.AreEqual("foo", n.GetFullName(), "namespace full name3");
Assert.AreEqual("bar", c.UnqualifiedName, "class name3");
Assert.AreEqual("bar", c.GetQualifiedName(), "class full name3");
}
示例12: Parse
public static Assignment Parse(ref string input, Namespace ns)
{
var orgInput = input;
var ident = Identifier.Parse(ref input);
if (ident == null)
return null;
Whitespace.Parse(ref input);
if (input[0] != '=')
return null;
input = input.Substring(1);
Whitespace.Parse(ref input);
var expr = Expression.Parse(ref input, ns);
if (ident.Value.Contains("."))
{
input = orgInput;
return null;
}
var id = ns.GetScope().Add(ident.Value, expr.ReturnType);
return new Assignment(ident, expr, id);
}
示例13: SortDeclarations
private static void SortDeclarations(Namespace @namespace)
{
@namespace.Declarations = @namespace.Declarations.OrderBy(
declaration => declaration.DefinitionOrder).ToList();
foreach (var childNamespace in @namespace.Namespaces)
SortDeclarations(childNamespace);
}
示例14: SortDeclarations
private static void SortDeclarations(Namespace @namespace)
{
@namespace.Classes.Sort((c, c1) =>
(int)(c.DefinitionOrder - c1.DefinitionOrder));
foreach (var childNamespace in @namespace.Namespaces)
SortDeclarations(childNamespace);
}
示例15: BuildNamespace
// Build a namespace expression
public static void BuildNamespace(IronyParser parser, Root root, Expression parentExpression, ParseTreeNode currentNode)
{
Namespace n = new Namespace(parentExpression, currentNode.FindToken().Convert());
n.Name = currentNode.ChildNodes[1].FindTokenAndGetText();
parentExpression.ChildExpressions.Add(n);
parser.ConsumeParseTree(root, n, currentNode.ChildNodes[2]);
}