Exemplo n.º 1
0
 public TypeDef ResolveType(TypeName name)
 {
     var typeDef = default(TypeDef);
     if (!nameToTypeDefCache.TryGetValue(name, out typeDef))
         return null;
     return typeDef;
 }
Exemplo n.º 2
0
        public IList<IComponentDescriptor> FindByServiceTypeName(TypeName serviceTypeName)
        {
            if (serviceTypeName == null)
                throw new ArgumentNullException("serviceTypeName");

            return FindByServiceTypeNameImpl(serviceTypeName);
        }
 /// <summary>
 /// Creates a component registration.
 /// </summary>
 /// <param name="plugin">The plugin to which the component will belong.</param>
 /// <param name="service">The service implemented by the component.</param>
 /// <param name="componentId">The component id.</param>
 /// <param name="componentTypeName">The component type name, or null to use the default component type specified by the service.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="plugin"/>, <paramref name="service"/>,
 /// <paramref name="componentId"/> is null.</exception>
 public ComponentRegistration(IPluginDescriptor plugin, IServiceDescriptor service, string componentId, TypeName componentTypeName)
 {
     Plugin = plugin;
     Service = service;
     ComponentId = componentId;
     ComponentTypeName = componentTypeName;
 }
Exemplo n.º 4
0
        /// <summary>
        /// instantiate a new Jewel
        /// </summary>
        /// <param name="contentManager">game content manager object</param>
        /// <param name="spriteName">file name of sprite</param>
        /// <param name="position">vector position of Jewel</param>
        public Jewel(
            ContentManager contentManager,
            TypeName type,
            Vector2 position
            )
        {
            _contentManager = contentManager;
            _type = type;
            _position = position;

            // load the jewel image
            if (type == TypeName.Green)
            {
                _sprite = _contentManager.Load<Texture2D>("green_jewel");
            }

            _active = true;

            _spriteWidth = _sprite.Width;
            _spriteHeight = _sprite.Height;

            // set the initial center and bounding rectangle for the player
            _center = new Vector2(position.X + (_spriteWidth / 2), position.Y + (_spriteHeight / 2));
            _boundingRectangle = new Rectangle((int)position.X, (int)position.Y, _spriteWidth, _spriteHeight);
        }
Exemplo n.º 5
0
        public NamedType TypeOf(TypeName name)
        {
            if (!types.ContainsKey(name))
            {
                if (name.Name == typeof(IEnumerable<>).QualifiedName())
                {
                    var itemType = TypeOf(name.GenericArguments.Single());
                    if (itemType == null)
                        return null;
                    types.Add(name, NamedType.Enumerable(itemType));
                }
                else if (name.Name == typeof(Vector<>).QualifiedName())
                {
                    var itemType = TypeOf(name.GenericArguments.Single());
                    if (itemType == null)
                        return null;
                    types.Add(name, NamedType.Vector(itemType));
                }
                else if (name.Name == typeof(Nullable<>).QualifiedName())
                {
                    var itemType = TypeOf(name.GenericArguments.Single());
                    if (itemType == null)
                        return null;
                    types.Add(name, NamedType.Nullable(itemType));
                }
                else
                {
                    return null;
                }
            }

            return types[name];
        }
Exemplo n.º 6
0
        public void ProgressGatherStat(TypeName typeName)
        {
            if(_gatherSkillCollection[typeName] > 300)
                return;

            _gatherSkillCollection[typeName]++;
        }
Exemplo n.º 7
0
 public Coin(TypeName name, string description, int value, int countInGameInventory )
 {
     _name = name;
     _description = description;
     _valueInDollars = value;
     _countInGameInventory = countInGameInventory;
 }
Exemplo n.º 8
0
        public void Add(Class @class)
        {
            var typeName = new TypeName(@class.Name.Identifier);

            types[typeName] = new NamedType(@class);
            classes[typeName] = @class;
        }
Exemplo n.º 9
0
        public IServiceDescriptor GetByServiceTypeName(TypeName serviceTypeName)
        {
            if (serviceTypeName == null)
                throw new ArgumentNullException("serviceTypeName");

            return GetByServiceTypeNameImpl(serviceTypeName);
        }
