Exemple #1
0
    public ComponentAttributeValues(AttributedType attributedType)
    {
        if (attributedType.Attribute.Properties.ContainsKey("InvokeOnObjectCreationEvent"))
        {
            this.InvokeOnObjectCreationEvent = (bool)attributedType.Attribute.Properties["InvokeOnObjectCreationEvent"].Value;
        }
        foreach (var item in attributedType.Attribute.ConstructorArguments)
        {
            switch (item.Type.FullName)
            {
            case "System.String":
                this.ContractName = item.Value as string;
                break;

            case "System.Type":
                this.ContractType = (item.Value as TypeReference)?.ToBuilderType() ?? item.Value as BuilderType ?? Builder.Current.Import(item.Value as Type)?.ToBuilderType();
                break;

            case "System.UInt32":
                this.Priority = (uint)item.Value;
                break;

            case "Cauldron.Activator.FactoryCreationPolicy":
                this.Policy = (int)item.Value;
                break;
            }
        }
    }
        public static FactoryTypeInfoWeaverBase Create(AttributedType component)
        {
            var result = Create(component.Type, new ComponentAttributeValues(component));

            component.Attribute.Remove();
            return(result);
        }
Exemple #3
0
        public override AST.Type VisitAttributed(AttributedType type)
        {
            var _type = new CppSharp.AST.AttributedType();

            VisitType(type, _type);
            _type.Modified   = VisitQualified(type.Modified);
            _type.Equivalent = VisitQualified(type.Equivalent);
            return(_type);
        }
Exemple #4
0
        public bool VisitAttributedType(AttributedType attributed, TypeQualifiers quals)
        {
            if (!VisitType(attributed, quals))
            {
                return(false);
            }

            return(attributed.Modified.Visit(this));
        }
        public void ObjectGetAttribute_ReflectedInfo_AsExpected()
        {
            // ----------------------- Arrange -----------------------
            var instance = new AttributedType();

            // -----------------------   Act   -----------------------
            // -----------------------  Assert -----------------------
            Assert.NotNull(instance.GetAttribute <IsTestedAttribute>());
            Assert.Null(this.GetAttribute <IsTestedAttribute>());
        }
        public void ObjectHasAttribute_ReflectedInfo_AsExpected()
        {
            // ----------------------- Arrange -----------------------
            var instance = new AttributedType();

            // -----------------------   Act   -----------------------
            // -----------------------  Assert -----------------------
            Assert.True(instance.HasAttribute <IsTestedAttribute>());
            Assert.False(this.HasAttribute <IsTestedAttribute>());
        }
        public void op_JsonSerialize_object_whenAttributedType(string expected)
        {
            var example = new AttributedType
            {
                Ignore = "ignore",
                Value  = "value"
            };

            var actual = example.JsonSerialize();

            Assert.Equal(expected, actual);
        }
Exemple #8
0
 protected AttributedType(AttributedType.Internal* native, bool isInternalImpl = false)
     : base((CppSharp.Parser.AST.Type.Internal*) native)
 {
 }
Exemple #9
0
 private static AttributedType.Internal* __CopyValue(AttributedType.Internal native)
 {
     var ret = Marshal.AllocHGlobal(40);
     CppSharp.Parser.AST.AttributedType.Internal.cctor_2(ret, new global::System.IntPtr(&native));
     return (AttributedType.Internal*) ret;
 }
Exemple #10
0
 public bool VisitAttributedType(AttributedType attributed, TypeQualifiers quals)
 {
     throw new NotImplementedException();
 }
Exemple #11
0
 public BooleanExpressionCallCoder NewObj(AttributedType attributedType)
 {
     this.NewObj(attributedType.customAttribute);
     return(new BooleanExpressionCallCoder(this, attributedType.Attribute.Type));
 }
Exemple #12
0
 private AttributedType(AttributedType.Internal native, bool skipVTables = false)
     : this(__CopyValue(native), skipVTables)
 {
     __ownsNativeInstance = true;
     NativeToManagedMap[__Instance] = this;
 }
Exemple #13
0
 private AttributedType(AttributedType.Internal native)
     : this(__CopyValue(native))
 {
     __ownsNativeInstance = true;
 }
Exemple #14
0
 internal AttributedType(AttributedType.Internal native)
     : this(__CopyValue(native))
 {
 }
 public bool VisitAttributedType(AttributedType attributed, TypeQualifiers quals)
 {
     return(false);
 }
