Beispiel #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));
        }
Beispiel #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;
        }
Beispiel #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;
        }
Beispiel #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;
 }
Beispiel #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;
 }
Beispiel #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;
 }
Beispiel #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;
 }