Exemplo n.º 10
0
        public IList<IComponentDescriptor> FindComponentsByServiceTypeName(TypeName serviceTypeName)
        {
            ServiceDescriptor service = GetServiceByServiceTypeName(serviceTypeName);
            if (service == null)
                return EmptyArray<IComponentDescriptor>.Instance;

            return FindComponentsByServiceId(service.ServiceId);
        }
Exemplo n.º 11
0
 public ServiceDescriptor(Registry registry, ServiceRegistration serviceRegistration)
 {
     this.registry = registry;
     pluginDescriptor = (PluginDescriptor) serviceRegistration.Plugin;
     serviceId = serviceRegistration.ServiceId;
     serviceTypeName = serviceRegistration.ServiceTypeName;
     defaultComponentTypeName = serviceRegistration.DefaultComponentTypeName;
     traitsHandlerFactory = serviceRegistration.TraitsHandlerFactory;
 }
        private void RegisterComponentForServices(Type type, IPluginDescriptor plugin)
        {
            var componentId = type.FullName;

            var interfaceTypes = GetDirectInterfaces(type);
            var typeName = new TypeName(type).ConvertToPartialAssemblyName();

            RegisterFirstInterface(interfaceTypes, plugin, componentId, typeName);
            RegisterEventHandlers(interfaceTypes, plugin, componentId, typeName);
        }
Exemplo n.º 13
0
        public void HasValueEqualitySemantics()
        {
            var type = new TypeName("B", new TypeName("A"));
            type.ShouldEqual(type);
            type.ShouldEqual(new TypeName("B", new TypeName("A")));
            type.ShouldNotEqual(new TypeName("B"));

            type.GetHashCode().ShouldEqual(new TypeName("B", new TypeName("A")).GetHashCode());
            type.GetHashCode().ShouldNotEqual(new TypeName("B").GetHashCode());
        }
Exemplo n.º 14
0
 public ComponentDescriptor(Registry registry, ComponentRegistration componentRegistration)
 {
     this.registry = registry;
     pluginDescriptor = (PluginDescriptor) componentRegistration.Plugin;
     serviceDescriptor = (ServiceDescriptor) componentRegistration.Service;
     componentId = componentRegistration.ComponentId;
     componentTypeName = componentRegistration.ComponentTypeName ?? serviceDescriptor.DefaultComponentTypeName;
     componentProperties = componentRegistration.ComponentProperties.Copy().AsReadOnly();
     traitsProperties = componentRegistration.TraitsProperties.Copy().AsReadOnly();
     componentHandlerFactory = componentRegistration.ComponentHandlerFactory;
 }
Exemplo n.º 15
0
        public Binding[] MembersOf(NamedType type)
        {
            var typeName = new TypeName(type.Name);

            if (!classes.ContainsKey(typeName))
                return new Binding[] { };

            var @class = classes[typeName];

            var result = @class.Methods.Select(m => (Binding)new MethodBinding(m.Name.Identifier, DeclaredType(m))).ToArray();
            //TODO: Cache these results instead of recalculating each time.
            return result;
        }
Exemplo n.º 16
0
 public PluginDescriptor(Registry registry, PluginRegistration pluginRegistration, IList<IPluginDescriptor> completePluginDependenciesCopy)
 {
     this.registry = registry;
     pluginId = pluginRegistration.PluginId;
     pluginTypeName = pluginRegistration.PluginTypeName;
     baseDirectory = pluginRegistration.BaseDirectory;
     pluginProperties = pluginRegistration.PluginProperties.Copy().AsReadOnly();
     traitsProperties = pluginRegistration.TraitsProperties.Copy().AsReadOnly();
     pluginHandlerFactory = pluginRegistration.PluginHandlerFactory;
     assemblyBindings = new ReadOnlyCollection<AssemblyBinding>(GenericCollectionUtils.ToArray(pluginRegistration.AssemblyBindings));
     pluginDependencies = new ReadOnlyCollection<IPluginDescriptor>(completePluginDependenciesCopy);
     probingPaths = new ReadOnlyCollection<string>(GenericCollectionUtils.ToArray(pluginRegistration.ProbingPaths));
     enableCondition = pluginRegistration.EnableCondition;
     recommendedInstallationPath = pluginRegistration.RecommendedInstallationPath;
     filePaths = new ReadOnlyCollection<string>(GenericCollectionUtils.ToArray(pluginRegistration.FilePaths));
 }