Exemple #16
0
 public virtual TypePrinterResult VisitAttributedType(AttributedType attributed,
                                                      TypeQualifiers quals)
 {
     throw new NotImplementedException();
 }
 public void TestMethod7() => // Noncompliant, attribute must be on the method itself
 AttributedType.AttributeOnType();
 private static void* __CopyValue(AttributedType.__Internal native)
 {
     var ret = Marshal.AllocHGlobal(24);
     global::CppSharp.Parser.AST.AttributedType.__Internal.cctor_2(ret, new global::System.IntPtr(&native));
     return ret.ToPointer();
 }
Exemple #19
0
 public static AttributedType __CreateInstance(AttributedType.Internal native, bool skipVTables = false)
 {
     return new AttributedType(native, skipVTables);
 }
Exemple #20
0
 internal AttributedType(AttributedType.Internal* native)
     : this(new global::System.IntPtr(native))
 {
 }
Exemple #21
0
 protected AttributedType(AttributedType.Internal* native, bool skipVTables = false)
     : base((CppSharp.Parser.AST.Type.Internal*) null)
 {
     __PointerAdjustment = 0;
     if (native == null)
         return;
     __Instance = new global::System.IntPtr(native);
 }
Exemple #22
0
 internal AttributedType(AttributedType.Internal native)
     : this(&native)
 {
 }
 public CSharpTypePrinterResult VisitAttributedType(AttributedType attributed,
                                                    TypeQualifiers quals)
 {
     return(attributed.Modified.Visit(this));
 }
Exemple #24
0
 public abstract TRet VisitAttributed(AttributedType type);
Exemple #25
0
 public static AttributedType __CreateInstance(AttributedType.Internal native)
 {
     return new AttributedType(native);
 }
Exemple #26
0
        public TRet Visit(Parser.AST.Type type)
        {
            if (type.__Instance == IntPtr.Zero)
            {
                return(default(TRet));
            }

            switch (type.Kind)
            {
            case TypeKind.Tag:
            {
                var _type = new TagType(type.__Instance);
                return(VisitTag(_type));
            }

            case TypeKind.Array:
            {
                var _type = new ArrayType(type.__Instance);
                return(VisitArray(_type));
            }

            case TypeKind.Function:
            {
                var _type = new FunctionType(type.__Instance);
                return(VisitFunction(_type));
            }

            case TypeKind.Pointer:
            {
                var _type = new PointerType(type.__Instance);
                return(VisitPointer(_type));
            }

            case TypeKind.MemberPointer:
            {
                var _type = new MemberPointerType(type.__Instance);
                return(VisitMemberPointer(_type));
            }

            case TypeKind.Typedef:
            {
                var _type = new TypedefType(type.__Instance);
                return(VisitTypedef(_type));
            }

            case TypeKind.Attributed:
            {
                var _type = new AttributedType(type.__Instance);
                return(VisitAttributed(_type));
            }

            case TypeKind.Decayed:
            {
                var _type = new DecayedType(type.__Instance);
                return(VisitDecayed(_type));
            }

            case TypeKind.TemplateSpecialization:
            {
                var _type = new TemplateSpecializationType(type.__Instance);
                return(VisitTemplateSpecialization(_type));
            }

            case TypeKind.TemplateParameter:
            {
                var _type = new TemplateParameterType(type.__Instance);
                return(VisitTemplateParameter(_type));
            }

            case TypeKind.TemplateParameterSubstitution:
            {
                var _type = new TemplateParameterSubstitutionType(type.__Instance);
                return(VisitTemplateParameterSubstitution(_type));
            }

            case TypeKind.InjectedClassName:
            {
                var _type = new InjectedClassNameType(type.__Instance);
                return(VisitInjectedClassName(_type));
            }

            case TypeKind.DependentName:
            {
                var _type = new DependentNameType(type.__Instance);
                return(VisitDependentName(_type));
            }

            case TypeKind.Builtin:
            {
                var _type = new BuiltinType(type.__Instance);
                return(VisitBuiltin(_type));
            }
            }

            throw new ArgumentOutOfRangeException();
        }
Exemple #27
0
 private AttributedType(AttributedType.Internal native)
     : this(__CopyValue(native))
 {
     __ownsNativeInstance = true;
     NativeToManagedMap[__Instance] = this;
 }
 private static string GetTypeName(AttributedType type)
 {
     return(GetTypeName(PrimitiveType.Void));
 }
Exemple #29
0
 public string VisitAttributedType(AttributedType attributed, TypeQualifiers quals)
 {
     return(attributed.Modified.Visit(this));
 }
 public string VisitAttributedType(AttributedType attributed, TypeQualifiers quals)
 {
     throw new NotSupportedException( );
 }