alias

PHP: How to get a fully qualified class name from an alias?

邮差的信 提交于 2019-12-01 00:12:49
问题 In PHP, if I want to get the fully qualified class name of a class that's included with a use statement, how do I do that? For instance, <?php namespace MyNamespace; use Namespace\To\Class as MyClass; function getNamespaceOfMyClass() { // Return ?? } echo getNamespaceOfMyClass(); I know one way is to do get_class(new MyClass()) , but what if I can't/don't want to make an instance of MyClass ? Thanks! 回答1: In PHP 5.5 onwards you can do this using ::class: echo MyClass::class; Unfortunately

How to get the namespace alias operator :: to work under C#?

岁酱吖の 提交于 2019-11-30 22:06:45
问题 I've come up against the unlikely scenario when I reference two external assemblies that both have the same namespace and type names. When I try to use the type, the compiler throws an error that it cannot resolve which one I want to use. I see that C# offers a mechanism to use aliases for references. You can even specify these aliases via the Property window of a reference in Visual Studio 2008. How do I use this alias in my code? As I understand, I should be using the :: operator, but it

XStream short dynamic aliases

我与影子孤独终老i 提交于 2019-11-30 21:50:37
I want to have short names for classes, now i can do it with aliases XStream x = new XStream(); x.alias("dic", Dic.class); but i have to define alias manually for every class, is there any way to configure xstream to do it automatically? Internally, XStream uses its Mapper interface to handle the mapping of classes and fields to their corresponding names in the XML. There are a large number of implementations of this interface. The XStream class itself can take a Mapper in its constructor. You might want to check out the source code of that class to see which Mapper implementation it uses by

How to check whether Sitecore item is using alias

假如想象 提交于 2019-11-30 21:23:46
Currently an "Alias" in Sitecore will produce multiple routes to the same content item which can negatively affect SEO in some cases. I am looking for a way to programatically check whether the current Page/Item/URL/Request is using an alias or not. I was hoping there would be something along the lines of: Sitecore.Web.WebUtil.IsAlias Any ideas on how to check for aliases? -------UPDATE------- Here is my current solution which appears to work just fine... Unless anyone has a better ideas?: protected bool IsAlias { get { string fullPath = LinkManager.GetItemUrl(Sitecore.Context.Item); return

NHibernate 2.1: LEFT JOIN on SubQuery with Alias (ICriteria)

你说的曾经没有我的故事 提交于 2019-11-30 21:18:42
I am basically trying to create this query with NHibernate ICriteria interface: SomeTable 1:n AnotherTable SomeTable has columns: PrimaryKey, NonAggregateColumn AnotherTable has columns: PrimaryKey, ForeignKey, AnotherNonAggregate, YetAnotherNonAggregate SELECT table1.NonAggregateColumn, subquery.SubQueryAggregate1, subquery.SubQueryAggregate2 FROM SomeTable AS table1 LEFT JOIN ( SELECT table2.ForeignKey, COUNT(table2.AnotherNonAggregate) AS SubQueryAggregate1, AVG(table2.YetAnotherNonAggregate) AS SubQueryAggregate2 FROM AnotherTable AS table2 GROUP BY (table2.ForeignKey) ) AS subquery ON

jQuery ready function aliases

不羁的心 提交于 2019-11-30 20:42:13
I'm a little confused about all the different ways to create a new jQuery object. the relevent docs seem to be: http://api.jquery.com/ready/ http://api.jquery.com/jQuery/ From those two docs the following are all equivalent, (with the exception of aliasing or not aliasing '$'): $(document).ready(handler) $().ready(handler) $(handler) jQuery(function($) {}); jQuery(document).ready(function($) {}); Is that correct? Did I miss any? Well, there is another. From the docs: There is also $(document).bind("ready", handler) . This behaves similarly to the ready method but with one exception: If the

How do you alias a type?

自闭症网瘾萝莉.ら 提交于 2019-11-30 19:07:26
In some (mostly functional) languages you can do something like this: type row = list(datum) or type row = [datum] So that we can build things like this: type row = [datum] type table = [row] type database = [table] Is there a way to do this in Python? You could do it using classes, but Python has quite some functional aspects so I was wondering if it could be done an easier way. Python is dynamically typed. While Łukasz R.'s answer is correct for type hinting purposes (which can in turn be used for static analysis and linting), strictly speaking, you do not need to do anything to make this

Is it possible to create a type alias to a generic class in Delphi

最后都变了- 提交于 2019-11-30 18:43:16
I would like to define a class type (type alias) for a generic class. I would like to do this so users of unit b can have access to TMyType without using unit a. I have units like this: unit a; interface type TMyNormalObject = class FData: Integer; end; TMyType<T> = class FData: <T>; end; implementation end. unit b; interface type TMyNormalObject = a.TMyNormalObject; // works TMyType<T> = a.TMyType<T>; // E2508 type parameters not allowed on this type implementation end. I already found a possible workaround which I don't like because it can introduce hard to find bugs: TMyType<T> = class(a

XStream short dynamic aliases

心已入冬 提交于 2019-11-30 18:26:34
问题 I want to have short names for classes, now i can do it with aliases XStream x = new XStream(); x.alias("dic", Dic.class); but i have to define alias manually for every class, is there any way to configure xstream to do it automatically? 回答1: Internally, XStream uses its Mapper interface to handle the mapping of classes and fields to their corresponding names in the XML. There are a large number of implementations of this interface. The XStream class itself can take a Mapper in its

How do create an alias in shell scripts?

有些话、适合烂在心里 提交于 2019-11-30 17:48:27
问题 Definin an alias on Linux system is very simple. From the following example we see that: the I_am_only_ls_alias alias command gives us the output as ls command # alias I_am_only_ls_alias=ls # I_am_only_ls_alias Output: file file1 But when I trying to do the same in bash script ( define alias I_am_only_ls_alias ), I get I_am_only_ls_alias: command not found . Example of my bash script: alias_test.bash #!/bin/bash alias I_am_only_ls_alias=ls I_am_only_ls_alias Run the bash script - alias_test