コード例 #1
0
        protected virtual XamlTextSyntax LookupTextSyntax()
        {
            // Look for a type converter on the Property.
            object[] objs = LookupCustomAttributes(typeof(TypeConverterAttribute));

            XamlTextSyntax representer;

            // If there were attributes on the Property then get that
            // TypeConverter, else look on the Type.
            if (objs.Length > 0)
            {
                TypeConverterAttribute[] tcAttrs = (TypeConverterAttribute[])objs;
                representer = ClrNamespace.GetOrCreateTextSyntaxFromAttributes(this.SchemaContext, tcAttrs);
            }
            else
            {
                XamlType xamlType = this.Type;
                representer = xamlType.TextSyntax;
            }
            if (representer == null)
            {
                representer = XamlTextSyntax.NoSyntax;
            }
            return(representer);
        }
コード例 #2
0
        public void NamespaceProperties()
        {
            ClrNamespace dedeNamespace         = new ClrNamespace("Dede");
            string       dedeNamespaceToString = EvaluateAndConvert("str(clr.Dede)") as string;

            Assert.AreEqual(dedeNamespaceToString, dedeNamespace.ToString());
        }
コード例 #3
0
        public void GetClrNsByPrefix()
        {
            var clrNs    = registry.GetClrNamespaceByPrefix("clr");
            var expected = new ClrNamespace(type.GetTypeInfo().Assembly, type.Namespace);

            Assert.AreEqual(expected, clrNs);
        }
コード例 #4
0
        public void UnknownNamespace()
        {
            ClrNamespace dedeNamespace = EvaluateAndConvert("clr.Dede") as ClrNamespace;

            Assert.IsNotNull(dedeNamespace);
            Assert.AreEqual(dedeNamespace.Name, "Dede");
            Assert.AreEqual(dedeNamespace.Parent, null);
        }
コード例 #5
0
        public void KnownNamespace()
        {
            ClrNamespace systemNamespace = EvaluateAndConvert("clr.System") as ClrNamespace;

            Assert.IsNotNull(systemNamespace);
            Assert.AreEqual(systemNamespace.Name, "System");
            Assert.AreEqual(systemNamespace.Parent, null);

            ClrNamespace systemReflectionNamespace = EvaluateAndConvert("clr.System.Reflection") as ClrNamespace;

            Assert.IsNotNull(systemReflectionNamespace);
            Assert.AreEqual(systemReflectionNamespace.Name, "Reflection");
            Assert.IsNotNull(systemReflectionNamespace.Parent);
            Assert.AreEqual(systemReflectionNamespace.Parent.Name, "System");
        }
コード例 #6
0
ファイル: ClrExtensionMethod.cs プロジェクト: jbatonnet/PyNet
        private static PythonObject __call__(PythonObject self, PythonTuple args)
        {
            ClrNamespace me = instances[self];

            string name     = (args[0] as PythonString).ToString();
            string fullName = me.ToIdentifier() + "." + name;

            Type type = AppDomain.CurrentDomain.GetAssemblies()
                        .Select(a => a.GetType(fullName))
                        .FirstOrDefault(t => t != null);

            if (type == null)
            {
                return(new ClrNamespace(name, me));
            }
            else
            {
                return(TypeManager.ToPython(type));
            }
        }
コード例 #7
0
 public override int GetHashCode()
 {
     return(ClrNamespace.GetHashCode() ^ this.unifiedAssemblyName.GetHashCode());
 }
コード例 #8
0
 public void GetClrNsByPrefix()
 {
     var clrNs = registry.GetClrNamespaceByPrefix("clr");
     var expected = new ClrNamespace(type.GetTypeInfo().Assembly, type.Namespace);
     Assert.AreEqual(expected, clrNs);
 }
コード例 #9
0
			internal string GetXmlNamespace(TypeDeclaration type)
			{
				ClrNamespace ns = new ClrNamespace(type.Namespace, type.Assembly);
				return (string)reverseTable[ns];
			}
コード例 #10
0
			public void AddNamespaceMapping(string xmlNamespace, string clrNamespace, string assembly)
			{
				ClrNamespace ns = new ClrNamespace(clrNamespace, assembly);
				table[xmlNamespace] = ns;
				reverseTable[ns] = xmlNamespace;
			}