Exemplo n.º 1
0
        /// <summary>
        /// Creates a new instance of the class.
        /// </summary>
        /// <param name="type">The attribute type.</param>
        /// <param name="attribute">The CCI attribute.</param>
        internal ScriptAttribute(ICustomAttribute attribute)
        {
            if (attribute == null)
                throw new InvalidOperationException();

            var typeRef = attribute.Type as INamedTypeReference;

            if (typeRef == null)
            {
                throw new InvalidOperationException("Attribute type must be a named type.");
            }

            var type = ScriptDomain.CurrentDomain.ResolveType(typeRef);

            if (type == null)
            {
                throw new InvalidOperationException("Unable to resolve type for attribute: " + typeRef.Name);
            }

            _type = type;
            _cciAttribute = attribute;

            _arguments = _cciAttribute.Arguments
                .Select(a => GetConstantValue(a)).ToArray();

            _namedArgs = _cciAttribute.NamedArguments.ToDictionary(a =>
                a.ArgumentName.Value, a => GetConstantValue(a));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new instance of the class.
        /// </summary>
        /// <param name="container">The containing type.</param>
        /// <param name="memberDef">The CCI member definition.</param>
        internal ScriptMember(ScriptType container, ITypeDefinitionMember memberDef)
        {
            if (container == null || memberDef == null)
                throw new InvalidOperationException();

            _container = container;
            _cciMember = memberDef;
        }
Exemplo n.º 3
0
        // get the unique ID for a type
        private static string GetKey(ScriptType type)
        {
            if (type == null)
                return null;

            return type._container.Id + "/" + type.Name;
        }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a new instance of the class.
 /// </summary>
 /// <param name="container">The containing type.</param>
 /// <param name="fieldDef">The CCI field definition.</param>
 internal ScriptField(ScriptType container, IFieldDefinition fieldDef)
     : base(container, fieldDef)
 {
     _cciField = fieldDef;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Creates a new instance of the class.
 /// </summary>
 /// <param name="container">The containing type.</param>
 /// <param name="methodDef">The CCI method definition.</param>
 internal ScriptMethod(ScriptType container, IMethodDefinition methodDef)
     : base(container, methodDef)
 {
     _cciMethod = methodDef;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Creates a new instance of the class.
 /// </summary>
 /// <param name="container">The containing type.</param>
 /// <param name="propDef">The CCI property definition.</param>
 internal ScriptProperty(ScriptType container, IPropertyDefinition propDef)
     : base(container, propDef)
 {
     _cciProperty = propDef;
 }
Exemplo n.º 7
0
 /// <summary>
 /// Creates a new instance of the class.
 /// </summary>
 /// <param name="container">The containing type.</param>
 /// <param name="propDef">The CCI property definition.</param>
 internal ScriptProperty(ScriptType container, IPropertyDefinition propDef)
     : base(container, propDef)
 {
     _cciProperty = propDef;
 }