Exemplo n.º 17
0
        public void Scan()
        {
            var plugin = registry.Plugins[PluginId];

            var assembly = Assembly.GetExecutingAssembly();

            foreach (var type in assembly.GetTypes())
            {
                if (type.IsInterface || type.IsAbstract)
                    continue;

                var typeName = new TypeName(type).ConvertToPartialAssemblyName();

                RegisterComponentForServices(assembly, type, typeName, plugin);
            }
        }
        private void RegisterFirstInterface(IEnumerable<Type> interfaceTypes, IPluginDescriptor plugin, 
            string componentId, TypeName typeName)
        {
            foreach (var interfaceType in interfaceTypes)
            {
                if (IsOpenGenericType(interfaceType))
                    return;

                if (ComponentIsAlreadyRegisteredForService(interfaceType, typeName))
                    return;

                var serviceDescriptor = GetServiceDescriptor(interfaceType, plugin);
                RegisterComponent(componentId, typeName, plugin, serviceDescriptor);
                
                return;
            }
        }
Exemplo n.º 19
0
		private TypeName BuildName(string name, TypeName[] genericTypes)
		{
			var typeStartsHere = name.LastIndexOf('.');
			string typeName;
			string @namespace = null;

			if (typeStartsHere > -1 && typeStartsHere < (name.Length - 1))
			{
				typeName = name.Substring(typeStartsHere + 1);
				@namespace = name.Substring(0, typeStartsHere);
			}
			else
			{
				typeName = name;
			}
			return new TypeName(@namespace, typeName, genericTypes);
		}
        public void TypeNameClone()
        {
            TypeName tn = new TypeName()
            {
                Namespace = "SurveyEngine.DataTypeConverters",
                Name = "CalendarQuestionConstraintType",
                Assembly = "SurveyEngine.DataTypeConverters",
                Version = new Version("2.3.5.2"),
                Culture = "neutral",
                PublicKeyToken = "79cd5921ea88a364"
            };

            TypeName clone = tn.Clone();
            Assert.IsFalse(object.ReferenceEquals(tn, clone));
            Assert.AreEqual(tn.Assembly, clone.Assembly);
            Assert.AreEqual(tn.Culture, clone.Culture);
            Assert.AreEqual(tn.Name, clone.Name);
            Assert.AreEqual(tn.Namespace, clone.Namespace);
            Assert.AreEqual(tn.PublicKeyToken, clone.PublicKeyToken);
            Assert.AreEqual(tn.Version, clone.Version);
        }
Exemplo n.º 21
0
        private void RegisterComponentForServices(Assembly assembly, Type type,
            TypeName typeName, IPluginDescriptor plugin)
        {
            var componentId = type.FullName;

            foreach (var interfaceType in type.GetInterfaces())
            {
                if (false == RelevantInterface(interfaceType, assembly))
                    continue;

                if (IsOpenGenericType(interfaceType))
                    continue;

                if (ComponentAlreadyRegisteredForService(interfaceType, typeName))
                    continue;

                var serviceDescriptor = GetServiceDescriptor(interfaceType, plugin);

                RegisterComponent(interfaceType, componentId, typeName,
                    plugin, serviceDescriptor);
            }
        }
Exemplo n.º 22
0
		private TypeName[] ParseNames(string substring, int count)
		{
			if (count == 1)
			{
				var name = Parse(substring);
				if (name == null)
				{
					return new TypeName[0];
				}
				return new[] { name };
			}
			var names = new TypeName[count];

			var location = 0;
			for (var i = 0; i < count; i++)
			{
				var newLocation = MoveToEnd(location,substring);
				names[i] = Parse(substring.Substring(location, newLocation - location));
				location = MoveToBeginning(newLocation, substring) + 1;
			}
			return names;
		}
