Esempio n. 1
0
        private void VerifyCloneForFreezable(Freezable frozenObject)
        {
            if (frozenObject == null)
            {
                return;
            }

            TrustedType       type   = PT.Trust(frozenObject.GetType());
            TrustedMethodInfo method = type.GetMethod("Clone", BindingFlags.Public | BindingFlags.Instance);

            if (method == null)
            {
                throw new ApplicationException("Could not find Clone method on " + type.Name);
            }

            Freezable copy = (Freezable)method.Invoke(frozenObject, null);

            if (!ObjectUtils.DeepEqualsToAnimatable(frozenObject, copy))
            {
                AddFailure("{0}.Copy failed to produce an exact copy", type.Name);
            }

            method = type.GetMethod("CloneCurrentValue", BindingFlags.Public | BindingFlags.Instance);
            if (method == null)
            {
                throw new ApplicationException("Could not find CloneCurrentValue method on " + type.Name);
            }

            copy = (Freezable)method.Invoke(frozenObject, null);

            if (!ObjectUtils.DeepEqualsToAnimatable(frozenObject, copy))
            {
                AddFailure("{0}.CloneCurrentValue failed to produce an exact copy", type.Name);
            }
        }
Esempio n. 2
0
            public DeclarationsGenerator(TrustedType type, string generatedClassName)
            {
                ArrayList list = new ArrayList();

                list.Add(new ConstructorGenerator(type, generatedClassName));

                if (type.IsAbstract)
                {
                    TrustedMethodInfo[] methodInfos = type.GetMethods(flags);
                    if (methodInfos != null)
                    {
                        foreach (TrustedMethodInfo method in methodInfos)
                        {
                            // PropertyGenerators will be created in the next step.  Don't add them here.
                            if (!method.Name.Contains("get_") && !method.Name.Contains("set_") &&
                                MethodNeedsOverride(method, type))
                            {
                                list.Add(new MethodGenerator(method));
                            }
                        }
                    }

                    TrustedPropertyInfo[] properties = type.GetProperties(flags);
                    if (properties != null)
                    {
                        foreach (TrustedPropertyInfo property in properties)
                        {
                            TrustedMethodInfo get = property.GetGetMethod();
                            TrustedMethodInfo set = property.GetSetMethod();

                            if (MethodNeedsOverride(get, type) || MethodNeedsOverride(set, type))
                            {
                                list.Add(new PropertyGenerator(property));
                            }
                        }
                    }
                }

                methods = new MethodGeneratorBase[list.Count];
                list.CopyTo(methods);
            }
Esempio n. 3
0
 public MethodGenerator(TrustedMethodInfo method)
     : base(method)
 {
 }