Exemplo n.º 23
0
		public TypeName Parse(string name)
		{
			var isPotentiallyFullyQualifiedName = false;
			if (name.IndexOf(',') != -1)
			{
				isPotentiallyFullyQualifiedName = true;
			}
			var genericIndex = name.IndexOf('`');
			var genericTypes = new TypeName[] { };
			if (genericIndex > -1)
			{
				var start = name.IndexOf("[[", genericIndex);
				if (start != -1)
				{
					int count;
					var countString = name.Substring(genericIndex + 1, start - genericIndex - 1);
					if (int.TryParse(countString, out count) == false)
					{
						return null;
					}
					genericTypes = ParseNames(name.Substring(start + 2, name.LastIndexOf("]]") - 2 - start), count);
					if (genericTypes == null)
					{
						return null;
					}
					isPotentiallyFullyQualifiedName = false;
					name = name.Substring(0, start);
				}
			}
			if(isPotentiallyFullyQualifiedName)
			{
				//well at this point it either is a fully qualified name, or invalid string
				return new TypeName(name);
			}
			// at this point we assume we have just the type name, probably prefixed with namespace so let's see which one is it
			return BuildName(name, genericTypes);
		}
        static XunitTestFrameworkMetadata()
        {
            Assembly_XunitAssert = ShortAssemblyName.FromName("xunit.assert");
            Assembly_XunitCore = ShortAssemblyName.FromName("xunit.core");

            Type_Assert = MakeTypeName("Assert");
            Type_AssertException = MakeTypeName("XunitException", Namespace_XunitSdk, Assembly_XunitAssert);
            Type_FactAttribute = MakeTypeName("FactAttribute");
            Type_TheoryAttribute = MakeTypeName("TheoryAttribute");
            Type_TraitAttribute = MakeTypeName("TraitAttribute");

            Ctor_FactAttribute = MetadataBuilderHelper.Attributes.ConstructorName(Type_FactAttribute.Definition);
            Ctor_TraitAttribute = MetadataBuilderHelper.Attributes.ConstructorName(Type_TraitAttribute.Definition);

            Method_PexAssertInconclusive = new Lazy<Method>(() => MakePexAssertInconclusive());

            MethodDefinition_AssertEqual = MakeAssertEqual();
            MethodDefinition_AssertNotEqual = MakeAssertNotEqual();
            MethodDefinition_AssertNotNull = MakeAssertNotNull();
            MethodDefinition_AssertNull = MakeAssertNull();
            MethodDefinition_AssertTrue = MakeAssertTrue();

            Property_Skip = new PropertyDefinitionName(Assembly_XunitCore, -1, Type_FactAttribute.Definition, "Skip", SystemTypes.String.SerializableName).SelfInstantiation;
        }
Exemplo n.º 25
0
 private void RegisterComponent(Type interfaceType, string componentId, TypeName typeName,
     IPluginDescriptor plugin, IServiceDescriptor serviceDescriptor)
 {
     ComponentRegistration componentRegistration;
     if (IsAnEventHandler(interfaceType))
     {
         componentRegistration = RegisterEventHandlerProxy(interfaceType, plugin,
             serviceDescriptor, componentId);
     }
     else
     {
         componentRegistration = new ComponentRegistration(plugin, serviceDescriptor,
             componentId, typeName);
     }
     registry.RegisterComponent(componentRegistration);
 }
Exemplo n.º 26
0
 public SpUpdateGather(TypeName type, short value)
 {
     Type  = type;
     Value = value;
 }
Exemplo n.º 27
0
 private bool ComponentAlreadyRegisteredForService(Type interfaceType, TypeName typeName)
 {
     var componentDescriptors = registry.Components.FindByServiceType(interfaceType);
     foreach (var componentDescriptor in componentDescriptors)
     {
         if (componentDescriptor.ComponentTypeName.Equals(typeName))
             return true;
     }
     return false;
 }
Exemplo n.º 28
0
		internal Type ResolveNestedType(TypeName typeName)
		{
			return FindNestedType(typeName) ?? Module.universe.GetMissingTypeOrThrow(Module, this, typeName);
		}
Exemplo n.º 29
0
 public string DebugString()
 {
     return(string.Format("DeclVarStmt: {0} {1} = {2}, IsContext = {3}", TypeName.NameOf(Type), Name, InitExpression, IsContext));
 }
Exemplo n.º 30
0
        public string AddFile(byte[] content, string name, TypeName typeName, bool compress, bool multithreading)
        {
            Debug.Assert(name == name.ToUpperInvariant());

            if (multithreading)
            {
                var mre = new ManualResetEvent(false);
                finishedTask.Add(mre);
                ThreadPool.QueueUserWorkItem(delegate
                    {
                        CompressDoUpdateHelper(content, name, typeName, compress);
                        mre.Set();
                    }
                );
            }
            else
                CompressDoUpdateHelper(content, name, typeName, compress);

            return name;
        }
Exemplo n.º 31
0
 /// <summary>
 /// Returns a string that represents the current object.
 /// </summary>
 public override string ToString()
 {
     return(TypeName.ToString() + ": Value");
 }
Exemplo n.º 32
0
 private void CompressDoUpdateHelper(byte[] content, string name, TypeName typeName, bool compress)
 {
     if (compress)
         content = SevenZipHelper.Compress(content);
     DoUpdateResource(typeName.ToString() + (compress ? "_LZMA" : ""), name, content);
 }
Exemplo n.º 33
0
        internal static IEnumerable <Assembly> GetAssemblies(TypeResolutionState typeResolutionState, TypeName typeName)
        {
#if CORECLR
            string typeNameToSearch = typeResolutionState.GetAlternateTypeName(typeName.Name) ?? typeName.Name;
            return(GetAssemblies(typeNameToSearch));
#else
            return(GetAssemblies());
#endif
        }
Exemplo n.º 34
0
		// unlike the public API, this takes the namespace and name into account
		internal virtual Type FindNestedType(TypeName name)
		{
			foreach (Type type in __GetDeclaredTypes())
			{
				if (type.__Namespace == name.Namespace && type.__Name == name.Name)
				{
					return type;
				}
			}
			return null;
		}
Exemplo n.º 35
0
    //	public object Lambda;

    public override string ToString()
    {
//		if (Lambda != null)
//		{
//			return string.Format("var {0}")
//		}
        if (InitExpression != null && InitExpression.Length > 0 && InitExpression [InitExpression.Length - 1] == '.')
        {
            InitExpression = InitExpression.Substring(0, InitExpression.Length - 1);
        }

        if (IsArg || IsHidden)
        {
            if (!IsDeclaration)
            {
                if (InitExpression == null)
                {
                    return(string.Format("//{0} {1}; //IsContext = {2} IsNew = {3}", "", Name, IsContext, IsNew));
                }
                else
                {
                    return(string.Format("//{0} {1} = {2}; //IsContext = {3} IsNew = {4}", "", Name, InitExpression, IsContext, IsNew));
                }
            }
            if (InitExpression == null)
            {
                return(string.Format("//{0} {1}; //IsContext = {2} IsNew = {3}", TypeName.NameOf(Type), Name, IsContext, IsNew));
            }
            else
            {
                return(string.Format("//{0} {1} = {2}; //IsContext = {3} IsNew = {4}", TypeName.NameOf(Type), Name, InitExpression, IsContext, IsNew));
            }
        }
        if (!IsDeclaration)
        {
            if (InitExpression == null)
            {
                return(string.Format("{0} {1}; //IsContext = {2} IsNew = {3}", "", Name, IsContext, IsNew));
            }
            else
            {
                return(string.Format("{0} {1} = {2}; //IsContext = {3} IsNew = {4}", "", Name, InitExpression, IsContext, IsNew));
            }
        }
        if (InitExpression == null)
        {
            return(string.Format("{0} {1}; //IsContext = {2} IsNew = {3}", TypeName.NameOf(Type), Name, IsContext, IsNew));
        }
        else
        {
            return(string.Format("{0} {1} = {2}; //IsContext = {3} IsNew = {4}", TypeName.NameOf(Type), Name, InitExpression, IsContext, IsNew));
        }
    }